Forge
1.x
Docs/Forge/Functions
Open

Reading1 min
Updated31 Jul 2026
Sourcev1/extensions/webrtc/functions.mdx

Extension Construction01

FunctionDescription
New(streamingExt, config, opts...) (*Extension, error)Create the WebRTC extension with a streaming dependency

Peer Connections02

FunctionDescription
NewPeerConnection(id, userID, config, logger) (PeerConnection, error)Create a new WebRTC peer connection
NewLocalTrack(kind, id, label, logger) (MediaTrack, error)Create a local media track

Signaling03

FunctionDescription
NewSignalingManager(streamingExt, logger) SignalingManagerCreate a signaling manager using streaming rooms

Call Rooms04

FunctionDescription
NewMeshCallRoom(roomID, streamingRoom, logger, metrics, config) CallRoomCreate a mesh (P2P) call room
NewMeshCallRoomFromOptions(roomID, streamingRoom, logger, metrics, config) (CallRoom, error)Create a mesh room with validation
NewSFUCallRoomFromOptions(roomID, streamingRoom, logger, metrics, config) (CallRoom, error)Create an SFU call room

SFU05

FunctionDescription
NewSFURouter(roomID, logger, metrics) SFURouterCreate an SFU media router

Quality06

FunctionDescription
NewQualityMonitor(peerID, peer, config, logger, metrics) QualityMonitorCreate a quality monitor for a peer

CallRoom Interface07

MethodDescription
Join(ctx, conn, options) errorAdd a participant to the call
Leave(ctx, conn) errorRemove a participant
GetParticipants() []ParticipantList current participants
GetParticipant(userID) (*Participant, error)Get a specific participant

PeerConnection Interface08

MethodDescription
CreateOffer() (*SessionDescription, error)Generate an SDP offer
CreateAnswer() (*SessionDescription, error)Generate an SDP answer
SetLocalDescription(sdp) errorSet the local SDP
SetRemoteDescription(sdp) errorSet the remote SDP
AddICECandidate(candidate) errorAdd an ICE candidate
AddTrack(track) errorAdd a media track
RemoveTrack(trackID) errorRemove a media track
CreateDataChannel(label, options) (DataChannel, error)Create a data channel
GetStats() PeerStatsGet connection statistics
Close() errorClose the peer connection

SignalingManager Interface09

MethodDescription
SendOffer(ctx, roomID, targetID, offer) errorSend an SDP offer
SendAnswer(ctx, roomID, targetID, answer) errorSend an SDP answer
SendICECandidate(ctx, roomID, targetID, candidate) errorSend an ICE candidate

QualityMonitor Interface10

MethodDescription
Start(ctx) errorStart monitoring
Stop() errorStop monitoring
GetQuality() CallQualityGet current quality assessment
GetConnectionQuality() ConnectionQualityGet connection quality metrics