Home
WebRTC module

WebRtcTrackSender

PacketProcessor that sends encoded media to a single libdatachannel Track via sendFrame().

WebRtcTrackSender

#include <icy/webrtc/tracksender.h>
class WebRtcTrackSender

Defined in src/webrtc/include/icy/webrtc/tracksender.h:56

Inherits: PacketProcessor

PacketProcessor that sends encoded media to a single libdatachannel Track via sendFrame().

Bind to one track (video or audio). Accepts the corresponding packet type from the PacketStream and converts timestamps from FFmpeg microseconds to the track's RTP clock rate.

Usage: auto vh = createVideoTrack(pc, codec); WebRtcTrackSender videoSender(vh);

PacketStream stream; stream.attachSource(capture); stream.attach(encoder, 1, true); stream.attach(&videoSender, 5, false); stream.start();

Only emits the packet downstream on successful send, so a chained recorder won't record frames that failed to transmit.

Accepts only the packet type that matches the bound track. Non-matching packets are passed through unchanged so mixed audio/video PacketStream chains can share one source cleanly.

List of all members

NameKindOwner
emittervariableDeclared here
WebRtcTrackSenderfunctionDeclared here
WebRtcTrackSenderfunctionDeclared here
bindfunctionDeclared here
unbindfunctionDeclared here
processfunctionDeclared here
acceptsfunctionDeclared here
onStreamStateChangefunctionDeclared here
isVideofunctionDeclared here
boundfunctionDeclared here
_trackvariableDeclared here
_rtpConfigvariableDeclared here
_kindvariableDeclared here
_mutexvariableDeclared here
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
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 PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

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/tracksender.h:96

Public Methods

ReturnNameDescription
WebRtcTrackSenderConstruct an unbound sender. Call bind() before use.
WebRtcTrackSender explicitConstruct bound to a track handle from createVideoTrack() or createAudioTrack().
voidbindBind to a track. Can be called to rebind to a different track.
voidunbindUnbind from the current track.
voidprocess virtual overrideSend an encoded media frame to the bound WebRTC track. Converts the FFmpeg microsecond timestamp to an RTP timestamp using the track's clock rate, then calls rtc::Track::sendFrame(). Only forwards the packet downstream on a successful send.
boolaccepts virtual overrideReturn true only for the packet type that matches the bound track.
voidonStreamStateChange virtual overrideCalled by the PacketStream when stream state changes. Logs when the stream is stopping; no other action is taken.
boolisVideo constTrue if this sender is bound to a video track.
boolbound constTrue if bound to any track.

WebRtcTrackSender

WebRtcTrackSender()

Defined in src/webrtc/include/icy/webrtc/tracksender.h:60

Construct an unbound sender. Call bind() before use.


WebRtcTrackSender

explicit

explicit WebRtcTrackSender(const TrackHandle & handle)

Defined in src/webrtc/include/icy/webrtc/tracksender.h:64

Construct bound to a track handle from createVideoTrack() or createAudioTrack().


bind

void bind(const TrackHandle & handle)

Defined in src/webrtc/include/icy/webrtc/tracksender.h:67

Bind to a track. Can be called to rebind to a different track.


unbind

void unbind()

Defined in src/webrtc/include/icy/webrtc/tracksender.h:70

Unbind from the current track.


process

virtual override

virtual void process(IPacket & packet) override

Defined in src/webrtc/include/icy/webrtc/tracksender.h:78

Send an encoded media frame to the bound WebRTC track. Converts the FFmpeg microsecond timestamp to an RTP timestamp using the track's clock rate, then calls rtc::Track::sendFrame(). Only forwards the packet downstream on a successful send.

Parameters

Reimplements

accepts

virtual override

virtual bool accepts(IPacket * packet) override

Defined in src/webrtc/include/icy/webrtc/tracksender.h:83

Return true only for the packet type that matches the bound track.

Parameters

  • packet Packet to test. May be nullptr.

Returns

True if the packet can be processed by this sender.

Reimplements

onStreamStateChange

virtual override

virtual void onStreamStateChange(const PacketStreamState & state) override

Defined in src/webrtc/include/icy/webrtc/tracksender.h:88

Called by the PacketStream when stream state changes. Logs when the stream is stopping; no other action is taken.

Parameters

Reimplements

isVideo

const

bool isVideo() const

Defined in src/webrtc/include/icy/webrtc/tracksender.h:91

True if this sender is bound to a video track.


bound

const

bool bound() const

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

True if bound to any track.

Private Attributes

ReturnNameDescription
std::shared_ptr< rtc::Track >_track
std::shared_ptr< rtc::RtpPacketizationConfig >_rtpConfig
std::atomic< TrackKind >_kind
std::mutex_mutex

_track

std::shared_ptr< rtc::Track > _track

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


_rtpConfig

std::shared_ptr< rtc::RtpPacketizationConfig > _rtpConfig

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


_kind

std::atomic< TrackKind > _kind {TrackKind::Unbound}

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


_mutex

std::mutex _mutex

Defined in src/webrtc/include/icy/webrtc/tracksender.h:109