tests: update for query API changes

This commit is contained in:
Tim-Philipp Müller 2011-07-27 00:28:50 +01:00
parent 99742dc57e
commit 6248fefaa5
4 changed files with 29 additions and 64 deletions

View file

@ -603,7 +603,6 @@ GST_START_TEST (test_position)
GstPad *sinkpad;
GstStateChangeReturn ret;
gboolean qret;
GstFormat qformat;
gint64 qcur;
GstBuffer *buffer;
GstFlowReturn fret;
@ -627,16 +626,14 @@ GST_START_TEST (test_position)
fail_if (sinkpad == NULL);
/* do position query, this should fail, we have nothing received yet */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
ret = gst_element_set_state (pipeline, GST_STATE_READY);
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
/* do position query, this should fail, we have nothing received yet */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
/* make pipeline and element ready to accept data */
@ -644,8 +641,7 @@ GST_START_TEST (test_position)
fail_unless (ret == GST_STATE_CHANGE_ASYNC);
/* do position query, this should fail, we have nothing received yet */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
/* send segment, this should work */
@ -665,8 +661,7 @@ GST_START_TEST (test_position)
/* FIXME, do position query, this should succeed with the time value from the
* segment. */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 1 * GST_SECOND);
@ -686,8 +681,7 @@ GST_START_TEST (test_position)
/* do position query, this should succeed with the time value from the
* segment. */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 1 * GST_SECOND);
@ -706,8 +700,7 @@ GST_START_TEST (test_position)
/* do position query, this should succeed with the time value from the
* segment before the flush. */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 1 * GST_SECOND);
@ -721,8 +714,7 @@ GST_START_TEST (test_position)
}
/* do position query, this should fail, the segment is flushed */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
/* send segment, this should work */
@ -756,8 +748,7 @@ GST_START_TEST (test_position)
/* do position query, this should succeed with the time value from the
* segment. */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 1 * GST_SECOND);
@ -766,8 +757,7 @@ GST_START_TEST (test_position)
/* position now is increasing but never exceeds the boundaries of the segment */
for (i = 0; i < 5; i++) {
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
GST_DEBUG ("position %" GST_TIME_FORMAT, GST_TIME_ARGS (qcur));
fail_unless (qret == TRUE);
fail_unless (qcur >= 1 * GST_SECOND && qcur <= 3 * GST_SECOND);
@ -780,8 +770,7 @@ GST_START_TEST (test_position)
/* after rendering the position must be bigger then the stream_time of the
* buffer */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur >= 2 * GST_SECOND && qcur <= 3 * GST_SECOND);
@ -795,8 +784,7 @@ GST_START_TEST (test_position)
}
/* this should now just report the stream time of the last buffer */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 2 * GST_SECOND);
@ -809,8 +797,7 @@ GST_START_TEST (test_position)
}
/* do position query, this should fail, the segment is flushed */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
/* send segment, this should work */
@ -849,8 +836,7 @@ GST_START_TEST (test_position)
/* do position query, this should succeed with the stream time of the buffer
* against the clock. Since the buffer is synced against the clock, the time
* should be at least the stream time of the buffer. */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur >= 2 * GST_SECOND && qcur <= 3 * GST_SECOND);
@ -858,8 +844,7 @@ GST_START_TEST (test_position)
* against the segment */
g_usleep (2 * G_USEC_PER_SEC);
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur == 3 * GST_SECOND);
@ -871,8 +856,7 @@ GST_START_TEST (test_position)
/* we report the time of the last start of the buffer. This is slightly
* incorrect, we should report the exact time when we paused but there is no
* record of that anywhere */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == TRUE);
fail_unless (qcur >= 4 * GST_SECOND);
@ -880,14 +864,12 @@ GST_START_TEST (test_position)
fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
/* fails again because we are in the wrong state */
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
gst_element_set_state (pipeline, GST_STATE_NULL);
qformat = GST_FORMAT_TIME;
qret = gst_element_query_position (sink, &qformat, &qcur);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &qcur);
fail_unless (qret == FALSE);
gst_object_unref (sinkpad);

View file

@ -65,19 +65,17 @@ cleanup_filesink (GstElement * filesink)
/* this queries via the element vfunc, which is currently not implemented */
#define CHECK_QUERY_POSITION(filesink,format,position) \
G_STMT_START { \
GstFormat fmt = format; \
gint64 pos; \
fail_unless (gst_element_query_position (filesink, &fmt, &pos)); \
fail_unless (gst_element_query_position (filesink, format, &pos)); \
fail_unless_equals_int (pos, position); \
} G_STMT_END
#else
#define CHECK_QUERY_POSITION(filesink,format,position) \
G_STMT_START { \
GstFormat fmt = format; \
GstPad *pad; \
gint64 pos; \
pad = gst_element_get_static_pad (filesink, "sink"); \
fail_unless (gst_pad_query_position (pad, &fmt, &pos)); \
fail_unless (gst_pad_query_position (pad, format, &pos)); \
fail_unless_equals_int (pos, position); \
gst_object_unref (pad); \
} G_STMT_END

