GstBase.BaseTransform

g GObject.InitiallyUnowned GObject.InitiallyUnowned Gst.Object Gst.Object GObject.InitiallyUnowned->Gst.Object GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gst.Element Gst.Element GstBase.BaseTransform GstBase.BaseTransform Gst.Element->GstBase.BaseTransform Gst.Object->Gst.Element

Subclasses:

None

Methods

Inherited:

Gst.Element (82), Gst.Object (27), GObject.Object (37)

Structs:

Gst.ElementClass (10), GObject.ObjectClass (5)

get_allocator ()

get_buffer_pool ()

is_in_place ()

is_passthrough ()

is_qos_enabled ()

reconfigure ()

reconfigure_sink ()

reconfigure_src ()

set_gap_aware (gap_aware)

set_in_place (in_place)

set_passthrough (passthrough)

set_prefer_passthrough (prefer_passthrough)

set_qos_enabled (enabled)

update_qos (proportion, diff, timestamp)

update_src_caps (updated_caps)

Virtual Methods

Inherited:

Gst.Element (16), Gst.Object (1), GObject.Object (7)

do_accept_caps (direction, caps)

do_before_transform (buffer)

do_copy_metadata (input, outbuf)

do_decide_allocation (query)

do_filter_meta (query, api, params)

do_fixate_caps (direction, caps, othercaps)

do_generate_output ()

do_get_unit_size (caps)

do_prepare_output_buffer (input)

do_propose_allocation (decide_query, query)

do_query (direction, query)

do_set_caps (incaps, outcaps)

do_sink_event (event)

do_src_event (event)

do_start ()

do_stop ()

do_submit_input_buffer (is_discont, input)

do_transform (inbuf, outbuf)

do_transform_caps (direction, caps, filter)

do_transform_ip (buf)

do_transform_meta (outbuf, meta, inbuf)

do_transform_size (direction, caps, size, othercaps)

Properties

Inherited:

Gst.Object (2)

Name

Type

Flags

Short Description

qos

bool

r/w

Handle Quality-of-Service events

Signals

Inherited:

Gst.Element (3), Gst.Object (1), GObject.Object (1)

Fields

Inherited:

Gst.Element (3), Gst.Object (1), GObject.Object (1)

Name

Type

Access

Description

element

Gst.Element

r

have_segment

bool

r

queued_buf

Gst.Buffer

r

segment

Gst.Segment

r

sinkpad

Gst.Pad

r

srcpad

Gst.Pad

r

Class Details

class GstBase.BaseTransform(**kwargs)
Bases:

Gst.Element

Abstract:

Yes

Structure:

GstBase.BaseTransformClass

This base class is for filter elements that process data. Elements that are suitable for implementation using GstBase.BaseTransform 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 GstBase.BaseTransformClass.passthrough_on_same_caps variable will automatically set/unset passthrough based on whether the element negotiates the same caps on both pads.

  • GstBase.BaseTransformClass.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 GstBase.BaseTransform
  • 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.

get_allocator()[source]
Returns:

allocator:

the Gst.Allocator used

params:

the Gst.AllocationParams of allocator

Return type:

(allocator: Gst.Allocator or None, params: Gst.AllocationParams)

Lets GstBase.BaseTransform sub-classes know the memory allocator used by the base class and its params.

Unref the allocator after use.

get_buffer_pool()[source]
Returns:

the instance of the Gst.BufferPool used by self; free it after use

Return type:

Gst.BufferPool or None

is_in_place()[source]
Returns:

True if the transform is configured in in_place mode.

MT safe.

Return type:

bool

See if self is configured as a in_place transform.

is_passthrough()[source]
Returns:

True if the transform is configured in passthrough mode.

MT safe.

Return type:

bool

See if self is configured as a passthrough transform.

is_qos_enabled()[source]
Returns:

True if QoS is enabled.

MT safe.

Return type:

bool

Queries if the transform will handle QoS.

reconfigure()[source]
Returns:

True if the negotiation succeeded, else False.

Return type:

bool

Negotiates src pad caps with downstream elements if the source pad is marked as needing reconfiguring. Unmarks Gst.PadFlags.NEED_RECONFIGURE in any case. But marks it again if negotiation fails.

Do not call this in the #GstBaseTransformClass::transform or #GstBaseTransformClass::transform_ip vmethod. Call this in #GstBaseTransformClass::submit_input_buffer, #GstBaseTransformClass::prepare_output_buffer or in #GstBaseTransformClass::generate_output _before_ any output buffer is allocated.

It will be default be called when handling an ALLOCATION query or at the very beginning of the default #GstBaseTransformClass::submit_input_buffer implementation.

New in version 1.18.

reconfigure_sink()[source]

Instructs self to request renegotiation upstream. This function is typically called after properties on the transform were set that influence the input format.

reconfigure_src()[source]

Instructs self 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.

set_gap_aware(gap_aware)[source]
Parameters:

gap_aware (bool) – New state

If gap_aware is False (the default), output buffers will have the Gst.BufferFlags.GAP flag unset.

If set to True, the element must handle output buffers with this flag set correctly, i.e. it can assume that the buffer contains neutral data but must unset the flag if the output is no neutral data.

MT safe.

set_in_place(in_place)[source]
Parameters:

in_place (bool) – Boolean value indicating that we would like to operate on in_place buffers.

Determines whether a non-writable buffer will be copied before passing to the transform_ip function.

  • Always True if no transform function is implemented.

  • Always False if ONLY transform function is implemented.

MT safe.

set_passthrough(passthrough)[source]
Parameters:

passthrough (bool) – boolean indicating passthrough mode.

Set passthrough mode for this filter by default. This is mostly useful for filters that do not care about negotiation.

