WebRtcTrackSender
WebRtcTrackSender
#include <icy/webrtc/tracksender.h>class WebRtcTrackSenderDefined 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
| Name | Kind | Owner |
|---|---|---|
emitter | variable | Declared here |
WebRtcTrackSender | function | Declared here |
WebRtcTrackSender | function | Declared here |
bind | function | Declared here |
unbind | function | Declared here |
process | function | Declared here |
accepts | function | Declared here |
onStreamStateChange | function | Declared here |
isVideo | function | Declared here |
bound | function | Declared here |
_track | variable | Declared here |
_rtpConfig | variable | Declared here |
_kind | variable | Declared here |
_mutex | variable | Declared here |
PacketProcessor | function | Inherited from PacketProcessor |
process | function | Inherited from PacketProcessor |
accepts | function | Inherited from PacketProcessor |
operator<< | function | Inherited from PacketProcessor |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
~PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
emit | function | Inherited from PacketStreamAdapter |
getEmitter | function | Inherited from PacketStreamAdapter |
retention | function | Inherited from PacketStreamAdapter |
onStreamStateChange | function | Inherited from PacketStreamAdapter |
_emitter | variable | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
PacketStreamAdapter | function | Inherited from PacketStreamAdapter |
operator= | function | Inherited from PacketStreamAdapter |
Inherited from PacketProcessor
| Kind | Name | Description |
|---|---|---|
function | PacketProcessor inline | |
function | process virtual | This method performs processing on the given packet and emits the result. |
function | accepts virtual inline | This method ensures compatibility with the given packet type. Return false to reject the packet. |
function | operator<< virtual inline | Stream operator alias for process() |
Inherited from PacketStreamAdapter
| Kind | Name | Description |
|---|---|---|
function | PacketStreamAdapter | Construct the adapter, binding it to the given packet signal. |
function | ~PacketStreamAdapter virtual inline | |
function | emit virtual | Emit a mutable raw buffer as a packet. |
function | emit virtual | Emit a read-only raw buffer as a packet (data is copied internally). |
function | emit virtual | Emit a string as a packet (data is copied internally). |
function | emit virtual | Emit a flag-only packet carrying no payload data. |
function | emit virtual | Emit an existing packet directly onto the outgoing signal. |
function | getEmitter | Returns a reference to the outgoing packet signal. |
function | retention virtual const | Returns 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. |
function | onStreamStateChange virtual inline | Called 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 | |
function | PacketStreamAdapter | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | PacketStreamAdapter | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
emitter
PacketSignal emitterDefined in src/webrtc/include/icy/webrtc/tracksender.h:96
Public Methods
| Return | Name | Description |
|---|---|---|
WebRtcTrackSender | Construct an unbound sender. Call bind() before use. | |
WebRtcTrackSender explicit | Construct bound to a track handle from createVideoTrack() or createAudioTrack(). | |
void | bind | Bind to a track. Can be called to rebind to a different track. |
void | unbind | Unbind from the current track. |
void | process virtual override | 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. |
bool | accepts virtual override | Return true only for the packet type that matches the bound track. |
void | onStreamStateChange virtual override | Called by the PacketStream when stream state changes. Logs when the stream is stopping; no other action is taken. |
bool | isVideo const | True if this sender is bound to a video track. |
bool | bound const | True 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) overrideDefined 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
packetAn av::VideoPacket or av::AudioPacket carrying the encoded frame data and a microsecond timestamp.
Reimplements
accepts
virtual override
virtual bool accepts(IPacket * packet) overrideDefined in src/webrtc/include/icy/webrtc/tracksender.h:83
Return true only for the packet type that matches the bound track.
Parameters
packetPacket 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) overrideDefined 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
stateNew PacketStream state.
Reimplements
isVideo
const
bool isVideo() constDefined in src/webrtc/include/icy/webrtc/tracksender.h:91
True if this sender is bound to a video track.
bound
const
bool bound() constDefined in src/webrtc/include/icy/webrtc/tracksender.h:94
True if bound to any track.
Private Attributes
| Return | Name | Description |
|---|---|---|
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 > _trackDefined in src/webrtc/include/icy/webrtc/tracksender.h:106
_rtpConfig
std::shared_ptr< rtc::RtpPacketizationConfig > _rtpConfigDefined 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