Skip to main content

PySource

Struct PySource 

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

A Python frame source hosted as a first-class g2g source.

Implementations§

Source§

impl PySource

Source

pub fn new(module: impl Into<String>, class: impl Into<String>) -> Self

Host class from Python module as a frame source. Default caps are RGBA 320x240 @ 30; override with with_caps or the format / width / height / framerate properties.

Source

pub fn with_caps(self, caps: Caps) -> Self

Set the fixed output caps (must be fully fixed: concrete format/dims/rate).

Source

pub fn with_num_buffers(self, n: u64) -> Self

Stop after n frames (otherwise run until the Python source returns EOS).

Source

pub fn with_cuda_frames(self, on: bool) -> Self

Host a source that produces GPU-resident CUDA surfaces through g2g_produce_cuda, so the frames leave in the Cuda memory domain and the caps must be semi-planar (NV12 / P010).

Source

pub fn emitted_count(&self) -> u64

Count of frames pushed downstream. Useful in tests.

Trait Implementations§

Source§

impl Debug for PySource

Source§

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

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

impl SourceLoop for PySource

Source§

fn configured_output_caps(&self) -> Option<Caps>

The output caps are property-fixed, so the auto-plug parser can read them without negotiation.

Source§

fn output_memory(&self) -> MemoryDomainKind

A GPU source emits into the Cuda domain, so a downstream GPU consumer takes the frames with no upload and a CPU consumer gets a download spliced (M985).

Source§

type RunFuture<'a> = Pin<Box<dyn Future<Output = Result<u64, G2gError>> + 'a>> where Self: 'a

Source§

type CapsFuture<'a> = Ready<Result<Caps, G2gError>> where Self: 'a

Future returned by [intercept_caps]. Async so a source can perform I/O during negotiation (e.g. RTSP DESCRIBE + SDP parse, hardware capability probe). Sources that produce caps without I/O can return core::future::Ready and the runner pays no cost.
Source§

fn intercept_caps<'a>(&'a mut self) -> Self::CapsFuture<'a>

Negotiation-time caps query. Awaited by the runner during startup (and on re-fixate retries). &mut self because real implementations (e.g. RtspSrc) open a session here and stash the connected state for run to resume from. Synchronous sources just return core::future::ready(Ok(caps)).
Source§

fn configure_pipeline( &mut self, absolute_caps: &Caps, ) -> Result<ConfigureOutcome, G2gError>

Source§

fn run<'a>(&'a mut self, out: &'a mut dyn OutputSink) -> Self::RunFuture<'a>

Runs the source until EOS or error. The implementation MUST emit a final PipelinePacket::Eos before returning Ok. Returns the number of DataFrame packets pushed (excluding Eos).
Source§

fn properties(&self) -> &'static [PropertySpec]

The runtime properties this source type exposes (M104), the GObject property-spec analog. Default: none. A source overrides this (and set_property / get_property) to be settable by name from a gst-launch pipeline (eg filesrc location=..., videotestsrc pattern=...).
Source§

fn set_property( &mut self, name: &str, value: PropValue, ) -> Result<(), PropError>

Set a property by name (M104). Default: PropError::Unknown.
Source§

fn get_property(&self, name: &str) -> Option<PropValue>

Read a property back by name (M104). Default: None.
Source§

fn reconfigure(&mut self, _request: Reconfigure) -> Result<Caps, G2gError>

Handle a downstream-originated Reconfigure request observed via PushOutcome::Reconfigure during run. Implementations that can retarget (eg picking a sub-stream over a main stream from an IP camera, or switching bitrate) return the new caps they will produce next; the source’s run loop is then responsible for emitting a CapsChanged packet and resuming under those caps. Read more
Source§

fn latency(&self) -> LatencyReport

This source’s latency contribution to the pipeline latency query (M12). Live capture sources (cameras, RTSP) override this to report live with their capture interval as min_ns; the default is zero, non-live (eg a file or test-pattern source that can produce data on demand).
Source§

fn output_domains(&self) -> DomainSet

The full set of memory domains this source can emit (M351). The producer-capability half of the two-sided allocation-domain negotiation; see AsyncElement::output_domains. Default: just output_memory. A GPU capture source that can also deliver to System overrides this.
Source§

fn query_duration(&self) -> Option<u64>

The total stream duration in nanoseconds, the source’s answer to the application DURATION query (M203). A source that knows the total length (a file / container source after reading its header, e.g. Mp4Src) overrides this; the runner publishes it on the PipelineProgress handle and posts a DurationChanged. The default None is “unknown” (a live / open-ended source, or one whose length is not yet parsed). Polled by the runner just before run.
Source§

fn configure_allocation(&mut self, _params: &AllocationParams)

Receive the downstream peer’s allocation proposal (M12) so the source can allocate its output BufferPool from compatible parameters (size, count, alignment, domain). Default: ignore and allocate the source’s own way. The proposal is advisory; a source that cannot honor it (eg cannot produce the requested domain) falls back silently.
Source§

fn provide_clock(&self) -> Option<ClockCandidate>

Offer a clock to the pipeline’s clock election (M12). Default: none. Live capture sources override this to provide their hardware capture clock at ClockPriority::LiveSource so the pipeline paces to capture cadence.
Source§

fn caps_constraint<'a>( &'a mut self, ) -> impl Future<Output = Result<CapsConstraint<'a>, G2gError>> + 'a

