Commit f85331c0 authored by Andy Wingo's avatar Andy Wingo
Browse files

tests/check/pipelines/: Port to bufferstraw.

Original commit message from CVS:
2006-07-21  Andy Wingo  <wingo@pobox.com>

* tests/check/pipelines/vorbisenc.c:
* tests/check/pipelines/theoraenc.c: Port to bufferstraw.
Bufferstraw was actually factored out of these tests. Now we share
code yay.
parent 5f3f1086
2006-07-21 Andy Wingo <wingo@pobox.com>
* tests/check/pipelines/vorbisenc.c:
* tests/check/pipelines/theoraenc.c: Port to bufferstraw.
Bufferstraw was actually factored out of these tests. Now we share
code yay.
* configure.ac (GST_MAJORMINOR): Rev core requirements to 0.10.9.1
for bufferstraw addition to gstcheck.
2006-07-21 Wim Taymans <wim@fluendo.com>
 
* ext/theora/theoradec.c: (clip_buffer):
......
common @ c22b0a7f
Subproject commit 53ecdc0c97a2992e5abeddd41d514bc142401e5d
Subproject commit c22b0a7fbd8ebcf0a531f2898163d9b834f89ab1
......@@ -52,7 +52,7 @@ dnl AS_LIBTOOL_TAGS
AM_PROG_LIBTOOL
dnl *** required versions of GStreamer stuff ***
GST_REQ=0.10.8.1
GST_REQ=0.10.9.1
dnl *** autotools stuff ****
......
......@@ -21,6 +21,7 @@
*/
#include <gst/check/gstcheck.h>
#include <gst/check/gstbufferstraw.h>
#ifndef GST_DISABLE_PARSE
......@@ -30,104 +31,6 @@
/* I know all of these have a shift of 6 bits */
#define GRANULEPOS_SHIFT 6
static GCond *cond = NULL;
static GMutex *lock = NULL;
static GstBuffer *buf = NULL;
static gulong id;
/* called for every buffer. Waits until the global "buf" variable is unset,
* then sets it to the buffer received, and signals. */
static gboolean
buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused)
{
g_mutex_lock (lock);
while (buf != NULL)
g_cond_wait (cond, lock);
/* increase the refcount because we store it globally for others to use */
buf = gst_buffer_ref (buffer);
g_cond_signal (cond);
g_mutex_unlock (lock);
return TRUE;
}
static void
start_pipeline (GstElement * bin, GstPad * pad)
{
GstStateChangeReturn ret;
id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe), NULL);
cond = g_cond_new ();
lock = g_mutex_new ();
ret = gst_element_set_state (bin, GST_STATE_PLAYING);
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not start test pipeline");
if (ret == GST_STATE_CHANGE_ASYNC) {
ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not start test pipeline");
}
}
/* waits until the probe receives a buffer. will catch every buffer */
static GstBuffer *
get_buffer (GstElement * bin, GstPad * pad)
{
GstBuffer *ret;
g_mutex_lock (lock);
while (buf == NULL)
g_cond_wait (cond, lock);
ret = buf;
buf = NULL;
g_cond_signal (cond);
g_mutex_unlock (lock);
return ret;
}
static void
stop_pipeline (GstElement * bin, GstPad * pad)
{
GstStateChangeReturn ret;
g_mutex_lock (lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
gst_pad_remove_buffer_probe (pad, (guint) id);
id = 0;
g_cond_signal (cond);
g_mutex_unlock (lock);
ret = gst_element_set_state (bin, GST_STATE_NULL);
fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not stop test pipeline");
if (ret == GST_STATE_CHANGE_ASYNC) {
ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
}
g_mutex_lock (lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
g_mutex_unlock (lock);
g_mutex_free (lock);
g_cond_free (cond);
lock = NULL;
cond = NULL;
}
static void
check_buffer_is_header (GstBuffer * buffer, gboolean is_header)
{
......@@ -228,24 +131,24 @@ GST_START_TEST (test_granulepos_offset)
gst_object_unref (sink);
}
start_pipeline (bin, pad);
gst_buffer_straw_start_pipeline (bin, pad);
/* header packets should have timestamp == NONE, granulepos 0, IN_CAPS */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
check_buffer_is_header (buffer, TRUE);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
check_buffer_is_header (buffer, TRUE);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
......@@ -262,7 +165,7 @@ GST_START_TEST (test_granulepos_offset)
* same value due to loss of precision with granulepos. theoraenc does
* take care to timestamp correctly based on the offset of the input data
* however, so it does do sub-granulepos timestamping. */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
check_buffer_timestamp (buffer, TIMESTAMP_OFFSET);
/* don't really have a good way of checking duration... */
......@@ -274,7 +177,7 @@ GST_START_TEST (test_granulepos_offset)
gst_buffer_unref (buffer);
/* check continuity with the next buffer */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, next_timestamp);
check_buffer_duration (buffer,
gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
......@@ -286,7 +189,7 @@ GST_START_TEST (test_granulepos_offset)
gst_buffer_unref (buffer);
}
stop_pipeline (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_object_unref (pad);
gst_object_unref (bin);
......@@ -322,24 +225,24 @@ GST_START_TEST (test_continuity)
gst_object_unref (sink);
}
start_pipeline (bin, pad);
gst_buffer_straw_start_pipeline (bin, pad);
/* header packets should have timestamp == NONE, granulepos 0 */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
check_buffer_is_header (buffer, TRUE);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
check_buffer_is_header (buffer, TRUE);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
......@@ -356,7 +259,7 @@ GST_START_TEST (test_continuity)
* same value due to loss of precision with granulepos. theoraenc does
* take care to timestamp correctly based on the offset of the input data
* however, so it does do sub-granulepos timestamping. */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
check_buffer_timestamp (buffer, 0);
/* plain division because I know the answer is exact */
......@@ -369,7 +272,7 @@ GST_START_TEST (test_continuity)
gst_buffer_unref (buffer);
/* check continuity with the next buffer */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, next_timestamp);
check_buffer_duration (buffer, GST_SECOND / 10);
check_buffer_granulepos (buffer, 1);
......@@ -378,7 +281,7 @@ GST_START_TEST (test_continuity)
gst_buffer_unref (buffer);
}
stop_pipeline (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_object_unref (pad);
gst_object_unref (bin);
......
......@@ -21,92 +21,12 @@
*/
#include <gst/check/gstcheck.h>
#include <gst/check/gstbufferstraw.h>
#ifndef GST_DISABLE_PARSE
#define TIMESTAMP_OFFSET G_GINT64_CONSTANT(3249870963)
static GCond *cond = NULL;
static GMutex *lock = NULL;
static GstBuffer *buf = NULL;
static gulong id;
static gboolean
buffer_probe (GstPad * pad, GstBuffer * buffer, gpointer unused)
{
g_mutex_lock (lock);
while (buf != NULL)
g_cond_wait (cond, lock);
buf = gst_buffer_ref (buffer);
g_cond_signal (cond);
g_mutex_unlock (lock);
return TRUE;
}
static void
start_pipeline (GstElement * bin, GstPad * pad)
{
id = gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe), NULL);
cond = g_cond_new ();
lock = g_mutex_new ();
gst_element_set_state (bin, GST_STATE_PLAYING);
}
static GstBuffer *
get_buffer (GstElement * bin, GstPad * pad)
{
GstBuffer *ret;
g_mutex_lock (lock);
while (buf == NULL)
g_cond_wait (cond, lock);
ret = buf;
buf = NULL;
g_cond_signal (cond);
g_mutex_unlock (lock);
return ret;
}
static void
stop_pipeline (GstElement * bin, GstPad * pad)
{
g_mutex_lock (lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
g_cond_signal (cond);
gst_pad_remove_buffer_probe (pad, (guint) id);
id = 0;
g_mutex_unlock (lock);
gst_element_set_state (bin, GST_STATE_NULL);
g_mutex_lock (lock);
if (buf)
gst_buffer_unref (buf);
buf = NULL;
g_mutex_unlock (lock);
g_mutex_free (lock);
g_cond_free (cond);
lock = NULL;
cond = NULL;
}
static void
check_buffer_timestamp (GstBuffer * buffer, GstClockTime timestamp)
{
......@@ -194,10 +114,10 @@ GST_START_TEST (test_granulepos_offset)
gst_object_unref (sink);
}
start_pipeline (bin, pad);
gst_buffer_straw_start_pipeline (bin, pad);
/* header packets should have timestamp == NONE, granulepos 0 */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
GST_DEBUG ("Got buffer in test");
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
......@@ -205,13 +125,13 @@ GST_START_TEST (test_granulepos_offset)
gst_buffer_unref (buffer);
GST_DEBUG ("Unreffed buffer in test");
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
......@@ -227,7 +147,7 @@ GST_START_TEST (test_granulepos_offset)
* value due to loss of precision with granulepos. vorbisenc does take care
* to timestamp correctly based on the offset of the input data however, so
* it does do sub-granulepos timestamping. */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
check_buffer_timestamp (buffer, TIMESTAMP_OFFSET);
/* don't really have a good way of checking duration... */
......@@ -239,7 +159,7 @@ GST_START_TEST (test_granulepos_offset)
gst_buffer_unref (buffer);
/* check continuity with the next buffer */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, next_timestamp);
check_buffer_duration (buffer,
gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
......@@ -251,7 +171,7 @@ GST_START_TEST (test_granulepos_offset)
gst_buffer_unref (buffer);
}
stop_pipeline (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_object_unref (pad);
gst_object_unref (bin);
......@@ -286,22 +206,22 @@ GST_START_TEST (test_timestamps)
gst_object_unref (sink);
}
start_pipeline (bin, pad);
gst_buffer_straw_start_pipeline (bin, pad);
/* check header packets */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
gst_buffer_unref (buffer);
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, GST_CLOCK_TIME_NONE);
check_buffer_duration (buffer, GST_CLOCK_TIME_NONE);
check_buffer_granulepos (buffer, 0);
......@@ -312,7 +232,7 @@ GST_START_TEST (test_timestamps)
gint64 last_granulepos;
/* first buffer has timestamp 0 */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
last_granulepos = GST_BUFFER_OFFSET_END (buffer);
check_buffer_timestamp (buffer, 0);
/* don't really have a good way of checking duration... */
......@@ -323,7 +243,7 @@ GST_START_TEST (test_timestamps)
gst_buffer_unref (buffer);
/* check continuity with the next buffer */
buffer = get_buffer (bin, pad);
buffer = gst_buffer_straw_get_buffer (bin, pad);
check_buffer_timestamp (buffer, next_timestamp);
check_buffer_duration (buffer,
gst_util_uint64_scale (GST_BUFFER_OFFSET_END (buffer), GST_SECOND,
......@@ -335,7 +255,7 @@ GST_START_TEST (test_timestamps)
gst_buffer_unref (buffer);
}
stop_pipeline (bin, pad);
gst_buffer_straw_stop_pipeline (bin, pad);
gst_object_unref (pad);
gst_object_unref (bin);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment