aboutsummaryrefslogtreecommitdiff
path: root/tests/check/libs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check/libs')
-rw-r--r--tests/check/libs/adapter.c42
-rw-r--r--tests/check/libs/basesink.c4
-rw-r--r--tests/check/libs/basesrc.c4
-rw-r--r--tests/check/libs/bitreader.c4
-rw-r--r--tests/check/libs/bytereader.c4
-rw-r--r--tests/check/libs/bytewriter.c4
-rw-r--r--tests/check/libs/collectpads.c489
-rw-r--r--tests/check/libs/controller.c51
-rw-r--r--tests/check/libs/gstlibscpp.cc4
-rw-r--r--tests/check/libs/gstnetclientclock.c4
-rw-r--r--tests/check/libs/gstnettimeprovider.c4
-rw-r--r--tests/check/libs/gsttestclock.c969
-rw-r--r--tests/check/libs/libsabi.c6
-rw-r--r--tests/check/libs/queuearray.c212
-rw-r--r--tests/check/libs/struct_arm.h64
-rw-r--r--tests/check/libs/test_transform.c18
-rw-r--r--tests/check/libs/transform1.c751
-rw-r--r--tests/check/libs/typefindhelper.c4
18 files changed, 1682 insertions, 956 deletions
diff --git a/tests/check/libs/adapter.c b/tests/check/libs/adapter.c
index e3b801a..df740f9 100644
--- a/tests/check/libs/adapter.c
+++ b/tests/check/libs/adapter.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#include <gst/check/gstcheck.h>
@@ -376,7 +376,7 @@ GST_START_TEST (test_timestamp)
fail_unless (avail == 100);
/* timestamp is now undefined */
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == GST_CLOCK_TIME_NONE);
fail_unless (dist == 0);
@@ -385,7 +385,7 @@ GST_START_TEST (test_timestamp)
fail_unless (avail == 50);
/* still undefined, dist changed, though */
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == GST_CLOCK_TIME_NONE);
fail_unless (dist == 50);
@@ -398,7 +398,7 @@ GST_START_TEST (test_timestamp)
fail_unless (avail == 150);
/* timestamp is still undefined */
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == GST_CLOCK_TIME_NONE);
fail_unless (dist == 50);
@@ -407,7 +407,7 @@ GST_START_TEST (test_timestamp)
avail = gst_adapter_available (adapter);
fail_unless (avail == 100);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 1 * GST_SECOND);
fail_unless (dist == 0);
@@ -416,7 +416,7 @@ GST_START_TEST (test_timestamp)
avail = gst_adapter_available (adapter);
fail_unless (avail == 50);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 1 * GST_SECOND);
fail_unless (dist == 50);
@@ -433,7 +433,7 @@ GST_START_TEST (test_timestamp)
fail_unless (avail == 250);
/* timestamp still as it was before the push */
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 1 * GST_SECOND);
fail_unless (dist == 50);
@@ -441,7 +441,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_flush (adapter, 50);
avail = gst_adapter_available (adapter);
fail_unless (avail == 200);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 1 * GST_SECOND);
fail_unless (dist == 100);
@@ -449,7 +449,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_flush (adapter, 50);
avail = gst_adapter_available (adapter);
fail_unless (avail == 150);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 1 * GST_SECOND);
fail_unless (dist == 150);
@@ -457,7 +457,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_flush (adapter, 50);
avail = gst_adapter_available (adapter);
fail_unless (avail == 100);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 2 * GST_SECOND);
fail_unless (dist == 0);
@@ -465,7 +465,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_flush (adapter, 100);
avail = gst_adapter_available (adapter);
fail_unless (avail == 0);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 2 * GST_SECOND);
fail_unless (dist == 100);
@@ -473,7 +473,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_clear (adapter);
avail = gst_adapter_available (adapter);
fail_unless (avail == 0);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == GST_CLOCK_TIME_NONE);
fail_unless (dist == 0);
@@ -483,7 +483,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_push (adapter, buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 0);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 2 * GST_SECOND);
fail_unless (dist == 0);
@@ -493,7 +493,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_push (adapter, buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 0);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 2 * GST_SECOND);
fail_unless (dist == 0);
@@ -503,14 +503,14 @@ GST_START_TEST (test_timestamp)
gst_adapter_push (adapter, buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 100);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 2 * GST_SECOND);
fail_unless (dist == 0);
gst_adapter_flush (adapter, 1);
avail = gst_adapter_available (adapter);
fail_unless (avail == 99);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 4 * GST_SECOND);
fail_unless (dist == 1);
@@ -520,7 +520,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_push (adapter, buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 99);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 4 * GST_SECOND);
fail_unless (dist == 1);
@@ -529,7 +529,7 @@ GST_START_TEST (test_timestamp)
gst_adapter_push (adapter, buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 199);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 4 * GST_SECOND);
fail_unless (dist == 1);
@@ -540,7 +540,7 @@ GST_START_TEST (test_timestamp)
gst_buffer_unref (buffer);
avail = gst_adapter_available (adapter);
fail_unless (avail == 100);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 5 * GST_SECOND);
fail_unless (dist == 0);
@@ -554,7 +554,7 @@ GST_START_TEST (test_timestamp)
g_free (data);
avail = gst_adapter_available (adapter);
fail_unless (avail == 50);
- timestamp = gst_adapter_prev_timestamp (adapter, &dist);
+ timestamp = gst_adapter_prev_pts (adapter, &dist);
fail_unless (timestamp == 5 * GST_SECOND);
fail_unless (dist == 50);
diff --git a/tests/check/libs/basesink.c b/tests/check/libs/basesink.c
index 595c4ce..2953ce7 100644
--- a/tests/check/libs/basesink.c
+++ b/tests/check/libs/basesink.c
@@ -14,8 +14,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/basesrc.c b/tests/check/libs/basesrc.c
index 21e2481..b9e66d1 100644
--- a/tests/check/libs/basesrc.c
+++ b/tests/check/libs/basesrc.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/bitreader.c b/tests/check/libs/bitreader.c
index 1cdb55d..8910c36 100644
--- a/tests/check/libs/bitreader.c
+++ b/tests/check/libs/bitreader.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/bytereader.c b/tests/check/libs/bytereader.c
index 0aa41c5..ecb3ddb 100644
--- a/tests/check/libs/bytereader.c
+++ b/tests/check/libs/bytereader.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/bytewriter.c b/tests/check/libs/bytewriter.c
index fab4a5e..89999af 100644
--- a/tests/check/libs/bytewriter.c
+++ b/tests/check/libs/bytewriter.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/collectpads.c b/tests/check/libs/collectpads.c
index fea3f67..97d2e65 100644
--- a/tests/check/libs/collectpads.c
+++ b/tests/check/libs/collectpads.c
@@ -17,18 +17,254 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <gst/check/gstcheck.h>
#include <gst/base/gstcollectpads.h>
+/* dummy collectpads based element */
+
+#define GST_TYPE_AGGREGATOR (gst_aggregator_get_type ())
+#define GST_AGGREGATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AGGREGATOR, GstAggregator))
+#define GST_AGGREGATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AGGREGATOR, GstAggregatorClass))
+#define GST_AGGREGATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AGGREGATOR, GstAggregatorClass))
+
+typedef struct _GstAggregator GstAggregator;
+typedef struct _GstAggregatorClass GstAggregatorClass;
+
+struct _GstAggregator
+{
+ GstElement parent;
+ GstCollectPads *collect;
+ GstPad *srcpad;
+ GstPad *sinkpad[2];
+ gint padcount;
+ gboolean first;
+};
+struct _GstAggregatorClass
+{
+ GstElementClass parent_class;
+};
+
+static GType gst_aggregator_get_type (void);
+
+G_DEFINE_TYPE (GstAggregator, gst_aggregator, GST_TYPE_ELEMENT);
+
+static GstStaticPadTemplate gst_aggregator_src_template =
+GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate gst_aggregator_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink_%u", GST_PAD_SINK, GST_PAD_REQUEST,
+ GST_STATIC_CAPS_ANY);
+
+static GstFlowReturn
+gst_agregator_collected (GstCollectPads * pads, gpointer user_data)
+{
+ GstAggregator *aggregator = GST_AGGREGATOR (user_data);
+ GstBuffer *inbuf;
+ GstCollectData *collect_data = (GstCollectData *) pads->data->data;
+ guint outsize = gst_collect_pads_available (pads);
+
+ /* can only happen when no pads to collect or all EOS */
+ if (outsize == 0)
+ goto eos;
+
+ inbuf = gst_collect_pads_take_buffer (pads, collect_data, outsize);
+ if (!inbuf)
+ goto eos;
+
+ if (aggregator->first) {
+ GstSegment segment;
+
+ gst_segment_init (&segment, GST_FORMAT_BYTES);
+ gst_pad_push_event (aggregator->srcpad,
+ gst_event_new_stream_start ("test"));
+ gst_pad_push_event (aggregator->srcpad, gst_event_new_segment (&segment));
+ aggregator->first = FALSE;
+ }
+
+ /* just forward the first buffer */
+ GST_DEBUG_OBJECT (aggregator, "forward buffer %p", inbuf);
+ return gst_pad_push (aggregator->srcpad, inbuf);
+ /* ERRORS */
+eos:
+ {
+ GST_DEBUG_OBJECT (aggregator, "no data available, must be EOS");
+ gst_pad_push_event (aggregator->srcpad, gst_event_new_eos ());
+ return GST_FLOW_EOS;
+ }
+}
+
+static GstPad *
+gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ,
+ const gchar * unused, const GstCaps * caps)
+{
+ GstAggregator *aggregator = GST_AGGREGATOR (element);
+ gchar *name;
+ GstPad *newpad;
+ gint padcount;
+
+ if (templ->direction != GST_PAD_SINK)
+ return NULL;
+
+ /* create new pad */
+ padcount = g_atomic_int_add (&aggregator->padcount, 1);
+ name = g_strdup_printf ("sink_%u", padcount);
+ newpad = gst_pad_new_from_template (templ, name);
+ g_free (name);
+
+ gst_collect_pads_add_pad (aggregator->collect, newpad,
+ sizeof (GstCollectData), NULL, TRUE);
+
+ /* takes ownership of the pad */
+ if (!gst_element_add_pad (GST_ELEMENT (aggregator), newpad))
+ goto could_not_add;
+
+ GST_DEBUG_OBJECT (aggregator, "added new pad %s", GST_OBJECT_NAME (newpad));
+ return newpad;
+
+ /* errors */
+could_not_add:
+ {
+ GST_DEBUG_OBJECT (aggregator, "could not add pad");
+ gst_collect_pads_remove_pad (aggregator->collect, newpad);
+ gst_object_unref (newpad);
+ return NULL;
+ }
+}
+
+static void
+gst_aggregator_release_pad (GstElement * element, GstPad * pad)
+{
+ GstAggregator *aggregator = GST_AGGREGATOR (element);
+
+ if (aggregator->collect)
+ gst_collect_pads_remove_pad (aggregator->collect, pad);
+ gst_element_remove_pad (element, pad);
+}
+
+static GstStateChangeReturn
+gst_aggregator_change_state (GstElement * element, GstStateChange transition)
+{
+ GstAggregator *aggregator = GST_AGGREGATOR (element);
+ GstStateChangeReturn ret;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ gst_collect_pads_start (aggregator->collect);
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
+ break;
+ case GST_STATE_CHANGE_PAUSED_TO_READY:
+ /* need to unblock the collectpads before calling the
+ * parent change_state so that streaming can finish */
+ gst_collect_pads_stop (aggregator->collect);
+ break;
+ default:
+ break;
+ }
+
+ ret =
+ GST_ELEMENT_CLASS (gst_aggregator_parent_class)->change_state (element,
+ transition);
+
+ switch (transition) {
+ default:
+ break;
+ }
+
+ return ret;
+}
+
+static void
+gst_aggregator_dispose (GObject * object)
+{
+ GstAggregator *aggregator = GST_AGGREGATOR (object);
+
+ if (aggregator->collect) {
+ gst_object_unref (aggregator->collect);
+ aggregator->collect = NULL;
+ }
+
+ G_OBJECT_CLASS (gst_aggregator_parent_class)->dispose (object);
+}
+
+static void
+gst_aggregator_class_init (GstAggregatorClass * klass)
+{
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+ GstElementClass *gstelement_class = (GstElementClass *) klass;
+
+ gobject_class->dispose = gst_aggregator_dispose;
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_aggregator_src_template));
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_aggregator_sink_template));
+ gst_element_class_set_static_metadata (gstelement_class, "Aggregator",
+ "Testing", "Combine N buffers", "Stefan Sauer <ensonic@users.sf.net>");
+
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad);
+ gstelement_class->release_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_release_pad);
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_aggregator_change_state);
+}
+
+static void
+gst_aggregator_init (GstAggregator * agregator)
+{
+ GstPadTemplate *template;
+
+ template = gst_static_pad_template_get (&gst_aggregator_src_template);
+ agregator->srcpad = gst_pad_new_from_template (template, "src");
+ gst_object_unref (template);
+
+ GST_PAD_SET_PROXY_CAPS (agregator->srcpad);
+ gst_element_add_pad (GST_ELEMENT (agregator), agregator->srcpad);
+
+ /* keep track of the sinkpads requested */
+ agregator->collect = gst_collect_pads_new ();
+ gst_collect_pads_set_function (agregator->collect,
+ GST_DEBUG_FUNCPTR (gst_agregator_collected), agregator);
+
+ agregator->first = TRUE;
+}
+
+static gboolean
+gst_agregator_plugin_init (GstPlugin * plugin)
+{
+ return gst_element_register (plugin, "aggregator", GST_RANK_NONE,
+ GST_TYPE_AGGREGATOR);
+}
+
+static gboolean
+gst_agregator_plugin_register (void)
+{
+ return gst_plugin_register_static (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "aggregator",
+ "Combine buffers",
+ gst_agregator_plugin_init,
+ VERSION, GST_LICENSE, PACKAGE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
+}
+
+
#define fail_unless_collected(expected) \
G_STMT_START { \
g_mutex_lock (&lock); \
while (expected == TRUE && collected == FALSE) \
- g_cond_wait (&cond,& lock); \
+ g_cond_wait (&cond, &lock); \
fail_unless_equals_int (collected, expected); \
g_mutex_unlock (&lock); \
} G_STMT_END;
@@ -61,6 +297,7 @@ static gboolean collected;
static GstPad *srcpad1, *srcpad2;
static GstPad *sinkpad1, *sinkpad2;
static TestData *data1, *data2;
+static GstBuffer *outbuf1, *outbuf2;
static GMutex lock;
static GCond cond;
@@ -68,6 +305,26 @@ static GCond cond;
static GstFlowReturn
collected_cb (GstCollectPads * pads, gpointer user_data)
{
+ outbuf1 = gst_collect_pads_pop (pads, (GstCollectData *) data1);
+ outbuf2 = gst_collect_pads_pop (pads, (GstCollectData *) data2);
+
+ g_mutex_lock (&lock);
+ collected = TRUE;
+ g_cond_signal (&cond);
+ g_mutex_unlock (&lock);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+handle_buffer_cb (GstCollectPads * pads, GstCollectData * data,
+ GstBuffer * buf, gpointer user_data)
+{
+ GST_DEBUG ("collected buffers via callback");
+
+ outbuf1 = gst_collect_pads_pop (pads, (GstCollectData *) data1);
+ outbuf2 = gst_collect_pads_pop (pads, (GstCollectData *) data2);
+
g_mutex_lock (&lock);
collected = TRUE;
g_cond_signal (&cond);
@@ -82,6 +339,7 @@ push_buffer (gpointer user_data)
GstFlowReturn flow;
GstCaps *caps;
TestData *test_data = (TestData *) user_data;
+ GstSegment segment;
gst_pad_push_event (test_data->pad, gst_event_new_stream_start ("test"));
@@ -89,6 +347,9 @@ push_buffer (gpointer user_data)
gst_pad_push_event (test_data->pad, gst_event_new_caps (caps));
gst_caps_unref (caps);
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ gst_pad_push_event (test_data->pad, gst_event_new_segment (&segment));
+
flow = gst_pad_push (test_data->pad, test_data->buffer);
fail_unless (flow == GST_FLOW_OK, "got flow %s instead of OK",
gst_flow_get_name (flow));
@@ -107,10 +368,9 @@ push_event (gpointer user_data)
}
static void
-setup (void)
+setup_default (void)
{
collect = gst_collect_pads_new ();
- gst_collect_pads_set_function (collect, collected_cb, NULL);
srcpad1 = gst_pad_new_from_static_template (&srctemplate, "src1");
srcpad2 = gst_pad_new_from_static_template (&srctemplate, "src2");
@@ -126,10 +386,26 @@ setup (void)
data1 = NULL;
data2 = NULL;
+ outbuf1 = NULL;
+ outbuf2 = NULL;
collected = FALSE;
}
static void
+setup (void)
+{
+ setup_default ();
+ gst_collect_pads_set_function (collect, collected_cb, NULL);
+}
+
+static void
+setup_buffer_cb (void)
+{
+ setup_default ();
+ gst_collect_pads_set_buffer_function (collect, handle_buffer_cb, NULL);
+}
+
+static void
teardown (void)
{
gst_object_unref (sinkpad1);
@@ -154,7 +430,7 @@ GST_END_TEST;
GST_START_TEST (test_collect)
{
- GstBuffer *buf1, *buf2, *tmp;
+ GstBuffer *buf1, *buf2;
GThread *thread1, *thread2;
data1 = (TestData *) gst_collect_pads_add_pad (collect,
@@ -185,10 +461,8 @@ GST_START_TEST (test_collect)
/* now both pads have a buffer */
fail_unless_collected (TRUE);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
- fail_unless (tmp == buf1);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
- fail_unless (tmp == buf2);
+ fail_unless (outbuf1 == buf1);
+ fail_unless (outbuf2 == buf2);
/* these will return immediately as at this point the threads have been
* unlocked and are finished */
@@ -203,9 +477,10 @@ GST_START_TEST (test_collect)
GST_END_TEST;
+
GST_START_TEST (test_collect_eos)
{
- GstBuffer *buf1, *tmp;
+ GstBuffer *buf1;
GThread *thread1, *thread2;
data1 = (TestData *) gst_collect_pads_add_pad (collect,
@@ -234,11 +509,9 @@ GST_START_TEST (test_collect_eos)
/* now sinkpad1 has a buffer and sinkpad2 has EOS */
fail_unless_collected (TRUE);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
- fail_unless (tmp == buf1);
+ fail_unless (outbuf1 == buf1);
/* sinkpad2 has EOS so a NULL buffer is returned */
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
- fail_unless (tmp == NULL);
+ fail_unless (outbuf2 == NULL);
/* these will return immediately as when the data is popped the threads are
* unlocked and will terminate */
@@ -254,7 +527,7 @@ GST_END_TEST;
GST_START_TEST (test_collect_twice)
{
- GstBuffer *buf1, *buf2, *tmp;
+ GstBuffer *buf1, *buf2;
GThread *thread1, *thread2;
data1 = (TestData *) gst_collect_pads_add_pad (collect,
@@ -287,11 +560,9 @@ GST_START_TEST (test_collect_twice)
/* one of the pads has a buffer, the other has EOS */
fail_unless_collected (TRUE);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
- fail_unless (tmp == buf1);
+ fail_unless (outbuf1 == buf1);
/* there's nothing to pop from the one which received EOS */
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
- fail_unless (tmp == NULL);
+ fail_unless (outbuf2 == NULL);
/* these will return immediately as at this point the threads have been
* unlocked and are finished */
@@ -326,10 +597,65 @@ GST_START_TEST (test_collect_twice)
/* now both pads have a buffer */
fail_unless_collected (TRUE);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data1);
- fail_unless (tmp == buf1);
- tmp = gst_collect_pads_pop (collect, (GstCollectData *) data2);
- fail_unless (tmp == buf2);
+ fail_unless (outbuf1 == buf1);
+ fail_unless (outbuf2 == buf2);
+
+ /* these will return immediately as at this point the threads have been
+ * unlocked and are finished */
+ g_thread_join (thread1);
+ g_thread_join (thread2);
+
+ gst_collect_pads_stop (collect);
+
+ gst_buffer_unref (buf1);
+ gst_buffer_unref (buf2);
+
+}
+
+GST_END_TEST;
+
+
+/* Test the default collected buffer func */
+GST_START_TEST (test_collect_default)
+{
+ GstBuffer *buf1, *buf2;
+ GThread *thread1, *thread2;
+
+ data1 = (TestData *) gst_collect_pads_add_pad (collect,
+ sinkpad1, sizeof (TestData), NULL, TRUE);
+ fail_unless (data1 != NULL);
+
+ data2 = (TestData *) gst_collect_pads_add_pad (collect,
+ sinkpad2, sizeof (TestData), NULL, TRUE);
+ fail_unless (data2 != NULL);
+
+ buf1 = gst_buffer_new ();
+ GST_BUFFER_TIMESTAMP (buf1) = 0;
+ buf2 = gst_buffer_new ();
+ GST_BUFFER_TIMESTAMP (buf2) = GST_SECOND;
+
+ /* start collect pads */
+ gst_collect_pads_start (collect);
+
+ /* push buffers on the pads */
+ data1->pad = srcpad1;
+ data1->buffer = buf1;
+ thread1 = g_thread_try_new ("gst-check", push_buffer, data1, NULL);
+ /* here thread1 is blocked and srcpad1 has a queued buffer */
+ fail_unless_collected (FALSE);
+
+ data2->pad = srcpad2;
+ data2->buffer = buf2;
+ thread2 = g_thread_try_new ("gst-check", push_buffer, data2, NULL);
+
+ /* now both pads have a buffer */
+ fail_unless_collected (TRUE);
+
+ /* The default callback should have popped the buffer with lower timestamp,
+ * and this should therefore be NULL: */
+ fail_unless (outbuf1 == NULL);
+ /* While this one should still be pending: */
+ fail_unless (outbuf2 == buf2);
/* these will return immediately as at this point the threads have been
* unlocked and are finished */
@@ -340,16 +666,119 @@ GST_START_TEST (test_collect_twice)
gst_buffer_unref (buf1);
gst_buffer_unref (buf2);
+}
+
+GST_END_TEST;
+
+
+#define NUM_BUFFERS 3
+static void
+handoff (GstElement * fakesink, GstBuffer * buf, GstPad * pad, guint * count)
+{
+ *count = *count + 1;
+}
+
+/* Test a linear pipeline using aggregator */
+GST_START_TEST (test_linear_pipeline)
+{
+ GstElement *pipeline, *src, *agg, *sink;
+ GstBus *bus;
+ GstMessage *msg;
+ gint count = 0;
+
+ pipeline = gst_pipeline_new ("pipeline");
+ src = gst_check_setup_element ("fakesrc");
+ g_object_set (src, "num-buffers", NUM_BUFFERS, "sizetype", 2, "sizemax", 4,
+ NULL);
+ agg = gst_check_setup_element ("aggregator");
+ sink = gst_check_setup_element ("fakesink");
+ g_object_set (sink, "signal-handoffs", TRUE, NULL);
+ g_signal_connect (sink, "handoff", (GCallback) handoff, &count);
+
+ fail_unless (gst_bin_add (GST_BIN (pipeline), src));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), agg));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), sink));
+ fail_unless (gst_element_link (src, agg));
+ fail_unless (gst_element_link (agg, sink));
+
+ bus = gst_element_get_bus (pipeline);
+ fail_if (bus == NULL);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
+ fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
+ gst_message_unref (msg);
+
+ fail_unless_equals_int (count, NUM_BUFFERS);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (bus);
+ gst_object_unref (pipeline);
+}
+GST_END_TEST;
+
+/* Test a linear pipeline using aggregator */
+GST_START_TEST (test_branched_pipeline)
+{
+ GstElement *pipeline, *src, *tee, *queue[2], *agg, *sink;
+ GstBus *bus;
+ GstMessage *msg;
+ gint count = 0;
+
+ pipeline = gst_pipeline_new ("pipeline");
+ src = gst_check_setup_element ("fakesrc");
+ g_object_set (src, "num-buffers", NUM_BUFFERS, "sizetype", 2, "sizemax", 4,
+ NULL);
+ tee = gst_check_setup_element ("tee");
+ queue[0] = gst_check_setup_element ("queue");
+ gst_object_set_name (GST_OBJECT (queue[0]), "queue0");
+ queue[1] = gst_check_setup_element ("queue");
+ gst_object_set_name (GST_OBJECT (queue[1]), "queue1");
+ agg = gst_check_setup_element ("aggregator");
+ sink = gst_check_setup_element ("fakesink");
+ g_object_set (sink, "signal-handoffs", TRUE, NULL);
+ g_signal_connect (sink, "handoff", (GCallback) handoff, &count);
+
+ fail_unless (gst_bin_add (GST_BIN (pipeline), src));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), tee));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), queue[0]));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), queue[1]));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), agg));
+ fail_unless (gst_bin_add (GST_BIN (pipeline), sink));
+ fail_unless (gst_element_link (src, tee));
+ fail_unless (gst_element_link (tee, queue[0]));
+ fail_unless (gst_element_link (tee, queue[1]));
+ fail_unless (gst_element_link (queue[0], agg));
+ fail_unless (gst_element_link (queue[1], agg));
+ fail_unless (gst_element_link (agg, sink));
+
+ bus = gst_element_get_bus (pipeline);
+ fail_if (bus == NULL);
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+
+ msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
+ fail_if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_EOS);
+ gst_message_unref (msg);
+
+ /* we have two branches, but we still only forward buffers from one branch */
+ fail_unless_equals_int (count, NUM_BUFFERS);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (bus);
+ gst_object_unref (pipeline);
}
GST_END_TEST;
+
static Suite *
gst_collect_pads_suite (void)
{
Suite *suite;
- TCase *general;
+ TCase *general, *buffers, *pipeline;
+
+ gst_agregator_plugin_register ();
suite = suite_create ("GstCollectPads");
general = tcase_create ("general");
@@ -360,6 +789,16 @@ gst_collect_pads_suite (void)
tcase_add_test (general, test_collect_eos);
tcase_add_test (general, test_collect_twice);
+ buffers = tcase_create ("buffers");
+ suite_add_tcase (suite, buffers);
+ tcase_add_checked_fixture (buffers, setup_buffer_cb, teardown);
+ tcase_add_test (buffers, test_collect_default);
+
+ pipeline = tcase_create ("pipeline");
+ suite_add_tcase (suite, pipeline);
+ tcase_add_test (pipeline, test_linear_pipeline);
+ tcase_add_test (pipeline, test_branched_pipeline);
+
return suite;
}
diff --git a/tests/check/libs/controller.c b/tests/check/libs/controller.c
index bdb5e36..f385c6b 100644
--- a/tests/check/libs/controller.c
+++ b/tests/check/libs/controller.c
@@ -17,8 +17,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -1371,52 +1371,6 @@ GST_START_TEST (controller_lfo_triangle)
GST_END_TEST;
-/* test lfo control source with nothing set */
-GST_START_TEST (controller_lfo_none)
-{
- GstControlSource *cs;
- GstElement *elem;
-
- elem = gst_element_factory_make ("testobj", NULL);
-
- /* new lfo control source */
- cs = gst_lfo_control_source_new ();
-
- fail_unless (gst_object_add_control_binding (GST_OBJECT (elem),
- gst_direct_control_binding_new (GST_OBJECT (elem), "int", cs)));
-
- /* now pull in values for some timestamps */
- gst_object_sync_values (GST_OBJECT (elem), 0 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 250 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 500 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 750 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1000 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 2000 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1250 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1500 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
- gst_object_sync_values (GST_OBJECT (elem), 1750 * GST_MSECOND);
- fail_unless_equals_int (GST_TEST_OBJ (elem)->val_int, 0);
-
- gst_object_unref (cs);
- gst_object_unref (elem);
-}
-
-GST_END_TEST;
-
/* test timed value handling in trigger mode */
GST_START_TEST (controller_trigger_exact)
{
@@ -1537,7 +1491,6 @@ gst_controller_suite (void)
tcase_add_test (tc, controller_lfo_saw);
tcase_add_test (tc, controller_lfo_rsaw);
tcase_add_test (tc, controller_lfo_triangle);
- tcase_add_test (tc, controller_lfo_none);
tcase_add_test (tc, controller_trigger_exact);
tcase_add_test (tc, controller_trigger_tolerance);
diff --git a/tests/check/libs/gstlibscpp.cc b/tests/check/libs/gstlibscpp.cc
index 0009ec3..f7f89e3 100644
--- a/tests/check/libs/gstlibscpp.cc
+++ b/tests/check/libs/gstlibscpp.cc
@@ -13,8 +13,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
diff --git a/tests/check/libs/gstnetclientclock.c b/tests/check/libs/gstnetclientclock.c
index 72b7af3..117004f 100644
--- a/tests/check/libs/gstnetclientclock.c
+++ b/tests/check/libs/gstnetclientclock.c
@@ -15,8 +15,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#include <gst/check/gstcheck.h>
diff --git a/tests/check/libs/gstnettimeprovider.c b/tests/check/libs/gstnettimeprovider.c
index 49bfee0..3ba2bde 100644
--- a/tests/check/libs/gstnettimeprovider.c
+++ b/tests/check/libs/gstnettimeprovider.c
@@ -15,8 +15,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#include <gst/check/gstcheck.h>
diff --git a/tests/check/libs/gsttestclock.c b/tests/check/libs/gsttestclock.c
new file mode 100644
index 0000000..de59031
--- /dev/null
+++ b/tests/check/libs/gsttestclock.c
@@ -0,0 +1,969 @@
+/*
+ * Unit test for a deterministic clock for Gstreamer unit tests
+ *
+ * Copyright (C) 2008 Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>
+ * Copyright (C) 2012 Sebastian Rasmussen <sebastian.rasmussen@axis.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gst/check/gstcheck.h>
+#include <gst/check/gsttestclock.h>
+
+typedef struct
+{
+ GstTestClock *test_clock;
+ GstClockID id;
+ GstClockTime reference;
+} GtuClockWaitContext;
+
+typedef struct
+{
+ GstClockID clock_id;
+ GstClockTimeDiff jitter;
+} SyncClockWaitContext;
+
+#define assert_pending_id(pending_id, id, type, time) \
+G_STMT_START { \
+ GstClockEntry *entry = GST_CLOCK_ENTRY (pending_id); \
+ g_assert (entry == (id)); \
+ g_assert (GST_CLOCK_ENTRY_TYPE (entry) == (type)); \
+ g_assert_cmpuint (GST_CLOCK_ENTRY_TIME (entry), ==, (time)); \
+} G_STMT_END
+
+#define assert_processed_id(processed_id, id, type, time) \
+G_STMT_START { \
+ GstClockEntry *entry = GST_CLOCK_ENTRY (processed_id); \
+ g_assert (entry == (id)); \
+ g_assert (GST_CLOCK_ENTRY_TYPE (entry) == (type)); \
+ g_assert_cmpuint (GST_CLOCK_ENTRY_STATUS (entry), ==, (time)); \
+} G_STMT_END
+
+static gpointer test_wait_pending_single_shot_id_sync_worker (gpointer data);
+static gpointer test_wait_pending_single_shot_id_async_worker (gpointer data);
+static gpointer test_wait_pending_periodic_id_waiter_thread (gpointer data);
+static gboolean test_async_wait_cb (GstClock * clock, GstClockTime time,
+ GstClockID id, gpointer user_data);
+
+static GtuClockWaitContext *gst_test_util_wait_for_clock_id_begin (GstTestClock
+ * clock, GstClockID id, GstClockTimeDiff * jitter);
+static GstClockReturn gst_test_util_wait_for_clock_id_end (GtuClockWaitContext *
+ wait_ctx);
+static gboolean
+gst_test_util_clock_wait_context_has_completed (GtuClockWaitContext * wait_ctx);
+
+static gpointer
+test_wait_pending_single_shot_id_sync_worker (gpointer data)
+{
+ SyncClockWaitContext *ctx = data;
+
+ gst_clock_id_wait (ctx->clock_id, &ctx->jitter);
+
+ return NULL;
+}
+
+static gpointer
+test_wait_pending_single_shot_id_async_worker (gpointer data)
+{
+ GstClockID clock_id = data;
+
+ g_usleep (G_USEC_PER_SEC / 10);
+ gst_clock_id_wait_async (clock_id, test_async_wait_cb, NULL, NULL);
+
+ return NULL;
+}
+
+static gpointer
+test_wait_pending_periodic_id_waiter_thread (gpointer data)
+{
+ GstClockID clock_id = data;
+ gst_clock_id_wait (clock_id, NULL);
+ return NULL;
+}
+
+static gboolean
+test_async_wait_cb (GstClock * clock,
+ GstClockTime time, GstClockID id, gpointer user_data)
+{
+
+ gboolean *wait_complete = user_data;
+
+ if (wait_complete != NULL)
+ *wait_complete = TRUE;
+
+ return TRUE;
+}
+
+static GtuClockWaitContext *
+gst_test_util_wait_for_clock_id_begin (GstTestClock * test_clock, GstClockID id,
+ GstClockTimeDiff * jitter)
+{
+ GtuClockWaitContext *wait_ctx;
+
+ wait_ctx = g_slice_new (GtuClockWaitContext);
+ wait_ctx->test_clock = gst_object_ref (test_clock);
+ wait_ctx->reference = gst_clock_get_time (GST_CLOCK (wait_ctx->test_clock));
+ wait_ctx->id = gst_clock_id_ref (id);
+
+ if (jitter) {
+ GstClockEntry *entry = GST_CLOCK_ENTRY (wait_ctx->id);
+ GstClockTime requested = GST_CLOCK_ENTRY_TIME (entry);
+ GstClockTime reference = wait_ctx->reference;
+
+ *jitter = GST_CLOCK_DIFF (requested, reference);
+ }
+
+ if (!gst_test_clock_has_id (wait_ctx->test_clock, wait_ctx->id)) {
+ GstClockClass *klass = GST_CLOCK_GET_CLASS (wait_ctx->test_clock);
+ GstClock *clock = GST_CLOCK (wait_ctx->test_clock);
+ g_assert (klass->wait_async (clock, wait_ctx->id) == GST_CLOCK_OK);
+ }
+
+ g_assert (gst_test_clock_has_id (wait_ctx->test_clock, wait_ctx->id));
+ g_assert_cmpint (gst_test_clock_peek_id_count (wait_ctx->test_clock), >, 0);
+
+ return wait_ctx;
+}
+
+static GstClockReturn
+gst_test_util_wait_for_clock_id_end (GtuClockWaitContext * wait_ctx)
+{
+ GstClockReturn status = GST_CLOCK_ERROR;
+ GstClockEntry *entry = GST_CLOCK_ENTRY (wait_ctx->id);
+
+ if (G_UNLIKELY (GST_CLOCK_ENTRY_STATUS (entry) == GST_CLOCK_UNSCHEDULED)) {
+ status = GST_CLOCK_UNSCHEDULED;
+ } else {
+ GstClockTime requested = GST_CLOCK_ENTRY_TIME (entry);
+ GstClockTimeDiff diff;
+
+ g_assert (gst_test_clock_has_id (wait_ctx->test_clock, wait_ctx->id));
+
+ diff = GST_CLOCK_DIFF (requested, wait_ctx->reference);
+
+ if (diff > 0) {
+ status = GST_CLOCK_EARLY;
+ } else {
+ status = GST_CLOCK_OK;
+ }
+
+ g_atomic_int_set (&GST_CLOCK_ENTRY_STATUS (entry), status);
+ }
+
+ if (GST_CLOCK_ENTRY_TYPE (entry) == GST_CLOCK_ENTRY_SINGLE) {
+ GstClockClass *klass = GST_CLOCK_GET_CLASS (wait_ctx->test_clock);
+ GstClock *clock = GST_CLOCK (wait_ctx->test_clock);
+
+ klass->unschedule (clock, wait_ctx->id);
+ g_assert (!gst_test_clock_has_id (wait_ctx->test_clock, wait_ctx->id));
+ } else {
+ GST_CLOCK_ENTRY_TIME (entry) += GST_CLOCK_ENTRY_INTERVAL (entry);
+ g_assert (gst_test_clock_has_id (wait_ctx->test_clock, wait_ctx->id));
+ }
+
+ gst_clock_id_unref (wait_ctx->id);
+ gst_object_unref (wait_ctx->test_clock);
+ g_slice_free (GtuClockWaitContext, wait_ctx);
+
+ return status;
+}
+
+static gboolean
+gst_test_util_clock_wait_context_has_completed (GtuClockWaitContext * wait_ctx)
+{
+ GstClock *clock = GST_CLOCK (wait_ctx->test_clock);
+ GstClockEntry *entry = GST_CLOCK_ENTRY (wait_ctx->id);
+ GstClockTime requested = GST_CLOCK_ENTRY_TIME (entry);
+ GstClockTime now = gst_clock_get_time (clock);
+
+ return requested < now;
+}
+
+GST_START_TEST (test_object_flags)
+{
+ GstClock *clock = gst_test_clock_new ();
+ g_assert (GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC));
+ g_assert (GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC));
+ g_assert (GST_OBJECT_FLAG_IS_SET (clock,
+ GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC));
+ g_assert (GST_OBJECT_FLAG_IS_SET (clock,
+ GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC));
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_resolution_query)
+{
+ GstClock *clock = gst_test_clock_new ();
+ g_assert_cmpuint (gst_clock_get_resolution (clock), ==, 1);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_start_time)
+{
+ GstClock *clock;
+ guint64 start_time;
+
+ clock = gst_test_clock_new ();
+ g_assert_cmpuint (gst_clock_get_time (clock), ==, 0);
+ g_object_get (clock, "start-time", &start_time, NULL);
+ g_assert_cmpuint (start_time, ==, 0);
+ gst_object_unref (clock);
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ g_assert_cmpuint (gst_clock_get_time (clock), ==, GST_SECOND);
+ g_object_get (clock, "start-time", &start_time, NULL);
+ g_assert_cmpuint (start_time, ==, GST_SECOND);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_set_time)
+{
+ GstClock *clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ gst_test_clock_set_time (GST_TEST_CLOCK (clock), GST_SECOND);
+ g_assert_cmpuint (gst_clock_get_time (clock), ==, GST_SECOND);
+ gst_test_clock_set_time (GST_TEST_CLOCK (clock), GST_SECOND + 1);
+ g_assert_cmpuint (gst_clock_get_time (clock), ==, GST_SECOND + 1);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_advance_time)
+{
+ GstClock *clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 0);
+ g_assert_cmpuint (gst_clock_get_time (clock), ==, GST_SECOND);
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 42 * GST_MSECOND);
+ g_assert_cmpuint (gst_clock_get_time (clock), ==,
+ GST_SECOND + (42 * GST_MSECOND));
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_wait_synchronous_no_timeout)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GThread *worker_thread;
+ GstClockID pending_id;
+ GstClockID processed_id;
+ SyncClockWaitContext context;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND - 1);
+ context.clock_id = gst_clock_id_ref (clock_id);
+ context.jitter = 0;
+ worker_thread =
+ g_thread_new ("worker_thread",
+ test_wait_pending_single_shot_id_sync_worker, &context);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_SECOND - 1);
+ gst_clock_id_unref (pending_id);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_EARLY);
+ gst_clock_id_unref (processed_id);
+ g_thread_join (worker_thread);
+ g_assert_cmpuint (context.jitter, ==, 1);
+ gst_clock_id_unref (context.clock_id);
+ gst_clock_id_unref (clock_id);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
+ context.clock_id = gst_clock_id_ref (clock_id);
+ context.jitter = 0;
+ worker_thread =
+ g_thread_new ("worker_thread",
+ test_wait_pending_single_shot_id_sync_worker, &context);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_SINGLE, GST_SECOND);
+ gst_clock_id_unref (pending_id);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ g_thread_join (worker_thread);
+ g_assert_cmpuint (context.jitter, ==, 0);
+ gst_clock_id_unref (context.clock_id);
+ gst_clock_id_unref (clock_id);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND + 1);
+ context.clock_id = gst_clock_id_ref (clock_id);
+ context.jitter = 0;
+ worker_thread =
+ g_thread_new ("worker_thread",
+ test_wait_pending_single_shot_id_sync_worker, &context);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_SECOND + 1);
+ gst_clock_id_unref (pending_id);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ g_assert (processed_id == NULL);
+ gst_test_clock_advance_time (test_clock, 1);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ g_thread_join (worker_thread);
+ g_assert_cmpuint (context.jitter, ==, -1);
+ gst_clock_id_unref (context.clock_id);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_wait_pending_single_shot_id)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+ GThread *worker_thread;
+ GstClockID pending_id;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
+ gst_clock_id_wait_async (clock_id, test_async_wait_cb, NULL, NULL);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_SINGLE, GST_SECOND);
+ gst_clock_id_unref (pending_id);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ gst_clock_id_unref (clock_id);
+
+ clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ worker_thread =
+ g_thread_new ("worker_thread",
+ test_wait_pending_single_shot_id_async_worker, clock_id);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ 2 * GST_SECOND);
+ gst_clock_id_unref (pending_id);
+ g_thread_join (worker_thread);
+ gst_clock_id_unref (clock_id);
+
+ clock_id = gst_clock_new_single_shot_id (clock, 3 * GST_SECOND);
+ worker_thread =
+ g_thread_new ("worker_thread",
+ test_wait_pending_single_shot_id_async_worker, clock_id);
+ gst_test_clock_wait_for_next_pending_id (test_clock, NULL);
+ g_thread_join (worker_thread);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_wait_pending_periodic_id)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+ clock_id = gst_clock_new_periodic_id (clock, GST_SECOND, GST_MSECOND);
+
+ {
+ GThread *waiter_thread;
+
+ waiter_thread =
+ g_thread_new ("waiter_thread",
+ test_wait_pending_periodic_id_waiter_thread, clock_id);
+
+ gst_test_clock_wait_for_next_pending_id (test_clock, NULL);
+ gst_test_clock_set_time (test_clock, GST_SECOND);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_PERIODIC,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+
+ g_thread_join (waiter_thread);
+ }
+
+ {
+ guint i;
+ GThread *waiter_thread;
+
+ for (i = 0; i < 3; i++) {
+ g_assert (!gst_test_clock_peek_next_pending_id (test_clock, NULL));
+ g_usleep (G_USEC_PER_SEC / 10 / 10);
+ }
+
+ waiter_thread =
+ g_thread_new ("waiter_thread",
+ test_wait_pending_periodic_id_waiter_thread, clock_id);
+
+ gst_test_clock_wait_for_next_pending_id (test_clock, NULL);
+ gst_clock_id_unschedule (clock_id);
+
+ g_thread_join (waiter_thread);
+ }
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_past)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GstClockTimeDiff jitter;
+ GtuClockWaitContext *wait_ctx;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND - 1);
+ wait_ctx =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, &jitter);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx) == GST_CLOCK_EARLY);
+ g_assert_cmpint (jitter, ==, 1);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_present)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GstClockTimeDiff jitter;
+ GtuClockWaitContext *wait_ctx;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
+ wait_ctx =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, &jitter);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx) == GST_CLOCK_OK);
+ g_assert_cmpint (jitter, ==, 0);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_future)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GstClockTimeDiff jitter;
+ GtuClockWaitContext *wait_ctx;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ wait_ctx =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, &jitter);
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx) == GST_CLOCK_OK);
+ g_assert_cmpint (jitter, ==, -GST_SECOND);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_unschedule)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ GtuClockWaitContext *wait_ctx;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
+ gst_clock_id_unschedule (clock_id);
+ gst_clock_id_unref (clock_id);
+
+ clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ wait_ctx = gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, NULL);
+ gst_clock_id_unschedule (clock_id);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx)
+ == GST_CLOCK_UNSCHEDULED);
+ gst_clock_id_unref (clock_id);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_ordering)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id_a, clock_id_b;
+ GtuClockWaitContext *wait_ctx_a, *wait_ctx_b;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id_a = gst_clock_new_single_shot_id (clock, 3 * GST_SECOND);
+ wait_ctx_a =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id_a, NULL);
+
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+
+ clock_id_b = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ wait_ctx_b =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id_b, NULL);
+
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx_b) == GST_CLOCK_OK);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx_a) == GST_CLOCK_OK);
+
+ gst_clock_id_unref (clock_id_b);
+ gst_clock_id_unref (clock_id_a);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_ordering_parallel)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id_a, clock_id_b;
+ GtuClockWaitContext *wait_ctx_a, *wait_ctx_b;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id_a = gst_clock_new_single_shot_id (clock, 3 * GST_SECOND);
+ clock_id_b = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ wait_ctx_a = gst_test_util_wait_for_clock_id_begin (test_clock, clock_id_a,
+ NULL);
+ wait_ctx_b = gst_test_util_wait_for_clock_id_begin (test_clock, clock_id_b,
+ NULL);
+
+ g_assert_cmpuint (gst_test_clock_get_next_entry_time (test_clock), ==,
+ 2 * GST_SECOND);
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx_b) == GST_CLOCK_OK);
+
+ g_assert_cmpuint (gst_test_clock_get_next_entry_time (test_clock), ==,
+ 3 * GST_SECOND);
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+ g_assert (gst_test_util_wait_for_clock_id_end (wait_ctx_a) == GST_CLOCK_OK);
+
+ gst_clock_id_unref (clock_id_b);
+ gst_clock_id_unref (clock_id_a);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_sync_simultaneous_no_timeout)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id_a;
+ GstClockID clock_id_b;
+ SyncClockWaitContext context_a;
+ SyncClockWaitContext context_b;
+ GThread *worker_thread_a;
+ GThread *worker_thread_b;
+ GstClockID processed_id;
+ GstClockID pending_id;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id_a = gst_clock_new_single_shot_id (clock, 5 * GST_SECOND);
+ clock_id_b = gst_clock_new_single_shot_id (clock, 6 * GST_SECOND);
+
+ context_a.clock_id = gst_clock_id_ref (clock_id_a);
+ context_a.jitter = 0;
+ context_b.clock_id = gst_clock_id_ref (clock_id_b);
+ context_b.jitter = 0;
+
+ gst_test_clock_wait_for_pending_id_count (test_clock, 0);
+
+ worker_thread_b =
+ g_thread_new ("worker_thread_b",
+ test_wait_pending_single_shot_id_sync_worker, &context_b);
+
+ gst_test_clock_wait_for_pending_id_count (test_clock, 1);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id_b, GST_CLOCK_ENTRY_SINGLE,
+ 6 * GST_SECOND);
+ gst_clock_id_unref (pending_id);
+
+ worker_thread_a =
+ g_thread_new ("worker_thread_a",
+ test_wait_pending_single_shot_id_sync_worker, &context_a);
+
+ gst_test_clock_wait_for_pending_id_count (test_clock, 2);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id_a, GST_CLOCK_ENTRY_SINGLE,
+ 5 * GST_SECOND);
+ gst_clock_id_unref (pending_id);
+
+ g_assert_cmpuint (gst_test_clock_get_next_entry_time (test_clock), ==,
+ 5 * GST_SECOND);
+ gst_test_clock_advance_time (test_clock, 5 * GST_SECOND);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id_a, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+
+ gst_test_clock_wait_for_pending_id_count (test_clock, 1);
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id_b, GST_CLOCK_ENTRY_SINGLE,
+ 6 * GST_SECOND);
+ gst_clock_id_unref (pending_id);
+
+ g_assert_cmpuint (gst_test_clock_get_next_entry_time (test_clock), ==,
+ 6 * GST_SECOND);
+ gst_test_clock_advance_time (test_clock, 6 * GST_SECOND);
+ processed_id = gst_test_clock_process_next_clock_id (test_clock);
+ assert_processed_id (processed_id, clock_id_b, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+
+ gst_test_clock_wait_for_pending_id_count (test_clock, 0);
+
+ g_thread_join (worker_thread_a);
+ g_thread_join (worker_thread_b);
+
+ g_assert_cmpuint (context_a.jitter, ==, -4 * GST_SECOND);
+ g_assert_cmpuint (context_b.jitter, ==, -5 * GST_SECOND);
+
+ gst_clock_id_unref (context_a.clock_id);
+ gst_clock_id_unref (context_b.clock_id);
+
+ gst_clock_id_unref (clock_id_a);
+ gst_clock_id_unref (clock_id_b);
+
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_async_past)
+{
+ GstClock *clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+ gboolean wait_complete = FALSE;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND - 1);
+ g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
+ &wait_complete, NULL) == GST_CLOCK_OK);
+ g_assert (!wait_complete);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (wait_complete);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_EARLY);
+ gst_clock_id_unref (processed_id);
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_async_present)
+{
+ GstClock *clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+ gboolean wait_complete = FALSE;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ clock_id = gst_clock_new_single_shot_id (clock, GST_SECOND);
+ g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
+ &wait_complete, NULL) == GST_CLOCK_OK);
+ g_assert (!wait_complete);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (wait_complete);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_async_future)
+{
+ GstClock *clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+ gboolean wait_complete = FALSE;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+ clock_id = gst_clock_new_single_shot_id (clock, 2 * GST_SECOND);
+ g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
+ &wait_complete, NULL) == GST_CLOCK_OK);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (processed_id == NULL);
+ g_assert (!wait_complete);
+ g_assert (GST_CLOCK_ENTRY_STATUS (GST_CLOCK_ENTRY (clock_id))
+ == GST_CLOCK_OK);
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), GST_SECOND - 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (processed_id == NULL);
+ g_assert (!wait_complete);
+ g_assert (GST_CLOCK_ENTRY_STATUS (GST_CLOCK_ENTRY (clock_id))
+ == GST_CLOCK_OK);
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (wait_complete);
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_SINGLE,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ g_assert (GST_CLOCK_ENTRY_STATUS (GST_CLOCK_ENTRY (clock_id))
+ == GST_CLOCK_OK);
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_single_shot_async_unschedule)
+{
+ GstClock *clock;
+ GstClockID clock_id;
+ gboolean wait_complete = FALSE;
+
+ clock = gst_test_clock_new_with_start_time (GST_SECOND);
+
+ clock_id = gst_clock_new_single_shot_id (clock, 3 * GST_SECOND);
+ g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
+ &wait_complete, NULL) == GST_CLOCK_OK);
+
+ gst_clock_id_unschedule (clock_id);
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 2 * GST_SECOND);
+ g_assert (gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock))
+ == NULL);
+ g_assert (!wait_complete);
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_periodic_sync)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ guint i;
+ const GstClockTime interval = 4 * GST_MSECOND;
+
+ clock = gst_test_clock_new ();
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_periodic_id (clock, GST_SECOND, interval);
+
+ for (i = 0; i < 3; i++) {
+ GtuClockWaitContext *wait_ctx;
+ GstClockID pending_id;
+ guint j;
+
+ wait_ctx =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, NULL);
+
+ gst_test_clock_wait_for_next_pending_id (test_clock, &pending_id);
+ assert_pending_id (pending_id, clock_id, GST_CLOCK_ENTRY_PERIODIC,
+ GST_SECOND + (i * interval));
+ gst_clock_id_unref (pending_id);
+
+ for (j = 0; j < 10; j++) {
+ g_usleep (G_USEC_PER_SEC / 10 / 10);
+ g_assert (!gst_test_util_clock_wait_context_has_completed (wait_ctx));
+ }
+
+ if (i == 0)
+ gst_test_clock_advance_time (test_clock, GST_SECOND);
+ else
+ gst_test_clock_advance_time (test_clock, interval);
+
+ gst_test_util_wait_for_clock_id_end (wait_ctx);
+ }
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_periodic_async)
+{
+ GstClock *clock;
+ GstClockID clock_id;
+ GstClockID processed_id;
+ gboolean wait_complete = FALSE;
+ const GstClockTime interval = 4 * GST_MSECOND;
+
+ clock = gst_test_clock_new ();
+ clock_id = gst_clock_new_periodic_id (clock, gst_clock_get_time (clock),
+ interval);
+ g_assert (gst_clock_id_wait_async (clock_id, test_async_wait_cb,
+ &wait_complete, NULL) == GST_CLOCK_OK);
+
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_PERIODIC,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+
+ g_assert (wait_complete);
+ wait_complete = FALSE;
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), interval - 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (processed_id == NULL);
+ g_assert (!wait_complete);
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_PERIODIC,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ g_assert (wait_complete);
+ wait_complete = FALSE;
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), interval - 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ g_assert (processed_id == NULL);
+ g_assert (!wait_complete);
+
+ gst_test_clock_advance_time (GST_TEST_CLOCK (clock), 1);
+ processed_id = gst_test_clock_process_next_clock_id (GST_TEST_CLOCK (clock));
+ assert_processed_id (processed_id, clock_id, GST_CLOCK_ENTRY_PERIODIC,
+ GST_CLOCK_OK);
+ gst_clock_id_unref (processed_id);
+ g_assert (wait_complete);
+ wait_complete = FALSE;
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_periodic_uniqueness)
+{
+ GstClock *clock;
+ GstTestClock *test_clock;
+ GstClockID clock_id;
+ guint i;
+ const GstClockTime interval = 4 * GST_MSECOND;
+
+ clock = gst_test_clock_new ();
+ test_clock = GST_TEST_CLOCK (clock);
+
+ clock_id = gst_clock_new_periodic_id (clock, 0, interval);
+
+ for (i = 0; i < 3; i++) {
+ GtuClockWaitContext *wait_ctx;
+ guint j;
+
+ wait_ctx =
+ gst_test_util_wait_for_clock_id_begin (test_clock, clock_id, NULL);
+
+ for (j = 0; j < 10; j++) {
+ g_usleep (G_USEC_PER_SEC / 10 / 10);
+ g_assert_cmpuint (gst_test_clock_peek_id_count (test_clock), ==, 1);
+ }
+
+ gst_test_clock_advance_time (test_clock, interval);
+ gst_test_util_wait_for_clock_id_end (wait_ctx);
+ }
+
+ gst_clock_id_unref (clock_id);
+ gst_object_unref (clock);
+}
+
+GST_END_TEST;
+
+static Suite *
+gst_test_clock_suite (void)
+{
+ Suite *s = suite_create ("GstTestClock");
+ TCase *tc_chain = tcase_create ("testclock");
+
+ suite_add_tcase (s, tc_chain);
+
+ tcase_add_test (tc_chain, test_object_flags);
+ tcase_add_test (tc_chain, test_resolution_query);
+ tcase_add_test (tc_chain, test_start_time);
+ tcase_add_test (tc_chain, test_set_time);
+ tcase_add_test (tc_chain, test_advance_time);
+ tcase_add_test (tc_chain, test_wait_synchronous_no_timeout);
+ tcase_add_test (tc_chain, test_wait_pending_single_shot_id);
+ tcase_add_test (tc_chain, test_wait_pending_periodic_id);
+ tcase_add_test (tc_chain, test_single_shot_sync_simultaneous_no_timeout);
+ tcase_add_test (tc_chain, test_single_shot_sync_past);
+ tcase_add_test (tc_chain, test_single_shot_sync_present);
+ tcase_add_test (tc_chain, test_single_shot_sync_future);
+ tcase_add_test (tc_chain, test_single_shot_sync_unschedule);
+ tcase_add_test (tc_chain, test_single_shot_sync_ordering);
+ tcase_add_test (tc_chain, test_single_shot_sync_ordering_parallel);
+ tcase_add_test (tc_chain, test_single_shot_async_past);
+ tcase_add_test (tc_chain, test_single_shot_async_present);
+ tcase_add_test (tc_chain, test_single_shot_async_future);
+ tcase_add_test (tc_chain, test_single_shot_async_unschedule);
+ tcase_add_test (tc_chain, test_periodic_sync);
+ tcase_add_test (tc_chain, test_periodic_async);
+ tcase_add_test (tc_chain, test_periodic_uniqueness);
+
+ return s;
+}
+
+GST_CHECK_MAIN (gst_test_clock);
diff --git a/tests/check/libs/libsabi.c b/tests/check/libs/libsabi.c
index e24f4fb..42ca40f 100644
--- a/tests/check/libs/libsabi.c
+++ b/tests/check/libs/libsabi.c
@@ -15,8 +15,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#include <config.h>
@@ -70,7 +70,7 @@
#else
#ifdef HAVE_CPU_ARM
#include "struct_arm.h"
-#define HAVE_ABI_SIZES FALSE
+#define HAVE_ABI_SIZES TRUE
#else
/* in case someone wants to generate a new arch */
#include "struct_i386.h"
diff --git a/tests/check/libs/queuearray.c b/tests/check/libs/queuearray.c
index b8fac2b..0141a11 100644
--- a/tests/check/libs/queuearray.c
+++ b/tests/check/libs/queuearray.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -26,8 +26,7 @@
#include <gst/gst.h>
#include <gst/check/gstcheck.h>
-#include "../../../plugins/elements/gstqueuearray.h"
-#include "../../../plugins/elements/gstqueuearray.c"
+#include <gst/base/gstqueuearray.h>
/* Simplest test
* Initial size : 10
@@ -45,7 +44,7 @@ GST_START_TEST (test_array_1)
for (i = 0; i < 5; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
- fail_unless_equals_int (array->length, 5);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 5);
/* pull 5 values out */
for (i = 0; i < 5; i++) {
@@ -53,7 +52,7 @@ GST_START_TEST (test_array_1)
i);
}
- fail_unless_equals_int (array->length, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 0);
gst_queue_array_free (array);
}
@@ -67,31 +66,18 @@ GST_START_TEST (test_array_grow)
/* Create an array of initial size 10 */
array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
/* push 10 values in */
for (i = 0; i < 10; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
- fail_unless_equals_int (array->length, 10);
- /* It did not grow beyond initial size */
- fail_unless_equals_int (array->size, 10);
- /* The head is still at the beginning */
- fail_unless_equals_int (array->head, 0);
- /* The tail wrapped around to the head */
- fail_unless_equals_int (array->tail, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 10);
/* If we add one value, it will grow */
gst_queue_array_push_tail (array, GINT_TO_POINTER (10));
- fail_unless_equals_int (array->length, 11);
- /* It did grow beyond initial size */
- fail_unless_equals_int (array->size, 15);
- /* The head remains the same */
- fail_unless_equals_int (array->head, 0);
- /* The tail was brought to position 11 */
- fail_unless_equals_int (array->tail, 11);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 11);
/* pull the 11 values out */
for (i = 0; i < 11; i++) {
@@ -99,7 +85,7 @@ GST_START_TEST (test_array_grow)
i);
}
- fail_unless_equals_int (array->length, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 0);
gst_queue_array_free (array);
}
@@ -112,23 +98,20 @@ GST_START_TEST (test_array_grow_multiple)
/* Create an array of initial size 10 */
array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
/* push 11 values in */
for (i = 0; i < 11; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
/* With 11 values, it should have grown once (15) */
- fail_unless_equals_int (array->length, 11);
- fail_unless_equals_int (array->size, 15);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 11);
for (i = 11; i < 20; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
/* With 20 total values, it should have grown another time (3 * 15) / 2 = 22) */
- fail_unless_equals_int (array->length, 20);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 20);
/* It did grow beyond initial size */
- fail_unless_equals_int (array->size, 22);
/* pull the 20 values out */
for (i = 0; i < 20; i++) {
@@ -136,7 +119,7 @@ GST_START_TEST (test_array_grow_multiple)
i);
}
- fail_unless_equals_int (array->length, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 0);
gst_queue_array_free (array);
}
@@ -149,7 +132,6 @@ GST_START_TEST (test_array_grow_middle)
/* Create an array of initial size 10 */
array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
/* push/pull 5 values to end up in the middle */
for (i = 0; i < 5; i++) {
@@ -162,15 +144,11 @@ GST_START_TEST (test_array_grow_middle)
for (i = 0; i < 10; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
- fail_unless_equals_int (array->length, 10);
- /* It did not grow beyond initial size */
- fail_unless_equals_int (array->size, 10);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 10);
/* If we add one value, it will grow */
gst_queue_array_push_tail (array, GINT_TO_POINTER (10));
- fail_unless_equals_int (array->length, 11);
- /* It did grow beyond initial size */
- fail_unless_equals_int (array->size, 15);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 11);
/* pull the 11 values out */
for (i = 0; i < 11; i++) {
@@ -178,7 +156,7 @@ GST_START_TEST (test_array_grow_middle)
i);
}
- fail_unless_equals_int (array->length, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 0);
gst_queue_array_free (array);
}
@@ -191,7 +169,6 @@ GST_START_TEST (test_array_grow_end)
/* Create an array of initial size 10 */
array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
/* push/pull 9 values to end up at the last position */
for (i = 0; i < 9; i++) {
@@ -204,15 +181,11 @@ GST_START_TEST (test_array_grow_end)
for (i = 0; i < 10; i++)
gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
- fail_unless_equals_int (array->length, 10);
- /* It did not grow beyond initial size */
- fail_unless_equals_int (array->size, 10);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 10);
/* If we add one value, it will grow */
gst_queue_array_push_tail (array, GINT_TO_POINTER (10));
- fail_unless_equals_int (array->length, 11);
- /* It did grow beyond initial size */
- fail_unless_equals_int (array->size, 15);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 11);
/* pull the 11 values out */
for (i = 0; i < 11; i++) {
@@ -220,7 +193,7 @@ GST_START_TEST (test_array_grow_end)
i);
}
- fail_unless_equals_int (array->length, 0);
+ fail_unless_equals_int (gst_queue_array_get_length (array), 0);
gst_queue_array_free (array);
}
@@ -232,144 +205,6 @@ compare_pointer_value (gconstpointer a, gconstpointer b)
return (int) ((guintptr) a - (guintptr) b);
}
-GST_START_TEST (test_array_find)
-{
- GstQueueArray *array;
- guint i;
- guint index;
-
- guint random_initial = g_random_int_range (10, 100);
- guint value_to_find = 5;
-
- /* Create an array of initial size 10 */
- array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
-
- while (random_initial--) {
- gst_queue_array_push_tail (array, GINT_TO_POINTER (g_random_int ()));
- gst_queue_array_pop_head (array);
- }
-
- /* push 10 values in */
- for (i = 0; i < 10; i++)
- gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
-
- fail_unless_equals_int (array->length, 10);
- fail_unless_equals_int (array->size, 10);
-
- index =
- gst_queue_array_find (array, compare_pointer_value,
- GINT_TO_POINTER (value_to_find));
- fail_if (index == -1);
- fail_unless_equals_int (value_to_find, GPOINTER_TO_INT (array->array[index]));
-
- /* push 10 values in */
- for (i = 0; i < 10; i++)
- gst_queue_array_pop_head (array);
-
- index =
- gst_queue_array_find (array, compare_pointer_value,
- GINT_TO_POINTER (value_to_find));
- fail_unless (index == -1);
-
- gst_queue_array_free (array);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_array_drop)
-{
- GstQueueArray *array;
- guint i;
- guint index;
- guint index_2;
-
- /* Create an array of initial size 10 */
- array = gst_queue_array_new (10);
- fail_unless_equals_int (array->size, 10);
-
- for (i = 0; i < 5; i++)
- gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
-
- fail_unless (array->length == 5);
-
- /* Naive case remove head */
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (0));
- fail_if (index == -1);
- gst_queue_array_drop_element (array, index);
- fail_unless (array->length == 4);
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (0));
- fail_unless (index == -1);
-
- /* Naive case remove tail */
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (4));
- fail_if (index == -1);
- gst_queue_array_drop_element (array, index);
- fail_unless (array->length == 3);
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (4));
- fail_unless (index == -1);
-
- /* Remove in middle of non-wrapped */
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (2));
- index_2 =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (3));
- fail_if (index == -1);
- fail_if (index_2 == -1);
- gst_queue_array_drop_element (array, index);
- fail_unless (array->length == 2);
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (2));
- fail_unless (index == -1);
- index_2 =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (3));
- fail_if (index_2 == -1);
-
- /* Remove the rest */
- while (array->length)
- gst_queue_array_pop_head (array);
-
- /* Add until wrapping */
- for (i = 0; i < 9; i++)
- gst_queue_array_push_tail (array, GINT_TO_POINTER (i));
-
- fail_unless (array->head > array->tail);
-
- /* Remove from between head and array end */
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (1));
- fail_if (index == -1);
- fail_unless (index > array->head);
- index_2 = array->head;
- gst_queue_array_drop_element (array, index);
- fail_unless (array->length == 8);
- fail_if (array->head == index_2);
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (1));
- fail_unless (index == -1);
-
- /* Remove from between head and array end */
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (8));
- fail_if (index == -1);
- fail_unless (index < array->tail);
- index_2 = array->tail;
- gst_queue_array_drop_element (array, index);
- fail_unless (array->length == 7);
- fail_if (array->tail == index_2);
- index =
- gst_queue_array_find (array, compare_pointer_value, GINT_TO_POINTER (8));
- fail_unless (index == -1);
-
- gst_queue_array_free (array);
-}
-
-GST_END_TEST;
-
GST_START_TEST (test_array_drop2)
{
#define NUM_QA_ELEMENTS 674
@@ -390,21 +225,24 @@ GST_START_TEST (test_array_drop2)
for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
count += in_array[j] ? 1 : 0;
- fail_unless_equals_int (array->length, count);
+ fail_unless_equals_int (gst_queue_array_get_length (array), count);
- while (array->length > 0) {
+ while (gst_queue_array_get_length (array) > 0) {
for (i = 0; i < NUM_QA_ELEMENTS; i++) {
+ gpointer dropped;
+
if (g_random_boolean () && g_random_boolean () && in_array[i]) {
idx = gst_queue_array_find (array, compare_pointer_value,
GUINT_TO_POINTER (i));
- gst_queue_array_drop_element (array, idx);
+ dropped = gst_queue_array_drop_element (array, idx);
+ fail_unless_equals_int (i, GPOINTER_TO_INT (dropped));
in_array[i] = FALSE;
}
}
for (j = 0, count = 0; j < NUM_QA_ELEMENTS; j++)
count += in_array[j] ? 1 : 0;
- fail_unless_equals_int (array->length, count);
+ fail_unless_equals_int (gst_queue_array_get_length (array), count);
}
gst_queue_array_free (array);
@@ -425,8 +263,6 @@ gst_queue_array_suite (void)
tcase_add_test (tc_chain, test_array_grow_multiple);
tcase_add_test (tc_chain, test_array_grow_middle);
tcase_add_test (tc_chain, test_array_grow_end);
- tcase_add_test (tc_chain, test_array_find);
- tcase_add_test (tc_chain, test_array_drop);
tcase_add_test (tc_chain, test_array_drop2);
return s;
diff --git a/tests/check/libs/struct_arm.h b/tests/check/libs/struct_arm.h
index 484298e..8c99bf2 100644
--- a/tests/check/libs/struct_arm.h
+++ b/tests/check/libs/struct_arm.h
@@ -1,39 +1,39 @@
GstCheckABIStruct list[] = {
- {"GstBaseParseClass", sizeof (GstBaseParseClass), 728},
- {"GstBaseParse", sizeof (GstBaseParse), 576},
- {"GstBaseSinkClass", sizeof (GstBaseSinkClass), 792},
- {"GstBaseSink", sizeof (GstBaseSink), 664},
- {"GstBaseSrcClass", sizeof (GstBaseSrcClass), 800},
- {"GstBaseSrc", sizeof (GstBaseSrc), 648},
- {"GstBaseTransformClass", sizeof (GstBaseTransformClass), 816},
- {"GstBaseTransform", sizeof (GstBaseTransform), 576},
- {"GstBitReader", sizeof (GstBitReader), 56},
- {"GstByteReader", sizeof (GstByteReader), 48},
- {"GstByteWriter", sizeof (GstByteWriter), 96},
- {"GstCollectData", sizeof (GstCollectData), 200},
- {"GstCollectPadsClass", sizeof (GstCollectPadsClass), 216},
- {"GstCollectPads", sizeof (GstCollectPads), 152},
- {"GstARGBControlBindingClass", sizeof (GstARGBControlBindingClass), 280},
- {"GstARGBControlBinding", sizeof (GstARGBControlBinding), 248},
- {"GstDirectControlBindingClass", sizeof (GstDirectControlBindingClass), 280},
- {"GstDirectControlBinding", sizeof (GstDirectControlBinding), 248},
- {"GstInterpolationControlSourceClass", sizeof (GstInterpolationControlSourceClass), 280},
- {"GstInterpolationControlSource", sizeof (GstInterpolationControlSource), 240},
- {"GstLFOControlSourceClass", sizeof (GstLFOControlSourceClass), 248},
- {"GstLFOControlSource", sizeof (GstLFOControlSource), 184},
+ {"GstBaseParseClass", sizeof (GstBaseParseClass), 368},
+ {"GstBaseParse", sizeof (GstBaseParse), 392},
+ {"GstBaseSinkClass", sizeof (GstBaseSinkClass), 400},
+ {"GstBaseSink", sizeof (GstBaseSink), 464},
+ {"GstBaseSrcClass", sizeof (GstBaseSrcClass), 404},
+ {"GstBaseSrc", sizeof (GstBaseSrc), 448},
+ {"GstBaseTransformClass", sizeof (GstBaseTransformClass), 416},
+ {"GstBaseTransform", sizeof (GstBaseTransform), 392},
+ {"GstBitReader", sizeof (GstBitReader), 32},
+ {"GstByteReader", sizeof (GstByteReader), 28},
+ {"GstByteWriter", sizeof (GstByteWriter), 56},
+ {"GstCollectData", sizeof (GstCollectData), 144},
+ {"GstCollectPadsClass", sizeof (GstCollectPadsClass), 108},
+ {"GstCollectPads", sizeof (GstCollectPads), 104},
+ {"GstARGBControlBindingClass", sizeof (GstARGBControlBindingClass), 140},
+ {"GstARGBControlBinding", sizeof (GstARGBControlBinding), 160},
+ {"GstDirectControlBindingClass", sizeof (GstDirectControlBindingClass), 140},
+ {"GstDirectControlBinding", sizeof (GstDirectControlBinding), 168},
+ {"GstInterpolationControlSourceClass", sizeof (GstInterpolationControlSourceClass), 140},
+ {"GstInterpolationControlSource", sizeof (GstInterpolationControlSource), 152},
+ {"GstLFOControlSourceClass", sizeof (GstLFOControlSourceClass), 124},
+ {"GstLFOControlSource", sizeof (GstLFOControlSource), 120},
{"GstControlPoint", sizeof (GstControlPoint), 32},
- {"GstTimedValueControlSourceClass", sizeof (GstTimedValueControlSourceClass), 248},
- {"GstTimedValueControlSource", sizeof (GstTimedValueControlSource), 200},
- {"GstTriggerControlSourceClass", sizeof (GstTriggerControlSourceClass), 280},
- {"GstTriggerControlSource", sizeof (GstTriggerControlSource), 240},
- {"GstNetClientClockClass", sizeof (GstNetClientClockClass), 328},
- {"GstNetClientClock", sizeof (GstNetClientClock), 208},
+ {"GstTimedValueControlSourceClass", sizeof (GstTimedValueControlSourceClass), 124},
+ {"GstTimedValueControlSource", sizeof (GstTimedValueControlSource), 128},
+ {"GstTriggerControlSourceClass", sizeof (GstTriggerControlSourceClass), 140},
+ {"GstTriggerControlSource", sizeof (GstTriggerControlSource), 152},
+ {"GstNetClientClockClass", sizeof (GstNetClientClockClass), 164},
+ {"GstNetClientClock", sizeof (GstNetClientClock), 136},
{"GstNetTimePacket", sizeof (GstNetTimePacket), 16},
- {"GstNetTimeProviderClass", sizeof (GstNetTimeProviderClass), 216},
- {"GstNetTimeProvider", sizeof (GstNetTimeProvider), 128},
- {"GstPushSrcClass", sizeof (GstPushSrcClass), 856},
- {"GstPushSrc", sizeof (GstPushSrc), 680},
+ {"GstNetTimeProviderClass", sizeof (GstNetTimeProviderClass), 108},
+ {"GstNetTimeProvider", sizeof (GstNetTimeProvider), 88},
+ {"GstPushSrcClass", sizeof (GstPushSrcClass), 432},
+ {"GstPushSrc", sizeof (GstPushSrc), 464},
{"GstTimedValue", sizeof (GstTimedValue), 16},
{NULL, 0, 0}
};
diff --git a/tests/check/libs/test_transform.c b/tests/check/libs/test_transform.c
index 0d10d02..403f701 100644
--- a/tests/check/libs/test_transform.c
+++ b/tests/check/libs/test_transform.c
@@ -183,6 +183,8 @@ gst_test_trans_new (void)
gst_element_set_state (res->trans, GST_STATE_PAUSED);
gst_pad_set_active (res->srcpad, TRUE);
+ gst_pad_push_event (res->srcpad, gst_event_new_stream_start ("test"));
+
return res;
}
@@ -233,3 +235,19 @@ gst_test_trans_pop (TestTransData * data)
}
return ret;
}
+
+static gboolean
+gst_test_trans_setcaps (TestTransData * data, GstCaps * caps)
+{
+ return gst_pad_set_caps (data->srcpad, caps);
+}
+
+static gboolean
+gst_test_trans_push_segment (TestTransData * data)
+{
+ GstSegment segment;
+
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+
+ return gst_pad_push_event (data->srcpad, gst_event_new_segment (&segment));
+}
diff --git a/tests/check/libs/transform1.c b/tests/check/libs/transform1.c
index 8a04a45..f8f32e2 100644
--- a/tests/check/libs/transform1.c
+++ b/tests/check/libs/transform1.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -29,25 +29,6 @@
#include "test_transform.c"
-static gboolean buffer_alloc_pt1_called;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_pt1 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_pt1_called = TRUE;
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, caps);
-
- return GST_FLOW_OK;
-}
-#endif
-
static gboolean set_caps_pt1_called;
static gboolean
@@ -67,78 +48,52 @@ GST_START_TEST (basetransform_chain_pt1)
TestTransData *trans;
GstBuffer *buffer;
GstFlowReturn res;
- //GstCaps *caps;
+ GstCaps *caps;
klass_set_caps = set_caps_pt1;
trans = gst_test_trans_new ();
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer without caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
fail_unless (set_caps_pt1_called == FALSE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- /* caps should not have been set */
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
-#endif
gst_buffer_unref (buffer);
GST_DEBUG_OBJECT (trans, "buffer without caps, size 10");
buffer = gst_buffer_new_and_alloc (10);
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
fail_unless (set_caps_pt1_called == FALSE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 10);
-#if 0
- /* caps should not have been set */
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
caps = gst_caps_new_empty_simple ("foo/x-bar");
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt1_called == FALSE);
- gst_buffer_unref (buffer);
-
- /* once more */
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt1_called == FALSE);
- gst_buffer_unref (buffer);
-
+ gst_test_trans_setcaps (trans, caps);
+ fail_unless (set_caps_pt1_called == TRUE);
gst_caps_unref (caps);
-#endif
+
+ gst_test_trans_push_segment (trans);
gst_test_trans_free (trans);
}
@@ -172,103 +127,66 @@ GST_START_TEST (basetransform_chain_pt2)
trans = gst_test_trans_new ();
/* first buffer */
+ set_caps_pt2_called = FALSE;
caps = gst_caps_new_empty_simple ("foo/x-bar");
+ gst_test_trans_setcaps (trans, caps);
+ gst_test_trans_push_segment (trans);
GST_DEBUG_OBJECT (trans, "buffer with caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
- //fail_unless (set_caps_pt2_called == TRUE);
+ fail_unless (set_caps_pt2_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
-
gst_caps_unref (caps);
/* second buffer, renegotiates, keeps extra type arg in caps */
caps = gst_caps_new_simple ("foo/x-bar", "type", G_TYPE_INT, 1, NULL);
+ set_caps_pt2_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
GST_DEBUG_OBJECT (trans, "buffer with caps, size 10");
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
- //fail_unless (set_caps_pt2_called == TRUE);
+ fail_unless (set_caps_pt2_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 10);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
-
gst_caps_unref (caps);
/* with caps that is a superset */
caps = gst_caps_new_empty_simple ("foo/x-bar");
+ set_caps_pt2_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
-#if 0
- GST_DEBUG_OBJECT (trans, "alloc with superset caps, size 20");
+ GST_DEBUG_OBJECT (trans, "buffer with caps, size 10");
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
+ buffer = gst_buffer_new_and_alloc (10);
+
+ res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
+ fail_unless (set_caps_pt2_called == TRUE);
+
+ buffer = gst_test_trans_pop (trans);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 10);
+
gst_buffer_unref (buffer);
-#endif
gst_caps_unref (caps);
@@ -304,19 +222,18 @@ GST_START_TEST (basetransform_chain_ip1)
klass_transform_ip = transform_ip_1;
trans = gst_test_trans_new ();
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer without caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
transform_ip_1_called = FALSE;
transform_ip_1_writable = TRUE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
fail_unless (transform_ip_1_called == TRUE);
fail_unless (transform_ip_1_writable == TRUE);
- /* FIXME, in-place without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
@@ -333,13 +250,11 @@ GST_START_TEST (basetransform_chain_ip1)
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
fail_unless (transform_ip_1_called == TRUE);
/* copy should have been taken with pad-alloc */
fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (buffer_alloc_pt1_called == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
@@ -354,14 +269,6 @@ GST_START_TEST (basetransform_chain_ip1)
/* with caps buffer */
GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-#if 0
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- gst_buffer_unref (buffer);
-#endif
-
gst_test_trans_free (trans);
}
@@ -402,33 +309,8 @@ GST_START_TEST (basetransform_chain_ip2)
trans = gst_test_trans_new ();
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 20);
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
- gst_buffer_unref (buffer);
-#endif
-
caps = gst_caps_new_empty_simple ("foo/x-bar");
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 20);
- fail_unless (GST_BUFFER_CAPS (buffer) == caps);
- gst_buffer_unref (buffer);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
@@ -437,60 +319,41 @@ GST_START_TEST (basetransform_chain_ip2)
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
set_caps_1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ip_1_called == FALSE);
fail_unless (transform_ip_1_writable == FALSE);
fail_unless (set_caps_1_called == FALSE);
- fail_unless (buffer_alloc_pt1_called == FALSE);
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_1_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer with caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- set_caps_1_called = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ip_1_called == TRUE);
- //fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (set_caps_1_called == TRUE);
- /* FIXME, in-place without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ip_1_called == TRUE);
+ fail_unless (transform_ip_1_writable == TRUE);
+ fail_unless (set_caps_1_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
gst_buffer_unref (buffer);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps extra ref, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
@@ -498,36 +361,20 @@ GST_START_TEST (basetransform_chain_ip2)
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ip_1_called == TRUE);
- //fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ip_1_called == TRUE);
+ fail_unless (transform_ip_1_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
-#endif
gst_caps_unref (caps);
@@ -614,31 +461,6 @@ transform_size_ct1 (GstBaseTransform * trans, GstPadDirection direction,
return TRUE;
}
-gboolean buffer_alloc_ct1_called;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_ct1 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GstCaps *outcaps;
-
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_ct1_called = TRUE;
-
- outcaps = gst_caps_new_empty_simple ("foo/x-bar");
- fail_unless (gst_caps_is_equal (outcaps, caps));
- gst_caps_unref (outcaps);
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, caps);
-
- return GST_FLOW_OK;
-}
-#endif
-
/* basic copy-transform, check if the transform function is called,
* buffer should be writable. we also set a setcaps function and
* see if it's called. */
@@ -659,42 +481,7 @@ GST_START_TEST (basetransform_chain_ct1)
incaps = gst_caps_new_empty_simple ("baz/x-foo");
outcaps = gst_caps_new_empty_simple ("foo/x-bar");
-
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-#endif
-
-#if 0
- /* with wrong (unsupported) caps */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* FIXME, why would this call the alloc function? we try to alloc something
- * with caps that are not supported on the sinkpad */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct1_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
@@ -704,45 +491,38 @@ GST_START_TEST (basetransform_chain_ct1)
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
set_caps_ct1_called = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct1_called == FALSE);
fail_unless (transform_ct1_writable == FALSE);
fail_unless (set_caps_ct1_called == FALSE);
- fail_unless (buffer_alloc_ct1_called == FALSE);
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_ct1_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
- set_caps_ct1_called = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct1_called == TRUE);
- //fail_unless (transform_ct1_writable == TRUE);
- //fail_unless (set_caps_ct1_called == TRUE);
- //fail_unless (buffer_alloc_ct1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct1_called == TRUE);
+ fail_unless (transform_ct1_writable == TRUE);
+ fail_unless (set_caps_ct1_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 40);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 40);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
@@ -752,52 +532,20 @@ GST_START_TEST (basetransform_chain_ct1)
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct1_called == TRUE);
- //fail_unless (transform_ct1_writable == TRUE);
- //fail_unless (buffer_alloc_ct1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct1_called == TRUE);
+ fail_unless (transform_ct1_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 40);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 40);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- /* should not call pad-alloc because the caps and sizes are different, it
- * currently still calls the pad alloc for no reason and then throws away the
- * buffer. */
- fail_unless (buffer_alloc_ct1_called == FALSE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* should not call the pad-alloc function */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-#endif
gst_caps_unref (incaps);
gst_caps_unref (outcaps);
@@ -863,7 +611,10 @@ transform_caps_ct2 (GstBaseTransform * trans, GstPadDirection dir,
if (dir == GST_PAD_SINK) {
/* everything on the sinkpad can be transformed to the output formats */
- res = gst_caps_from_string ("foo/x-bar;baz/x-foo");
+ if (set_caps_ct2_case == 1)
+ res = gst_caps_new_empty_simple ("foo/x-bar");
+ else
+ res = gst_caps_new_empty_simple ("baz/x-foo");
} else {
/* all on the srcpad can be transformed to the format of the sinkpad */
res = gst_caps_new_empty_simple ("foo/x-bar");
@@ -896,54 +647,6 @@ transform_size_ct2 (GstBaseTransform * trans, GstPadDirection direction,
return TRUE;
}
-static gint buffer_alloc_ct2_case;
-static gboolean buffer_alloc_ct2_called;
-static gboolean buffer_alloc_ct2_suggest;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_ct2 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GstCaps *incaps, *outcaps;
-
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_ct2_called = TRUE;
-
- if (buffer_alloc_ct2_case == 1) {
- incaps = gst_caps_new_empty_simple ("foo/x-bar");
- if (buffer_alloc_ct2_suggest) {
- outcaps = gst_caps_new_empty_simple ("baz/x-foo");
- size *= 2;
- } else
- outcaps = gst_caps_ref (incaps);
- } else {
- incaps = gst_caps_new_empty_simple ("baz/x-foo");
- if (buffer_alloc_ct2_suggest) {
- outcaps = gst_caps_new_empty_simple ("foo/x-bar");
- size /= 2;
- } else
- outcaps = gst_caps_ref (incaps);
- }
- GST_DEBUG_OBJECT (pad, "expect %" GST_PTR_FORMAT, incaps);
-
- fail_unless (gst_caps_is_equal (caps, incaps));
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, outcaps);
-
- GST_DEBUG_OBJECT (pad, "return buffer of size %u, caps %" GST_PTR_FORMAT,
- size, outcaps);
-
- gst_caps_unref (outcaps);
- gst_caps_unref (incaps);
-
- return GST_FLOW_OK;
-}
-#endif
-
/* basic copy-transform, check if the transform function is called,
* buffer should be writable. we also set a setcaps function and
* see if it's called. */
@@ -965,43 +668,7 @@ GST_START_TEST (basetransform_chain_ct2)
incaps = gst_caps_new_empty_simple ("foo/x-bar");
outcaps = gst_caps_new_empty_simple ("baz/x-foo");
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
-#if 0
- /* with passthrough caps */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with passthrough caps %"
- GST_PTR_FORMAT, incaps);
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with wrong caps %" GST_PTR_FORMAT,
- outcaps);
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
@@ -1011,47 +678,40 @@ GST_START_TEST (basetransform_chain_ct2)
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct2_called == FALSE);
fail_unless (transform_ct2_writable == FALSE);
fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (buffer_alloc_ct2_called == FALSE);
+
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_ct2_case = 1;
+ set_caps_ct2_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
- buffer_alloc_ct2_case = 1;
- set_caps_ct2_case = 1;
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
- set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (transform_ct2_writable == TRUE);
- //fail_unless (set_caps_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
+ fail_unless (transform_ct2_writable == TRUE);
+ fail_unless (set_caps_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
@@ -1061,51 +721,20 @@ GST_START_TEST (basetransform_chain_ct2)
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (transform_ct2_writable == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
+ fail_unless (transform_ct2_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* should not call the pad-alloc function */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
gst_caps_unref (incaps);
gst_caps_unref (outcaps);
@@ -1135,44 +764,11 @@ GST_START_TEST (basetransform_chain_ct3)
incaps = gst_caps_new_empty_simple ("foo/x-bar");
outcaps = gst_caps_new_empty_simple ("baz/x-foo");
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
/* with passthrough caps */
+ gst_test_trans_push_segment (trans);
GST_DEBUG_OBJECT (trans, "alloc size 20, with passthrough caps %"
GST_PTR_FORMAT, incaps);
-#if 0
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with wrong caps %" GST_PTR_FORMAT,
- outcaps);
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
@@ -1181,45 +777,37 @@ GST_START_TEST (basetransform_chain_ct3)
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct2_called == FALSE);
fail_unless (transform_ct2_writable == FALSE);
fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (buffer_alloc_ct2_called == FALSE);
/* try to push a buffer with caps */
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
- buffer_alloc_ct2_case = 1;
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
set_caps_ct2_case = 1;
- transform_ct2_called = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
+ transform_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == FALSE);
- //fail_unless (set_caps_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == FALSE);
+ fail_unless (set_caps_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
@@ -1228,137 +816,60 @@ GST_START_TEST (basetransform_chain_ct3)
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == FALSE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == FALSE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- /* if we don't push here, basetransform will think it doesn't need do a
- * pad alloc for downstream caps suggestions */
- res = gst_test_trans_push (trans, buffer);
- buffer = gst_test_trans_pop (trans);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* FIXME should not call the pad-alloc function but it currently does */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
/* change the return value of the buffer-alloc function */
GST_DEBUG_OBJECT (trans, "switching transform output");
- buffer_alloc_ct2_suggest = TRUE;
GST_DEBUG_OBJECT (trans,
"buffer with in passthrough with caps %" GST_PTR_FORMAT, incaps);
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* don't suggest anything else */
- buffer_alloc_ct2_case = 1;
set_caps_ct2_case = 2;
+ gst_pad_push_event (trans->sinkpad, gst_event_new_reconfigure ());
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- /* FIXME, pad alloc must be called to get the new caps, because we don't call
- * pad alloc */
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- /* FIXME changing src caps should produce converted buffer */
-#if 0
- GST_DEBUG_OBJECT (trans, "received caps %" GST_PTR_FORMAT,
- GST_BUFFER_CAPS (buffer));
-#endif
- //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
- //fail_unless (gst_buffer_get_size (buffer) == 20);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- set_caps_ct2_case = 0;
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- set_caps_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- /* FIXME a buffer alloc should never set caps */
- fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- /* FIXME, ideally we want to reuse these caps */
- fail_unless (GST_BUFFER_CAPS (buffer) == incaps);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* don't suggest anything else */
- buffer_alloc_ct2_suggest = FALSE;
- buffer_alloc_ct2_case = 0;
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
/* after push, get rid of the final ref we had */
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
- //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
+ gst_buffer_unref (buffer);
gst_caps_unref (incaps);
gst_caps_unref (outcaps);
diff --git a/tests/check/libs/typefindhelper.c b/tests/check/libs/typefindhelper.c
index 346539b..750fc18 100644
--- a/tests/check/libs/typefindhelper.c
+++ b/tests/check/libs/typefindhelper.c
@@ -16,8 +16,8 @@
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H