Expand description
Elements that produce buffers.
Three shapes live here. Readers pull from something that already exists —
a container, an RTSP stream, a capture device, or the application itself
through AppSource. Generators synthesize
(TestVideoSource, TestAudioSource). And fan-in elements
(AudioMixer and the video compositors) are sources with inputs: they
accept buffers from several upstream branches and emit one combined stream
on their own schedule.
Pipeline::new builds the common
single-source case. PipelineBuilder
can register one or more of these in the same pipeline; each one’s
SourceElement::run loop drives its
own branches on a separate background thread.
Structs§
- AppSource
- A source whose data comes from application code pushing buffers in,
rather than this element reading them itself — GStreamer’s
appsrcequivalent, the reverse ofcrate::elements::AppSink. Push encodedMediaBuffer::Packets (straight into a decoder) or already-decodedMediaBuffer::Video/MediaBuffer::Audio(e.g. frames from a camera SDK, or synthetic test data) viaAppSourceHandle, from any thread — a live capture callback, a network receive loop, a test. - AppSource
Handle - A cheaply-cloneable handle for pushing buffers into an
AppSourcefrom any thread —Cloneis just two refcount bumps (nameand the channel sender are both cheap to share). - Audio
Mixer - Sums an arbitrary, dynamically-changing number of audio sources into
one output stream — the structural mirror of
crate::elements::Tee:Teeis one input fanned out to a dynamic set of outputs behind a lock;AudioMixeris a dynamic set of inputs (added/removed viaMixerHandle, from whatever thread each one’s own source pipeline runs on) summed into one output. UnlikeTee, which is a passiveSinkdriven entirely by whatever callsconsume,AudioMixerhas to drive itself: it’s aSourceElementwith its ownrunthread, ticking everyTICK_INTERVALto sum however many samples each currently-attached input has ready — because mixing has to keep producing something on a steady clock even when some (or all) inputs have gone quiet, the same reasonWasapiCaptureSourcesynthesizes silence for gaps rather than just emitting nothing. - Audio
Mixer Options - Construction-time options for
AudioMixer::new— the mixer’s fixed output format. Every input is resampled to match this on the way in (seeInputBuffer::push); the mixer never adapts to whatever an input happens to produce. - File
Demuxer - Demuxes a file, exposing one src pad per container stream (indexed the
same way as
StreamInfo::index). Linking a pad “selects” that stream; leaving it unlinked just drops its packets. Real demuxer I/O is blocking, so this is meant to be run as the pipeline’s source thread. - File
Demuxer Handle - Runtime control for a
FileDemuxer, taken withFileDemuxer::looping_handlebefore the demuxer is moved into its pipeline. - MixFormat
- The format every input is resampled to and every output frame carries.
- Mixer
Handle - A cheaply-cloneable handle for adding or removing an
AudioMixer’s input sources while the pipeline is running — the mirror image ofcrate::elements::TeeHandle:Teelets you attach/detach outputs from another thread; this lets you attach/detach inputs. Keeps only aWeakreference for the same reasonTeeHandledoes: retaining a handle after the mixer’s own pipeline finishes must not keep its internal state alive forever, and every operation becomes a harmless no-op once the mixer is gone. - Mixer
Input Sink - One
AudioMixerinput, returned byMixerHandle::add_source. Resamples every incoming frame to the mixer’s fixed output format and appends it to this input’s own buffer — the actual summing happens later, onAudioMixer::run’s own thread, not here.consumeruns on whatever thread is driving the upstream source this got linked to (a different pipeline’s own thread, in the normal case), so every access to the shared input map goes throughMixerShared’s lock. - Pipeline
Bridge - Carries buffers from one
crate::pipeline::Pipelineinto another, so the two can start, end and fail independently. - Pipeline
Bridge Handle - A cheaply-cloneable way to connect a pipeline to a
PipelineBridge, and to end it. - Pipeline
Bridge Options - Construction-time options for
PipelineBridge::new. - Rtsp
Options - Construction-time options for
RtspSource::open. - Rtsp
Source - Demuxes a live RTSP stream — the client/receive counterpart to
crate::elements::RtspSink(which publishes). One src pad per stream the server advertises, same shape ascrate::elements::FileDemuxer. - Stream
Info - Metadata about one stream in an opened container, reported up front so callers can decide what to build downstream before the pipeline runs.
- SwVideo
Compositor - Composites the latest frames from any number of independent input pipelines into one fixed-rate opaque BGRA video stream.
- SwVideo
Compositor Handle - A cheaply cloneable handle for adding and removing compositor inputs.
It mirrors
crate::elements::MixerHandle, but each registration also returns aSwVideoLayerHandlefor changing that input’s placement. - SwVideo
Compositor Input - The two endpoints created for one compositor input registration.
Move
sinkinto the upstream pipeline and retainlayerin application code for runtime placement changes. - SwVideo
Compositor Input Sink - One terminal video input returned by
SwVideoCompositorHandle::add_source. It stores only the latest frame, so a fast producer cannot build an unbounded queue behind a slower compositor output rate. - SwVideo
Layer Handle - Thread-safe runtime placement control for one compositor input. Retaining it does not keep the input or compositor alive.
- Test
Audio Options - Construction-time options for
TestAudioSource::new. - Test
Audio Source - Generates a synthetic sine-wave tone — GStreamer’s
audiotestsrcequivalent. No real capture device involved:TestAudioSource::runfabricates however many samples wall-clock time now owes on a drift-free absolute schedule (expected = elapsed * sample_rate,needed = expected - samples_emitted— the same shapeWasapiCaptureSource::fill_silence_gap/AudioMixer::mix_tickboth use, not a fixed per-tick sample count, which would drift the same way a fixed-durationthread::sleep-only schedule would), stamps it with an increasingpts(one sample per tick ofTestAudioSource::time_base’s units), and pushes it straight downstream — useful for exercisingAudioMixer/an encoder/a muxer without a real microphone. - Test
Video Options - Construction-time options for
TestVideoSource::new. - Test
Video Source - Generates a synthetic, moving-diagonal-gradient video stream —
GStreamer’s
videotestsrcequivalent. No real decode/demux involved:run()fabricates onePixel::YUV420Pframe per tick, stamps it with an increasingpts(one tick per frame, inTestVideoSource::time_base’s units), and pushes it straight downstream — useful for exercisingSwScaler/Pacer/D3d12Renderer/etc. without a real file or camera.D3d12Rendererin particular already handlesPixel::YUV420Pon its CPU-upload path, so this can feed a renderer directly, no decoder needed. - Text
Layer - Construction-time settings for one text layer, passed to
D3d11VideoCompositorHandle::add_text_layer— the text sibling ofsuper::video_layer::VideoLayer, whichadd_sourcetakes the same way.font_data(raw TTF/OTF bytes; this crate bundles no font of its own) has no sane default, so — mirroringsuper::video_layer::VideoLayer::new, which takes the one field a caller must supply (rect) and defaults the rest —Self::newtakes onlyfont_dataand defaultsfont_size/color/x/y, all freely reassignable before the call toadd_text_layer. - Video
Compositor Options - The compositor’s fixed output definition. Every emitted frame is an
opaque
ffmpeg::format::Pixel::BGRAframe atwidthxheight. - Video
Input Id - An opaque, stable identity for one compositor input registration. Replacing an input with the same name creates a different identity, so an old sink or layer handle can never affect its replacement.
- Video
Layer - Runtime-adjustable spatial settings for one compositor input.
- Video
Rect - An output-space rectangle. Signed coordinates allow a layer to be moved partially outside the canvas while its size remains positive.
- Video
Source Rect - An input-space rectangle: the part of a frame a layer draws.
Enums§
- AppSource
Error - Errors specific to
AppSource. Converts into the crate-wideErrorvia?(seecrate::error::Error). - Audio
Mixer Error - Errors specific to
AudioMixer. Converts into the crate-wideErrorvia?(seecrate::error::Error). - File
Demux Error - Errors specific to
FileDemuxer. Converts into the crate-wideErrorvia?(seecrate::error::Error). - Pipeline
Bridge Error - Errors specific to
PipelineBridge. - Rtsp
Source Error - Errors specific to
RtspSource. Converts into the crate-wideErrorvia?(seecrate::error::Error). - SwVideo
Compositor Error - Errors specific to
SwVideoCompositor. - Test
Audio Source Error - Errors specific to
TestAudioSource. Converts into the crate-wideErrorvia?(seecrate::error::Error). - Test
Video Source Error - Errors specific to
TestVideoSource. Converts into the crate-wideErrorvia?(seecrate::error::Error). - Video
Fit - How an input’s aspect ratio is mapped into its
VideoRect.