Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

A runtime collection of element factories the auto-plugger searches over, the analog of GStreamer’s plugin registry. Registration order is the tie-break only indirectly: find_chain is breadth-first, so among equal-length chains the one whose elements register earliest is found first.

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

An empty registry.

Source

pub fn register(&mut self, factory: ElementFactory) -> &mut Self

Register one element factory (a transform / sink the search composes into chains), returning &mut self to chain calls.

Source

pub fn register_source(&mut self, source: SourceFactory) -> &mut Self

Register one source factory (a graph root for [build_playbin]), returning &mut self to chain calls.

Source

pub fn register_uri(&mut self, handler: UriSourceFactory) -> &mut Self

Register one URI-scheme handler (a graph root for build_uridecodebin), returning &mut self to chain calls.

Source

pub fn register_launch(&mut self, factory: LaunchFactory) -> &mut Self

Register a named transform / sink for the gst-launch parser and gst-inspect (M105), returning &mut self to chain calls.

Source

pub fn register_muxer(&mut self, factory: MuxerFactory) -> &mut Self

Register a named fan-in muxer for the gst-launch parser (M122), returning &mut self to chain calls.

Source

pub fn register_fanout_src(&mut self, factory: FanoutSrcFactory) -> &mut Self

Register a named fan-out demuxer for the gst-launch parser (M210), returning &mut self to chain calls.

Source

pub fn is_fanout_src(&self, name: &str) -> bool

Whether name is a registered terminal fan-out source.

Source

pub fn make_fanout_src( &self, name: &str, outputs: usize, ) -> Option<Box<dyn DynMultiOutputSource>>

Build a registered terminal fan-out source with outputs ports.

Source

pub fn register_demux(&mut self, factory: DemuxFactory) -> &mut Self

Source

pub fn register_playbin(&mut self, hook: PlaybinHook) -> &mut Self

Register a playbin uri=X auto-fan-out hook (M382): a lone playbin in a parse_launch pipeline tries the registered hooks in order until one handles the URI. Register one per container type (MKV, TS, …); each declines a container it does not parse. Returns &mut self to chain calls.

Source

pub fn demux_select_hooks(&self) -> &[DemuxSelectHook]

The registered explicit-demux fan-out hooks (M476), tried in order by parse_launch for a named demux element with several output-pad references and a file source upstream.

Source

pub fn register_demux_select(&mut self, hook: DemuxSelectHook) -> &mut Self

Register an explicit-demux fan-out hook (M476): a named demux element (matroskademux name=d d.video_0 ! ... d.audio_0 ! ...) fed by a file source tries the registered hooks in order until one probes the file and builds the multi-output demuxer. Register one per container type; each declines a container it does not parse. Returns &mut self to chain.

Source

pub fn decodebin_select_hooks(&self) -> &[DecodebinSelectHook]

The decodebin fan-out hooks (M482), tried in order by parse_launch for a decodebin name=d with several d. references and a file source upstream.

Source

pub fn register_decodebin_select( &mut self, hook: DecodebinSelectHook, ) -> &mut Self

Register a decodebin fan-out hook (M482): a decodebin name=d fed by a file source tries the registered hooks until one parses the container, returning the multi-output demuxer + per-port caps so the parser splices a decoder onto each port. One per container type. Returns &mut self.

Source

pub fn register_primary_stream(&mut self, hook: PrimaryStreamHook) -> &mut Self

Register a bare-decodebin primary-stream hook (M746): a filesrc location=X ! decodebin on a container tries each until one sniffs the file and names the single-stream demux + stream selection for its primary decodable stream. One per container type. Returns &mut self.

Source

pub fn primary_stream( &self, location: &str, caps: &Caps, ) -> Option<PrimaryStream>

The single-stream demux + decode selection for a bare decodebin on the container at location with caps, from the first hook that parses it (M746); None when none applies (no video-less container to fix, an unreadable file, or no hook registered).

Source