View file

@ -1000,15 +1000,13 @@ static GstBusSyncReply
async_done_func (GstBus * bus, GstMessage * msg, GstElement * sink)
{
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) {
GstFormat format;
gint64 position;
GST_DEBUG ("we have ASYNC_DONE now");
fail_unless (have_preroll == TRUE, "no preroll buffer received");
/* get the position now */
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("we have position %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
@ -1052,7 +1050,6 @@ GST_START_TEST (test_async_done)
GstFlowReturn res;
GstBus *bus;
GThread *thread;
GstFormat format;
gint64 position;
gboolean qret;
GstSegment segment;
@ -1085,9 +1082,8 @@ GST_START_TEST (test_async_done)
/* We have not yet received any buffers so we are still in the READY state,
* the position is therefore still not queryable. */
format = GST_FORMAT_TIME;
position = -1;
qret = gst_element_query_position (sink, &format, &position);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &position);
fail_unless (qret == TRUE, "position wrong");
fail_unless (position == 10 * GST_SECOND, "position is wrong");
@ -1111,8 +1107,7 @@ GST_START_TEST (test_async_done)
fail_unless (res == GST_FLOW_OK, "no OK flow return");
/* check if position is still 10 seconds */
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("first buffer position %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
fail_unless (position == 10 * GST_SECOND, "position is wrong");
@ -1130,8 +1125,7 @@ GST_START_TEST (test_async_done)
/* check if position is still 10 seconds. This is racy because the above
* thread might not yet have started the push, because of the above sleep,
* this is very unlikely, though. */
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("second buffer position %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
fail_unless (position == 10 * GST_SECOND, "position is wrong");
@ -1146,8 +1140,7 @@ GST_START_TEST (test_async_done)
GST_DEBUG ("joining thread");
g_thread_join (thread);
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("last buffer position %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
fail_unless (position == 310 * GST_SECOND, "position is wrong");
@ -1166,14 +1159,12 @@ static GstBusSyncReply
async_done_eos_func (GstBus * bus, GstMessage * msg, GstElement * sink)
{
if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ASYNC_DONE) {
GstFormat format;
gint64 position;
GST_DEBUG ("we have ASYNC_DONE now");
/* get the position now */
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("we have position %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
@ -1196,7 +1187,6 @@ GST_START_TEST (test_async_done_eos)
GstPad *sinkpad;
gboolean res;
GstBus *bus;
GstFormat format;
gint64 position;
gboolean qret;
GstSegment segment;
@ -1224,9 +1214,8 @@ GST_START_TEST (test_async_done_eos)
/* We have not yet received any buffers so we are still in the READY state,
* the position is therefore still not queryable. */
format = GST_FORMAT_TIME;
position = -1;
qret = gst_element_query_position (sink, &format, &position);
qret = gst_element_query_position (sink, GST_FORMAT_TIME, &position);
fail_unless (qret == TRUE, "position wrong");
fail_unless (position == 10 * GST_SECOND, "position is wrong");
@ -1239,8 +1228,7 @@ GST_START_TEST (test_async_done_eos)
fail_unless (res == TRUE, "no TRUE return");
/* check if position is still 10 seconds */
format = GST_FORMAT_TIME;
gst_element_query_position (sink, &format, &position);
gst_element_query_position (sink, GST_FORMAT_TIME, &position);
GST_DEBUG ("EOS position %" GST_TIME_FORMAT, GST_TIME_ARGS (position));
fail_unless (position == 10 * GST_SECOND, "position is wrong");

View file

@ -89,7 +89,6 @@ int
main (int argc, char *argv[])
{
GstElement *bin, *videotestsrc, *appsink;
GstFormat format;
gint64 pos;
gst_init (&argc, &argv);
@ -133,8 +132,7 @@ main (int argc, char *argv[])
/* wait for step to really complete */
gst_element_get_state (bin, NULL, NULL, -1);
format = GST_FORMAT_TIME;
gst_element_query_position (bin, &format, &pos);
gst_element_query_position (bin, GST_FORMAT_TIME, &pos);
g_message ("stepped two frames, now at %" GST_TIME_FORMAT,
GST_TIME_ARGS (pos));
@ -150,8 +148,7 @@ main (int argc, char *argv[])
/* wait for step to really complete */
gst_element_get_state (bin, NULL, NULL, -1);
format = GST_FORMAT_TIME;
gst_element_query_position (bin, &format, &pos);
gst_element_query_position (bin, GST_FORMAT_TIME, &pos);
g_message ("stepped 120ms frames, now at %" GST_TIME_FORMAT,
GST_TIME_ARGS (pos));