pub struct PySource { /* private fields */ }Expand description
A Python frame source hosted as a first-class g2g source.
Implementations§
Source§impl PySource
impl PySource
Sourcepub fn new(module: impl Into<String>, class: impl Into<String>) -> Self
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.
Sourcepub fn with_caps(self, caps: Caps) -> Self
pub fn with_caps(self, caps: Caps) -> Self
Set the fixed output caps (must be fully fixed: concrete format/dims/rate).
Sourcepub fn with_num_buffers(self, n: u64) -> Self
pub fn with_num_buffers(self, n: u64) -> Self
Stop after n frames (otherwise run until the Python source returns EOS).
Sourcepub fn with_cuda_frames(self, on: bool) -> Self
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).
Sourcepub fn emitted_count(&self) -> u64
pub fn emitted_count(&self) -> u64
Count of frames pushed downstream. Useful in tests.
Trait Implementations§
Source§impl SourceLoop for PySource
impl SourceLoop for PySource
Source§fn configured_output_caps(&self) -> Option<Caps>
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
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).
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
type CapsFuture<'a> = Ready<Result<Caps, G2gError>> where Self: 'a
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>
fn intercept_caps<'a>(&'a mut self) -> Self::CapsFuture<'a>
&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)).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>
fn run<'a>(&'a mut self, out: &'a mut dyn OutputSink) -> Self::RunFuture<'a>
PipelinePacket::Eos before returning Ok. Returns the number
of DataFrame packets pushed (excluding Eos).Source§fn properties(&self) -> &'static [PropertySpec]
fn properties(&self) -> &'static [PropertySpec]
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>
fn set_property( &mut self, name: &str, value: PropValue, ) -> Result<(), PropError>
PropError::Unknown.Source§fn get_property(&self, name: &str) -> Option<PropValue>
fn get_property(&self, name: &str) -> Option<PropValue>
None.Source§fn reconfigure(&mut self, _request: Reconfigure) -> Result<Caps, G2gError>
fn reconfigure(&mut self, _request: Reconfigure) -> Result<Caps, G2gError>
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 moreSource§fn latency(&self) -> LatencyReport
fn latency(&self) -> LatencyReport
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
fn output_domains(&self) -> DomainSet
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>
fn query_duration(&self) -> Option<u64>
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)
fn configure_allocation(&mut self, _params: &AllocationParams)
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>
fn provide_clock(&self) -> Option<ClockCandidate>
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
fn caps_constraint<'a>( &'a mut self, ) -> impl Future<Output = Result<CapsConstraint<'a>, G2gError>> + 'a
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>
fn caps_preferences(&self) -> Option<CapsPreferences>
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>
fn probe_output_caps(&mut self) -> Option<Caps>
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
fn metadata(&self) -> ElementMetadata
gst-inspect “Factory Details”. Default: empty.Source§fn set_instance_name(&mut self, _name: String)
fn set_instance_name(&mut self, _name: String)
Source§fn set_log_category(&mut self, _category: String)
fn set_log_category(&mut self, _category: String)
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§
impl Freeze for PySource
impl RefUnwindSafe for PySource
impl Send for PySource
impl Sync for PySource
impl Unpin for PySource
impl UnsafeUnpin for PySource
impl UnwindSafe for PySource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> DynSourceLoop for Twhere
T: SourceLoop,
impl<T> DynSourceLoop for Twhere
T: SourceLoop,
Source§fn produced_caps<'a>(
&'a mut self,
) -> Pin<Box<dyn Future<Output = Result<CapsSet, G2gError>> + 'a>>
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.
fn intercept_caps<'a>( &'a mut self, ) -> Pin<Box<dyn Future<Output = Result<Caps, G2gError>> + 'a>>
Source§fn caps_preferences(&self) -> Option<CapsPreferences>
fn caps_preferences(&self) -> Option<CapsPreferences>
SourceLoop::caps_preferences, so an erased
source’s declared per-alternative costs reach the solver. Defaults to
None (cost = alternative index), matching SourceLoop.fn configure_pipeline( &mut self, absolute_caps: &Caps, ) -> Result<ConfigureOutcome, G2gError>
fn run<'a>( &'a mut self, out: &'a mut dyn OutputSink, ) -> Pin<Box<dyn Future<Output = Result<u64, G2gError>> + 'a>>
fn reconfigure(&mut self, request: Reconfigure) -> Result<Caps, G2gError>
Source§fn latency(&self) -> LatencyReport
fn latency(&self) -> LatencyReport
SourceLoop::latency, so the DAG runner folds a
source’s latency contribution like the linear runner does.Source§fn output_memory(&self) -> MemoryDomainKind
fn output_memory(&self) -> MemoryDomainKind
SourceLoop::output_memory. Default
System.Source§fn output_domains(&self) -> DomainSet
fn output_domains(&self) -> DomainSet
SourceLoop::output_domains. Default
only(output_memory()).Source§fn query_duration(&self) -> Option<u64>
fn query_duration(&self) -> Option<u64>
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>
fn provide_clock(&self) -> Option<ClockCandidate>
SourceLoop::provide_clock, for the runner’s clock
election.Source§fn configure_allocation(&mut self, params: &AllocationParams)
fn configure_allocation(&mut self, params: &AllocationParams)
SourceLoop::configure_allocation, the upstream end
of the M12 allocation cascade.Source§fn configured_output_caps(&self) -> Option<Caps>
fn configured_output_caps(&self) -> Option<Caps>
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>
fn probe_output_caps(&mut self) -> Option<Caps>
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]
fn properties(&self) -> &'static [PropertySpec]
SourceLoop::properties, for gst-inspect /
gst-launch introspection of an erased source.Source§fn metadata(&self) -> ElementMetadata
fn metadata(&self) -> ElementMetadata
SourceLoop::metadata, for the gst-inspect
“Factory Details” of an erased source. Defaults to empty.Source§fn log_category(&self) -> &'static str
fn log_category(&self) -> &'static str
Source§fn set_instance_name(&mut self, name: String)
fn set_instance_name(&mut self, name: String)
SourceLoop::set_instance_name.Source§fn set_log_category(&mut self, category: String)
fn set_log_category(&mut self, category: String)
SourceLoop::set_log_category.Source§fn set_property(
&mut self,
name: &str,
value: PropValue,
) -> Result<(), PropError>
fn set_property( &mut self, name: &str, value: PropValue, ) -> Result<(), PropError>
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>
fn get_property(&self, name: &str) -> Option<PropValue>
SourceLoop::get_property. Defaults to None; the
blanket impl forwards to the source.