#include <basesink.h>
Public Member Functions | |
virtual | ~BaseSink () |
GstBaseSink* | gobj () |
Provides access to the underlying C GObject. | |
const GstBaseSink* | gobj () const |
Provides access to the underlying C GObject. | |
GstBaseSink* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
bool | query_latency (bool& live, bool& upstream_live, ClockTime& min_latency, ClockTime& max_latency) |
Query the sink for the latency parameters. | |
ClockTime | get_latency () |
Get the currently configured latency. | |
FlowReturn | wait_preroll () |
If the Gst::BaseSinkClass::render method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to render the remaining data. | |
ClockReturn | wait_clock (ClockTime time, ClockTimeDiff& jitter) |
FlowReturn | wait_eos (ClockTime time, ClockTimeDiff& jitter) |
This function will block until time is reached. | |
void | set_sync (bool sync) |
Configures sink to synchronize on the clock or not. | |
bool | get_sync () |
Checks if sink is currently configured to synchronize against the clock. | |
void | set_max_lateness (gint64 max_lateness) |
Sets the new max lateness value to max_lateness. | |
gint64 | get_max_lateness () |
Gets the max lateness value. | |
void | set_qos_enabled (bool enabled) |
Configures sink to send Quality-of-Service events upstream. | |
bool | is_qos_enabled () |
Checks if sink is currently configured to send Quality-of-Service events upstream. | |
void | set_async_enabled (bool enabled) |
Configures sink to perform all state changes asynchronusly. | |
bool | is_async_enabled () |
Checks if sink is currently configured to perform asynchronous state changes to PAUSED. | |
void | set_ts_offset (ClockTimeDiff offset) |
Adjust the synchronisation of sink with offset. | |
ClockTimeDiff | get_ts_offset () |
Get the synchronisation offset of sink. | |
Glib::RefPtr<Gst::Buffer> | get_last_buffer () |
Get the last buffer that arrived in the sink and was used for preroll or for rendering. | |
Glib::RefPtr<Gst::Pad> | get_sink_pad () const |
Gets the sink Gst::Pad object of the element. | |
Glib::PropertyProxy<bool> | property_async () |
Go asynchronously to PAUSED. | |
Glib::PropertyProxy_ReadOnly <bool> | property_async () const |
Go asynchronously to PAUSED. | |
Glib::PropertyProxy_ReadOnly <Glib::RefPtr<Gst::Buffer>> | property_last_buffer () const |
The last buffer received in the sink. | |
Glib::PropertyProxy<gint64> | property_max_lateness () |
Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited). | |
Glib::PropertyProxy_ReadOnly <gint64> | property_max_lateness () const |
Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited). | |
Glib::PropertyProxy<guint> | property_preroll_queue_len () |
Number of buffers to queue during preroll. | |
Glib::PropertyProxy_ReadOnly <guint> | property_preroll_queue_len () const |
Number of buffers to queue during preroll. | |
Glib::PropertyProxy<bool> | property_qos () |
Generate Quality-of-Service events upstream. | |
Glib::PropertyProxy_ReadOnly <bool> | property_qos () const |
Generate Quality-of-Service events upstream. | |
Glib::PropertyProxy<bool> | property_sync () |
Sync on the clock. | |
Glib::PropertyProxy_ReadOnly <bool> | property_sync () const |
Sync on the clock. | |
Glib::PropertyProxy<gint64> | property_ts_offset () |
Timestamp offset in nanoseconds. | |
Glib::PropertyProxy_ReadOnly <gint64> | property_ts_offset () const |
Timestamp offset in nanoseconds. | |
virtual Glib::RefPtr<Gst::Caps> | get_caps_vfunc () |
Called to get sink pad caps from the subclass. | |
virtual void | get_times_vfunc (const Glib::RefPtr<Gst::Buffer>& buffer, ClockTime& start, ClockTime& end) |
Notify subclass of changed caps. | |
virtual FlowReturn | preroll_vfunc (const Glib::RefPtr<Gst::Buffer>& buffer) |
Start processing. | |
virtual FlowReturn | render_vfunc (const Glib::RefPtr<Gst::Buffer>& buffer) |
Called when a buffer should be presented or output, at the correct moment if the Gst::BaseSink has been set to sync to the clock. | |
virtual StateChangeReturn | async_play_vfunc () |
Subclasses should override this when they need to perform special processing when changing to the PLAYING state asynchronously. | |
virtual void | fixate_vfunc (const Glib::RefPtr<Gst::Caps>& caps) |
Subclasses should override this when they can provide an alternate method of spawning a thread to drive the pipeline in pull mode. | |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr<Gst::BaseSink> | wrap (GstBaseSink* object, bool take_copy=false) |
A Glib::wrap() method for this object. |
Gst::BaseSink is the base class for sink elements in GStreamer, such as xvimagesink or filesink. It is a layer on top of Gst::Element that provides a simplified interface to plugin writers. Gst::BaseSink handles many details for you, for example: preroll, clock synchronization, state changes, activation in push or pull mode, and queries.
In most cases, when writing sink elements, there is no need to implement class methods from Gst::Element or to set functions on pads, because the Gst::BaseSink infrastructure should be sufficient.
TODO: correct paragraph below for C++ and include example from C API:
Gst::BaseSink provides support for exactly one sink pad, which should be named "sink". A sink implementation (subclass of Gst::BaseSink) should install a pad template in its base_init function, like so:
Gst::BaseSink will handle the prerolling correctly. This means that it will return Gst::STATE_CHANGE_ASYNC from a state change to PAUSED until the first buffer arrives in this element. The base class will call the Gst::BaseSink::preroll_vfunc() vmethod with this preroll buffer and will then commit the state change to the next asynchronously pending state.
When the element is set to PLAYING, Gst::BaseSink will synchronise on the clock using the times returned from get_times_vfunc(). If this function returns Gst::CLOCK_TIME_NONE for the start time, no synchronisation will be done. Synchronisation can be disabled entirely by setting the object "sync" property to FALSE.
After synchronisation the virtual method Gst::BaseSink::render_vfunc() will be called. Subclasses should minimally implement this method.
Since GStreamer 0.10.3 subclasses that synchronise on the clock in the render_vfunc() vmethod are supported as well. These classes typically receive a buffer in the render method and can then potentially block on the clock while rendering. A typical example is an audiosink. Since GStreamer 0.10.11 these subclasses can use wait_preroll() to perform the blocking wait.
Upon receiving the EOS event in the PLAYING state, Gst::BaseSink will wait for the clock to reach the time indicated by the stop time of the last get_times_vfunc() call before posting an EOS message. When the element receives EOS in PAUSED, preroll completes, the event is queued and an EOS message is posted when going to PLAYING.
Gst::BaseSink will internally use the Gst::EVENT_NEWSEGMENT events to schedule synchronisation and clipping of buffers. Buffers that fall completely outside of the current segment are dropped. Buffers that fall partially in the segment are rendered (and prerolled). Subclasses should do any subbuffer clipping themselves when needed.
Gst::BaseSink will by default report the current playback position in Gst::FORMAT_TIME based on the current clock time and segment information. If no clock has been set on the element, the query will be forwarded upstream.
The set_caps_vfunc() function will be called when the subclass should configure itself to process a specific media type.
The start_vfunc() and stop_vfunc() virtual methods will be called when resources should be allocated. Any preroll_vfunc(), render_vfunc() and set_caps_vfunc() function will be called between the start_vfunc() and stop_vfunc() calls.
The event_vfunc() virtual method will be called when an event is received by Gst::BaseSink. Normally this method should only be overriden by very specific elements (such as file sinks) which need to handle the newsegment event specially.
Gst::BaseSink provides an overridable buffer_alloc_vfunc() function that can be used by sinks that want to do reverse negotiation or to provide custom buffers (hardware buffers for example) to upstream elements.
The unlock_vfunc() method is called when the elements should unblock any blocking operations they perform in the render_vfunc() method. This is mostly useful when the render_vfunc() method performs a blocking write on a file descriptor, for example.
The max-lateness property affects how the sink deals with buffers that arrive too late in the sink. A buffer arrives too late in the sink when the presentation time (as a combination of the last segment, buffer timestamp and element base_time) plus the duration is before the current time of the clock. If the frame is later than max-lateness, the sink will drop the buffer without calling the render method. This feature is disabled if sync is disabled, the get_times_vfunc() method does not return a valid start time or max-lateness is set to -1 (the default). Subclasses can use set_max_lateness() to configure the max-lateness value.
The qos property will enable the quality-of-service features of the basesink which gather statistics about the real-time performance of the clock synchronisation. For each buffer received in the sink, statistics are gathered and a QOS event is sent upstream with these numbers. This information can then be used by upstream elements to reduce their processing rate, for example.
Since GStreamer 0.10.15 the async property can be used to instruct the sink to never perform an ASYNC state change. This feature is mostly usable when dealing with non-synchronized streams or sparse streams.
Last reviewed on 2007-08-29 (0.10.15)
virtual Gst::BaseSink::~BaseSink | ( | ) | [virtual] |
virtual StateChangeReturn Gst::BaseSink::async_play_vfunc | ( | ) | [virtual] |
Subclasses should override this when they need to perform special processing when changing to the PLAYING state asynchronously.
Called with the OBJECT_LOCK held.
virtual void Gst::BaseSink::fixate_vfunc | ( | const Glib::RefPtr<Gst::Caps>& | caps | ) | [virtual] |
Subclasses should override this when they can provide an alternate method of spawning a thread to drive the pipeline in pull mode.
Should start or stop the pulling thread, depending on the value of the "active" argument. Called after actually activating the sink pad in pull mode. The default implementation starts a task on the sink pad. Only useful in pull mode, this vmethod will be called in response to Gst::Pad::fixate_caps() being called on the sink pad. Implement if you have ideas about what should be the default values for the caps you support.
virtual Glib::RefPtr<Gst::Caps> Gst::BaseSink::get_caps_vfunc | ( | ) | [virtual] |
Called to get sink pad caps from the subclass.
Glib::RefPtr<Gst::Buffer> Gst::BaseSink::get_last_buffer | ( | ) |
Get the last buffer that arrived in the sink and was used for preroll or for rendering.
This property can be used to generate thumbnails.
The Gst::Caps on the buffer can be used to determine the type of the buffer.
0
when no buffer has arrived in the sink yet or when the sink is not in PAUSED or PLAYING.ClockTime Gst::BaseSink::get_latency | ( | ) |
Get the currently configured latency.
gint64 Gst::BaseSink::get_max_lateness | ( | ) |
Gets the max lateness value.
See gst_base_sink_set_max_lateness for more details.
Glib::RefPtr<Gst::Pad> Gst::BaseSink::get_sink_pad | ( | ) | const |
Gets the sink Gst::Pad object of the element.
bool Gst::BaseSink::get_sync | ( | ) |
Checks if sink is currently configured to synchronize against the clock.
true
if the sink is configured to synchronize against the clock.virtual void Gst::BaseSink::get_times_vfunc | ( | const Glib::RefPtr<Gst::Buffer>& | buffer, | |
ClockTime& | start, | |||
ClockTime& | end | |||
) | [virtual] |
Notify subclass of changed caps.
Called to get the start and end times for synchronising the passed buffer to the clock.
ClockTimeDiff Gst::BaseSink::get_ts_offset | ( | ) |
Get the synchronisation offset of sink.
const GstBaseSink* Gst::BaseSink::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gst::Element.
Reimplemented in Gst::FakeSink, Gst::FdSink, Gst::FileSink, GstBase::AlsaSink, GstBase::AudioSink, GstBase::BaseAudioSink, GstBase::GioSink, GstBase::GioStreamSink, GstBase::VideoSink, GstBase::XImageSink, and GstBase::XvImageSink.
GstBaseSink* Gst::BaseSink::gobj | ( | ) | [inline] |
Provides access to the underlying C GObject.
Reimplemented from Gst::Element.
Reimplemented in Gst::FakeSink, Gst::FdSink, Gst::FileSink, GstBase::AlsaSink, GstBase::AudioSink, GstBase::BaseAudioSink, GstBase::GioSink, GstBase::GioStreamSink, GstBase::VideoSink, GstBase::XImageSink, and GstBase::XvImageSink.
GstBaseSink* Gst::BaseSink::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::FakeSink, Gst::FdSink, Gst::FileSink, GstBase::AlsaSink, GstBase::AudioSink, GstBase::BaseAudioSink, GstBase::GioSink, GstBase::GioStreamSink, GstBase::VideoSink, GstBase::XImageSink, and GstBase::XvImageSink.
bool Gst::BaseSink::is_async_enabled | ( | ) |
Checks if sink is currently configured to perform asynchronous state changes to PAUSED.
true
if the sink is configured to perform asynchronous state changes.bool Gst::BaseSink::is_qos_enabled | ( | ) |
Checks if sink is currently configured to send Quality-of-Service events upstream.
true
if the sink is configured to perform Quality-of-Service.virtual FlowReturn Gst::BaseSink::preroll_vfunc | ( | const Glib::RefPtr<Gst::Buffer>& | buffer | ) | [virtual] |
Start processing.
Ideal for opening resources in the subclass. Stop processing. Subclasses should use this to close resources. Unlock any pending access to the resource. Subclasses should unblock any blocked function ASAP. Override this to handle events arriving on the sink pad. Called to present the preroll buffer if desired.
Glib::PropertyProxy_ReadOnly<bool> Gst::BaseSink::property_async | ( | ) | const |
Go asynchronously to PAUSED.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> Gst::BaseSink::property_async | ( | ) |
Go asynchronously to PAUSED.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<Glib::RefPtr<Gst::Buffer>> Gst::BaseSink::property_last_buffer | ( | ) | const |
The last buffer received in the sink.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<gint64> Gst::BaseSink::property_max_lateness | ( | ) | const |
Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<gint64> Gst::BaseSink::property_max_lateness | ( | ) |
Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited).
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<guint> Gst::BaseSink::property_preroll_queue_len | ( | ) | const |
Number of buffers to queue during preroll.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<guint> Gst::BaseSink::property_preroll_queue_len | ( | ) |
Number of buffers to queue during preroll.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<bool> Gst::BaseSink::property_qos | ( | ) | const |
Generate Quality-of-Service events upstream.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> Gst::BaseSink::property_qos | ( | ) |
Generate Quality-of-Service events upstream.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<bool> Gst::BaseSink::property_sync | ( | ) | const |
Sync on the clock.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> Gst::BaseSink::property_sync | ( | ) |
Sync on the clock.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly<gint64> Gst::BaseSink::property_ts_offset | ( | ) | const |
Timestamp offset in nanoseconds.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<gint64> Gst::BaseSink::property_ts_offset | ( | ) |
Timestamp offset in nanoseconds.
You rarely need to use properties because there are get_ and set_ methods for almost all of them.
bool Gst::BaseSink::query_latency | ( | bool & | live, | |
bool & | upstream_live, | |||
ClockTime& | min_latency, | |||
ClockTime& | max_latency | |||
) |
Query the sink for the latency parameters.
The latency will be queried from the upstream elements. live will be true
if sink is configured to synchronize against the clock. upstream_live will be true
if an upstream element is live.
If both live and upstream_live are true
, the sink will want to compensate for the latency introduced by the upstream elements by setting the min_latency to a strictly possitive value.
This function is mostly used by subclasses.
live | If the sink is live. | |
upstream_live | If an upstream element is live. | |
min_latency | The min latency of the upstream elements. | |
max_latency | The max latency of the upstream elements. |
true
if the query succeeded.virtual FlowReturn Gst::BaseSink::render_vfunc | ( | const Glib::RefPtr<Gst::Buffer>& | buffer | ) | [virtual] |
Called when a buffer should be presented or output, at the correct moment if the Gst::BaseSink has been set to sync to the clock.
void Gst::BaseSink::set_async_enabled | ( | bool | enabled | ) |
Configures sink to perform all state changes asynchronusly.
When async is disabled, the sink will immediatly go to PAUSED instead of waiting for a preroll buffer. This feature is usefull if the sink does not synchronize against the clock or when it is dealing with sparse streams.
Since: 0.10.15
enabled | The new async value. |
void Gst::BaseSink::set_max_lateness | ( | gint64 | max_lateness | ) |
Sets the new max lateness value to max_lateness.
This value is used to decide if a buffer should be dropped or not based on the buffer timestamp and the current clock time. A value of -1 means an unlimited time.
Since: 0.10.4
max_lateness | The new max lateness value. |
void Gst::BaseSink::set_qos_enabled | ( | bool | enabled | ) |
Configures sink to send Quality-of-Service events upstream.
Since: 0.10.5
enabled | The new qos value. |
void Gst::BaseSink::set_sync | ( | bool | sync | ) |
Configures sink to synchronize on the clock or not.
When sync is false
, incomming samples will be played as fast as possible. If sync is true
, the timestamps of the incomming buffers will be used to schedule the exact render time of its contents.
Since: 0.10.4
sync | The new sync value. |
void Gst::BaseSink::set_ts_offset | ( | ClockTimeDiff | offset | ) |
Adjust the synchronisation of sink with offset.
A negative value will render buffers earlier than their timestamp. A positive value will delay rendering. This function can be used to fix playback of badly timestamped buffers.
Since: 0.10.15
offset | The new offset. |
ClockReturn Gst::BaseSink::wait_clock | ( | ClockTime | time, | |
ClockTimeDiff& | jitter | |||
) |
FlowReturn Gst::BaseSink::wait_eos | ( | ClockTime | time, | |
ClockTimeDiff& | jitter | |||
) |
This function will block until time is reached.
It is usually called by subclasses that use their own internal synchronisation but want to let the EOS be handled by the base class.
This function should only be called with the PREROLL_LOCK held, like when receiving an EOS event in the event vmethod.
The time argument should be the running_time of when the EOS should happen and will be adjusted with any latency and offset configured in the sink.
Since 0.10.15
time | The running_time to be reached. | |
jitter | The jitter to be filled with time diff (can be 0 ). |
FlowReturn Gst::BaseSink::wait_preroll | ( | ) |
If the Gst::BaseSinkClass::render method performs its own synchronisation against the clock it must unblock when going from PLAYING to the PAUSED state and call this method before continuing to render the remaining data.
This function will block until a state change to PLAYING happens (in which case this function returns Gst::FLOW_OK) or the processing must be stopped due to a state change to READY or a FLUSH event (in which case this function Returns: Gst::FLOW_OK if the preroll completed and processing can
Glib::RefPtr<Gst::BaseSink> wrap | ( | GstBaseSink * | object, | |
bool | take_copy = false | |||
) | [related] |
A Glib::wrap() method for this object.
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. |