WebRTC module

WebRTC module

WebRTC media transport via libdatachannel; peer sessions, media bridge, codec negotiation.

Classes

NameDescription
SignallingInterfaceTransport-agnostic signalling interface for WebRTC session setup.
MediaBridgeConvenience wrapper that creates WebRTC tracks on a PeerConnection and exposes per-track sender/receiver adapters for PacketStream integration.
PeerSessionManages a WebRTC peer connection lifecycle over any signalling transport that implements SignallingInterface.
WebRtcTrackSenderPacketProcessor that sends encoded media to a single libdatachannel Track via sendFrame().
WebRtcTrackReceiverPacketStreamAdapter that receives depacketized frames from a single remote libdatachannel Track and emits them as VideoPacket or AudioPacket into a PacketStream.
CodecNegotiatorMaps RTP codec names to FFmpeg encoders and queries FFmpeg at runtime to determine what codecs are available.
TrackHandleResult of creating a track: the track itself plus its RTP config. Keep the config around - you need it for WebRtcTrackSender.
JitterBufferConfigReceive-side jitter buffer behaviour for depacketized WebRTC media frames.
CodecSpecCanonical description of a codec supported by icey's WebRTC helpers.
NegotiatedCodecResult of codec negotiation between a remote SDP offer and the local FFmpeg codec inventory.

Macros

NameDescription
WEBRTC_API

WEBRTC_API

#define WEBRTC_API ICY_IMPORT

Defined in src/webrtc/include/icy/webrtc/webrtc.h:24

Enumerations

NameDescription
CodecMediaTypeWhether a codec carries audio or video media.
CodecIdStable codec identifiers used across negotiation and track setup.

CodecMediaType

enum CodecMediaType

Defined in src/webrtc/include/icy/webrtc/codecnegotiator.h:40

Whether a codec carries audio or video media.

ValueDescription
VideoVideo RTP payload.
AudioAudio RTP payload.

CodecId

enum CodecId

Defined in src/webrtc/include/icy/webrtc/codecnegotiator.h:48

Stable codec identifiers used across negotiation and track setup.

ValueDescription
UnknownUnrecognized or unsupported codec.
H264H.264 / AVC.
H265H.265 / HEVC.
VP8Google VP8.
VP9Google VP9.
AV1AOMedia AV1.
OpusOpus audio.
PCMUG.711 mu-law audio.
PCMAG.711 A-law audio.
G722G.722 wideband audio.
AACAAC audio.

Functions

ReturnNameDescription
TrackHandlecreateVideoTrackCreate a video send track on a PeerConnection.
TrackHandlecreateAudioTrackCreate an audio send track on a PeerConnection.
std::shared_ptr< rtc::Track >createVideoReceiveTrackCreate a pure receive-side video track on a PeerConnection.
std::shared_ptr< rtc::Track >createAudioReceiveTrackCreate a pure receive-side audio track on a PeerConnection.
boolsetupReceiveTrackSet up the receive-side media handler chain on a remote track.
uint32_tgenerateSsrcGenerate a random SSRC.
const char *stateToStringConvert a PeerSession::State to a lowercase C string for logging.

createVideoTrack

TrackHandle createVideoTrack(std::shared_ptr< rtc::PeerConnection > pc, const av::VideoCodec & codec, uint32_t ssrc = 0, const std::string & cname = {}, const std::string & mid = {}, rtc::Description::Direction direction = rtc::Description::Direction::SendRecv, unsigned nackBuffer = 512, std::function< void()> onPli = nullptr, std::function< void(unsigned int)> onRemb = nullptr, int payloadType = -1)

Defined in src/webrtc/include/icy/webrtc/track.h:63

Create a video send track on a PeerConnection.

Sets up the full outgoing media handler chain: Packetizer → SrReporter → NackResponder → PliHandler → RembHandler

The packetizer is selected based on the codec: H264 → H264RtpPacketizer (Annex-B long start sequence) H265 → H265RtpPacketizer (Annex-B long start sequence) VP8/VP9/other → generic RtpPacketizer

Returns

TrackHandle with the track and its RTP config.

Parameters

