#include <icy/webrtc/tracksender.h>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.
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
PacketSignal emitter| 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 | 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 | Return true only for the packet type that matches the bound track. |
void | onStreamStateChange virtual | 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()Construct an unbound sender. Call bind() before use.
explicit
explicit WebRtcTrackSender(const TrackHandle & handle)Construct bound to a track handle from createVideoTrack() or createAudioTrack().
void bind(const TrackHandle & handle)Bind to a track. Can be called to rebind to a different track.
void unbind()Unbind from the current track.
virtual
virtual void process(IPacket & packet)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.
packet An av::VideoPacket or av::AudioPacket carrying the encoded frame data and a microsecond timestamp.virtual
virtual bool accepts(IPacket * packet)Return true only for the packet type that matches the bound track.
packet Packet to test. May be nullptr.True if the packet can be processed by this sender.
virtual
virtual void onStreamStateChange(const PacketStreamState & state)Called by the PacketStream when stream state changes. Logs when the stream is stopping; no other action is taken.
state New PacketStream state.const
bool isVideo() constTrue if this sender is bound to a video track.
const
bool bound() constTrue if bound to any track.
| Return | Name | Description |
|---|---|---|
std::shared_ptr< rtc::Track > | _track | |
std::shared_ptr< rtc::RtpPacketizationConfig > | _rtpConfig | |
std::atomic< TrackKind > | _kind | |
std::mutex | _mutex |
std::shared_ptr< rtc::Track > _trackstd::shared_ptr< rtc::RtpPacketizationConfig > _rtpConfigstd::atomic< TrackKind > _kind {TrackKind::Unbound}std::mutex _mutex