BaseTransform
Superclasses: Element
, Object
, InitiallyUnowned
, Object
- Constructors:
BaseTransform(**properties)
Methods
- class BaseTransform
- get_allocator() tuple[Allocator, AllocationParams]
Lets
BaseTransform
sub-classes know the memoryallocator
used by the base class and itsparams
.Unref the
allocator
after use.
- get_buffer_pool() BufferPool | None
- 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 orGstBaseTransformClass
::transform_ip vmethod. Call this inGstBaseTransformClass
::submit_input_buffer,GstBaseTransformClass
::prepare_output_buffer or inGstBaseTransformClass
::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.Added in version 1.18.
- 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.
- 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.
- set_gap_aware(gap_aware: bool) None
If
gap_aware
isFalse
(the default), output buffers will have the%GST_BUFFER_FLAG_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.
- Parameters:
gap_aware – New state
- set_in_place(in_place: bool) None
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.
- Parameters:
in_place – Boolean value indicating that we would like to operate on in_place buffers.
- 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
True
for filters which don’t implement either a transform or transform_ip or generate_output method.MT safe.
- Parameters:
passthrough – boolean indicating passthrough mode.
- set_prefer_passthrough(prefer_passthrough: bool) None
If
prefer_passthrough
isTrue
(the default),trans
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.
Added in version 1.0.1.
- Parameters:
prefer_passthrough – New state
- set_qos_enabled(enabled: bool) None
Enable or disable QoS handling in the transform.
MT safe.
- Parameters:
enabled – new state
- 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.
- Parameters:
proportion – the proportion
diff – the diff against the clock
timestamp – the timestamp of the buffer generating the QoS expressed in running_time.
- update_src_caps(updated_caps: 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.
Added in version 1.6.
- Parameters:
updated_caps – An updated version of the srcpad caps to be pushed downstream
Properties
Virtual Methods
- class BaseTransform
- do_accept_caps(direction: PadDirection, caps: Caps) 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.- Parameters:
direction
caps
- do_before_transform(buffer: Buffer) None
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.
- Parameters:
buffer
- do_copy_metadata(input: Buffer, outbuf: Buffer) 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.
- Parameters:
input
outbuf
- do_decide_allocation(query: Query) 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.- Parameters:
query
- do_filter_meta(query: Query, api: type, params: Structure) bool
Return
True
if the metadata API should be proposed in the upstream allocation query. The default implementation isNone
and will cause all metadata to be removed.- Parameters:
query
api
params
- do_fixate_caps(direction: PadDirection, caps: Caps, othercaps: Caps) Caps
- Parameters:
direction
caps
othercaps
- do_generate_output() tuple[FlowReturn, Buffer]
- do_prepare_output_buffer(input: Buffer) tuple[FlowReturn, Buffer]
- Parameters:
input
- do_propose_allocation(decide_query: Query, query: Query) 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.- Parameters:
decide_query
query
- do_query(direction: PadDirection, query: Query) bool
Optional. Handle a requested query. Subclasses that implement this must chain up to the parent if they didn’t handle the query
- Parameters:
direction
query
- do_set_caps(incaps: Caps, outcaps: Caps) bool
Allows the subclass to be notified of the actual caps set.
- Parameters:
incaps
outcaps
- do_start() bool
Optional. Called when the element starts processing. Allows opening external resources.
- do_stop() bool
Optional. Called when the element stops processing. Allows closing external resources.
- do_submit_input_buffer(is_discont: bool, input: Buffer) 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, thenis_discont
is set toTrue
. (Since: 1.6)- Parameters:
is_discont
input
- do_transform(inbuf: Buffer, outbuf: Buffer) 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.
- Parameters:
inbuf
outbuf
- do_transform_caps(direction: PadDirection, caps: Caps, filter: Caps) Caps
Optional. Given the pad in this direction and the given caps, what caps are allowed on the other pad in this element ?
- Parameters:
direction
caps
filter
- do_transform_ip(buf: Buffer) FlowReturn
Required if the element operates in-place. Transform the incoming buffer in-place.
- Parameters:
buf
- do_transform_meta(outbuf: Buffer, meta: Meta, inbuf: Buffer) 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.- Parameters:
outbuf
meta
inbuf