Skip to main content

PyTransform

Struct PyTransform 

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

A gst-python-ml element hosted as a first-class g2g transform.

Implementations§

Source§

impl PyTransform

Source

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.

Source

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.

Source

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.

Source

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

Set the draw-label overlay flag forwarded to the Python task.

Source

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).

Source

pub fn emitted_count(&self) -> u64

Count of frames pushed downstream. Useful in tests.

Trait Implementations§

Source§

impl AsyncElement for PyTransform

Source§

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

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

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

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>

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.

Source§

type ProcessFuture<'a> = Pin<Box<dyn Future<Output = Result<(), G2gError>> + 'a>> where Self: 'a

Source§

fn intercept_caps(&self, upstream_caps: &Caps) -> Result<Caps, G2gError>

Source§

fn output_memory(&self) -> MemoryDomainKind

The memory domain of the frames this element emits on its output pad. Default 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).
Source§

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

Source§

fn process<'a>( &'a mut self, packet: PipelinePacket, out: &'a mut dyn OutputSink, ) -> Self::ProcessFuture<'a>

Source§

fn metadata(&self) -> ElementMetadata

Static introspection metadata for this element type (M178): the 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]

The runtime properties this element type exposes (M104), the GObject property-spec analog. Default: none. An element overrides this (and 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>

Set a property by name (M104). Default: every name is 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>

Read a property back by name (M104). Default: None. Overriding elements return the current value for a known property.
Source§

fn configure_output(&mut self, _output_caps: &Caps) -> Result<(), G2gError>

Receive this element’s negotiated OUTPUT (source-pad) caps after the solve, alongside the input caps from [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

This element’s contribution to the pipeline latency query (M12). Default: zero, non-live. Transforms that buffer (jitter buffers, reorder queues) and live sources override this; the linear runners fold the chain into RunStats::latency.
Source§

fn output_domains(&self) -> DomainSet

The full set of memory domains this element can emit on its output pad, not just its preferred one. The producer-capability half of the M351 two-sided allocation-domain negotiation: the runner intersects it with the downstream consumers’ acceptance set and settles on a single domain, so a decoder that can deliver to System or stay resident on the GPU lets the runner keep the frame copy-free when a downstream wants it. Default: just 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)

Receive the downstream peer’s allocation proposal (M12) so this element can allocate its output buffers from a compatible pool. Default: ignore and allocate however the element sees fit.
Source§

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

Offer a clock to the pipeline’s clock election (M12). Default: none. Elements that pace to real hardware (an audio sink to its DAC) override this; the runner elects the highest-priority offered clock.
Source§

fn set_clock_sync(&mut self, _sync: ClockSync)

Receive the pipeline’s elected clock + base time after election, so a sink can present each frame at its running-time deadline (PTS mapped through the active 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>

Take any QoS signal this element wants to send upstream, consuming it. A synchronising sink that dropped a late frame returns a 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>

Cumulative presentation counters a paced sink kept over the run, read by the runner once its arm ends and surfaced in 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>

Take any 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>

Take a target send bitrate (bits/second) this element wants to push upstream, consuming it. A WebRTC egress sink returns its latest congestion-control / BWE estimate here; the runner forwards it onto the incoming link, where the encoder observes it as PushOutcome::Bitrate and retargets. Called by the runner after each process. Default: none.
Source§

fn handles_keyframe_requests(&self) -> bool

Whether this element consumes a downstream keyframe request (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

As Self::handles_keyframe_requests, for a downstream bitrate target (PushOutcome::Bitrate): an encoder that retargets returns true.
Source§

fn absorbs_orientation(&self) -> bool

Whether this sink applies an 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

Whether 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 more
Source§

fn handles_qos(&self) -> bool

Whether this element acts on a downstream QoS report itself, ie it sheds work when the sink is behind (a decoder skipping non-reference frames). Default 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

The per-frame metadata this element wants attached to the frames it receives (M976), the pull half of 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 more
Source§

fn caps_constraint_as_sink(&self) -> CapsConstraint<'_>

M16 step 5b: declare this element’s negotiation-time constraint when used as the sink of a chain. The default returns the legacy bridge (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>

What this element is willing to pay for each alternative of the set its 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)

Receive this instance’s log name (M179), assigned by the runner as <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)

Override this instance’s log category (M845), which is otherwise the element type name. Default: ignore. An element that logs about itself stores it (in a 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

The log category for this element (M179): its short type name by default, the G2G_DEBUG filtering key. A wrapper that erases another element forwards the inner one’s category instead.
Source§

impl Debug for PyTransform

Source§

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

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

impl PadTemplates for PyTransform

Source§

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>

The first pad template in the given direction, if any.

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> DynAsyncElement for T
where T: AsyncElement,

Source§

fn intercept_caps(&self, upstream_caps: &Caps) -> Result<Caps, G2gError>

Source§

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

Source§

fn configure_output(&mut self, output_caps: &Caps) -> Result<(), G2gError>

Dyn-safe mirror of AsyncElement::configure_output (M185). Defaults to no-op so unaffected erased elements need not implement it.
Source§

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<'_>

Dyn-safe mirror of 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<'_>

Dyn-safe mirror of 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>

Dyn-safe mirror of 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>

Dyn-safe mirror of 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)

Source§

fn latency(&self) -> LatencyReport

Dyn-safe mirror of 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

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

fn output_domains(&self) -> DomainSet

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

fn input_domains(&self) -> DomainSet

Dyn-safe mirror of AsyncElement::input_domains. Default DomainSet::ALL.
Source§

fn meta_requests(&self) -> MetaRequests

Dyn-safe mirror of AsyncElement::meta_requests. Default: nothing requested.
Source§

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

Dyn-safe mirror of 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)

Dyn-safe mirror of 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>

Dyn-safe mirror of AsyncElement::take_qos, so an erased sink can send a QoS signal upstream. Defaults to nothing.
Source§

fn presentation_stats(&self) -> Option<PresentationStats>

Dyn-safe mirror of 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>

Dyn-safe mirror of AsyncElement::take_reconfigure, so an erased sink can request a keyframe / renegotiation upstream. Defaults to nothing.
Source§

fn take_bitrate(&mut self) -> Option<u32>

Dyn-safe mirror of AsyncElement::take_bitrate, so an erased sink can push a target bitrate upstream. Defaults to nothing.
Source§

fn handles_keyframe_requests(&self) -> bool

Dyn-safe mirror of AsyncElement::handles_keyframe_requests (M720).
Source§

fn handles_bitrate_requests(&self) -> bool

Dyn-safe mirror of AsyncElement::handles_bitrate_requests (M720).
Source§

fn absorbs_orientation(&self) -> bool

Dyn-safe mirror of AsyncElement::absorbs_orientation (M1058).
Source§

fn handles_orientation(&self) -> bool

Dyn-safe mirror of AsyncElement::handles_orientation (M1058).
Source§

fn handles_qos(&self) -> bool

Dyn-safe mirror of AsyncElement::handles_qos (M997).
Source§

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

Dyn-safe mirror of AsyncElement::properties, so a gst-inspect dump and the gst-launch parser can introspect / set an erased element.
Source§

fn metadata(&self) -> ElementMetadata

Dyn-safe mirror of 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

The log category for this erased element (M179): its short type name by default (the blanket impl fills it from 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)

Dyn-safe mirror of AsyncElement::set_instance_name, so the runner can name an erased element instance for logging.
Source§

fn set_log_category(&mut self, category: String)

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

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

Dyn-safe mirror of 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>

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

fn drive_transform_arm<'s>( self: Box<T>, io: TransformArmIo, ) -> Pin<Box<dyn Future<Output = Result<u64, G2gError>> + 's>>
where T: 's,

Source§

fn drive_sink_arm<'s>( self: Box<T>, io: SinkArmIo, ) -> Pin<Box<dyn Future<Output = Result<u64, G2gError>> + 's>>
where T: 's,

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.