gstreamermm: Gst::BaseTransform Class Reference

gstreamermm 0.10.10

- Main Page
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | Related Functions

# Gst::BaseTransform Class Reference
gstreamermm Base Classes

A base class for simple transform filters. More...

Inheritance diagram for Gst::BaseTransform:
[legend]
Collaboration diagram for Gst::BaseTransform:
[legend]

List of all members.

## Public Member Functions
virtual | ~BaseTransform ()
GstBaseTransform* | gobj ()
| Provides access to the underlying C GObject.
const GstBaseTransform* | gobj () const
| Provides access to the underlying C GObject.
GstBaseTransform* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool | is_passthrough () const
| See if trans is configured as a passthrough transform.
void | set_passthrough (bool passthrough)
| Set passthrough mode for this filter by default.
bool | is_in_place () const
| See if trans is configured as a in_place transform.
void | set_in_place (bool in_place)
| Determines whether a non-writable buffer will be copied before passing to the transform_ip function.
bool | is_qos_enabled () const
| Queries if the transform will handle QoS.
void | set_qos_enabled (bool enabled)
| Enable or disable QoS handling in the transform.
void | update_qos (double proportion, ClockTimeDiff diff, ClockTime timestamp)
| Set the QoS parameters in the transform.
void | set_gap_aware (bool gap_aware)
| If gap_aware is `false` (the default), output buffers will have the Gst::BUFFER_FLAG_GAP flag unset.
void | suggest (const Glib::RefPtr< Gst::Caps >& caps, guint size)
| Instructs trans to suggest new caps upstream.
void | reconfigure ()
| Instructs trans to renegotiate a new downstream transform on the next buffer.
void | lock ()
| Obtain a lock to protect the transform function from concurrent access.
void | unlock ()
| Release the lock that protects the transform function from concurrent access.
Glib::RefPtr< Gst::Pad > | get_sink_pad ()
| Gives the refptr to the sink Gst::Pad object of the element.
Glib::RefPtr< const Gst::Pad > | get_sink_pad () const
Glib::RefPtr< Gst::Pad > | get_src_pad ()
| Gives the refptr to the source Gst::Pad object of the element.
Glib::RefPtr< const Gst::Pad > | get_src_pad () const
Glib::PropertyProxy< bool > | property_qos ()
| Handle Quality-of-Service events.
Glib::PropertyProxy_ReadOnly < bool > | property_qos () const
| Handle Quality-of-Service events.
virtual Glib::RefPtr< Gst::Caps > | transform_caps_vfunc (PadDirection direction, const Glib::RefPtr< Gst::Caps >& caps)
| Optional.
virtual void | fixate_caps_vfunc (PadDirection direction, const Glib::RefPtr< Gst::Caps >& caps, const Glib::RefPtr< Gst::Caps >& othercaps)
| Optional.
virtual bool | get_unit_size_vfunc (const Glib::RefPtr< Gst::Caps >& caps, guint&size) const
| Optional.
virtual bool | set_caps_vfunc (const Glib::RefPtr< Gst::Caps >& incaps, const Glib::RefPtr< Gst::Caps >& outcaps)
| Allows the subclass to be notified of the actual caps set.
virtual bool | start_vfunc ()
| Optional.
virtual bool | stop_vfunc ()
| Optional.
virtual bool | event_vfunc (const Glib::RefPtr< Gst::Event >& event)
virtual FlowReturn | transform_vfunc (const Glib::RefPtr< Gst::Buffer >& inbuf, const Glib::RefPtr< Gst::Buffer >& outbuf)
| Required if the element does not operate in-place.
virtual FlowReturn | transform_ip_vfunc (const Glib::RefPtr< Gst::Buffer >& buf)
| Required if the element operates in-place.
virtual FlowReturn | prepare_output_buffer_vfunc (const Glib::RefPtr< Gst::Buffer >& input, int size, const Glib::RefPtr< Gst::Caps >& caps, Glib::RefPtr< Gst::Buffer >& buffer)
| Optional.
virtual bool | src_event_vfunc (const Glib::RefPtr< Gst::Event >& event)
| Optional.
virtual void | before_transform_vfunc (const Glib::RefPtr< Gst::Buffer >& buffer)
| Optional.
virtual bool | accept_caps_vfunc (PadDirection direction, const Glib::RefPtr< const Gst::Caps >& caps)
| Optional.
## Static Public Attributes
static const Glib::ustring | SINK_NAME
| The name of the templates for the sink pad ("sink").
static const Glib::ustring | SRC_NAME
| The name of the templates for the source pad ("src").
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gst::BaseTransform > | wrap (GstBaseTransform* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A base class for simple transform filters.

This base class is for filter elements that process data.

It provides for:

- one sinkpad and one srcpad
- Possible formats on sink and source pad implemented with custom transform_caps_vfunc() function. By default uses same format on sink and source.
- Handles state changes.
- Does flushing.
- Push mode.
- Pull mode if the sub-class transform_vfunc() can operate on arbitrary data.

### Use Cases:

- 1. 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_vfunc() function. If there is no transform_ip_vfunc() function in passthrough mode, the buffer is pushed intact.
  - On the GstBaseTransformClass is the passthrough_on_same_caps variable which will automatically set/unset passthrough based on whether the element negotiates the same caps on both pads.
  - passthrough_on_same_caps on an element that doesn't implement a transform_caps_vfunc() function is useful for elements that only inspect data (such as level).
  Example elements
  - Level
  - VideoScale, AudioConvert, FfmpegColorSpace, AudioResample in certain modes.

- 2. Modifications in-place - input buffer and output buffer are the same thing.
  - The element must implement a transform_ip_vfunc() 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_vfunc() function, otherwise a new buffer will be created and the transform_vfunc() function called.
  - Incoming writable buffers will be passed to the transform_ip_vfunc() function immediately.
  - only implementing transform_ip_vfunc() and not transform_vfunc() implies always_in_place = TRUE.
  Example elements
  - Volume.
  - AudioConvert in certain modes (signed/unsigned conversion).
  - FfmpegColorSpace in certain modes (endianness swapping).

- 3. 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_vfunc() 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.

- 4. Normal mode
  - always_in_place flag is not set, or there is no transform_ip_vfunc() function.
  - Element will receive an input buffer and output buffer to operate on.
  - Output buffer is allocated by calling the prepare_output_buffer_vfunc() function.
  Example elements
  - VideoScale, FfmpegColorSpace, AudioConvert when doing scaling/conversions.

- 5. Special output buffer allocations
  - Elements which need to do special allocation of their output buffers other than what Gst::Pad::alloc_buffer() allows should implement a prepare_output_buffer_vfunc() method, which calls the parent implementation and passes the newly allocated buffer.
  Example elements
  - Efence.

Sub-class settable flags on Gst::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.

## Constructor & Destructor Documentation

virtual Gst::BaseTransform::~BaseTransform | ( |  | ) | `[virtual]`

## Member Function Documentation

virtual bool Gst::BaseTransform::accept_caps_vfunc | ( | PadDirection | direction,
|  | const Glib::RefPtr< const Gst::Caps >& | caps
| ) |  | `[virtual]`

Optional.

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

virtual void Gst::BaseTransform::before_transform_vfunc | ( | const Glib::RefPtr< Gst::Buffer >& | buffer | ) | `[virtual]`

Optional.

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

virtual bool Gst::BaseTransform::event_vfunc | ( | const Glib::RefPtr< Gst::Event >& | event | ) | `[virtual]`

virtual void Gst::BaseTransform::fixate_caps_vfunc | ( | PadDirection | direction,
|  | const Glib::RefPtr< Gst::Caps >& | caps,
|  | const Glib::RefPtr< Gst::Caps >& | othercaps
| ) |  | `[virtual]`

Optional.

Given the pad in this direction and the given caps, fixate the caps on the other pad.

Glib::RefPtr<Gst::Pad> Gst::BaseTransform::get_sink_pad | ( |  | ) |

Gives the refptr to the sink Gst::Pad object of the element.

Glib::RefPtr<const Gst::Pad> Gst::BaseTransform::get_sink_pad | ( |  | ) | const

Glib::RefPtr<Gst::Pad> Gst::BaseTransform::get_src_pad | ( |  | ) |

Gives the refptr to the source Gst::Pad object of the element.

Glib::RefPtr<const Gst::Pad> Gst::BaseTransform::get_src_pad | ( |  | ) | const

virtual bool Gst::BaseTransform::get_unit_size_vfunc | ( | const Glib::RefPtr< Gst::Caps >& | caps,
|  | guint & | size
| ) |  | const`[virtual]`

Optional.

Given the size of a buffer in the given direction with the given caps, calculate the size in bytes of a buffer on the other pad with the given other caps. The default implementation uses get_unit_size_vfunc() and keeps the number of units the same. Required if the transform is not in-place. Get the size in bytes of one unit for the given caps.

const GstBaseTransform* Gst::BaseTransform::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gst::Element.

Reimplemented in Gst::AudioFilter, Gst::AudioConvert, Gst::AudioResample, Gst::CapsFilter, Gst::FfmpegColorSpace, Gst::Identity, Gst::VideoScale, and Gst::Volume.

GstBaseTransform* Gst::BaseTransform::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Gst::Element.

Reimplemented in Gst::AudioFilter, Gst::AudioConvert, Gst::AudioResample, Gst::CapsFilter, Gst::FfmpegColorSpace, Gst::Identity, Gst::VideoScale, and Gst::Volume.

GstBaseTransform* Gst::BaseTransform::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

Reimplemented from Gst::Element.

Reimplemented in Gst::AudioFilter, Gst::AudioConvert, Gst::AudioResample, Gst::CapsFilter, Gst::FfmpegColorSpace, Gst::Identity, Gst::VideoScale, and Gst::Volume.

bool Gst::BaseTransform::is_in_place | ( |  | ) | const

See if trans is configured as a in_place transform.

Returns:
  `true` is the transform is configured in in_place mode.

MT safe.

bool Gst::BaseTransform::is_passthrough | ( |  | ) | const

See if trans is configured as a passthrough transform.

Returns:
  `true` is the transform is configured in passthrough mode.

MT safe.

bool Gst::BaseTransform::is_qos_enabled | ( |  | ) | const

Queries if the transform will handle QoS.

Returns:
  `true` if QoS is enabled.

MT safe.

void Gst::BaseTransform::lock | ( |  | ) |

Obtain a lock to protect the transform function from concurrent access.

virtual FlowReturn Gst::BaseTransform::prepare_output_buffer_vfunc | ( | const Glib::RefPtr< Gst::Buffer >& | input,
|  | int | size,
|  | const Glib::RefPtr< Gst::Caps >& | caps,
|  | Glib::RefPtr< Gst::Buffer >& | buffer
| ) |  | `[virtual]`

Optional.

Subclasses can override this to do their own allocation of output buffers. Elements that only do analysis can return a subbuffer or even just increment the reference to the input buffer (if in passthrough mode).

Glib::PropertyProxy_ReadOnly<bool> Gst::BaseTransform::property_qos | ( |  | ) | const

Handle Quality-of-Service events.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy<bool> Gst::BaseTransform::property_qos | ( |  | ) |

Handle Quality-of-Service events.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gst::BaseTransform::reconfigure | ( |  | ) |

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.

virtual bool Gst::BaseTransform::set_caps_vfunc | ( | const Glib::RefPtr< Gst::Caps >& | incaps,
|  | const Glib::RefPtr< Gst::Caps >& | outcaps
| ) |  | `[virtual]`

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

void Gst::BaseTransform::set_gap_aware | ( | bool | gap_aware | ) |

If gap_aware is `false` (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.

void Gst::BaseTransform::set_in_place | ( | bool | in_place | ) |

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

<itemizedlist> <listitem>Always `true` if no transform function is implemented.</listitem> <listitem>Always `false` if ONLY transform function is implemented.</listitem> </itemizedlist>

MT safe.

Parameters:

  in_place | Boolean value indicating that we would like to operate on in_place buffers.

void Gst::BaseTransform::set_passthrough | ( | bool | 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 method.

MT safe.

Parameters:

  passthrough | Boolean indicating passthrough mode.

void Gst::BaseTransform::set_qos_enabled | ( | bool | enabled | ) |

Enable or disable QoS handling in the transform.

MT safe.

Parameters:

  enabled | New state.

virtual bool Gst::BaseTransform::src_event_vfunc | ( | const Glib::RefPtr< Gst::Event >& | event | ) | `[virtual]`

Optional.

Event handler on the source pad.

virtual bool Gst::BaseTransform::start_vfunc | ( |  | ) | `[virtual]`

Optional.

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

virtual bool Gst::BaseTransform::stop_vfunc | ( |  | ) | `[virtual]`

Optional.

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

void Gst::BaseTransform::suggest | ( | const Glib::RefPtr< Gst::Caps >& | caps,
|  | guint | size
| ) |  |

Instructs trans to suggest new caps upstream.

A copy of caps will be taken.

Parameters:

  caps | Caps to suggest.
  size | Buffer size to suggest.

virtual Glib::RefPtr<Gst::Caps> Gst::BaseTransform::transform_caps_vfunc | ( | PadDirection | direction,
|  | const Glib::RefPtr< Gst::Caps >& | caps
| ) |  | `[virtual]`

Optional.

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

virtual FlowReturn Gst::BaseTransform::transform_ip_vfunc | ( | const Glib::RefPtr< Gst::Buffer >& | buf | ) | `[virtual]`

Required if the element operates in-place.

Transform the incoming buffer in-place.

virtual FlowReturn Gst::BaseTransform::transform_vfunc | ( | const Glib::RefPtr< Gst::Buffer >& | inbuf,
|  | const Glib::RefPtr< Gst::Buffer >& | outbuf
| ) |  | `[virtual]`

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.

void Gst::BaseTransform::unlock | ( |  | ) |

Release the lock that protects the transform function from concurrent access.

void Gst::BaseTransform::update_qos | ( | double | proportion,
|  | ClockTimeDiff | diff,
|  | ClockTime | timestamp
| ) |  |

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.

## Friends And Related Function Documentation

Glib::RefPtr< Gst::BaseTransform > wrap | ( | GstBaseTransform * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

## Member Data Documentation

const Glib::ustring Gst::BaseTransform::SINK_NAME`[static]`

The name of the templates for the sink pad ("sink").

const Glib::ustring Gst::BaseTransform::SRC_NAME`[static]`

The name of the templates for the source pad ("src").

The documentation for this class was generated from the following file:

- gstreamermm/basetransform.h