Home
WebRTC module

WebRtcTrackReceiver

PacketStreamAdapter that receives depacketized frames from a single remote libdatachannel Track and emits them as VideoPacket or AudioPacket into a PacketStream.

WebRtcTrackReceiver

#include <icy/webrtc/trackreceiver.h>
class WebRtcTrackReceiver

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:61

Inherits: PacketStreamAdapter

PacketStreamAdapter that receives depacketized frames from a single remote libdatachannel Track and emits them as VideoPacket or AudioPacket into a PacketStream.

Call setupReceiveTrack() on the track first to install the correct depacketizer, then bind this receiver to it.

Usage: pc->onTrack([&](shared_ptrrtc::Track track) { if (setupReceiveTrack(track)) videoReceiver.bind(track); });

videoReceiver.emitter += packetSlot(&recorder, &Recorder::onEncodedVideo);

Emits owning packets - the frame data is copied, so downstream processors can safely queue packets asynchronously.

Emits VideoPacket for video tracks, AudioPacket for audio tracks. Use those packets to drive a decoder, recorder, or custom pipeline. See samples/media-recorder for a complete receive -> decode -> file example.

List of all members

NameKindOwner
emittervariableDeclared here
WebRtcTrackReceiverfunctionDeclared here
~WebRtcTrackReceiverfunctionDeclared here
bindfunctionDeclared here
configureJitterBufferfunctionDeclared here
jitterBufferConfigfunctionDeclared here
jitterBufferEnabledfunctionDeclared here
_dispatchvariableDeclared here
_timervariableDeclared here
_mutexvariableDeclared here
_pendingvariableDeclared here
_jitterBuffervariableDeclared here
_jitterConfigvariableDeclared here
_timerTickMsvariableDeclared here
_timerNeedsUpdatevariableDeclared here
_statevariableDeclared here
_generationvariableDeclared here
enqueuefunctionDeclared here
flushPendingfunctionDeclared here
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Public Attributes

ReturnNameDescription
PacketSignalemitter

emitter

PacketSignal emitter

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:87

Public Methods

ReturnNameDescription
WebRtcTrackReceiverConstruct an unbound receiver. Call bind() to attach a remote track.
voidbindBind to a remote track. Must be called after setupReceiveTrack() returned true. Installs an onFrame callback that converts each depacketized frame to a VideoPacket or AudioPacket and emits it on the PacketStream. The track type (video/audio) is detected from the SDP description.
voidconfigureJitterBufferReplace the receive-side jitter-buffer settings.
JitterBufferConfigjitterBufferConfig constCurrent jitter-buffer settings for this receiver.
booljitterBufferEnabled constTrue when depacketized receive frames are buffered before emission.

WebRtcTrackReceiver

WebRtcTrackReceiver()

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:65

Construct an unbound receiver. Call bind() to attach a remote track.


bind

void bind(std::shared_ptr< rtc::Track > track)

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:74

Bind to a remote track. Must be called after setupReceiveTrack() returned true. Installs an onFrame callback that converts each depacketized frame to a VideoPacket or AudioPacket and emits it on the PacketStream. The track type (video/audio) is detected from the SDP description.

Parameters

  • track Remote track from the PeerConnection::onTrack callback.

configureJitterBuffer

void configureJitterBuffer(const JitterBufferConfig & config)

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:79

Replace the receive-side jitter-buffer settings.

Reconfiguring resets any buffered media still waiting for release.


jitterBufferConfig

const

JitterBufferConfig jitterBufferConfig() const

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:82

Current jitter-buffer settings for this receiver.


jitterBufferEnabled

const

bool jitterBufferEnabled() const

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:85

True when depacketized receive frames are buffered before emission.

Private Attributes

ReturnNameDescription
Synchronizer_dispatch
Timer_timer
std::mutex_mutex
std::deque< std::unique_ptr< IPacket > >_pending
std::unique_ptr< detail::ReceiverJitterBuffer >_jitterBuffer
JitterBufferConfig_jitterConfig
std::int64_t_timerTickMs
bool_timerNeedsUpdate
std::shared_ptr< DispatchState >_state
uint64_t_generation

_dispatch

Synchronizer _dispatch

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:99


_timer

Timer _timer

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:100


_mutex

std::mutex _mutex

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:101


_pending

std::deque< std::unique_ptr< IPacket > > _pending

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:102


_jitterBuffer

std::unique_ptr< detail::ReceiverJitterBuffer > _jitterBuffer

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:103


_jitterConfig

JitterBufferConfig _jitterConfig

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:104


_timerTickMs

std::int64_t _timerTickMs = 5

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:105


_timerNeedsUpdate

bool _timerNeedsUpdate = false

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:106


_state

std::shared_ptr< DispatchState > _state = std::make_shared<DispatchState>()

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:107


_generation

uint64_t _generation = 0

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

Private Methods

ReturnNameDescription
voidenqueue
voidflushPending

enqueue

void enqueue(std::unique_ptr< IPacket > packet)

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:96


flushPending

void flushPending()

Defined in src/webrtc/include/icy/webrtc/trackreceiver.h:97