gizlang:webrtc
WebRTC media and data channels through libdatachannel's stable C API. No inference or application policy lives here.
import * as Webrtc from "gizlang:webrtc";Types
Peer
type PeerOne WebRTC peer connection: its audio and video tracks and data channels (-1: absent) over libdatachannel.
id:i64audio:i64video:i64data:i64remoteData:i64
Functions
iceUrl
function iceUrl(url: string, username: string, password: string): string throws stringlibdatachannel carries TURN credentials in the URL, with user-info percent encoding.
Effects: fail.
h264Payload
function h264Payload(offer: string): i64 throws stringA baseline H.264 payload with non-interleaved packets, matching the stream the encoder emits.
Effects: fail.
answer
function answer(sys: System, offer: string, iceServers: Vec<string>, audioOnly: bool): Peer throws stringAnswers a receive-only browser offer. iceServers use STUN/TURN URLs understood by libdatachannel.
Effects: fail, io.
Methods
Peer.description
function Peer.description(self: Peer, timeoutMs: i64 = 3000): string throws stringCurrent gathered SDP. Wait until candidates have appeared, bounded by timeoutMs.
Effects: fail, io.
Peer.candidate
function Peer.candidate(self: Peer, candidate: string, mid: string): void throws stringAdds the remote ICE candidate candidate of media section mid.
Effects: fail, io.
Peer.receive
function Peer.receive(self: mut Peer): Vec<string> throws stringThe data-channel messages that arrived since the last call; it also takes in the connection's state changes.
Effects: fail, io.
Peer.connected
function Peer.connected(self: Peer): boolWhether the connection is up.
Peer.ended
function Peer.ended(self: Peer): boolWhether the connection failed or closed.
Peer.event
function Peer.event(self: Peer, message: string): void throws stringSends message on the first open data channel (the own, else the remote one); without one it is dropped.
Effects: fail, io.
Peer.send
function Peer.send(self: Peer, video: bool, data: bytes, timestamp: u64): void throws stringA packetized H264 length-prefixed access unit or an Opus packet at the track's timestamp.
Effects: fail, io.
Peer.close
function Peer.close(self: mut Peer): voidCloses the connection and releases its callbacks; a second close does nothing.
Effects: fail, io.