mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
videotestsrc: improve test for backwards playback
Improve test by checking that timestamps are decreasing
This commit is contained in:
parent
c2eb3d4e71
commit
7dfb903cb4
1 changed files with 46 additions and 1 deletions
|
@ -366,6 +366,12 @@ GST_START_TEST (test_rgb_formats)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
struct BackwardsPlaybackData
|
||||||
|
{
|
||||||
|
GstClockTime last_ts;
|
||||||
|
const gchar *error_msg;
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
eos_watch (GstBus * bus, GstMessage * message, GMainLoop * loop)
|
eos_watch (GstBus * bus, GstMessage * message, GMainLoop * loop)
|
||||||
{
|
{
|
||||||
|
@ -375,6 +381,27 @@ eos_watch (GstBus * bus, GstMessage * message, GMainLoop * loop)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstPadProbeReturn
|
||||||
|
backward_check_probe (GstPad * pad, GstPadProbeInfo * info, gpointer udata)
|
||||||
|
{
|
||||||
|
if (info->type & GST_PAD_PROBE_TYPE_BUFFER) {
|
||||||
|
GstBuffer *buf = info->data;
|
||||||
|
struct BackwardsPlaybackData *pdata = udata;
|
||||||
|
|
||||||
|
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (pdata->last_ts) &&
|
||||||
|
pdata->last_ts < GST_BUFFER_TIMESTAMP (buf)) {
|
||||||
|
pdata->error_msg = "Received buffer with increasing timestamp";
|
||||||
|
}
|
||||||
|
pdata->last_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
} else {
|
||||||
|
pdata->error_msg = "Received buffer without timestamp";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return GST_PAD_PROBE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_backward_playback)
|
GST_START_TEST (test_backward_playback)
|
||||||
{
|
{
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
@ -383,8 +410,16 @@ GST_START_TEST (test_backward_playback)
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
guint bus_watch = 0;
|
guint bus_watch = 0;
|
||||||
GstStateChangeReturn ret;
|
GstStateChangeReturn ret;
|
||||||
|
GstElement *src;
|
||||||
|
GstPad *pad;
|
||||||
|
gulong pad_probe;
|
||||||
|
struct BackwardsPlaybackData pdata;
|
||||||
|
|
||||||
bin = gst_parse_launch ("videotestsrc ! fakesink name=sink", &error);
|
pdata.last_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
pdata.error_msg = NULL;
|
||||||
|
|
||||||
|
bin = gst_parse_launch ("videotestsrc name=src ! fakesink name=sink "
|
||||||
|
"sync=true", &error);
|
||||||
|
|
||||||
/* run until we receive EOS */
|
/* run until we receive EOS */
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
@ -400,6 +435,11 @@ GST_START_TEST (test_backward_playback)
|
||||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline");
|
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src = gst_bin_get_by_name (GST_BIN (bin), "src");
|
||||||
|
pad = gst_element_get_static_pad (src, "src");
|
||||||
|
pad_probe = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER,
|
||||||
|
(GstPadProbeCallback) backward_check_probe, &pdata, NULL);
|
||||||
|
|
||||||
gst_element_seek (bin, -1.0, GST_FORMAT_TIME,
|
gst_element_seek (bin, -1.0, GST_FORMAT_TIME,
|
||||||
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
|
GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
|
||||||
0, GST_SEEK_TYPE_SET, 1 * GST_SECOND);
|
0, GST_SEEK_TYPE_SET, 1 * GST_SECOND);
|
||||||
|
@ -419,7 +459,12 @@ GST_START_TEST (test_backward_playback)
|
||||||
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
|
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pdata.error_msg)
|
||||||
|
fail ("%s", pdata.error_msg);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
gst_pad_remove_probe (pad, pad_probe);
|
||||||
|
gst_object_unref (pad);
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
g_source_remove (bus_watch);
|
g_source_remove (bus_watch);
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
|
|
Loading…
Reference in a new issue