This base class is for filter elements that process data.
Elements that are suitable for implementation using Transform 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_capss variable will automatically set/unset passthrough based on whether
the element negotiates the same caps on both pads.
* GstBaseTransformClass.passthrough_on_same_capss 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.
- public virtual bool accept_caps (PadDirection direction, Caps caps)
Optional.
- public virtual void before_transform (Buffer buffer)
Optional.
- public virtual bool copy_metadata (Buffer input, Buffer outbuf)
Optional.
- public virtual bool decide_allocation (Query query)
Setup the allocation parameters for allocating output buffers.
- public virtual bool filter_meta (Query query, Type api, Structure @params)
Return true if the metadata API
should be proposed in the upstream allocation query.
- public virtual Caps fixate_caps (PadDirection direction, Caps caps, owned Caps othercaps)
- public virtual FlowReturn generate_output (out Buffer outbuf)
- public void get_allocator (out Allocator? allocator, out unowned AllocationParams @params)
Lets Transform sub-classes know
the memory allocator used by the base class and its params.
- public BufferPool? get_buffer_pool ()
- public virtual bool get_unit_size (Caps caps, out size_t size)
- public bool is_in_place ()
See if this is configured as a
in_place transform.
- public bool is_passthrough ()
See if this is configured as a
passthrough transform.
- public bool is_qos_enabled ()
Queries if the transform will handle QoS.
- public virtual FlowReturn prepare_output_buffer (Buffer input, out Buffer outbuf)
- public virtual bool propose_allocation (Query decide_query, Query query)
Propose buffer allocation parameters for upstream elements.
- public virtual bool query (PadDirection direction, Query query)
Optional.
- public bool reconfigure ()
Negotiates src pad caps with downstream elements if the source pad is
marked as needing reconfiguring.
- public void reconfigure_sink ()
Instructs this to request
renegotiation upstream.
- public void reconfigure_src ()
Instructs this to renegotiate a new
downstream transform on the next buffer.
- public virtual bool set_caps (Caps incaps, Caps outcaps)
Allows the subclass to be notified of the actual caps set.
- public void set_gap_aware (bool gap_aware)
If gap_aware is false (
the default), output buffers will have the gst_buffer_flag_gap flag unset.
- public void set_in_place (bool in_place)
Determines whether a non-writable buffer will be copied before passing
to the transform_ip function.
- public void set_passthrough (bool passthrough)
Set passthrough mode for this filter by default.
- public void set_prefer_passthrough (bool prefer_passthrough)
If prefer_passthrough is true
(the default), this will check and prefer passthrough caps from the list of caps returned by
the transform_caps vmethod.
- public void set_qos_enabled (bool enabled)
Enable or disable QoS handling in the transform.
- public virtual bool sink_event (owned Event event)
- public virtual bool src_event (owned Event event)
- public virtual bool start ()
Optional.
- public virtual bool stop ()
Optional.
- public virtual FlowReturn submit_input_buffer (bool is_discont, Buffer input)
Function which accepts a new input buffer and pre-processes it.
- public virtual FlowReturn transform (Buffer inbuf, Buffer outbuf)
Required if the element does not operate in-place.
- public virtual Caps transform_caps (PadDirection direction, Caps caps, Caps filter)
Optional.
- public virtual FlowReturn transform_ip (Buffer buf)
Required if the element operates in-place.
- public virtual bool transform_meta (Buffer outbuf, Meta meta, Buffer inbuf)
Optional.
- public virtual bool transform_size (PadDirection direction, Caps caps, size_t size, Caps othercaps, out size_t othersize)
- public void update_qos (double proportion, ClockTimeDiff diff, ClockTime timestamp)
Set the QoS parameters in the transform.
- public bool update_src_caps (Caps updated_caps)
Updates the srcpad caps and sends the caps downstream.