![]() |
![]() |
![]() |
GStreamer 1.0 Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
#include <gst/base/gstbasesink.h> struct GstBaseSink; struct GstBaseSinkClass; gboolean gst_base_sink_query_latency (GstBaseSink *sink
,gboolean *live
,gboolean *upstream_live
,GstClockTime *min_latency
,GstClockTime *max_latency
); GstClockTime gst_base_sink_get_latency (GstBaseSink *sink
); GstFlowReturn gst_base_sink_do_preroll (GstBaseSink *sink
,GstMiniObject *obj
); GstFlowReturn gst_base_sink_wait_preroll (GstBaseSink *sink
); GstClockReturn gst_base_sink_wait_clock (GstBaseSink *sink
,GstClockTime time
,GstClockTimeDiff *jitter
); void gst_base_sink_set_sync (GstBaseSink *sink
,gboolean sync
); gboolean gst_base_sink_get_sync (GstBaseSink *sink
); void gst_base_sink_set_max_lateness (GstBaseSink *sink
,gint64 max_lateness
); gint64 gst_base_sink_get_max_lateness (GstBaseSink *sink
); void gst_base_sink_set_qos_enabled (GstBaseSink *sink
,gboolean enabled
); gboolean gst_base_sink_is_qos_enabled (GstBaseSink *sink
); void gst_base_sink_set_async_enabled (GstBaseSink *sink
,gboolean enabled
); gboolean gst_base_sink_is_async_enabled (GstBaseSink *sink
); void gst_base_sink_set_ts_offset (GstBaseSink *sink
,GstClockTimeDiff offset
); GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink
); void gst_base_sink_set_render_delay (GstBaseSink *sink
,GstClockTime delay
); GstClockTime gst_base_sink_get_render_delay (GstBaseSink *sink
); GstSample * gst_base_sink_get_last_sample (GstBaseSink *sink
); void gst_base_sink_set_blocksize (GstBaseSink *sink
,guint blocksize
); guint gst_base_sink_get_blocksize (GstBaseSink *sink
); guint64 gst_base_sink_get_throttle_time (GstBaseSink *sink
); void gst_base_sink_set_throttle_time (GstBaseSink *sink
,guint64 throttle
); #define GST_BASE_SINK_PAD (obj) #define GST_BASE_SINK_GET_PREROLL_COND (pad) #define GST_BASE_SINK_GET_PREROLL_LOCK (pad) #define GST_BASE_SINK_PREROLL_BROADCAST (pad) #define GST_BASE_SINK_PREROLL_LOCK (pad) #define GST_BASE_SINK_PREROLL_SIGNAL (pad) #define GST_BASE_SINK_PREROLL_TRYLOCK (pad) #define GST_BASE_SINK_PREROLL_UNLOCK (pad) #define GST_BASE_SINK_PREROLL_WAIT (pad)
"async" gboolean : Read / Write "blocksize" guint : Read / Write "enable-last-sample" gboolean : Read / Write "last-sample" GstSample* : Read "max-lateness" gint64 : Read / Write "qos" gboolean : Read / Write "render-delay" guint64 : Read / Write "sync" gboolean : Read / Write "throttle-time" guint64 : Read / Write "ts-offset" gint64 : Read / Write
struct GstBaseSinkClass { GstElementClass parent_class; /* get caps from subclass */ GstCaps* (*get_caps) (GstBaseSink *sink, GstCaps *filter); /* notify subclass of new caps */ gboolean (*set_caps) (GstBaseSink *sink, GstCaps *caps); /* fixate sink caps during pull-mode negotiation */ GstCaps * (*fixate) (GstBaseSink *sink, GstCaps *caps); /* start or stop a pulling thread */ gboolean (*activate_pull)(GstBaseSink *sink, gboolean active); /* get the start and end times for syncing on this buffer */ void (*get_times) (GstBaseSink *sink, GstBuffer *buffer, GstClockTime *start, GstClockTime *end); /* propose allocation parameters for upstream */ gboolean (*propose_allocation) (GstBaseSink *sink, GstQuery *query); /* start and stop processing, ideal for opening/closing the resource */ gboolean (*start) (GstBaseSink *sink); gboolean (*stop) (GstBaseSink *sink); /* unlock any pending access to the resource. subclasses should unlock * any function ASAP. */ gboolean (*unlock) (GstBaseSink *sink); /* Clear a previously indicated unlock request not that unlocking is * complete. Sub-classes should clear any command queue or indicator they * set during unlock */ gboolean (*unlock_stop) (GstBaseSink *sink); /* notify subclass of query */ gboolean (*query) (GstBaseSink *sink, GstQuery *query); /* notify subclass of event */ gboolean (*event) (GstBaseSink *sink, GstEvent *event); /* wait for eos, subclasses should chain up to parent first */ GstFlowReturn (*wait_eos) (GstBaseSink *sink, GstEvent *event); /* notify subclass of buffer or list before doing sync */ GstFlowReturn (*prepare) (GstBaseSink *sink, GstBuffer *buffer); GstFlowReturn (*prepare_list) (GstBaseSink *sink, GstBufferList *buffer_list); /* notify subclass of preroll buffer or real buffer */ GstFlowReturn (*preroll) (GstBaseSink *sink, GstBuffer *buffer); GstFlowReturn (*render) (GstBaseSink *sink, GstBuffer *buffer); /* Render a BufferList */ GstFlowReturn (*render_list) (GstBaseSink *sink, GstBufferList *buffer_list); };
Subclasses can override any of the available virtual methods or not, as
needed. At the minimum, the render
method should be overridden to
output/present buffers.
GstElementClass |
Element parent class |
Called to get sink pad caps from the subclass | |
Notify subclass of changed caps | |
Only useful in pull mode. Implement if you have ideas about what should be the default values for the caps you support. | |
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. | |
Called to get the start and end times for synchronising the passed buffer to the clock | |
configure the allocation query | |
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 | |
Clear the previous unlock request. Subclasses should clear
any state they set during unlock() , such as clearing command queues. |
|
perform a GstQuery on the element. | |
Override this to handle events arriving on the sink pad | |
Override this to implement custom logic to wait for the EOS time. subclasses should always first chain up to the default implementation. | |
Called to prepare the buffer for render and preroll . This
function is called before synchronisation is performed. |
|
Called to prepare the buffer list for render_list . This
function is called before synchronisation is performed. |
|
Called to present the preroll buffer if desired. | |
Called when a buffer should be presented or output, at the correct moment if the GstBaseSink has been set to sync to the clock. | |
Same as render but used whith buffer lists instead of
buffers. |
gboolean gst_base_sink_query_latency (GstBaseSink *sink
,gboolean *live
,gboolean *upstream_live
,GstClockTime *min_latency
,GstClockTime *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.
|
the sink |
|
if the sink is live. [out][allow-none] |
|
if an upstream element is live. [out][allow-none] |
|
the min latency of the upstream elements. [out][allow-none] |
|
the max latency of the upstream elements. [out][allow-none] |
Returns : |
TRUE if the query succeeded. |
GstClockTime gst_base_sink_get_latency (GstBaseSink *sink
);
Get the currently configured latency.
|
the sink |
Returns : |
The configured latency. |
GstFlowReturn gst_base_sink_do_preroll (GstBaseSink *sink
,GstMiniObject *obj
);
If the sink
spawns its own thread for pulling buffers from upstream it
should call this method after it has pulled a buffer. If the element needed
to preroll, this function will perform the preroll and will then block
until the element state is changed.
This function should be called with the PREROLL_LOCK held.
|
the sink |
|
the mini object that caused the preroll. [transfer none] |
Returns : |
GST_FLOW_OK if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod. |
GstFlowReturn gst_base_sink_wait_preroll (GstBaseSink *sink
);
If the GstBaseSinkClass.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_FLUSHING).
This function should only be called with the PREROLL_LOCK held, like in the render function.
|
the sink |
Returns : |
GST_FLOW_OK if the preroll completed and processing can continue. Any other return value should be returned from the render vmethod. |
GstClockReturn gst_base_sink_wait_clock (GstBaseSink *sink
,GstClockTime time
,GstClockTimeDiff *jitter
);
This function will block until time
is reached. It is usually called by
subclasses that use their own internal synchronisation.
If time
is not valid, no sycnhronisation is done and GST_CLOCK_BADTIME is
returned. Likewise, if synchronisation is disabled in the element or there
is no clock, no synchronisation is done and GST_CLOCK_BADTIME is returned.
This function should only be called with the PREROLL_LOCK held, like when
receiving an EOS event in the GstBaseSinkClass.event()
vmethod or when
receiving a buffer in
the GstBaseSinkClass.render()
vmethod.
The time
argument should be the running_time of when this method should
return and is not adjusted with any latency or offset configured in the
sink.
|
the sink |
|
the running_time to be reached |
|
the jitter to be filled with time diff, or NULL. [out][allow-none] |
Returns : |
GstClockReturn |
void gst_base_sink_set_sync (GstBaseSink *sink
,gboolean sync
);
Configures sink
to synchronize on the clock or not. When
sync
is FALSE, incoming 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.
|
the sink |
|
the new sync value. |
gboolean gst_base_sink_get_sync (GstBaseSink *sink
);
Checks if sink
is currently configured to synchronize against the
clock.
|
the sink |
Returns : |
TRUE if the sink is configured to synchronize against the clock. |
void gst_base_sink_set_max_lateness (GstBaseSink *sink
,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.
|
the sink |
|
the new max lateness value. |
gint64 gst_base_sink_get_max_lateness (GstBaseSink *sink
);
Gets the max lateness value. See gst_base_sink_set_max_lateness for more details.
|
the sink |
Returns : |
The maximum time in nanoseconds that a buffer can be late before it is dropped and not rendered. A value of -1 means an unlimited time. |
void gst_base_sink_set_qos_enabled (GstBaseSink *sink
,gboolean enabled
);
Configures sink
to send Quality-of-Service events upstream.
|
the sink |
|
the new qos value. |
gboolean gst_base_sink_is_qos_enabled (GstBaseSink *sink
);
Checks if sink
is currently configured to send Quality-of-Service events
upstream.
|
the sink |
Returns : |
TRUE if the sink is configured to perform Quality-of-Service. |
void gst_base_sink_set_async_enabled (GstBaseSink *sink
,gboolean enabled
);
Configures sink
to perform all state changes asynchronusly. When async is
disabled, the sink will immediately go to PAUSED instead of waiting for a
preroll buffer. This feature is useful if the sink does not synchronize
against the clock or when it is dealing with sparse streams.
|
the sink |
|
the new async value. |
gboolean gst_base_sink_is_async_enabled (GstBaseSink *sink
);
Checks if sink
is currently configured to perform asynchronous state
changes to PAUSED.
|
the sink |
Returns : |
TRUE if the sink is configured to perform asynchronous state changes. |
void gst_base_sink_set_ts_offset (GstBaseSink *sink
,GstClockTimeDiff 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.
|
the sink |
|
the new offset |
GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink
);
Get the synchronisation offset of sink
.
|
the sink |
Returns : |
The synchronisation offset. |
void gst_base_sink_set_render_delay (GstBaseSink *sink
,GstClockTime delay
);
Set the render delay in sink
to delay
. The render delay is the time
between actual rendering of a buffer and its synchronisation time. Some
devices might delay media rendering which can be compensated for with this
function.
After calling this function, this sink will report additional latency and other sinks will adjust their latency to delay the rendering of their media.
This function is usually called by subclasses.
|
a GstBaseSink |
|
the new delay |
GstClockTime gst_base_sink_get_render_delay (GstBaseSink *sink
);
Get the render delay of sink
. see gst_base_sink_set_render_delay()
for more
information about the render delay.
|
a GstBaseSink |
Returns : |
the render delay of sink . |
GstSample * gst_base_sink_get_last_sample (GstBaseSink *sink
);
Get the last sample that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails.
The GstCaps on the sample can be used to determine the type of the buffer.
Free-function: gst_sample_unref
|
the sink |
Returns : |
a GstSample. gst_sample_unref() after usage.
This function returns NULL when no buffer has arrived in the sink yet
or when the sink is not in PAUSED or PLAYING. [transfer full]
|
void gst_base_sink_set_blocksize (GstBaseSink *sink
,guint blocksize
);
Set the number of bytes that the sink will pull when it is operating in pull mode.
|
a GstBaseSink |
|
the blocksize in bytes |
guint gst_base_sink_get_blocksize (GstBaseSink *sink
);
Get the number of bytes that the sink will pull when it is operating in pull mode.
|
a GstBaseSink |
Returns : |
the number of bytes sink will pull in pull mode. |
guint64 gst_base_sink_get_throttle_time (GstBaseSink *sink
);
Get the time that will be inserted between frames to control the maximum buffers per second.
|
a GstBaseSink |
Returns : |
the number of nanoseconds sink will put between frames. |
void gst_base_sink_set_throttle_time (GstBaseSink *sink
,guint64 throttle
);
Set the time that will be inserted between rendered buffers. This can be used to control the maximum buffers per second that the sink will render.
|
a GstBaseSink |
|
the throttle time in nanoseconds |
#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad)
Gives the pointer to the GstPad object of the element.
|
base sink instance |
#define GST_BASE_SINK_GET_PREROLL_COND(pad) (&GST_BASE_SINK_CAST(pad)->preroll_cond)
#define GST_BASE_SINK_GET_PREROLL_LOCK(pad) (&GST_BASE_SINK_CAST(pad)->preroll_lock)
#define GST_BASE_SINK_PREROLL_BROADCAST(pad) g_cond_broadcast (GST_BASE_SINK_GET_PREROLL_COND (pad));
#define GST_BASE_SINK_PREROLL_LOCK(pad) (g_mutex_lock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
#define GST_BASE_SINK_PREROLL_SIGNAL(pad) g_cond_signal (GST_BASE_SINK_GET_PREROLL_COND (pad));
#define GST_BASE_SINK_PREROLL_TRYLOCK(pad) (g_mutex_trylock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
#define GST_BASE_SINK_PREROLL_UNLOCK(pad) (g_mutex_unlock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
"async"
property"async" gboolean : Read / Write
If set to TRUE, the basesink will perform asynchronous state changes. When set to FALSE, the sink will not signal the parent when it prerolls. Use this option when dealing with sparse streams or when synchronisation is not required.
Default value: TRUE
"blocksize"
property"blocksize" guint : Read / Write
The amount of bytes to pull when operating in pull mode.
Default value: 4096
"enable-last-sample"
property"enable-last-sample" gboolean : Read / Write
Enable the last-sample property. If FALSE, basesink doesn't keep a reference to the last buffer arrived and the last-sample property is always set to NULL. This can be useful if you need buffers to be released as soon as possible, eg. if you're using a buffer pool.
Default value: TRUE
"last-sample"
property"last-sample" GstSample* : Read
The last buffer that arrived in the sink and was used for preroll or for rendering. This property can be used to generate thumbnails. This property can be NULL when the sink has not yet received a bufer.
"max-lateness"
property "max-lateness" gint64 : Read / Write
Maximum number of nanoseconds that a buffer can be late before it is dropped (-1 unlimited).
Allowed values: >= -1
Default value: -1
"qos"
property"qos" gboolean : Read / Write
Generate Quality-of-Service events upstream.
Default value: FALSE
"render-delay"
property "render-delay" guint64 : Read / Write
The additional delay between synchronisation and actual rendering of the media. This property will add additional latency to the device in order to make other sinks compensate for the delay.
Default value: 0
"throttle-time"
property "throttle-time" guint64 : Read / Write
The time to insert between buffers. This property can be used to control the maximum amount of buffers per second to render. Setting this property to a value bigger than 0 will make the sink create THROTTLE QoS events.
Default value: 0