Class BaseTransform
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
AudioFilter
,BaseTransform.BaseTransformImpl
,VideoFilter
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Subclasses can override any of the available virtual methods or not, as needed.static class
The BaseTransformImpl type represents a native instance of the abstract BaseTransform class.static class
BaseTransform.Builder<B extends BaseTransform.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.Element
Element.ElementClass, Element.ElementImpl, Element.NoMorePadsCallback, Element.PadAddedCallback, Element.PadRemovedCallback
Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.ObjectClass, GstObject.ObjectImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionBaseTransform
(MemorySegment address) Create a BaseTransform proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
acceptCaps
(PadDirection direction, Caps caps) Optional.protected BaseTransform
asParent()
Returns this instance as if it were its parent type.protected void
beforeTransform
(Buffer buffer) Optional.static BaseTransform.Builder
<? extends BaseTransform.Builder> builder()
ABaseTransform.Builder
object constructs aBaseTransform
with the specified properties.protected boolean
copyMetadata
(Buffer input, Buffer outbuf) Optional.protected boolean
decideAllocation
(Query query) Setup the allocation parameters for allocating output buffers.protected boolean
filterMeta
(Query query, Type api, Structure params) Returntrue
if the metadata API should be proposed in the upstream allocation query.protected Caps
fixateCaps
(PadDirection direction, Caps caps, Caps othercaps) protected FlowReturn
generateOutput
(Out<Buffer> outbuf) void
getAllocator
(@Nullable Out<Allocator> allocator, @Nullable AllocationParams params) LetsGstBaseTransform
sub-classes know the memoryallocator
used by the base class and itsparams
.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the BaseTransform classprotected boolean
getUnitSize
(Caps caps, Out<Long> size) boolean
See if this BaseTransform is configured as a in_place transform.boolean
See if this BaseTransform is configured as a passthrough transform.boolean
Queries if the transform will handle QoS.protected FlowReturn
prepareOutputBuffer
(Buffer input, Out<Buffer> outbuf) protected boolean
proposeAllocation
(Query decideQuery, Query query) Propose buffer allocation parameters for upstream elements.protected boolean
query
(PadDirection direction, Query query) Optional.boolean
Negotiates src pad caps with downstream elements if the source pad is marked as needing reconfiguring.void
Instructs this BaseTransform to request renegotiation upstream.void
Instructs this BaseTransform to renegotiate a new downstream transform on the next buffer.protected boolean
Allows the subclass to be notified of the actual caps set.void
setGapAware
(boolean gapAware) void
setInPlace
(boolean inPlace) Determines whether a non-writable buffer will be copied before passing to the transform_ip function.void
setPassthrough
(boolean passthrough) Set passthrough mode for this filter by default.void
setPreferPassthrough
(boolean preferPassthrough) IfpreferPassthrough
istrue
(the default), this BaseTransform will check and prefer passthrough caps from the list of caps returned by the transform_caps vmethod.void
setQosEnabled
(boolean enabled) Enable or disable QoS handling in the transform.protected boolean
protected boolean
protected boolean
start()
Optional.protected boolean
stop()
Optional.protected FlowReturn
submitInputBuffer
(boolean isDiscont, Buffer input) Function which accepts a new input buffer and pre-processes it.protected FlowReturn
Required if the element does not operate in-place.protected Caps
transformCaps
(PadDirection direction, Caps caps, Caps filter) Optional.protected FlowReturn
transformIp
(Buffer buf) Required if the element operates in-place.protected boolean
transformMeta
(Buffer outbuf, Meta meta, Buffer inbuf) Optional.protected boolean
transformSize
(PadDirection direction, Caps caps, long size, Caps othercaps, Out<Long> othersize) void
updateQos
(double proportion, ClockTimeDiff diff, ClockTime timestamp) Set the QoS parameters in the transform.boolean
updateSrcCaps
(Caps updatedCaps) Updates the srcpad caps and sends the caps downstream.Methods inherited from class org.freedesktop.gstreamer.gst.Element
abortState, addPad, addPropertyDeepNotifyWatch, addPropertyNotifyWatch, callAsync, changeState, continueState, createAllPads, decorateStreamId, decorateStreamIdPrintf, emitNoMorePads, emitPadAdded, emitPadRemoved, foreachPad, foreachSinkPad, foreachSrcPad, getBaseTime, getBus, getClock, getCompatiblePad, getCompatiblePadTemplate, getContext, getContexts, getContextUnlocked, getCurrentClockTime, getCurrentRunningTime, getFactory, getMetadata, getPadTemplate, getPadTemplateList, getRequestPad, getStartTime, getState, getStaticPad, isLockedState, iteratePads, iterateSinkPads, iterateSrcPads, link, linkFiltered, linkMany, linkPads, linkPadsFiltered, linkPadsFull, linkPadsFull, lostState, makeFromUri, messageFull, messageFull, messageFullWithDetails, messageFullWithDetails, noMorePads, onNoMorePads, onPadAdded, onPadRemoved, padAdded, padRemoved, postMessage, provideClock, query, queryConvert, queryDuration, queryPosition, register, releasePad, releaseRequestPad, removePad, removePropertyNotifyWatch, requestPad, requestPadSimple, seek, seek, seekSimple, seekSimple, sendEvent, setBaseTime, setBus, setClock, setContext, setLockedState, setStartTime, setState, stateChanged, stateChangeReturnGetName, stateGetName, syncStateWithParent, typeSetSkipDocumentation, unlink, unlinkMany, unlinkPads
Methods inherited from class org.freedesktop.gstreamer.gst.GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unref
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
BaseTransform
Create a BaseTransform proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getAllocator
public void getAllocator(@Nullable @Nullable Out<Allocator> allocator, @Nullable @Nullable AllocationParams params) LetsGstBaseTransform
sub-classes know the memoryallocator
used by the base class and itsparams
.Unref the
allocator
after use.- Parameters:
allocator
- theGstAllocator
usedparams
- theGstAllocationParams
ofallocator
-
getBufferPool
-
isInPlace
public boolean isInPlace()See if this BaseTransform is configured as a in_place transform.- Returns:
true
if the transform is configured in in_place mode.MT safe.
-
isPassthrough
public boolean isPassthrough()See if this BaseTransform is configured as a passthrough transform.- Returns:
true
if the transform is configured in passthrough mode.MT safe.
-
isQosEnabled
public boolean isQosEnabled()Queries if the transform will handle QoS.- Returns:
true
if QoS is enabled.MT safe.
-
reconfigure
public boolean reconfigure()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.- Returns:
true
if the negotiation succeeded, elsefalse
.
-
reconfigureSink
public void reconfigureSink()Instructs this BaseTransform to request renegotiation upstream. This function is typically called after properties on the transform were set that influence the input format. -
reconfigureSrc
public void reconfigureSrc()Instructs this BaseTransform 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. -
setGapAware
public void setGapAware(boolean gapAware) IfgapAware
isfalse
(the default), output buffers will have theBufferFlags.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:
gapAware
- New state
-
setInPlace
public void setInPlace(boolean inPlace) 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:
inPlace
- Boolean value indicating that we would like to operate on in_place buffers.
- Always
-
setPassthrough
public void setPassthrough(boolean passthrough) 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.
-
setPreferPassthrough
public void setPreferPassthrough(boolean preferPassthrough) IfpreferPassthrough
istrue
(the default), this BaseTransform 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.
- Parameters:
preferPassthrough
- New state
-
setQosEnabled
public void setQosEnabled(boolean enabled) Enable or disable QoS handling in the transform.MT safe.
- Parameters:
enabled
- new state
-
updateQos
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 proportiondiff
- the diff against the clocktimestamp
- the timestamp of the buffer generating the QoS expressed in running_time.
-
updateSrcCaps
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.- Parameters:
updatedCaps
- An updated version of the srcpad caps to be pushed downstream- Returns:
true
if the caps could be sent downstreamfalse
otherwise
-
acceptCaps
Optional. Subclasses can override this method to check ifcaps
can be handled by the element. The default implementation might not be the most optimal way to check this in all cases. -
beforeTransform
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. -
copyMetadata
-
decideAllocation
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 afilterMeta
method implementation, it will be called for all metadata API in the downstream query, otherwise the metadata API is removed. -
filterMeta
-
fixateCaps
-
generateOutput
-
getUnitSize
-
prepareOutputBuffer
-
proposeAllocation
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 (ornull
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. -
query
Optional. Handle a requested query. Subclasses that implement this must chain up to the parent if they didn't handle the query -
setCaps
-
sinkEvent
-
srcEvent
-
start
protected boolean start()Optional. Called when the element starts processing. Allows opening external resources. -
stop
protected boolean stop()Optional. Called when the element stops processing. Allows closing external resources. -
submitInputBuffer
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 thequeuedBuf
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, thenisDiscont
is set totrue
. (Since: 1.6) -
transform
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. -
transformCaps
Optional. Given the pad in this direction and the given caps, what caps are allowed on the other pad in this element ? -
transformIp
Required if the element operates in-place. Transform the incoming buffer in-place. -
transformMeta
-
transformSize
protected boolean transformSize(PadDirection direction, Caps caps, long size, Caps othercaps, Out<Long> othersize) -
builder
ABaseTransform.Builder
object constructs aBaseTransform
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withBaseTransform.Builder.build()
.
-