pub trait SourceElement: Source {
// Required methods
fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>;
fn seek(&mut self, target: Duration) -> Result<Duration>;
}Expand description
A pure source: has output but no input. Its run method drives the
production loop and pushes buffers into its own src pad(s) until EOS or
an error. crate::pipeline::Pipeline::run normally invokes that loop
on the pipeline’s background source thread; a caller may also invoke a
concrete implementation directly. Sources typically wrap blocking I/O
reads (demuxer, file/network source).
Required Methods§
Sourcefn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
fn run(&mut self, control: &ControlReceiver, bus: &Bus) -> Result<()>
Drives this source until Eos (normal completion),
crate::pipeline::Pipeline::finish, or Stop (see
ControlMsg::Stop) — call crate::control::drain_control
once per loop iteration to make control responsive between
blocking reads.
bus is this source’s own way to report a failure pushing into
one of its pads without treating it as fatal — post a
crate::bus::BusEvent::Error and keep going (drop that one
buffer), the same way a crate::queue::Queue handles a failing
downstream Sink — rather than returning Err and ending this
source’s thread over one bad buffer. A returned Err is still
how genuinely fatal failures (this source can’t continue at all)
reach crate::pipeline::Pipeline::run, which posts it to bus
itself.
Sourcefn seek(&mut self, target: Duration) -> Result<Duration>
fn seek(&mut self, target: Duration) -> Result<Duration>
Repositions this source to target, an absolute position from the
start of the media (e.g. av_seek_frame for
crate::elements::FileDemuxer). Called by
crate::control::drain_control as part of handling
ControlMsg::Seek, before that message is forwarded to the
source’s own pads — so whatever’s read next comes from the new
position by the time downstream elements are told to flush for it.
Returns where this actually landed, which is allowed to differ
from target — a container seek can only ever reposition to a
keyframe at or before it (landing mid-GOP would leave downstream
decoders/muxers with no reference frame to start from), so
target is a request, not a guarantee. drain_control reports
the gap between the two via crate::bus::BusEvent::Seeked;
callers that need to know where playback actually resumed should
watch that instead of assuming target took effect verbatim.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl SourceElement for AppSource
impl SourceElement for AudioMixer
impl SourceElement for FileDemuxer
impl SourceElement for RtspSource
impl SourceElement for TestAudioSource
impl SourceElement for TestVideoSource
impl SourceElement for VideoCompositor
impl SourceElement for WebRtcTrackSource
webrtc only.