pub struct PyTransform { /* private fields */ }Expand description
A gst-python-ml element hosted as a first-class g2g transform.
Implementations§
Source§impl PyTransform
impl PyTransform
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 the class from Python module. The instance is created at
configure_pipeline time (under the GIL), not here, so construction
stays cheap and infallible like the other elements’ new.
Sourcepub fn with_accept(self, caps: Caps) -> Self
pub fn with_accept(self, caps: Caps) -> Self
Override the accepted sink caps (e.g. to host an NV12 element). The
supported set may carry Any dims/rate: negotiation fixes them against
concrete upstream caps, so process always sees a fixed format.
Sourcepub fn with_produce(self, caps: Caps) -> Self
pub fn with_produce(self, caps: Caps) -> Self
Emit caps downstream instead of the negotiated input caps, for a hosted
element that changes media type.
Sourcepub fn with_draw_label(self, on: bool) -> Self
pub fn with_draw_label(self, on: bool) -> Self
Set the draw-label overlay flag forwarded to the Python task.
Sourcepub fn with_cuda_frames(self, on: bool) -> Self
pub fn with_cuda_frames(self, on: bool) -> Self
Host an element that works on GPU-resident CUDA frames: they reach it as
__cuda_array_interface__ planes through g2g_process_cuda and flow on
still device-resident. Sets this element’s whole memory-domain story (see
AsyncElement::input_domains); the hosted class must define
g2g_process_cuda 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 AsyncElement for PyTransform
impl AsyncElement for PyTransform
Source§fn caps_constraint_as_transform(&self) -> CapsConstraint<'_>
fn caps_constraint_as_transform(&self) -> CapsConstraint<'_>
The hosted element reads and writes the frame in place, so the output
caps equal the input (when it is in the accepted set) unless
output-caps= declared a different media type. Declaring this native
constraint (rather than the default legacy intercept-only path, whose
output the solver leaves unconstrained) lets the graph solver derive this
element’s output edge and lets the runtime forward-caps resolve steer a
mid-stream CapsChanged (e.g. an upstream decoder’s first-frame caps)
cleanly through it, instead of stalling on an unconstrained boundary.
Source§fn is_format_boundary(&self) -> bool
fn is_format_boundary(&self) -> bool
A hosted element that declares output-caps= turns one media type into
another (audio into a transcript), which is what a boundary is.
Source§fn propose_output_caps(&self, input: &Caps) -> Caps
fn propose_output_caps(&self, input: &Caps) -> Caps
The legacy-bridge half of the constraint above, for the runner paths that derive a boundary element’s output side through this hook.
Source§fn input_domains(&self) -> DomainSet
fn input_domains(&self) -> DomainSet
The hosted element reads the frame where it already is and forwards it
untouched, so the domain it emits is the domain it consumes: System bytes
over the buffer protocol, or CUDA device memory over
__cuda_array_interface__ under cuda-frames. Declaring one domain on
both pads keeps that relation honest, so the domain-converter auto-plug
splices a download / upload ahead of this element when upstream cannot
deliver what the hosted code reads, and splices nothing after it (the
frame really does leave in the declared domain).
Source§fn propose_allocation(&self, caps: &Caps) -> Option<AllocationParams>
fn propose_allocation(&self, caps: &Caps) -> Option<AllocationParams>
Ask upstream to allocate in the domain the hosted code can read, so a multi-domain producer (an NVDEC that can keep frames on the device or download them) settles on it rather than needing a converter node. Only the domain is constrained: this element allocates nothing of its own, so it imposes no buffer count or alignment, and the size is one frame.
type ProcessFuture<'a> = Pin<Box<dyn Future<Output = Result<(), G2gError>> + 'a>> where Self: 'a
fn intercept_caps(&self, upstream_caps: &Caps) -> Result<Caps, G2gError>
Source§fn output_memory(&self) -> MemoryDomainKind
fn output_memory(&self) -> MemoryDomainKind
System; a GPU producer (a hardware
decoder emitting into VRAM, a wgpu/CUDA bridge) overrides it. Surfaced
per edge by the negotiate-only path so the DOT dump can mark the GPU /
zero-copy links (it is not part of Caps; see DESIGN.md 4.13.9).fn configure_pipeline( &mut self, absolute_caps: &Caps, ) -> Result<ConfigureOutcome, G2gError>
fn process<'a>( &'a mut self, packet: PipelinePacket, out: &'a mut dyn OutputSink, ) -> Self::ProcessFuture<'a>
Source§fn metadata(&self) -> ElementMetadata
fn metadata(&self) -> ElementMetadata
gst-inspect “Factory Details” (long-name / classification / description
/ author). Default: empty, like properties. An
element overrides it with a const ElementMetadata to document itself.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 or inspectable by a
gst-inspect dump. The with_* builders remain the zero-cost
construction path; this is the string-keyed runtime face.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 (no properties). An overriding element validates
the value kind against its properties spec and
applies it.Source§fn get_property(&self, name: &str) -> Option<PropValue>
fn get_property(&self, name: &str) -> Option<PropValue>
None. Overriding elements
return the current value for a known property.Source§fn configure_output(&mut self, _output_caps: &Caps) -> Result<(), G2gError>
fn configure_output(&mut self, _output_caps: &Caps) -> Result<(), G2gError>
configure_pipeline] (M185). A
geometry / format / rate-changing transform (videoscale, videoconvert,
audioresample) uses this to take its target from a downstream capsfilter
instead of its own properties, the gst caps-driven idiom. Default: no-op,
so elements that don’t need it (and runners that don’t yet deliver it)
are unaffected. Called only on transforms, with their single output
link’s caps; sources and sinks never receive it.Source§fn latency(&self) -> LatencyReport
fn latency(&self) -> LatencyReport
RunStats::latency.Source§fn output_domains(&self) -> DomainSet
fn output_domains(&self) -> DomainSet
output_memory, so a single-domain element
negotiates exactly as before. A multi-domain producer overrides this.Source§fn configure_allocation(&mut self, _params: &AllocationParams)
fn configure_allocation(&mut self, _params: &AllocationParams)
Source§fn provide_clock(&self) -> Option<ClockCandidate>
fn provide_clock(&self) -> Option<ClockCandidate>
Source§fn set_clock_sync(&mut self, _sync: ClockSync)
fn set_clock_sync(&mut self, _sync: ClockSync)
Segment) — the “use PTS to decide when to display”
path. The runner calls this once before streaming, only when a clock was
elected. Default: ignore (present as fast as backpressure allows, the
pre-sync behaviour). See ClockSync.Source§fn take_qos(&mut self) -> Option<QosMessage>
fn take_qos(&mut self) -> Option<QosMessage>
QosMessage
here; the runner forwards it onto the element’s incoming link, where the
producer observes it as PushOutcome::Qos. Called by the runner after
each process. Default: nothing to send.Source§fn presentation_stats(&self) -> Option<PresentationStats>
fn presentation_stats(&self) -> Option<PresentationStats>
RunStats::per_element. A
display / audio sink that counts what it actually presented overrides
this. Default: not a presenting sink.Source§fn take_reconfigure(&mut self) -> Option<Reconfigure>
fn take_reconfigure(&mut self) -> Option<Reconfigure>
Reconfigure this element wants to send upstream, consuming
it. The sink/transform analog of Self::take_qos: the runner forwards
it onto the element’s incoming link, where the producer observes it as
PushOutcome::Reconfigure. The keyframe-request path uses this: a
WebRTC egress sink that received a remote PLI returns
Reconfigure::ForceKeyframe so the upstream encoder emits an IDR.
Called by the runner after each process. Default: nothing to send.Source§fn take_bitrate(&mut self) -> Option<u32>
fn take_bitrate(&mut self) -> Option<u32>
PushOutcome::Bitrate
and retargets. Called by the runner after each process. Default: none.Source§fn handles_keyframe_requests(&self) -> bool
fn handles_keyframe_requests(&self) -> bool
PushOutcome::Reconfigure(ForceKeyframe)) itself, i.e. it is an
encoder that forces an IDR. Default false: the runner then relays the
request onto the element’s input link (M720), so a PLI crosses any
number of pass-through transforms (a parser between the encoder and a
WebRTC sink) to reach the encoder.Source§fn handles_bitrate_requests(&self) -> bool
fn handles_bitrate_requests(&self) -> bool
Self::handles_keyframe_requests, for a downstream bitrate target
(PushOutcome::Bitrate): an encoder that retargets returns true.Source§fn absorbs_orientation(&self) -> bool
fn absorbs_orientation(&self) -> bool
OrientationMeta itself, i.e. it can
turn the picture for free at present time. The runner sends
Reconfigure::AbsorbOrientation up this sink’s input link before the
first frame is pulled, so a videoflip upstream attaches the descriptor
instead of remapping pixels. Default false: the flip realizes the
rotation as it always did.Source§fn handles_orientation(&self) -> bool
fn handles_orientation(&self) -> bool
Reconfigure::AbsorbOrientation stops at this element instead
of being relayed toward the source. true for videoflip, which answers
it by switching to the descriptor, and for any transform whose output
geometry is chosen in the buffer’s stored coordinates (a crop), which
would mean something different once the picture is turned. Default
false: the advertisement crosses. Read moreSource§fn handles_qos(&self) -> bool
fn handles_qos(&self) -> bool
false: the runner relays the report onto the element’s input
link (M175) so it reaches the source, and process never sees it.
true surfaces it as PushOutcome::Qos from the element’s own push
instead, and the relay stops here.Source§fn meta_requests(&self) -> MetaRequests
fn meta_requests(&self) -> MetaRequests
meta_transform’s push half. The
runner unions the declaration into the allocation cascade travelling
upstream, so a producer any number of hops away can ask
MetaRequests::wants in
configure_allocation and skip work nobody
downstream reads. Default: nothing requested, and a graph where every
element defaults cascades exactly as it did before the hook existed. Read moreSource§fn caps_constraint_as_sink(&self) -> CapsConstraint<'_>
fn caps_constraint_as_sink(&self) -> CapsConstraint<'_>
LegacySink wrapping today’s intercept_caps).
Migrated sinks override with Accepts(CapsSet) (or a more
elaborate native variant) to participate in arc consistency
and skip the dynamic intercept callback.Source§fn caps_preferences(&self) -> Option<CapsPreferences>
fn caps_preferences(&self) -> Option<CapsPreferences>
caps_constraint_as_* advertises. Default None: the alternatives are
already in preference order and cost their index. An element overrides
this to declare equal cost between alternatives it does not care
about (so a neighbour’s preference decides) or a gap wide enough that a
neighbour’s preference cannot pull the chain onto its fallback.Source§fn set_instance_name(&mut self, _name: String)
fn set_instance_name(&mut self, _name: String)
<category>N. Default: ignore. An element that logs about itself stores
it and returns it from its LogSource so its log
lines carry the instance name.Source§fn set_log_category(&mut self, _category: String)
fn set_log_category(&mut self, _category: String)
LogName) and returns it from
LogSource::log_category_override, so G2G_DEBUG filtering keys off the
override for this instance while its siblings keep the type category.Source§fn log_category(&self) -> &'static str
fn log_category(&self) -> &'static str
G2G_DEBUG filtering key. A wrapper that erases another
element forwards the inner one’s category instead.Source§impl Debug for PyTransform
impl Debug for PyTransform
Source§impl PadTemplates for PyTransform
impl PadTemplates for PyTransform
Source§fn pad_templates() -> Vec<PadTemplate>
fn pad_templates() -> Vec<PadTemplate>
Advertise the default accepted format (RGBA, any geometry) on both pads
for gst-inspect / autoplug. A pyelement is a same-format transform,
so sink and source carry the same set. (with_accept can host another
format programmatically; the launch template reflects the default.)
Source§fn pad_template(direction: PadDirection) -> Option<PadTemplate>
fn pad_template(direction: PadDirection) -> Option<PadTemplate>
Auto Trait Implementations§
impl Freeze for PyTransform
impl RefUnwindSafe for PyTransform
impl Send for PyTransform
impl Sync for PyTransform
impl Unpin for PyTransform
impl UnsafeUnpin for PyTransform
impl UnwindSafe for PyTransform
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> DynAsyncElement for Twhere
T: AsyncElement,
impl<T> DynAsyncElement for Twhere
T: AsyncElement,
fn intercept_caps(&self, upstream_caps: &Caps) -> Result<Caps, G2gError>
fn configure_pipeline( &mut self, absolute_caps: &Caps, ) -> Result<ConfigureOutcome, G2gError>
Source§fn configure_output(&mut self, output_caps: &Caps) -> Result<(), G2gError>
fn configure_output(&mut self, output_caps: &Caps) -> Result<(), G2gError>
AsyncElement::configure_output (M185). Defaults to
no-op so unaffected erased elements need not implement it.fn process<'a>( &'a mut self, packet: PipelinePacket, out: &'a mut dyn OutputSink, ) -> Pin<Box<dyn Future<Output = Result<(), G2gError>> + 'a>>
Source§fn caps_constraint_as_sink(&self) -> CapsConstraint<'_>
fn caps_constraint_as_sink(&self) -> CapsConstraint<'_>
AsyncElement::caps_constraint_as_sink, so a
Box-erased branch sink (fan-out Phase C FO-2) can be re-solved
against its declared constraint on a mid-stream CapsChanged.Source§fn caps_constraint_as_transform(&self) -> CapsConstraint<'_>
fn caps_constraint_as_transform(&self) -> CapsConstraint<'_>
AsyncElement::caps_constraint_as_transform, so
an interior element of an N-element linear chain (run_linear_chain)
declares its transform constraint to the solver while erased.Source§fn caps_preferences(&self) -> Option<CapsPreferences>
fn caps_preferences(&self) -> Option<CapsPreferences>
AsyncElement::caps_preferences, so an erased
element’s declared per-alternative costs reach the solver. Defaults to
None (cost = alternative index), matching AsyncElement.Source§fn propose_allocation(&self, caps: &Caps) -> Option<AllocationParams>
fn propose_allocation(&self, caps: &Caps) -> Option<AllocationParams>
AsyncElement::propose_allocation, so a
Box-erased branch sink can re-derive its own pool on a mid-stream
caps change (fan-out element-local α).Source§fn configure_allocation(&mut self, params: &AllocationParams)
fn configure_allocation(&mut self, params: &AllocationParams)
AsyncElement::configure_allocation.Source§fn latency(&self) -> LatencyReport
fn latency(&self) -> LatencyReport
AsyncElement::latency, so a buffering interior
element of an N-element chain (run_linear_chain) contributes to the
runner’s latency fold. Defaults to zero, matching AsyncElement.Source§fn output_memory(&self) -> MemoryDomainKind
fn output_memory(&self) -> MemoryDomainKind
AsyncElement::output_memory. Default
System.Source§fn output_domains(&self) -> DomainSet
fn output_domains(&self) -> DomainSet
AsyncElement::output_domains. Default
only(output_memory()).Source§fn input_domains(&self) -> DomainSet
fn input_domains(&self) -> DomainSet
AsyncElement::input_domains. Default
DomainSet::ALL.Source§fn meta_requests(&self) -> MetaRequests
fn meta_requests(&self) -> MetaRequests
AsyncElement::meta_requests. Default: nothing
requested.Source§fn provide_clock(&self) -> Option<ClockCandidate>
fn provide_clock(&self) -> Option<ClockCandidate>
AsyncElement::provide_clock, so an interior
element that paces to hardware joins the runner’s clock election.
Defaults to none.Source§fn set_clock_sync(&mut self, sync: ClockSync)
fn set_clock_sync(&mut self, sync: ClockSync)
AsyncElement::set_clock_sync, so an erased sink
receives the elected clock + base time. Defaults to ignore.Source§fn take_qos(&mut self) -> Option<QosMessage>
fn take_qos(&mut self) -> Option<QosMessage>
AsyncElement::take_qos, so an erased sink can send
a QoS signal upstream. Defaults to nothing.Source§fn presentation_stats(&self) -> Option<PresentationStats>
fn presentation_stats(&self) -> Option<PresentationStats>
AsyncElement::presentation_stats, so the runner
can read an erased sink’s presentation counters at end of run.Source§fn take_reconfigure(&mut self) -> Option<Reconfigure>
fn take_reconfigure(&mut self) -> Option<Reconfigure>
AsyncElement::take_reconfigure, so an erased sink
can request a keyframe / renegotiation upstream. Defaults to nothing.Source§fn take_bitrate(&mut self) -> Option<u32>
fn take_bitrate(&mut self) -> Option<u32>
AsyncElement::take_bitrate, so an erased sink can
push a target bitrate upstream. Defaults to nothing.Source§fn handles_keyframe_requests(&self) -> bool
fn handles_keyframe_requests(&self) -> bool
AsyncElement::handles_keyframe_requests (M720).Source§fn handles_bitrate_requests(&self) -> bool
fn handles_bitrate_requests(&self) -> bool
AsyncElement::handles_bitrate_requests (M720).Source§fn absorbs_orientation(&self) -> bool
fn absorbs_orientation(&self) -> bool
AsyncElement::absorbs_orientation (M1058).Source§fn handles_orientation(&self) -> bool
fn handles_orientation(&self) -> bool
AsyncElement::handles_orientation (M1058).Source§fn handles_qos(&self) -> bool
fn handles_qos(&self) -> bool
AsyncElement::handles_qos (M997).Source§fn properties(&self) -> &'static [PropertySpec]
fn properties(&self) -> &'static [PropertySpec]
AsyncElement::properties, so a gst-inspect dump
and the gst-launch parser can introspect / set an erased element.Source§fn metadata(&self) -> ElementMetadata
fn metadata(&self) -> ElementMetadata
AsyncElement::metadata, so a gst-inspect dump can
read an erased element’s “Factory Details”. Defaults to empty.Source§fn log_category(&self) -> &'static str
fn log_category(&self) -> &'static str
core::any::type_name), so the
runner can name (<category>N) and log about any element. Filtering key.Source§fn set_instance_name(&mut self, name: String)
fn set_instance_name(&mut self, name: String)
AsyncElement::set_instance_name, so the runner can
name an erased element instance for logging.Source§fn set_log_category(&mut self, category: String)
fn set_log_category(&mut self, category: String)
AsyncElement::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>
AsyncElement::set_property. Defaults to “no
properties” so a hand-written DynAsyncElement need not implement it; the
blanket impl<T: AsyncElement> overrides it to forward to the element.Source§fn get_property(&self, name: &str) -> Option<PropValue>
fn get_property(&self, name: &str) -> Option<PropValue>
AsyncElement::get_property. Defaults to None; the
blanket impl forwards to the element.