gstbase.base_transform
Module for [BaseTransform] class
Types 3
This base class is for filter elements that process data. Elements that are suitable for implementation using #GstBaseTransform are ones where the size and caps of the output is known entirely from the input caps and buffer sizes. These include elements that directly transform one buffer into another, modify the contents of a buffer in-place, as well as elements that collate multiple input buffers into one output buffer, or that expand one input buffer into multiple output buffers. See below for more concrete use cases.
It provides for:
- one sinkpad and one srcpad
- Possible formats on sink and source pad implemented
with custom transform_caps function. By default uses same format on sink and source.
- Handles state changes
- Does flushing
- Push mode
- Pull mode if the sub-class transform can operate on arbitrary data
Use Cases
Passthrough mode
- Element has no interest in modifying the buffer. It may want to inspect it,
in which case the element should have a transform_ip function. If there is no transform_ip function in passthrough mode, the buffer is pushed intact.
- The #GstBaseTransformClass.passthrough_on_same_caps variable
will automatically set/unset passthrough based on whether the element negotiates the same caps on both pads.
- #GstBaseTransformClass.passthrough_on_same_caps on an element that
doesn't implement a transform_caps function is useful for elements that only inspect data (such as level)
- Example elements
- Level
- Videoscale, audioconvert, videoconvert, audioresample in certain modes.
Modifications in-place - input buffer and output buffer are the same thing.
- The element must implement a transform_ip function.
- Output buffer size must <= input buffer size
- If the always_in_place flag is set, non-writable buffers will be copied
and passed to the transform_ip function, otherwise a new buffer will be created and the transform function called.
- Incoming writable buffers will be passed to the transform_ip function
immediately.
- only implementing transform_ip and not transform implies always_in_place = true
- Example elements:
- Volume
- Audioconvert in certain modes (signed/unsigned conversion)
- videoconvert in certain modes (endianness swapping)
Modifications only to the caps/metadata of a buffer
- The element does not require writable data, but non-writable buffers
should be subbuffered so that the meta-information can be replaced.
- Elements wishing to operate in this mode should replace the
prepare_output_buffer method to create subbuffers of the input buffer and set always_in_place to true
- Example elements
- Capsfilter when setting caps on outgoing buffers that have
none.
- identity when it is going to re-timestamp buffers by
datarate.
Normal mode
- always_in_place flag is not set, or there is no transform_ip function
- Element will receive an input buffer and output buffer to operate on.
- Output buffer is allocated by calling the prepare_output_buffer function.
- Example elements:
- Videoscale, videoconvert, audioconvert when doing
scaling/conversions
Special output buffer allocations
- Elements which need to do special allocation of their output buffers
beyond allocating output buffers via the negotiated allocator or buffer pool should implement the prepare_output_buffer method.
- Example elements:
- efence
Sub-class settable flags on GstBaseTransform
- passthrough
- Implies that in the current configuration, the sub-class is not interested in modifying the buffers.
- Elements which are always in passthrough mode whenever the same caps has been negotiated on both pads can set the class variable passthrough_on_same_caps to have this behaviour automatically.
- always_in_place
- Determines whether a non-writable buffer will be copied before passing
to the transform_ip function.
- Implied true if no transform function is implemented.
- Implied false if ONLY transform function is implemented.
BaseTransform self()Returns `this`, for use in `with` statements.BaseTransformGidBuilder builder()Get builder for [gstbase.base_transform.BaseTransform] Returns: New builder objectbool qos() @propertyvoid qos(bool propval) @propertyvoid getAllocator(out gst.allocator.Allocator allocator, out gst.allocation_params.AllocationParams params)Lets #GstBaseTransform sub-classes know the memory allocator used by the base class and its params.bool isInPlace()See if trans is configured as a inplace transform. Returns: true if the transform is configured in inplace mode.bool isPassthrough()See if trans is configured as a passthrough transform. Returns: true if the transform is configured in passthrough mode.bool isQosEnabled()Queries if the transform will handle QoS. Returns: true if QoS is enabled.bool reconfigure()Negotiates src pad caps with downstream elements if the source pad is marked as needing reconfiguring. Unmarks GSTPADFLAGNEEDRECONFIGURE in any case. But marks it again if negotiation fails.void reconfigureSink()Instructs trans to request renegotiation upstream. This function is typically called after properties on the transform were set that influence the input format.void reconfigureSrc()Instructs trans to renegotiate a new downstream transform on the next buffer. This function is typically called after properties on the transform were set that influence the output format.void setGapAware(bool gapAware)If gap_aware is false (the default), output buffers will have the [gst.types.BufferFlags.Gap] flag unset.void setInPlace(bool inPlace)Determines whether a non-writable buffer will be copied before passing to the transform_ip function.void setPassthrough(bool passthrough)Set passthrough mode for this filter by default. This is mostly useful for filters that do not care about negotiation.void setPreferPassthrough(bool preferPassthrough)If preferpassthrough is true (the default), trans will check and prefer passthrough caps from the list of caps returned by the transformcaps vmethod.void setQosEnabled(bool enabled)Enable or disable QoS handling in the transform.void updateQos(double proportion, gst.types.ClockTimeDiff diff, gst.types.ClockTime timestamp)Set the QoS parameters in the transform. This function is called internally when a QOS event is received but subclasses can provide custom information when needed.bool updateSrcCaps(gst.caps.Caps updatedCaps)Updates the srcpad caps and sends the caps downstream. This function can be used by subclasses when they have already negotiated their caps but found a change in them (or computed new information)....T qos(bool propval)Fluent builder for [gstbase.base_transform.BaseTransform]