Always True for filters which don’t implement either a transform or transform_ip or generate_output method.

MT safe.

set_prefer_passthrough(prefer_passthrough)[source]
Parameters:

prefer_passthrough (bool) – New state

If prefer_passthrough is True (the default), self will check and prefer passthrough caps from the list of caps returned by the transform_caps vmethod.

If set to False, the element must order the caps returned from the transform_caps function in such a way that the preferred format is first in the list. This can be interesting for transforms that can do passthrough transforms but prefer to do something else, like a capsfilter.

MT safe.

New in version 1.0.1.

set_qos_enabled(enabled)[source]
Parameters:

enabled (bool) – new state

Enable or disable QoS handling in the transform.

MT safe.

update_qos(proportion, diff, timestamp)[source]
Parameters:
  • proportion (float) – the proportion

  • diff (int) – the diff against the clock

  • timestamp (int) – the timestamp of the buffer generating the QoS expressed in running_time.

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.

MT safe.

update_src_caps(updated_caps)[source]
Parameters:

updated_caps (Gst.Caps) – An updated version of the srcpad caps to be pushed downstream

Returns:

True if the caps could be sent downstream False otherwise

Return type:

bool

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). This way, they can notify downstream about that change without losing any buffer.

New in version 1.6.

do_accept_caps(direction, caps) virtual
Parameters:
Return type:

bool

Optional. Subclasses can override this method to check if caps can be handled by the element. The default implementation might not be the most optimal way to check this in all cases.

do_before_transform(buffer) virtual
Parameters:

buffer (Gst.Buffer) –

Optional. This method is called right before the base class will start processing. Dynamic properties or other delayed configuration could be performed in this method.

do_copy_metadata(input, outbuf) virtual
Parameters:
Return type:

bool

Optional. Copy the metadata from the input buffer to the output buffer. The default implementation will copy the flags, timestamps and offsets of the buffer.

do_decide_allocation(query) virtual
Parameters:

query (Gst.Query) –

Return type:

bool

Setup the allocation parameters for allocating output buffers. The passed in query contains the result of the downstream allocation query. This function is only called when not operating in passthrough mode. The default implementation will remove all memory dependent metadata. If there is a filter_meta method implementation, it will be called for all metadata API in the downstream query, otherwise the metadata API is removed.

do_filter_meta(query, api, params) virtual
Parameters:
Return type:

bool

Return True if the metadata API should be proposed in the upstream allocation query. The default implementation is None and will cause all metadata to be removed.

do_fixate_caps(direction, caps, othercaps) virtual
Parameters:
Return type:

Gst.Caps

do_generate_output() virtual
Return type:

(Gst.FlowReturn, outbuf: Gst.Buffer)

do_get_unit_size(caps) virtual
Parameters:

caps (Gst.Caps) –

Return type:

(bool, size: int)

do_prepare_output_buffer(input) virtual
Parameters:

input (Gst.Buffer) –

Return type:

(Gst.FlowReturn, outbuf: Gst.Buffer)

do_propose_allocation(decide_query, query) virtual
Parameters:
Return type:

bool

Propose buffer allocation parameters for upstream elements. This function must be implemented if the element reads or writes the buffer content. The query that was passed to the decide_allocation is passed in this method (or None when the element is in passthrough mode). The default implementation will pass the query downstream when in passthrough mode and will copy all the filtered metadata API in non-passthrough mode.

do_query(direction, query) virtual
Parameters:
Return type:

bool

Optional. Handle a requested query. Subclasses that implement this must chain up to the parent if they didn’t handle the query

do_set_caps(incaps, outcaps) virtual
Parameters:
Return type:

bool

Allows the subclass to be notified of the actual caps set.

do_sink_event(event) virtual
Parameters:

event (Gst.Event) –

Return type:

bool

do_src_event(event) virtual
Parameters:

event (Gst.Event) –

Return type:

bool

do_start() virtual
Return type:

bool

Optional. Called when the element starts processing. Allows opening external resources.

do_stop() virtual
Return type:

bool

Optional. Called when the element stops processing. Allows closing external resources.

do_submit_input_buffer(is_discont, input) virtual
Parameters:
Return type:

Gst.FlowReturn

Function which accepts a new input buffer and pre-processes it. The default implementation performs caps (re)negotiation, then QoS if needed, and places the input buffer into the queued_buf member variable. If the buffer is dropped due to QoS, it returns GST_BASE_TRANSFORM_FLOW_DROPPED. If this input buffer is not contiguous with any previous input buffer, then is_discont is set to True.

New in version 1.6.

do_transform(inbuf, outbuf) virtual
Parameters:
Return type:

Gst.FlowReturn

Required if the element does not operate in-place. Transforms one incoming buffer to one outgoing buffer. The function is allowed to change size/timestamp/duration of the outgoing buffer.

do_transform_caps(direction, caps, filter) virtual
Parameters:
Return type:

Gst.Caps

Optional. Given the pad in this direction and the given caps, what caps are allowed on the other pad in this element ?

do_transform_ip(buf) virtual
Parameters:

buf (Gst.Buffer) –

Return type:

Gst.FlowReturn

Required if the element operates in-place. Transform the incoming buffer in-place.

do_transform_meta(outbuf, meta, inbuf) virtual
Parameters:
Return type:

bool

Optional. Transform the metadata on the input buffer to the output buffer. By default this method copies all meta without tags. Subclasses can implement this method and return True if the metadata is to be copied.

do_transform_size(direction, caps, size, othercaps) virtual
Parameters:
Return type:

(bool, othersize: int)

Property Details

GstBase.BaseTransform.props.qos
Name:

qos

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Handle Quality-of-Service events