pub fn set_parser_provider( &mut self, provider: fn(&Caps) -> Option<&'static str>, ) -> &mut Self

Set the parser injector consulted by decodebin and decodebin_preferring (M421): before a decode chain is spliced, provider(input) may name a registered parser (e.g. an access-unit-re-framing h264parse) to prepend ahead of the decoder, so the decoder is fed one access unit per packet. The name-based decodebin expansion in parse_launch consults the same mapping via parser_name (M676). Returns &mut self to chain calls.

Source

pub fn set_encoder_provider(&mut self, provider: EncoderProvider) -> &mut Self

Set the encoder chooser consulted by the encodebin expansion: for a coded target caps (a stream of an encoding profile), provider(target) names the launch elements that can produce it, most preferred first, and encoder_name takes the first one this build actually registered. Returns &mut self to chain calls.

Source

pub fn set_muxer_provider(&mut self, provider: MuxerProvider) -> &mut Self

Set the muxer chooser consulted by the encodebin expansion: for a container caps, provider(container) names the muxers that write it, most preferred first. Returns &mut self to chain calls.

Source

pub fn encoder_choice(&self, target: &Caps) -> Option<&'static EncoderChoice>

The encoder that produces target: the first candidate this build registered and can run, with the properties that pin it to this codec. None when no provider is set, the target has no candidates, or every candidate is compiled out (the “no encoder for this profile” a caller reports).

Source

pub fn muxer_name(&self, container: &Caps) -> Option<&'static str>

The launch name of the muxer that writes container, chosen the way encoder_name chooses an encoder.

Source

pub fn set_domain_converter( &mut self, factory: fn(MemoryDomainKind, MemoryDomainKind) -> Option<GraphNode>, ) -> &mut Self

Set the memory-domain converter factory a parsed pipeline is spliced with (M1017): after the graph is built, an edge whose producer and consumer share no memory domain gets factory(from, to) inserted, so a text pipeline reaches a GPU sink from a GPU decoder without naming the bridge element. Returns &mut self to chain calls.

Source

pub fn domain_converter( &self, ) -> Option<fn(MemoryDomainKind, MemoryDomainKind) -> Option<GraphNode>>

The configured domain-converter factory, if any.

Source

pub fn parser_name(&self, input: &Caps) -> Option<&'static str>

The launch name of the re-framing parser decodebin prepends ahead of a decoder for input caps, if the provider names one (M676).

Source

pub fn playbin_hooks(&self) -> &[PlaybinHook]

The registered PlaybinHooks, in registration order (empty if none, so playbin stays the M196 single-stream pipeline). The parser tries them in turn for a lone playbin uri=.

Source

pub fn register_alias( &mut self, name: &'static str, targets: &'static [&'static str], ) -> &mut Self

Register a gst-canonical-name alias (M192): name resolves, at make_source / make_element time, to the first of targets that is actually registered. Use a one-entry list for a plain rename (avdec_h264 -> ffmpegdec) and a fallback chain for an auto element (autovideosink -> ["waylandsink", "kmssink", "fakesink"]). Returns &mut self to chain calls.

Source

pub fn make_source(&self, name: &str) -> Option<Box<dyn DynSourceLoop>>

Construct a registered source by name (the parser’s first element). None if no source is registered under name (after alias resolution).

Source

pub fn make_element(&self, name: &str) -> Option<Box<dyn DynAsyncElement>>

Construct a registered transform / sink by name (a parser interior or tail element), default-configured. None if name is not registered via register_launch (after alias resolution).

Source

pub fn declared_output_caps(&self, name: &str) -> Option<Caps>

The caps a registered element is known to produce on its source pad, without constructing or negotiating it: a source’s declared output, or a transform / sink’s first fixed source-pad template alternative. None for an unregistered name or one whose source pad is wildcard. The decodebin parser uses this to learn its upstream caps (the input to the auto-plug search). Reads the factory-declared media type; it does not reflect instance properties that re-type the output (e.g. a filesrc’s bytestream-format).

Source

pub fn make_muxer( &self, name: &str, inputs: usize, ) -> Option<Box<dyn DynMultiInputElement>>

Construct a registered fan-in muxer by name with inputs input pads (the parser derives the count from link degree, so it matches the muxer node’s input-pad count). None if name is not registered via register_muxer.

Source

pub fn make_demux( &self, name: &str, outputs: usize, ) -> Option<Box<dyn DynMultiOutputElement>>

Construct a registered fan-out demuxer by name with outputs output pads (the parser derives the count from the d. link degree, so it matches the demux node’s fan-out). None if name is not registered via register_demux.

Source

pub fn is_demux(&self, name: &str) -> bool

Whether name is registered as a fan-out demuxer (the parser uses this to allow a multi-output node without an explicit tee).

Source

pub fn knows_element(&self, name: &str) -> bool

The names of every element registerable by the parser: sources first, then transforms / sinks, each in registration order. The gst-inspect element list. Whether name names something this registry can build: any factory list, or an alias resolving into one. The launch parser asks this to tell a new chain’s head from a typo’d property, since both are bare tokens with no =.

Source

pub fn element_names(&self) -> Vec<&'static str>

Source

pub fn element_listing(&self) -> Vec<String>

One line per registerable element, name: Long-name (the long name from the element’s metadata, or just the name when it declares none), for the gst-inspect element index. Sources, then transforms / sinks, then muxers. Each non-muxer element is default-built to read its metadata (side-effect-free, like inspect).

Source

pub fn inspect(&self, name: &str) -> Option<String>

A gst-inspect-style dump for the named element: its role, its settable properties, and (for a transform / sink) its pad templates. None if the name is not registered. The element is default-built to read its property table (the specs are &'static, behind an instance method), so building must be side-effect-free, as the in-tree constructors are.

Source

pub fn describe(&self, name: &str) -> Option<ElementDoc>

Structured introspection: the same facts inspect dumps as text, returned as an ElementDoc for tooling to render (e.g. the searchable element reference the docs site is generated from). None if the name is not registered. Like inspect, it default-builds the element to read its &'static metadata / property table, so the in-tree constructors must be side-effect-free.

Source

pub fn describe_all(&self) -> Vec<ElementDoc>

Every registered element as an ElementDoc, in the same order as element_names (sources, transforms / sinks, then muxer-only names). The structured catalog behind g2g-docgen.

Source

pub fn autoplug_names_avoiding( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, preferred: MemoryDomainKind, avoided: &[&str], ) -> Option<Vec<&'static str>>

The names of the shortest chain that avoids every factory in avoided: the retry after one of them turned out not to decode the stream, where the search would otherwise pick it again. An empty avoided is autoplug_names_preferring.

Source

pub fn autoplug_avoiding( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, preferred: MemoryDomainKind, avoided: &[&str], ) -> Option<Vec<Box<dyn DynAsyncElement>>>

autoplug_names_avoiding, instantiated.

Source

pub fn factory_of_instance(&self, instance: &str) -> Option<&'static str>

The factory whose element the runner would name instance (its type’s log category plus a number, e.g. VulkanVideoDec0 -> vulkanvideodec). The bus names a failing element by instance; acting on it per factory, to auto-plug around the one that failed, needs the way back.

Each candidate is default-constructed to be asked its category, which costs an allocation and opens nothing (a decoder reaches its device at configure_pipeline). None if no registered factory matches.

Source

pub fn autoplug_names( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Option<Vec<&'static str>>

The names of the shortest chain converting input into caps satisfying target, without instantiating anything. Some(vec![]) if input already satisfies target; None if no chain exists within max_depth.

Source

pub fn autoplug( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Option<Vec<Box<dyn DynAsyncElement>>>

Find the shortest chain converting input into caps satisfying target and instantiate it: an ordered list of boxed elements (upstream first), each configured to produce the caps the search chose for it, ready to splice onto run_graph as transforms. Some(vec![]) if no elements are needed; None if no chain exists.

Source

pub fn decodebin( &self, graph: &mut Graph<GraphNode>, from: impl Into<PadId>, to: impl Into<PadId>, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Result<Vec<NodeId>, DecodebinError>

decodebin-equivalent: auto-plug a decode chain and splice it into graph as a run of transforms between an existing output pad from (which produces input caps) and an existing input pad to. Returns the inserted transform node ids in chain order.

This is the “returns a sub-graph onto run_graph” payoff: the caller builds its source and sink, names the input caps and the target shape (is_raw_video for playback), and the registry fills the middle. An empty chain (input already satisfies target) links from straight to to.

The memory-domain preference comes from the graph itself (M989): the element behind to declares what memory it accepts (input_domains), so a Cuda-only consumer gets the Cuda-producing decoder without the caller naming a domain (see derived_memory_preference). decodebin_preferring overrides it.

Source

pub fn derived_memory_preference( graph: &Graph<GraphNode>, to: PadId, ) -> MemoryDomainKind

The memory domain the decode chain’s consumer wants, read off the element behind the to pad: the most-preferred domain of its declared input_domains (GPU-resident before System, per DomainSet). An element that declares no requirement (DomainSet::ALL, the default) or a pad with no element behind it (a tee) derives System, the plain selection, so an ordinary graph is unaffected.

Only the immediate consumer is consulted, never a chain of them: a default ALL means “declares no requirement”, not “passes any domain through”, and most CPU elements never declare, so walking past them would hand a GPU frame to an element that can only read host bytes.

Source

pub fn declared_memory_preference(&self, name: &str) -> MemoryDomainKind

The memory domain the element registered under name wants its frames in, the same rule as derived_memory_preference but reached by launch name rather than through a built graph (M1018): the text parser expands a decodebin before any element exists, so its consumer is still just a name. An unregistered name derives System.

The name is default-constructed to be asked, since input_domains is a per-instance method and every implementation of it is constant per element type; a factory-level copy of the same fact could drift from it. A launch factory’s constructor takes no arguments and opens nothing (a sink reaches its device in configure_pipeline), so the throwaway instance costs an allocation.

Source

pub fn decodebin_with_params( &self, graph: &mut Graph<GraphNode>, from: impl Into<PadId>, to: impl Into<PadId>, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, params: &AutoplugParams, ) -> Result<Vec<NodeId>, AutoplugError>

decodebin with per-element property assignments (see AutoplugParams): each element the search selects, plus the injected parser, gets the assignments addressed to its factory name applied before it is spliced into the graph. The consumer’s memory domain is derived the same way as in decodebin.

Source

pub fn autoplug_names_preferring( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, preferred: MemoryDomainKind, ) -> Option<Vec<&'static str>>

Domain-aware autoplug_names: bias ties toward a chain whose terminal element emits the preferred memory feature (see ElementDesc::output_memory). MemoryDomainKind::System reproduces the default selection; Cuda prefers e.g. NvDec over a CPU decoder.

Source

pub fn autoplug_preferring( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, preferred: MemoryDomainKind, ) -> Option<Vec<Box<dyn DynAsyncElement>>>

Domain-aware autoplug: instantiate the chain the domain-aware search picks (see autoplug_names_preferring).

Source

pub fn autoplug_names_with( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ctx: SelectionContext, ) -> Option<Vec<&'static str>>

Capability-aware autoplug_names: score candidates against ctx (SelectionContext) to choose among elements satisfying the same caps (memory domain, hardware, then a rank tiebreaker). The generalization of autoplug_names_preferring (which is the memory-only case); a default ctx is the plain selection.

Source

pub fn autoplug_with( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ctx: SelectionContext, ) -> Option<Vec<Box<dyn DynAsyncElement>>>

Capability-aware autoplug: instantiate the chain the capability-scored search (autoplug_names_with) picks.

Source

pub fn autoplug_with_params( &self, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ctx: SelectionContext, params: &AutoplugParams, ) -> Result<Vec<Box<dyn DynAsyncElement>>, AutoplugError>

Capability-aware autoplug that also applies params to each element it builds (see AutoplugParams). The instantiation half of decodebin_with_params.

Source

pub fn decodebin_preferring( &self, graph: &mut Graph<GraphNode>, from: impl Into<PadId>, to: impl Into<PadId>, input: &Caps, target: &dyn Fn(&Caps) -> bool, max_depth: usize, preferred: MemoryDomainKind, ) -> Result<Vec<NodeId>, DecodebinError>

Domain-aware decodebin: splice in the chain the domain-aware search picks, biased toward preferred memory (e.g. Cuda to prefer NvDec when the downstream consumer is GPU-resident).

preferred wins over what decodebin would derive from the consumer’s declared input domains, so this is the caller’s override (ask for System and a Cuda-accepting consumer still gets the CPU decoder, with the converter auto-plug uploading on the edge).

Source

pub fn build_playbin<Sk: AsyncElement + 'static>( &self, source_name: &str, sink: Sk, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Result<Graph<GraphNode>, PlaybinError>

playbin-equivalent: assemble a complete runnable graph from a registered source name and a sink, auto-plugging the decode chain in between. Looks up the source factory, takes its declared output caps as the decodebin input, and returns source -> chain -> sink ready for run_graph. This is the “just play this” entry point, minus the URI-scheme front door (the caller still names the source rather than passing a uri=).

Source

pub fn build_playbin_with_params<Sk: AsyncElement + 'static>( &self, source_name: &str, sink: Sk, target: &dyn Fn(&Caps) -> bool, max_depth: usize, params: &AutoplugParams, ) -> Result<Graph<GraphNode>, AutoplugError>

build_playbin with per-element property assignments for the auto-plugged chain (see AutoplugParams).

Source

pub fn build_uri_source( &self, uri: &str, ) -> Result<(Box<dyn DynSourceLoop>, Caps), UriError>

uridecodebin-equivalent: the URI-scheme front door to build_playbin. Parses uri, dispatches to the registered UriSourceFactory for its scheme to construct the source from the URI, then auto-plugs source -> chain -> sink down to target, returning a graph ready for run_graph.

target is a shape predicate (commonly is_raw_video for playback); the source’s runtime caps are resolved at negotiation, so the handler’s declared output caps only need to name the media type the right decoder is plugged for. Dispatch a URI to its registered scheme handler, constructing the source from the URI and returning it with the caps it produces (the decode-chain input). The lower half of build_uridecodebin, exposed so the uridecodebin / playbin text-parser nodes can splice the source into a larger graph instead of getting a complete one.

Source

pub fn build_uridecodebin<Sk: AsyncElement + 'static>( &self, uri: &str, sink: Sk, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Result<Graph<GraphNode>, UriError>

Source

pub fn build_source_decodebin<Sk: AsyncElement + 'static>( &self, source: Box<dyn DynSourceLoop>, source_caps: &Caps, sink: Sk, target: &dyn Fn(&Caps) -> bool, max_depth: usize, ) -> Result<Graph<GraphNode>, UriError>

Auto-plug source -> chain -> sink from an already constructed source whose output is source_caps, the lower half of build_uridecodebin factored out so a caller that built (or wrapped) its own source can still get the decode chain auto-plugged. A gapless playlist source (GaplessSrc) uses this to splice its decode chain without the URI-handler step.

Source

pub fn build_playbin_graph<D: MultiOutputElement + 'static>( &self, uri: &str, demux: D, ports: Vec<PlaybinPort>, max_depth: usize, ) -> Result<Graph<GraphNode>, PlaybinGraphError>

playbin-equivalent (M379): assemble a complete runnable graph that splits a container into its selected streams and decodes each to its own sink. Builds the source from uri, adds demux (a MultiOutputElement, e.g. MkvDemuxN) as a fan-out node, and for each PlaybinPort (one per selected stream, in port order) auto-plugs a decode chain from that port’s elementary caps to its sink. Returns source -> demux -> {decode chain -> sink} ready for run_graph, the multi-stream counterpart of build_uridecodebin.

The app derives ports from the demux’s announced StreamCollection (M376) and its selection (M377); demux’s port count must equal ports.len(). Each branch retypes from the demux’s (byte-stream) input caps to its elementary stream via the per-port CapsChanged the demux emits, so a branch element must tolerate the startup broadcast and re-solve then (the M210 demux-node contract); per-branch static negotiation against the port caps is a follow-up.

Source

pub fn build_playbin_graph_with_params<D: MultiOutputElement + 'static>( &self, uri: &str, demux: D, ports: Vec<PlaybinPort>, max_depth: usize, params: &AutoplugParams, ) -> Result<Graph<GraphNode>, AutoplugError>

build_playbin_graph with per-element property assignments applied to every branch’s auto-plugged chain (see AutoplugParams). The same assignments are offered to each branch, so a factory selected on two branches is configured identically.

Source

pub fn build_playbin_graph_with_source<D: MultiOutputElement + 'static>( &self, source: Box<dyn DynSourceLoop>, demux: D, ports: Vec<PlaybinPort>, max_depth: usize, ) -> Result<Graph<GraphNode>, PlaybinGraphError>

Like build_playbin_graph but with a pre-built byte source instead of one derived from the URI’s scheme handler. The playbin uri= auto-fan-out hook (M382) uses this: having probed the file to choose the demuxer, it already knows the container, so it supplies the matching raw-byte source directly rather than the URI handler’s source (which, for file://, may self-demux a different container, e.g. MP4). source must emit the byte stream demux expects.

Trait Implementations§

Source§

impl Debug for Registry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ElementBound for T
where T: Send,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.