M16 step 5f: declare this source’s negotiation-time constraint. Default: eagerly await intercept_caps() and wrap as a LegacySource(Caps) for the solver. Migrated sources override to return Produces(CapsSet) (or another native variant) and the chain takes the native arc-consistency path when every other element is also native.
Source§

fn caps_preferences(&self) -> Option<CapsPreferences>

What this source is willing to pay for each alternative of the produce set its caps_constraint advertises. Default None: the alternatives are already in preference order and cost their index. A source overrides this to declare equal cost between formats it does not care about (so a downstream element’s preference decides) or a gap wide enough that a downstream preference cannot pull the chain onto its fallback.
Source§

fn probe_output_caps(&mut self) -> Option<Caps>

Like configured_output_caps but permitted to do I/O to determine the type (M480): the auto-plug decodebin parser calls this once, at parse time, to pick the demuxer. A bytestream-format= auto source overrides it to sniff the file header now (so a mislabeled .ts that is really an MP4 still auto-plugs the right demuxer, the way GStreamer’s runtime typefind would), where configured_output_caps returns None because it may not read. Default: the no-I/O caps.
Source§

fn metadata(&self) -> ElementMetadata

Static introspection metadata for this source type (M178), the gst-inspect “Factory Details”. Default: empty.
Source§

fn set_instance_name(&mut self, _name: String)

Receive this source instance’s log name (M179), assigned by the runner. Default: ignore.
Source§

fn set_log_category(&mut self, _category: String)

Override this instance’s log category (M845), mirroring AsyncElement::set_log_category. Default: ignore. A source that logs about itself stores it in a LogName and returns it from LogSource::log_category_override.

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> DynSourceLoop for T
where T: SourceLoop,

Source§

fn produced_caps<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<CapsSet, G2gError>> + 'a>>

A source shape is Produces (native) or LegacySource (the migration bridge). Any other variant means a sink / transform constraint on a source slot, which is an element bug, so it fails loud rather than negotiating something the source never offered.

Source§

fn intercept_caps<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Caps, G2gError>> + 'a>>

Source§

fn caps_preferences(&self) -> Option<CapsPreferences>

Dyn-safe mirror of SourceLoop::caps_preferences, so an erased source’s declared per-alternative costs reach the solver. Defaults to None (cost = alternative index), matching SourceLoop.
Source§

fn configure_pipeline( &mut self, absolute_caps: &Caps, ) -> Result<ConfigureOutcome, G2gError>

Source§

fn run<'a>( &'a mut self, out: &'a mut dyn OutputSink, ) -> Pin<Box<dyn Future<Output = Result<u64, G2gError>> + 'a>>

Source§

fn reconfigure(&mut self, request: Reconfigure) -> Result<Caps, G2gError>

Source§

fn latency(&self) -> LatencyReport

Dyn-safe mirror of SourceLoop::latency, so the DAG runner folds a source’s latency contribution like the linear runner does.
Source§

fn output_memory(&self) -> MemoryDomainKind

Dyn-safe mirror of SourceLoop::output_memory. Default System.
Source§

fn output_domains(&self) -> DomainSet

Dyn-safe mirror of SourceLoop::output_domains. Default only(output_memory()).
Source§

fn query_duration(&self) -> Option<u64>

Dyn-safe mirror of SourceLoop::query_duration (M203), so the DAG runner can publish an erased source’s duration on the progress handle.
Source§

fn provide_clock(&self) -> Option<ClockCandidate>

Dyn-safe mirror of SourceLoop::provide_clock, for the runner’s clock election.
Source§

fn configure_allocation(&mut self, params: &AllocationParams)

Dyn-safe mirror of SourceLoop::configure_allocation, the upstream end of the M12 allocation cascade.
Source§

fn configured_output_caps(&self) -> Option<Caps>

Dyn-safe mirror of SourceLoop::configured_output_caps (M195), so the decodebin parser can read an erased source’s property-driven caps.
Source§

fn probe_output_caps(&mut self) -> Option<Caps>

Dyn-safe mirror of SourceLoop::probe_output_caps (M480): the parse-time caps decodebin uses to pick a demuxer, allowed to sniff the header.
Source§

fn properties(&self) -> &'static [PropertySpec]

Dyn-safe mirror of SourceLoop::properties, for gst-inspect / gst-launch introspection of an erased source.
Source§

fn metadata(&self) -> ElementMetadata

Dyn-safe mirror of SourceLoop::metadata, for the gst-inspect “Factory Details” of an erased source. Defaults to empty.
Source§

fn log_category(&self) -> &'static str

The log category for this erased source (M179): its short type name by default (the blanket impl fills it), so the runner can name and log it.
Source§

fn set_instance_name(&mut self, name: String)

Dyn-safe mirror of SourceLoop::set_instance_name.
Source§

fn set_log_category(&mut self, category: String)

Dyn-safe mirror of SourceLoop::set_log_category.
Source§

fn set_property( &mut self, name: &str, value: PropValue, ) -> Result<(), PropError>

Dyn-safe mirror of SourceLoop::set_property. Defaults to “no properties”; the blanket impl<T: SourceLoop> overrides it to forward.
Source§

fn get_property(&self, name: &str) -> Option<PropValue>

Dyn-safe mirror of SourceLoop::get_property. Defaults to None; the blanket impl forwards to the source.
Source§

impl<T> ElementBound for T

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.