Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This base class is for filter elements that process data. Elements
that are suitable for implementation using 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
BaseTransformClass
.passthrough_on_same_caps
variable will automatically set/unset passthrough based on whether the element negotiates the same caps on both pads. 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 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.
Synopsis
- newtype BaseTransform = BaseTransform (ManagedPtr BaseTransform)
- class (GObject o, IsDescendantOf BaseTransform o) => IsBaseTransform o
- toBaseTransform :: (MonadIO m, IsBaseTransform o) => o -> m BaseTransform
- baseTransformGetAllocator :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m (Maybe Allocator, AllocationParams)
- baseTransformGetBufferPool :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m (Maybe BufferPool)
- baseTransformIsInPlace :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m Bool
- baseTransformIsPassthrough :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m Bool
- baseTransformIsQosEnabled :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m Bool
- baseTransformReconfigure :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m Bool
- baseTransformReconfigureSink :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m ()
- baseTransformReconfigureSrc :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> m ()
- baseTransformSetGapAware :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Bool -> m ()
- baseTransformSetInPlace :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Bool -> m ()
- baseTransformSetPassthrough :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Bool -> m ()
- baseTransformSetPreferPassthrough :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Bool -> m ()
- baseTransformSetQosEnabled :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Bool -> m ()
- baseTransformUpdateQos :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Double -> Int64 -> Word64 -> m ()
- baseTransformUpdateSrcCaps :: (HasCallStack, MonadIO m, IsBaseTransform a) => a -> Caps -> m Bool
- constructBaseTransformQos :: (IsBaseTransform o, MonadIO m) => Bool -> m (GValueConstruct o)
- getBaseTransformQos :: (MonadIO m, IsBaseTransform o) => o -> m Bool
- setBaseTransformQos :: (MonadIO m, IsBaseTransform o) => o -> Bool -> m ()
Exported types
newtype BaseTransform Source #
Memory-managed wrapper type.
Instances
Eq BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform (==) :: BaseTransform -> BaseTransform -> Bool # (/=) :: BaseTransform -> BaseTransform -> Bool # | |
GObject BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform | |
ManagedPtrNewtype BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform | |
TypedObject BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform | |
HasParentTypes BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform | |
IsGValue (Maybe BaseTransform) Source # | Convert |
Defined in GI.GstBase.Objects.BaseTransform gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe BaseTransform -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe BaseTransform) # | |
type ParentTypes BaseTransform Source # | |
Defined in GI.GstBase.Objects.BaseTransform |
class (GObject o, IsDescendantOf BaseTransform o) => IsBaseTransform o Source #
Type class for types which can be safely cast to BaseTransform
, for instance with toBaseTransform
.
Instances
(GObject o, IsDescendantOf BaseTransform o) => IsBaseTransform o Source # | |
Defined in GI.GstBase.Objects.BaseTransform |
toBaseTransform :: (MonadIO m, IsBaseTransform o) => o -> m BaseTransform Source #
Cast to BaseTransform
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
abortState, addControlBinding, addPad, addPropertyDeepNotifyWatch, addPropertyNotifyWatch, bindProperty, bindPropertyFull, callAsync, changeState, continueState, createAllPads, defaultError, forceFloating, foreachPad, foreachSinkPad, foreachSrcPad, freezeNotify, getv, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, isFloating, isInPlace, isLockedState, isPassthrough, isQosEnabled, iteratePads, iterateSinkPads, iterateSrcPads, link, linkFiltered, linkPads, linkPadsFiltered, linkPadsFull, lostState, messageFull, messageFullWithDetails, noMorePads, notify, notifyByPspec, postMessage, provideClock, query, queryConvert, queryDuration, queryPosition, reconfigure, reconfigureSink, reconfigureSrc, ref, refSink, releaseRequestPad, removeControlBinding, removePad, removePropertyNotifyWatch, requestPad, requestPadSimple, runDispose, seek, seekSimple, sendEvent, stealData, stealQdata, suggestNextSync, syncStateWithParent, syncValues, thawNotify, unlink, unlinkPads, unparent, unref, updateQos, updateSrcCaps, watchClosure.
Getters
getAllocator, getBaseTime, getBufferPool, getBus, getClock, getCompatiblePad, getCompatiblePadTemplate, getContext, getContextUnlocked, getContexts, getControlBinding, getControlRate, getCurrentClockTime, getCurrentRunningTime, getData, getFactory, getGValueArray, getMetadata, getName, getPadTemplate, getPadTemplateList, getParent, getPathString, getProperty, getQdata, getRequestPad, getStartTime, getState, getStaticPad, getValue.
Setters
setBaseTime, setBus, setClock, setContext, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setData, setDataFull, setGapAware, setInPlace, setLockedState, setName, setParent, setPassthrough, setPreferPassthrough, setProperty, setQosEnabled, setStartTime, setState.
getAllocator
baseTransformGetAllocator Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m (Maybe Allocator, AllocationParams) |
Lets BaseTransform
sub-classes know the memory allocator
used by the base class and its params
.
Unref the allocator
after use.
getBufferPool
baseTransformGetBufferPool Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m (Maybe BufferPool) | Returns: the instance of the |
No description available in the introspection data.
isInPlace
baseTransformIsInPlace Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m Bool | Returns: MT safe. |
See if trans
is configured as a in_place transform.
isPassthrough
baseTransformIsPassthrough Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m Bool | Returns: MT safe. |
See if trans
is configured as a passthrough transform.
isQosEnabled
baseTransformIsQosEnabled Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m Bool | Returns: MT safe. |
Queries if the transform will handle QoS.
reconfigure
baseTransformReconfigure Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m 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 BaseTransformClass
::transform
or
BaseTransformClass
::transform_ip
vmethod. Call this in
BaseTransformClass
::submit_input_buffer
,
BaseTransformClass
::prepare_output_buffer
or in
BaseTransformClass
::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 BaseTransformClass
::submit_input_buffer
implementation.
Since: 1.18
reconfigureSink
baseTransformReconfigureSink Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m () |
Instructs trans
to request renegotiation upstream. This function is
typically called after properties on the transform were set that
influence the input format.
reconfigureSrc
baseTransformReconfigureSrc Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> m () |
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.
setGapAware
baseTransformSetGapAware Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Bool |
|
-> m () |
If gapAware
is False
(the default), output buffers will have the
BufferFlagsGap
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.
setInPlace
baseTransformSetInPlace Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Bool |
|
-> m () |
setPassthrough
baseTransformSetPassthrough Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Bool |
|
-> m () |
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.
setPreferPassthrough
baseTransformSetPreferPassthrough Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Bool |
|
-> m () |
If preferPassthrough
is True
(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.
Since: 1.0.1
setQosEnabled
baseTransformSetQosEnabled Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Bool |
|
-> m () |
Enable or disable QoS handling in the transform.
MT safe.
updateQos
baseTransformUpdateQos Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Double |
|
-> Int64 |
|
-> Word64 |
|
-> m () |
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.
updateSrcCaps
baseTransformUpdateSrcCaps Source #
:: (HasCallStack, MonadIO m, IsBaseTransform a) | |
=> a |
|
-> Caps |
|
-> m Bool | Returns: |
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.
Since: 1.6
Properties
qos
No description available in the introspection data.
constructBaseTransformQos :: (IsBaseTransform o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “qos
” property. This is rarely needed directly, but it is used by new
.
getBaseTransformQos :: (MonadIO m, IsBaseTransform o) => o -> m Bool Source #
Get the value of the “qos
” property.
When overloading is enabled, this is equivalent to
get
baseTransform #qos
setBaseTransformQos :: (MonadIO m, IsBaseTransform o) => o -> Bool -> m () Source #
Set the value of the “qos
” property.
When overloading is enabled, this is equivalent to
set
baseTransform [ #qos:=
value ]