pub struct WebRtcTrackSource { /* private fields */ }webrtc only.Expand description
One inbound track — the mirror image of WebRtcTrackSink. A plain
SourceElement, same shape as crate::elements::AppSource: it
links into its own crate::pipeline::Pipeline via src_pads() like
any other source. The difference from AppSource is only who feeds
it — instead of an crate::elements::AppSourceHandle the app calls
itself, crate::driver::Driver::run pushes into the sending half of this same
channel internally, from its own thread, for every Event::MediaData
on this track’s Mid. Nothing here ever calls back into caller-supplied
code from WebRtcPeer::run’s own thread — that thread only ever touches
this crate’s own types (see the module docs for why WebRtcPeer hands
tracks out through WebRtcHandle::next_track instead of a callback).
Implementations§
Source§impl WebRtcTrackSource
impl WebRtcTrackSource
Sourcepub fn codec(&self) -> Option<Codec>
pub fn codec(&self) -> Option<Codec>
The codec this track is actually carrying, as seen on the most
recently received packet’s RTP payload type — None until the
first one arrives. Unlike WebRtcHandle::add_track’s codec
(which the caller declares up front for an outbound track), an
inbound track’s codec isn’t knowable ahead of time: SDP negotiation
can accept several codecs for one m= line, and only the packets
actually arriving say which one the remote side picked (see
Event::MediaData’s own params field). Whatever’s downstream
(e.g. a decoder) needs a keyframe before it can do anything useful
anyway, so waiting for the first packet to learn the codec isn’t an
extra constraint in practice.
Trait Implementations§
Source§impl Element for WebRtcTrackSource
impl Element for WebRtcTrackSource
Source§fn name(&self) -> Arc<str> ⓘ
fn name(&self) -> Arc<str> ⓘ
crate::bus::BusEvent stores names as
Arc<str> for exactly this reason: a hot path like
crate::queue::Queue posting BusEvent::Dropped once per
overflowed buffer shouldn’t pay for a fresh heap allocation every
time it wants to report which element it is.Source§fn element_type(&self) -> ElementType
fn element_type(&self) -> ElementType
ElementType.Source§fn pp_log(&self) -> &PpLog
fn pp_log(&self) -> &PpLog
crate::bus::Bus::post — same
id/name as Element::name, just already wrapped as the
crate::pp_log::PpLog its pp_info!/pp_warn!/pp_error! macros need. A
stored private field, not built fresh per call, for the same reason
name() returns a cheap Arc<str> clone instead of a fresh String
— see its own docs.Source§fn pp_log_mut(&mut self) -> &mut PpLog
fn pp_log_mut(&mut self) -> &mut PpLog
Element::pp_log reads — used by
crate::pipeline::ChainBuilder to stamp the owning
crate::pipeline::Pipeline’s id onto every element that
passes through it, via element_pp_log. Not meant to be called
from anywhere else.Source§impl SourceElement for WebRtcTrackSource
impl SourceElement for WebRtcTrackSource
Source§fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
Identical shape to crate::elements::AppSource::run: selects on
control and its own data channel together, so Stop/Pause
never wait behind a remote peer that’s gone quiet. The data channel
disconnecting — WebRtcPeer gone, whether from Stop or the
connection dying on its own — ends this the same way AppSource
ends when every AppSourceHandle is dropped: one final Eos, no
error.