:right-sidebar: True BaseTransform =================================================================== .. currentmodule:: gi.repository.GstBase .. class:: BaseTransform(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gst.Element`, :class:`~gi.repository.Gst.Object`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` This base class is for filter elements that process data. Elements that are suitable for implementation using :obj:`~gi.repository.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 ``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 = :const:`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 :const:`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 :const:`True` if no transform function is implemented. - Implied :const:`False` if ONLY transform function is implemented. Methods ------- .. rst-class:: interim-class .. class:: BaseTransform :no-index: .. method:: do_accept_caps(self, direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps) -> bool :param direction: :param caps: .. method:: do_before_transform(self, buffer: ~gi.repository.Gst.Buffer) -> None :param buffer: .. method:: do_decide_allocation(self, query: ~gi.repository.Gst.Query) -> bool :param query: .. method:: do_filter_meta(self, query: ~gi.repository.Gst.Query, api: ~gobject.GType, params: ~gi.repository.Gst.Structure) -> bool :param query: :param api: :param params: .. method:: do_fixate_caps(self, direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, othercaps: ~gi.repository.Gst.Caps) -> ~gi.repository.Gst.Caps :param direction: :param caps: :param othercaps: .. method:: do_generate_output(self) -> ~typing.Tuple[~gi.repository.Gst.FlowReturn, ~gi.repository.Gst.Buffer] .. method:: do_get_unit_size(self, caps: ~gi.repository.Gst.Caps) -> ~typing.Tuple[bool, int] :param caps: .. method:: do_prepare_output_buffer(self, input: ~gi.repository.Gst.Buffer) -> ~typing.Tuple[~gi.repository.Gst.FlowReturn, ~gi.repository.Gst.Buffer] :param input: .. method:: do_propose_allocation(self, decide_query: ~gi.repository.Gst.Query, query: ~gi.repository.Gst.Query) -> bool :param decide_query: :param query: .. method:: do_query(self, direction: ~gi.repository.Gst.PadDirection, query: ~gi.repository.Gst.Query) -> bool :param direction: :param query: .. method:: do_set_caps(self, incaps: ~gi.repository.Gst.Caps, outcaps: ~gi.repository.Gst.Caps) -> bool :param incaps: :param outcaps: .. method:: do_sink_event(self, event: ~gi.repository.Gst.Event) -> bool :param event: .. method:: do_src_event(self, event: ~gi.repository.Gst.Event) -> bool :param event: .. method:: do_start(self) -> bool .. method:: do_stop(self) -> bool .. method:: do_submit_input_buffer(self, is_discont: bool, input: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn :param is_discont: :param input: .. method:: do_transform(self, inbuf: ~gi.repository.Gst.Buffer, outbuf: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn :param inbuf: :param outbuf: .. method:: do_transform_caps(self, direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, filter: ~gi.repository.Gst.Caps) -> ~gi.repository.Gst.Caps :param direction: :param caps: :param filter: .. method:: do_transform_ip(self, buf: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn :param buf: .. method:: do_transform_meta(self, outbuf: ~gi.repository.Gst.Buffer, meta: ~gi.repository.Gst.Meta, inbuf: ~gi.repository.Gst.Buffer) -> bool :param outbuf: :param meta: :param inbuf: .. method:: do_transform_size(self, direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, size: int, othercaps: ~gi.repository.Gst.Caps) -> ~typing.Tuple[bool, int] :param direction: :param caps: :param size: :param othercaps: .. method:: get_allocator() -> ~typing.Tuple[~gi.repository.Gst.Allocator | None, ~gi.repository.Gst.AllocationParams] Lets :obj:`~gi.repository.GstBase.BaseTransform` sub-classes know the memory ``allocator`` used by the base class and its ``params``\. Unref the ``allocator`` after use. .. method:: get_buffer_pool() -> ~gi.repository.Gst.BufferPool | None .. method:: is_in_place() -> bool See if ``trans`` is configured as a in_place transform. .. method:: is_passthrough() -> bool See if ``trans`` is configured as a passthrough transform. .. method:: is_qos_enabled() -> bool Queries if the transform will handle QoS. .. method:: reconfigure() -> bool Negotiates src pad caps with downstream elements if the source pad is marked as needing reconfiguring. Unmarks GST_PAD_FLAG_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. .. versionadded:: 1.18 .. method:: reconfigure_sink() -> None Instructs ``trans`` to request renegotiation upstream. This function is typically called after properties on the transform were set that influence the input format. .. method:: reconfigure_src() -> None 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. .. method:: set_gap_aware(gap_aware: bool) -> None If ``gap_aware`` is :const:`False` (the default), output buffers will have the %GST_BUFFER_FLAG_GAP flag unset. If set to :const:`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. :param gap_aware: New state .. method:: set_in_place(in_place: bool) -> None Determines whether a non-writable buffer will be copied before passing to the transform_ip function. - Always :const:`True` if no transform function is implemented. - Always :const:`False` if ONLY transform function is implemented. MT safe. :param in_place: Boolean value indicating that we would like to operate on in_place buffers. .. method:: set_passthrough(passthrough: bool) -> None Set passthrough mode for this filter by default. This is mostly useful for filters that do not care about negotiation. Always :const:`True` for filters which don't implement either a transform or transform_ip or generate_output method. MT safe. :param passthrough: boolean indicating passthrough mode. .. method:: set_prefer_passthrough(prefer_passthrough: bool) -> None If ``prefer_passthrough`` is :const:`True` (the default), ``trans`` will check and prefer passthrough caps from the list of caps returned by the transform_caps vmethod. If set to :const:`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. .. versionadded:: 1.0.1 :param prefer_passthrough: New state .. method:: set_qos_enabled(enabled: bool) -> None Enable or disable QoS handling in the transform. MT safe. :param enabled: new state .. method:: update_qos(proportion: float, diff: int, timestamp: int) -> None 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. :param proportion: the proportion :param diff: the diff against the clock :param timestamp: the timestamp of the buffer generating the QoS expressed in running_time. .. method:: update_src_caps(updated_caps: ~gi.repository.Gst.Caps) -> 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. .. versionadded:: 1.6 :param updated_caps: An updated version of the srcpad caps to be pushed downstream Properties ---------- .. rst-class:: interim-class .. class:: BaseTransform :no-index: .. attribute:: props.qos :type: bool The type of the None singleton. Virtual Methods --------------- .. rst-class:: interim-class .. class:: BaseTransform :no-index: .. method:: do_accept_caps(direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps) -> bool The type of the None singleton. :param direction: :param caps: .. method:: do_before_transform(buffer: ~gi.repository.Gst.Buffer) -> None The type of the None singleton. :param buffer: .. method:: do_copy_metadata(input: ~gi.repository.Gst.Buffer, outbuf: ~gi.repository.Gst.Buffer) -> bool The type of the None singleton. :param input: :param outbuf: .. method:: do_decide_allocation(query: ~gi.repository.Gst.Query) -> bool The type of the None singleton. :param query: .. method:: do_filter_meta(query: ~gi.repository.Gst.Query, api: ~gobject.GType, params: ~gi.repository.Gst.Structure) -> bool The type of the None singleton. :param query: :param api: :param params: .. method:: do_fixate_caps(direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, othercaps: ~gi.repository.Gst.Caps) -> ~gi.repository.Gst.Caps The type of the None singleton. :param direction: :param caps: :param othercaps: .. method:: do_generate_output() -> ~typing.Tuple[~gi.repository.Gst.FlowReturn, ~gi.repository.Gst.Buffer] The type of the None singleton. .. method:: do_get_unit_size(caps: ~gi.repository.Gst.Caps) -> ~typing.Tuple[bool, int] The type of the None singleton. :param caps: .. method:: do_prepare_output_buffer(input: ~gi.repository.Gst.Buffer) -> ~typing.Tuple[~gi.repository.Gst.FlowReturn, ~gi.repository.Gst.Buffer] The type of the None singleton. :param input: .. method:: do_propose_allocation(decide_query: ~gi.repository.Gst.Query, query: ~gi.repository.Gst.Query) -> bool The type of the None singleton. :param decide_query: :param query: .. method:: do_query(direction: ~gi.repository.Gst.PadDirection, query: ~gi.repository.Gst.Query) -> bool Optional. Handle a requested query. Subclasses that implement this must chain up to the parent if they didn't handle the query :param direction: :param query: .. method:: do_set_caps(incaps: ~gi.repository.Gst.Caps, outcaps: ~gi.repository.Gst.Caps) -> bool The type of the None singleton. :param incaps: :param outcaps: .. method:: do_sink_event(event: ~gi.repository.Gst.Event) -> bool The type of the None singleton. :param event: .. method:: do_src_event(event: ~gi.repository.Gst.Event) -> bool The type of the None singleton. :param event: .. method:: do_start() -> bool The type of the None singleton. .. method:: do_stop() -> bool The type of the None singleton. .. method:: do_submit_input_buffer(is_discont: bool, input: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn The type of the None singleton. :param is_discont: :param input: .. method:: do_transform(inbuf: ~gi.repository.Gst.Buffer, outbuf: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn The type of the None singleton. :param inbuf: :param outbuf: .. method:: do_transform_caps(direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, filter: ~gi.repository.Gst.Caps) -> ~gi.repository.Gst.Caps The type of the None singleton. :param direction: :param caps: :param filter: .. method:: do_transform_ip(buf: ~gi.repository.Gst.Buffer) -> ~gi.repository.Gst.FlowReturn The type of the None singleton. :param buf: .. method:: do_transform_meta(outbuf: ~gi.repository.Gst.Buffer, meta: ~gi.repository.Gst.Meta, inbuf: ~gi.repository.Gst.Buffer) -> bool The type of the None singleton. :param outbuf: :param meta: :param inbuf: .. method:: do_transform_size(direction: ~gi.repository.Gst.PadDirection, caps: ~gi.repository.Gst.Caps, size: int, othercaps: ~gi.repository.Gst.Caps) -> ~typing.Tuple[bool, int] The type of the None singleton. :param direction: :param caps: :param size: :param othercaps: Fields ------ .. rst-class:: interim-class .. class:: BaseTransform :no-index: .. attribute:: element .. attribute:: have_segment .. attribute:: priv .. attribute:: queued_buf .. attribute:: segment .. attribute:: sinkpad .. attribute:: srcpad