ParameterTypeDescription
pcstd::shared_ptr< rtc::PeerConnection >PeerConnection to add the track to.
codecconst av::VideoCodec &Video codec. Must name a supported RTP codec or FFmpeg encoder (e.g. "H264" or "libx264").
ssrcuint32_tRTP SSRC. 0 = auto-generate.
cnameconst std::string &RTCP CNAME. Empty = "icey".
midconst std::string &MID to use for the track when answering an existing offer.
directionrtc::Description::DirectionDirection to advertise for the negotiated m-line.
nackBufferunsignedMax packets stored for NACK retransmission.
onPlistd::function< void()>Callback when remote peer requests a keyframe. Connect to your encoder to force IDR.
onRembstd::function< void(unsigned int)>Callback when remote peer reports bandwidth estimate. Bitrate in bits/sec.
payloadTypeintExplicit RTP payload type to reuse when answering an offer. -1 = use the codec's default/preferred type.

createAudioTrack

TrackHandle createAudioTrack(std::shared_ptr< rtc::PeerConnection > pc, const av::AudioCodec & codec, uint32_t ssrc = 0, const std::string & cname = {}, const std::string & mid = {}, rtc::Description::Direction direction = rtc::Description::Direction::SendRecv, int payloadType = -1)

Defined in src/webrtc/include/icy/webrtc/track.h:94

Create an audio send track on a PeerConnection.

Sets up the outgoing media handler chain: AudioRtpPacketizer → SrReporter

The packetizer clock rate is selected based on codec: opus → 48kHz, PCMU/PCMA → 8kHz, etc.

Returns

TrackHandle with the track and its RTP config.

Parameters

ParameterTypeDescription
pcstd::shared_ptr< rtc::PeerConnection >PeerConnection to add the track to.
codecconst av::AudioCodec &Audio codec. Must name a supported RTP codec or FFmpeg encoder (e.g. "opus" or "libopus").
ssrcuint32_tRTP SSRC. 0 = auto-generate.
cnameconst std::string &RTCP CNAME. Empty = "icey".
midconst std::string &MID to use for the track when answering an existing offer.
directionrtc::Description::DirectionDirection to advertise for the negotiated m-line.
payloadTypeintExplicit RTP payload type to reuse when answering an offer. -1 = use the codec's default/preferred type.

createVideoReceiveTrack

std::shared_ptr< rtc::Track > createVideoReceiveTrack(std::shared_ptr< rtc::PeerConnection > pc, const av::VideoCodec & codec, const std::string & mid = {}, rtc::Description::Direction direction = rtc::Description::Direction::RecvOnly, int payloadType = -1)

Defined in src/webrtc/include/icy/webrtc/track.h:108

Create a pure receive-side video track on a PeerConnection.

Unlike createVideoTrack(), this does not add a local SSRC or sender packetizer chain. It is for answers that only receive remote media.


createAudioReceiveTrack

std::shared_ptr< rtc::Track > createAudioReceiveTrack(std::shared_ptr< rtc::PeerConnection > pc, const av::AudioCodec & codec, const std::string & mid = {}, rtc::Description::Direction direction = rtc::Description::Direction::RecvOnly, int payloadType = -1)

Defined in src/webrtc/include/icy/webrtc/track.h:120

Create a pure receive-side audio track on a PeerConnection.

Unlike createAudioTrack(), this does not add a local SSRC or sender packetizer chain. It is for answers that only receive remote media.


setupReceiveTrack

bool setupReceiveTrack(std::shared_ptr< rtc::Track > track)

Defined in src/webrtc/include/icy/webrtc/track.h:141

Set up the receive-side media handler chain on a remote track.

Selects the correct depacketizer based on the track's SDP codec: Video: H264RtpDepacketizer, H265RtpDepacketizer, or generic Audio: OpusRtpDepacketizer, PCMURtpDepacketizer, etc.

Also chains an RtcpReceivingSession for receiver reports.

Call this from PeerConnection::onTrack() before binding a WebRtcTrackReceiver.

Returns

True when a supported depacketizer was installed.

Parameters

ParameterTypeDescription
trackstd::shared_ptr< rtc::Track >The remote track from onTrack callback.

generateSsrc

uint32_t generateSsrc()

Defined in src/webrtc/include/icy/webrtc/track.h:145

Generate a random SSRC.


stateToString

const char * stateToString(PeerSession::State state)

Defined in src/webrtc/include/icy/webrtc/peersession.h:206

Convert a PeerSession::State to a lowercase C string for logging.

Returns

One of: "idle", "outgoing-init", "incoming-init", "negotiating", "active", "ending", "ended".

Parameters

ParameterTypeDescription
statePeerSession::StateState value to convert.

Edit this page