mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
basesink: last-buffer -> last-sample
Rename the last-buffer property to last-sample and make it return the new GstSample type so that we can include caps and timing info in one nice bundle.
This commit is contained in:
parent
facf937276
commit
8acc2d9dc7
5 changed files with 90 additions and 84 deletions
|
@ -247,7 +247,7 @@ gst_base_sink_set_render_delay
|
||||||
gst_base_sink_get_render_delay
|
gst_base_sink_get_render_delay
|
||||||
gst_base_sink_set_last_buffer_enabled
|
gst_base_sink_set_last_buffer_enabled
|
||||||
gst_base_sink_is_last_buffer_enabled
|
gst_base_sink_is_last_buffer_enabled
|
||||||
gst_base_sink_get_last_buffer
|
gst_base_sink_get_last_sample
|
||||||
gst_base_sink_set_blocksize
|
gst_base_sink_set_blocksize
|
||||||
gst_base_sink_get_blocksize
|
gst_base_sink_get_blocksize
|
||||||
gst_base_sink_get_throttle_time
|
gst_base_sink_get_throttle_time
|
||||||
|
|
|
@ -240,11 +240,12 @@ struct _GstBaseSinkPrivate
|
||||||
gboolean have_latency;
|
gboolean have_latency;
|
||||||
|
|
||||||
/* the last buffer we prerolled or rendered. Useful for making snapshots */
|
/* the last buffer we prerolled or rendered. Useful for making snapshots */
|
||||||
gint enable_last_buffer; /* atomic */
|
gint enable_last_sample; /* atomic */
|
||||||
GstBuffer *last_buffer;
|
GstBuffer *last_buffer;
|
||||||
|
GstCaps *last_caps;
|
||||||
|
|
||||||
/* caps for pull based scheduling */
|
/* negotiated caps */
|
||||||
GstCaps *pull_caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
/* blocksize for pulling */
|
/* blocksize for pulling */
|
||||||
guint blocksize;
|
guint blocksize;
|
||||||
|
@ -307,7 +308,7 @@ enum
|
||||||
#define DEFAULT_TS_OFFSET 0
|
#define DEFAULT_TS_OFFSET 0
|
||||||
#define DEFAULT_BLOCKSIZE 4096
|
#define DEFAULT_BLOCKSIZE 4096
|
||||||
#define DEFAULT_RENDER_DELAY 0
|
#define DEFAULT_RENDER_DELAY 0
|
||||||
#define DEFAULT_ENABLE_LAST_BUFFER TRUE
|
#define DEFAULT_ENABLE_LAST_SAMPLE TRUE
|
||||||
#define DEFAULT_THROTTLE_TIME 0
|
#define DEFAULT_THROTTLE_TIME 0
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -318,8 +319,8 @@ enum
|
||||||
PROP_QOS,
|
PROP_QOS,
|
||||||
PROP_ASYNC,
|
PROP_ASYNC,
|
||||||
PROP_TS_OFFSET,
|
PROP_TS_OFFSET,
|
||||||
PROP_ENABLE_LAST_BUFFER,
|
PROP_ENABLE_LAST_SAMPLE,
|
||||||
PROP_LAST_BUFFER,
|
PROP_LAST_SAMPLE,
|
||||||
PROP_BLOCKSIZE,
|
PROP_BLOCKSIZE,
|
||||||
PROP_RENDER_DELAY,
|
PROP_RENDER_DELAY,
|
||||||
PROP_THROTTLE_TIME,
|
PROP_THROTTLE_TIME,
|
||||||
|
@ -473,22 +474,22 @@ gst_base_sink_class_init (GstBaseSinkClass * klass)
|
||||||
DEFAULT_TS_OFFSET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
DEFAULT_TS_OFFSET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstBaseSink:enable-last-buffer
|
* GstBaseSink:enable-last-sample
|
||||||
*
|
*
|
||||||
* Enable the last-buffer property. If FALSE, basesink doesn't keep a
|
* Enable the last-sample property. If FALSE, basesink doesn't keep a
|
||||||
* reference to the last buffer arrived and the last-buffer property is always
|
* 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
|
* 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.
|
* as possible, eg. if you're using a buffer pool.
|
||||||
*
|
*
|
||||||
* Since: 0.10.30
|
* Since: 0.10.30
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class, PROP_ENABLE_LAST_BUFFER,
|
g_object_class_install_property (gobject_class, PROP_ENABLE_LAST_SAMPLE,
|
||||||
g_param_spec_boolean ("enable-last-buffer", "Enable Last Buffer",
|
g_param_spec_boolean ("enable-last-sample", "Enable Last Buffer",
|
||||||
"Enable the last-buffer property", DEFAULT_ENABLE_LAST_BUFFER,
|
"Enable the last-sample property", DEFAULT_ENABLE_LAST_SAMPLE,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstBaseSink:last-buffer
|
* GstBaseSink:last-sample
|
||||||
*
|
*
|
||||||
* The last buffer that arrived in the sink and was used for preroll or for
|
* 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
|
* rendering. This property can be used to generate thumbnails. This property
|
||||||
|
@ -496,9 +497,9 @@ gst_base_sink_class_init (GstBaseSinkClass * klass)
|
||||||
*
|
*
|
||||||
* Since: 0.10.15
|
* Since: 0.10.15
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class, PROP_LAST_BUFFER,
|
g_object_class_install_property (gobject_class, PROP_LAST_SAMPLE,
|
||||||
g_param_spec_boxed ("last-buffer", "Last Buffer",
|
g_param_spec_boxed ("last-sample", "Last Sample",
|
||||||
"The last buffer received in the sink", GST_TYPE_BUFFER,
|
"The last sample received in the sink", GST_TYPE_SAMPLE,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
/**
|
/**
|
||||||
* GstBaseSink:blocksize
|
* GstBaseSink:blocksize
|
||||||
|
@ -663,7 +664,7 @@ gst_base_sink_init (GstBaseSink * basesink, gpointer g_class)
|
||||||
priv->render_delay = DEFAULT_RENDER_DELAY;
|
priv->render_delay = DEFAULT_RENDER_DELAY;
|
||||||
priv->blocksize = DEFAULT_BLOCKSIZE;
|
priv->blocksize = DEFAULT_BLOCKSIZE;
|
||||||
priv->cached_clock_id = NULL;
|
priv->cached_clock_id = NULL;
|
||||||
g_atomic_int_set (&priv->enable_last_buffer, DEFAULT_ENABLE_LAST_BUFFER);
|
g_atomic_int_set (&priv->enable_last_sample, DEFAULT_ENABLE_LAST_SAMPLE);
|
||||||
priv->throttle_time = DEFAULT_THROTTLE_TIME;
|
priv->throttle_time = DEFAULT_THROTTLE_TIME;
|
||||||
|
|
||||||
GST_OBJECT_FLAG_SET (basesink, GST_ELEMENT_FLAG_SINK);
|
GST_OBJECT_FLAG_SET (basesink, GST_ELEMENT_FLAG_SINK);
|
||||||
|
@ -915,32 +916,34 @@ gst_base_sink_get_ts_offset (GstBaseSink * sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_base_sink_get_last_buffer:
|
* gst_base_sink_get_last_sample:
|
||||||
* @sink: the sink
|
* @sink: the sink
|
||||||
*
|
*
|
||||||
* Get the last buffer that arrived in the sink and was used for preroll or for
|
* 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.
|
* rendering. This property can be used to generate thumbnails.
|
||||||
*
|
*
|
||||||
* The #GstCaps on the buffer can be used to determine the type of the buffer.
|
* The #GstCaps on the sample can be used to determine the type of the buffer.
|
||||||
*
|
*
|
||||||
* Free-function: gst_buffer_unref
|
* Free-function: gst_sample_unref
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): a #GstBuffer. gst_buffer_unref() after usage.
|
* Returns: (transfer full): a #GstSample. gst_sample_unref() after usage.
|
||||||
* This function returns NULL when no buffer has arrived in the sink yet
|
* This function returns NULL when no buffer has arrived in the sink yet
|
||||||
* or when the sink is not in PAUSED or PLAYING.
|
* or when the sink is not in PAUSED or PLAYING.
|
||||||
*
|
*
|
||||||
* Since: 0.10.15
|
* Since: 0.10.15
|
||||||
*/
|
*/
|
||||||
GstBuffer *
|
GstSample *
|
||||||
gst_base_sink_get_last_buffer (GstBaseSink * sink)
|
gst_base_sink_get_last_sample (GstBaseSink * sink)
|
||||||
{
|
{
|
||||||
GstBuffer *res;
|
GstSample *res = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BASE_SINK (sink), NULL);
|
g_return_val_if_fail (GST_IS_BASE_SINK (sink), NULL);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (sink);
|
GST_OBJECT_LOCK (sink);
|
||||||
if ((res = sink->priv->last_buffer))
|
if (sink->priv->last_buffer) {
|
||||||
gst_buffer_ref (res);
|
res = gst_sample_new (sink->priv->last_buffer,
|
||||||
|
sink->priv->last_caps, &sink->segment, NULL);
|
||||||
|
}
|
||||||
GST_OBJECT_UNLOCK (sink);
|
GST_OBJECT_UNLOCK (sink);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -958,6 +961,11 @@ gst_base_sink_set_last_buffer_unlocked (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
if (G_LIKELY (buffer))
|
if (G_LIKELY (buffer))
|
||||||
gst_buffer_ref (buffer);
|
gst_buffer_ref (buffer);
|
||||||
sink->priv->last_buffer = buffer;
|
sink->priv->last_buffer = buffer;
|
||||||
|
if (buffer)
|
||||||
|
/* copy over the caps */
|
||||||
|
gst_caps_replace (&sink->priv->last_caps, sink->priv->caps);
|
||||||
|
else
|
||||||
|
gst_caps_replace (&sink->priv->last_caps, NULL);
|
||||||
} else {
|
} else {
|
||||||
old = NULL;
|
old = NULL;
|
||||||
}
|
}
|
||||||
|
@ -973,7 +981,7 @@ gst_base_sink_set_last_buffer_unlocked (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
static void
|
static void
|
||||||
gst_base_sink_set_last_buffer (GstBaseSink * sink, GstBuffer * buffer)
|
gst_base_sink_set_last_buffer (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
if (!g_atomic_int_get (&sink->priv->enable_last_buffer))
|
if (!g_atomic_int_get (&sink->priv->enable_last_sample))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (sink);
|
GST_OBJECT_LOCK (sink);
|
||||||
|
@ -982,22 +990,22 @@ gst_base_sink_set_last_buffer (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_base_sink_set_last_buffer_enabled:
|
* gst_base_sink_set_last_sample_enabled:
|
||||||
* @sink: the sink
|
* @sink: the sink
|
||||||
* @enabled: the new enable-last-buffer value.
|
* @enabled: the new enable-last-sample value.
|
||||||
*
|
*
|
||||||
* Configures @sink to store the last received buffer in the last-buffer
|
* Configures @sink to store the last received sample in the last-sample
|
||||||
* property.
|
* property.
|
||||||
*
|
*
|
||||||
* Since: 0.10.30
|
* Since: 0.10.30
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_base_sink_set_last_buffer_enabled (GstBaseSink * sink, gboolean enabled)
|
gst_base_sink_set_last_sample_enabled (GstBaseSink * sink, gboolean enabled)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_BASE_SINK (sink));
|
g_return_if_fail (GST_IS_BASE_SINK (sink));
|
||||||
|
|
||||||
/* Only take lock if we change the value */
|
/* Only take lock if we change the value */
|
||||||
if (g_atomic_int_compare_and_exchange (&sink->priv->enable_last_buffer,
|
if (g_atomic_int_compare_and_exchange (&sink->priv->enable_last_sample,
|
||||||
!enabled, enabled) && !enabled) {
|
!enabled, enabled) && !enabled) {
|
||||||
GST_OBJECT_LOCK (sink);
|
GST_OBJECT_LOCK (sink);
|
||||||
gst_base_sink_set_last_buffer_unlocked (sink, NULL);
|
gst_base_sink_set_last_buffer_unlocked (sink, NULL);
|
||||||
|
@ -1006,22 +1014,22 @@ gst_base_sink_set_last_buffer_enabled (GstBaseSink * sink, gboolean enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_base_sink_is_last_buffer_enabled:
|
* gst_base_sink_is_last_sample_enabled:
|
||||||
* @sink: the sink
|
* @sink: the sink
|
||||||
*
|
*
|
||||||
* Checks if @sink is currently configured to store the last received buffer in
|
* Checks if @sink is currently configured to store the last received sample in
|
||||||
* the last-buffer property.
|
* the last-sample property.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the sink is configured to store the last received buffer.
|
* Returns: TRUE if the sink is configured to store the last received sample.
|
||||||
*
|
*
|
||||||
* Since: 0.10.30
|
* Since: 0.10.30
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_base_sink_is_last_buffer_enabled (GstBaseSink * sink)
|
gst_base_sink_is_last_sample_enabled (GstBaseSink * sink)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GST_IS_BASE_SINK (sink), FALSE);
|
g_return_val_if_fail (GST_IS_BASE_SINK (sink), FALSE);
|
||||||
|
|
||||||
return g_atomic_int_get (&sink->priv->enable_last_buffer);
|
return g_atomic_int_get (&sink->priv->enable_last_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1335,8 +1343,8 @@ gst_base_sink_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_RENDER_DELAY:
|
case PROP_RENDER_DELAY:
|
||||||
gst_base_sink_set_render_delay (sink, g_value_get_uint64 (value));
|
gst_base_sink_set_render_delay (sink, g_value_get_uint64 (value));
|
||||||
break;
|
break;
|
||||||
case PROP_ENABLE_LAST_BUFFER:
|
case PROP_ENABLE_LAST_SAMPLE:
|
||||||
gst_base_sink_set_last_buffer_enabled (sink, g_value_get_boolean (value));
|
gst_base_sink_set_last_sample_enabled (sink, g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
case PROP_THROTTLE_TIME:
|
case PROP_THROTTLE_TIME:
|
||||||
gst_base_sink_set_throttle_time (sink, g_value_get_uint64 (value));
|
gst_base_sink_set_throttle_time (sink, g_value_get_uint64 (value));
|
||||||
|
@ -1369,11 +1377,11 @@ gst_base_sink_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
case PROP_TS_OFFSET:
|
case PROP_TS_OFFSET:
|
||||||
g_value_set_int64 (value, gst_base_sink_get_ts_offset (sink));
|
g_value_set_int64 (value, gst_base_sink_get_ts_offset (sink));
|
||||||
break;
|
break;
|
||||||
case PROP_LAST_BUFFER:
|
case PROP_LAST_SAMPLE:
|
||||||
gst_value_take_buffer (value, gst_base_sink_get_last_buffer (sink));
|
gst_value_take_buffer (value, gst_base_sink_get_last_sample (sink));
|
||||||
break;
|
break;
|
||||||
case PROP_ENABLE_LAST_BUFFER:
|
case PROP_ENABLE_LAST_SAMPLE:
|
||||||
g_value_set_boolean (value, gst_base_sink_is_last_buffer_enabled (sink));
|
g_value_set_boolean (value, gst_base_sink_is_last_sample_enabled (sink));
|
||||||
break;
|
break;
|
||||||
case PROP_BLOCKSIZE:
|
case PROP_BLOCKSIZE:
|
||||||
g_value_set_uint (value, gst_base_sink_get_blocksize (sink));
|
g_value_set_uint (value, gst_base_sink_get_blocksize (sink));
|
||||||
|
@ -3346,6 +3354,11 @@ gst_base_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||||
if (bclass->set_caps)
|
if (bclass->set_caps)
|
||||||
result = bclass->set_caps (basesink, caps);
|
result = bclass->set_caps (basesink, caps);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
GST_OBJECT_LOCK (basesink);
|
||||||
|
gst_caps_replace (&basesink->priv->caps, caps);
|
||||||
|
GST_OBJECT_UNLOCK (basesink);
|
||||||
|
}
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4161,7 +4174,7 @@ gst_base_sink_pad_activate (GstPad * pad, GstObject * parent)
|
||||||
if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE)) {
|
if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE)) {
|
||||||
/* clear any pending caps */
|
/* clear any pending caps */
|
||||||
GST_OBJECT_LOCK (basesink);
|
GST_OBJECT_LOCK (basesink);
|
||||||
gst_caps_replace (&basesink->priv->pull_caps, NULL);
|
gst_caps_replace (&basesink->priv->caps, NULL);
|
||||||
GST_OBJECT_UNLOCK (basesink);
|
GST_OBJECT_UNLOCK (basesink);
|
||||||
GST_DEBUG_OBJECT (basesink, "failed to activate in pull mode");
|
GST_DEBUG_OBJECT (basesink, "failed to activate in pull mode");
|
||||||
goto fallback;
|
goto fallback;
|
||||||
|
@ -4252,10 +4265,6 @@ gst_base_sink_negotiate_pull (GstBaseSink * basesink)
|
||||||
gst_event_new_caps (caps)))
|
gst_event_new_caps (caps)))
|
||||||
goto could_not_set_caps;
|
goto could_not_set_caps;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (basesink);
|
|
||||||
gst_caps_replace (&basesink->priv->pull_caps, caps);
|
|
||||||
GST_OBJECT_UNLOCK (basesink);
|
|
||||||
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4332,10 +4341,6 @@ gst_base_sink_pad_activate_pull (GstPad * pad, GstObject * parent,
|
||||||
if (bclass->activate_pull)
|
if (bclass->activate_pull)
|
||||||
result &= bclass->activate_pull (basesink, FALSE);
|
result &= bclass->activate_pull (basesink, FALSE);
|
||||||
basesink->pad_mode = GST_PAD_MODE_NONE;
|
basesink->pad_mode = GST_PAD_MODE_NONE;
|
||||||
/* clear any pending caps */
|
|
||||||
GST_OBJECT_LOCK (basesink);
|
|
||||||
gst_caps_replace (&basesink->priv->pull_caps, NULL);
|
|
||||||
GST_OBJECT_UNLOCK (basesink);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5076,6 +5081,7 @@ gst_base_sink_change_state (GstElement * element, GstStateChange transition)
|
||||||
gst_clock_id_unref (priv->cached_clock_id);
|
gst_clock_id_unref (priv->cached_clock_id);
|
||||||
priv->cached_clock_id = NULL;
|
priv->cached_clock_id = NULL;
|
||||||
}
|
}
|
||||||
|
gst_caps_replace (&basesink->priv->caps, NULL);
|
||||||
GST_OBJECT_UNLOCK (basesink);
|
GST_OBJECT_UNLOCK (basesink);
|
||||||
|
|
||||||
gst_base_sink_set_last_buffer (basesink, NULL);
|
gst_base_sink_set_last_buffer (basesink, NULL);
|
||||||
|
|
|
@ -213,10 +213,10 @@ gboolean gst_base_sink_is_async_enabled (GstBaseSink *sink);
|
||||||
void gst_base_sink_set_ts_offset (GstBaseSink *sink, GstClockTimeDiff offset);
|
void gst_base_sink_set_ts_offset (GstBaseSink *sink, GstClockTimeDiff offset);
|
||||||
GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink);
|
GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink);
|
||||||
|
|
||||||
/* last buffer */
|
/* last sample */
|
||||||
GstBuffer * gst_base_sink_get_last_buffer (GstBaseSink *sink);
|
GstSample * gst_base_sink_get_last_sample (GstBaseSink *sink);
|
||||||
void gst_base_sink_set_last_buffer_enabled (GstBaseSink *sink, gboolean enabled);
|
void gst_base_sink_set_last_sample_enabled (GstBaseSink *sink, gboolean enabled);
|
||||||
gboolean gst_base_sink_is_last_buffer_enabled (GstBaseSink *sink);
|
gboolean gst_base_sink_is_last_sample_enabled (GstBaseSink *sink);
|
||||||
|
|
||||||
/* latency */
|
/* latency */
|
||||||
gboolean gst_base_sink_query_latency (GstBaseSink *sink, gboolean *live, gboolean *upstream_live,
|
gboolean gst_base_sink_query_latency (GstBaseSink *sink, gboolean *live, gboolean *upstream_live,
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
#include <gst/base/gstbasesink.h>
|
#include <gst/base/gstbasesink.h>
|
||||||
|
|
||||||
GST_START_TEST (basesink_last_buffer_enabled)
|
GST_START_TEST (basesink_last_sample_enabled)
|
||||||
{
|
{
|
||||||
GstElement *src, *sink, *pipeline;
|
GstElement *src, *sink, *pipeline;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
GstBuffer *last_buffer;
|
GstSample *last_sample;
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
@ -42,7 +42,7 @@ GST_START_TEST (basesink_last_buffer_enabled)
|
||||||
|
|
||||||
bus = gst_element_get_bus (pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
|
|
||||||
/* try with enable-last-buffer set to TRUE */
|
/* try with enable-last-sample set to TRUE */
|
||||||
g_object_set (src, "num-buffers", 1, NULL);
|
g_object_set (src, "num-buffers", 1, NULL);
|
||||||
fail_unless (gst_element_set_state (pipeline, GST_STATE_PLAYING)
|
fail_unless (gst_element_set_state (pipeline, GST_STATE_PLAYING)
|
||||||
!= GST_STATE_CHANGE_FAILURE);
|
!= GST_STATE_CHANGE_FAILURE);
|
||||||
|
@ -52,19 +52,19 @@ GST_START_TEST (basesink_last_buffer_enabled)
|
||||||
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
|
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
|
||||||
gst_message_unref (msg);
|
gst_message_unref (msg);
|
||||||
|
|
||||||
/* last-buffer should be != NULL */
|
/* last-sample should be != NULL */
|
||||||
fail_unless (gst_base_sink_is_last_buffer_enabled (GST_BASE_SINK (sink))
|
fail_unless (gst_base_sink_is_last_sample_enabled (GST_BASE_SINK (sink))
|
||||||
== TRUE);
|
== TRUE);
|
||||||
g_object_get (sink, "last-buffer", &last_buffer, NULL);
|
g_object_get (sink, "last-sample", &last_sample, NULL);
|
||||||
fail_unless (last_buffer != NULL);
|
fail_unless (last_sample != NULL);
|
||||||
gst_buffer_unref (last_buffer);
|
gst_sample_unref (last_sample);
|
||||||
|
|
||||||
/* set enable-last-buffer to FALSE now, this should set last-buffer to NULL */
|
/* set enable-last-sample to FALSE now, this should set last-sample to NULL */
|
||||||
g_object_set (sink, "enable-last-buffer", FALSE, NULL);
|
g_object_set (sink, "enable-last-sample", FALSE, NULL);
|
||||||
fail_unless (gst_base_sink_is_last_buffer_enabled (GST_BASE_SINK (sink))
|
fail_unless (gst_base_sink_is_last_sample_enabled (GST_BASE_SINK (sink))
|
||||||
== FALSE);
|
== FALSE);
|
||||||
g_object_get (sink, "last-buffer", &last_buffer, NULL);
|
g_object_get (sink, "last-sample", &last_sample, NULL);
|
||||||
fail_unless (last_buffer == NULL);
|
fail_unless (last_sample == NULL);
|
||||||
|
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
|
@ -76,12 +76,12 @@ GST_START_TEST (basesink_last_buffer_enabled)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (basesink_last_buffer_disabled)
|
GST_START_TEST (basesink_last_sample_disabled)
|
||||||
{
|
{
|
||||||
GstElement *src, *sink, *pipeline;
|
GstElement *src, *sink, *pipeline;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
GstBuffer *last_buffer;
|
GstSample *last_sample;
|
||||||
|
|
||||||
pipeline = gst_pipeline_new ("pipeline");
|
pipeline = gst_pipeline_new ("pipeline");
|
||||||
sink = gst_element_factory_make ("fakesink", "sink");
|
sink = gst_element_factory_make ("fakesink", "sink");
|
||||||
|
@ -93,9 +93,9 @@ GST_START_TEST (basesink_last_buffer_disabled)
|
||||||
|
|
||||||
bus = gst_element_get_bus (pipeline);
|
bus = gst_element_get_bus (pipeline);
|
||||||
|
|
||||||
/* set enable-last-buffer to FALSE */
|
/* set enable-last-sample to FALSE */
|
||||||
g_object_set (src, "num-buffers", 1, NULL);
|
g_object_set (src, "num-buffers", 1, NULL);
|
||||||
gst_base_sink_set_last_buffer_enabled (GST_BASE_SINK (sink), FALSE);
|
gst_base_sink_set_last_sample_enabled (GST_BASE_SINK (sink), FALSE);
|
||||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||||
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
||||||
fail_unless (msg != NULL);
|
fail_unless (msg != NULL);
|
||||||
|
@ -103,9 +103,9 @@ GST_START_TEST (basesink_last_buffer_disabled)
|
||||||
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
|
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
|
||||||
gst_message_unref (msg);
|
gst_message_unref (msg);
|
||||||
|
|
||||||
/* last-buffer should be NULL */
|
/* last-sample should be NULL */
|
||||||
g_object_get (sink, "last-buffer", &last_buffer, NULL);
|
g_object_get (sink, "last-sample", &last_sample, NULL);
|
||||||
fail_unless (last_buffer == NULL);
|
fail_unless (last_sample == NULL);
|
||||||
|
|
||||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ gst_basesrc_suite (void)
|
||||||
TCase *tc = tcase_create ("general");
|
TCase *tc = tcase_create ("general");
|
||||||
|
|
||||||
suite_add_tcase (s, tc);
|
suite_add_tcase (s, tc);
|
||||||
tcase_add_test (tc, basesink_last_buffer_enabled);
|
tcase_add_test (tc, basesink_last_sample_enabled);
|
||||||
tcase_add_test (tc, basesink_last_buffer_disabled);
|
tcase_add_test (tc, basesink_last_sample_disabled);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ EXPORTS
|
||||||
gst_base_parse_set_syncable
|
gst_base_parse_set_syncable
|
||||||
gst_base_sink_do_preroll
|
gst_base_sink_do_preroll
|
||||||
gst_base_sink_get_blocksize
|
gst_base_sink_get_blocksize
|
||||||
gst_base_sink_get_last_buffer
|
gst_base_sink_get_last_sample
|
||||||
gst_base_sink_get_latency
|
gst_base_sink_get_latency
|
||||||
gst_base_sink_get_max_lateness
|
gst_base_sink_get_max_lateness
|
||||||
gst_base_sink_get_render_delay
|
gst_base_sink_get_render_delay
|
||||||
|
@ -43,12 +43,12 @@ EXPORTS
|
||||||
gst_base_sink_get_ts_offset
|
gst_base_sink_get_ts_offset
|
||||||
gst_base_sink_get_type
|
gst_base_sink_get_type
|
||||||
gst_base_sink_is_async_enabled
|
gst_base_sink_is_async_enabled
|
||||||
gst_base_sink_is_last_buffer_enabled
|
gst_base_sink_is_last_sample_enabled
|
||||||
gst_base_sink_is_qos_enabled
|
gst_base_sink_is_qos_enabled
|
||||||
gst_base_sink_query_latency
|
gst_base_sink_query_latency
|
||||||
gst_base_sink_set_async_enabled
|
gst_base_sink_set_async_enabled
|
||||||
gst_base_sink_set_blocksize
|
gst_base_sink_set_blocksize
|
||||||
gst_base_sink_set_last_buffer_enabled
|
gst_base_sink_set_last_sample_enabled
|
||||||
gst_base_sink_set_max_lateness
|
gst_base_sink_set_max_lateness
|
||||||
gst_base_sink_set_qos_enabled
|
gst_base_sink_set_qos_enabled
|
||||||
gst_base_sink_set_render_delay
|
gst_base_sink_set_render_delay
|
||||||
|
|
Loading…
Reference in a new issue