summaryrefslogtreecommitdiffstats
path: root/tests/check/elements
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check/elements')
-rw-r--r--tests/check/elements/.gitignore3
-rw-r--r--tests/check/elements/kate.c6
-rw-r--r--tests/check/elements/rtpbin.c421
-rw-r--r--tests/check/elements/rtpbin_buffer_list.c331
4 files changed, 7 insertions, 754 deletions
diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore
index df2bb15d..30c67fe8 100644
--- a/tests/check/elements/.gitignore
+++ b/tests/check/elements/.gitignore
@@ -1,6 +1,7 @@
.dirstamp
aacparse
amrparse
+asfmux
camerabin
deinterleave
gdpdepay
@@ -19,8 +20,6 @@ souphttpsrc
rganalysis
rglimiter
rgvolume
-rtpbin
-rtpbin_buffer_list
selector
shapewipe
spectrum
diff --git a/tests/check/elements/kate.c b/tests/check/elements/kate.c
index c848cc5c..9eed574d 100644
--- a/tests/check/elements/kate.c
+++ b/tests/check/elements/kate.c
@@ -447,6 +447,8 @@ GST_START_TEST (test_kate_encode_simple)
GstCaps *caps;
kateenc = setup_kateenc ();
+ g_object_set (kateenc, "category", "subtitles", NULL);
+
fail_unless (gst_element_set_state (kateenc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@@ -498,6 +500,8 @@ GST_START_TEST (test_kate_encode_spu)
GstCaps *caps;
kateenc = setup_kateenc ();
+ g_object_set (kateenc, "category", "spu-subtitles", NULL);
+
fail_unless (gst_element_set_state (kateenc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
@@ -560,6 +564,8 @@ GST_START_TEST (test_kate_encode_keepalives)
for (round = 0; round < 3; ++round) {
kateenc = setup_kateenc ();
+ /* doesn't matter here, since we never send a packet */
+ g_object_set (kateenc, "category", "subtitles", NULL);
fail_unless (gst_element_set_state (kateenc,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
diff --git a/tests/check/elements/rtpbin.c b/tests/check/elements/rtpbin.c
deleted file mode 100644
index 8764da54..00000000
--- a/tests/check/elements/rtpbin.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/* GStreamer
- *
- * unit test for gstrtpbin
- *
- * Copyright (C) <2009> Wim Taymans <wim.taymans@gmail.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>
-
-GST_START_TEST (test_cleanup_send)
-{
- GstElement *rtpbin;
- GstPad *rtp_sink, *rtp_src, *rtcp_src;
- GObject *session;
- gint count = 2;
-
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
-
- while (count--) {
- /* request session 0 */
- rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
- fail_unless (rtp_sink != NULL);
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2);
-
- /* request again */
- rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
- fail_unless (rtp_sink != NULL);
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 3);
- gst_object_unref (rtp_sink);
-
- /* this static pad should be created automatically now */
- rtp_src = gst_element_get_static_pad (rtpbin, "send_rtp_src_0");
- fail_unless (rtp_src != NULL);
- ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 2);
-
- /* we should be able to get an internal session 0 now */
- g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
- fail_unless (session != NULL);
- g_object_unref (session);
-
- /* get the send RTCP pad too */
- rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0");
- fail_unless (rtcp_src != NULL);
- ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 2);
-
- /* second time */
- rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0");
- fail_unless (rtcp_src != NULL);
- ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 3);
- gst_object_unref (rtcp_src);
-
- gst_element_release_request_pad (rtpbin, rtp_sink);
- /* we should only have our refs to the pads now */
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
- ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
- ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 2);
-
- /* the other pad should be gone now */
- fail_unless (gst_element_get_static_pad (rtpbin, "send_rtp_src_0") == NULL);
-
- /* internal session should still be there */
- g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
- fail_unless (session != NULL);
- g_object_unref (session);
-
- /* release the RTCP pad */
- gst_element_release_request_pad (rtpbin, rtcp_src);
- /* we should only have our refs to the pads now */
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
- ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
- ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 1);
-
- /* the session should be gone now */
- g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
- fail_unless (session == NULL);
-
- /* unref the request pad and the static pad */
- gst_object_unref (rtp_sink);
- gst_object_unref (rtp_src);
- gst_object_unref (rtcp_src);
- }
-
- gst_object_unref (rtpbin);
-}
-
-GST_END_TEST;
-
-typedef struct
-{
- guint16 seqnum;
- gboolean pad_added;
- GstPad *pad;
- GMutex *lock;
- GCond *cond;
- GstPad *sinkpad;
- GList *pads;
-} CleanupData;
-
-static void
-init_data (CleanupData * data)
-{
- data->seqnum = 10;
- data->pad_added = FALSE;
- data->lock = g_mutex_new ();
- data->cond = g_cond_new ();
- data->pads = NULL;
-}
-
-static void
-clean_data (CleanupData * data)
-{
- g_list_foreach (data->pads, (GFunc) gst_object_unref, NULL);
- g_list_free (data->pads);
- g_mutex_free (data->lock);
- g_cond_free (data->cond);
-}
-
-static guint8 rtp_packet[] = { 0x80, 0x60, 0x94, 0xbc, 0x8f, 0x37, 0x4e, 0xb8,
- 0x44, 0xa8, 0xf3, 0x7c, 0x06, 0x6a, 0x0c, 0xce,
- 0x13, 0x25, 0x19, 0x69, 0x1f, 0x93, 0x25, 0x9d,
- 0x2b, 0x82, 0x31, 0x3b, 0x36, 0xc1, 0x3c, 0x13
-};
-
-static GstBuffer *
-make_rtp_packet (CleanupData * data)
-{
- static GstCaps *caps = NULL;
- GstBuffer *result;
- guint8 *datap;
-
- if (caps == NULL) {
- caps = gst_caps_from_string ("application/x-rtp,"
- "media=(string)audio, clock-rate=(int)44100, "
- "encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1");
- data->seqnum = 0;
- }
-
- result = gst_buffer_new_and_alloc (sizeof (rtp_packet));
- datap = GST_BUFFER_DATA (result);
- memcpy (datap, rtp_packet, sizeof (rtp_packet));
-
- datap[2] = (data->seqnum >> 8) & 0xff;
- datap[3] = data->seqnum & 0xff;
-
- data->seqnum++;
-
- gst_buffer_set_caps (result, caps);
-
- return result;
-}
-
-static GstFlowReturn
-dummy_chain (GstPad * pad, GstBuffer * buffer)
-{
- gst_buffer_unref (buffer);
-
- return GST_FLOW_OK;
-}
-
-static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-rtp"));
-
-
-static GstPad *
-make_sinkpad (CleanupData * data)
-{
- GstPad *pad;
-
- pad = gst_pad_new_from_static_template (&sink_factory, "sink");
-
- gst_pad_set_chain_function (pad, dummy_chain);
- gst_pad_set_active (pad, TRUE);
-
- data->pads = g_list_prepend (data->pads, pad);
-
- return pad;
-}
-
-static void
-pad_added_cb (GstElement * rtpbin, GstPad * pad, CleanupData * data)
-{
- GstPad *sinkpad;
-
- GST_DEBUG ("pad added %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
- if (GST_PAD_IS_SINK (pad))
- return;
-
- fail_unless (data->pad_added == FALSE);
-
- sinkpad = make_sinkpad (data);
- fail_unless (gst_pad_link (pad, sinkpad) == GST_PAD_LINK_OK);
-
- g_mutex_lock (data->lock);
- data->pad_added = TRUE;
- data->pad = pad;
- g_cond_signal (data->cond);
- g_mutex_unlock (data->lock);
-}
-
-static void
-pad_removed_cb (GstElement * rtpbin, GstPad * pad, CleanupData * data)
-{
- GST_DEBUG ("pad removed %s:%s\n", GST_DEBUG_PAD_NAME (pad));
-
- if (data->pad != pad)
- return;
-
- fail_unless (data->pad_added == TRUE);
-
- g_mutex_lock (data->lock);
- data->pad_added = FALSE;
- g_cond_signal (data->cond);
- g_mutex_unlock (data->lock);
-}
-
-GST_START_TEST (test_cleanup_recv)
-{
- GstElement *rtpbin;
- GstPad *rtp_sink;
- CleanupData data;
- GstStateChangeReturn ret;
- GstFlowReturn res;
- GstBuffer *buffer;
- gint count = 2;
-
- init_data (&data);
-
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
-
- g_signal_connect (rtpbin, "pad-added", (GCallback) pad_added_cb, &data);
- g_signal_connect (rtpbin, "pad-removed", (GCallback) pad_removed_cb, &data);
-
- ret = gst_element_set_state (rtpbin, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
-
- while (count--) {
- /* request session 0 */
- rtp_sink = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0");
- fail_unless (rtp_sink != NULL);
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2);
-
- /* no sourcepads are created yet */
- fail_unless (rtpbin->numsinkpads == 1);
- fail_unless (rtpbin->numsrcpads == 0);
-
- buffer = make_rtp_packet (&data);
- res = gst_pad_chain (rtp_sink, buffer);
- GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res));
- fail_unless (res == GST_FLOW_OK);
-
- buffer = make_rtp_packet (&data);
- res = gst_pad_chain (rtp_sink, buffer);
- GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res));
- fail_unless (res == GST_FLOW_OK);
-
- /* we wait for the new pad to appear now */
- g_mutex_lock (data.lock);
- while (!data.pad_added)
- g_cond_wait (data.cond, data.lock);
- g_mutex_unlock (data.lock);
-
- /* sourcepad created now */
- fail_unless (rtpbin->numsinkpads == 1);
- fail_unless (rtpbin->numsrcpads == 1);
-
- /* remove the session */
- gst_element_release_request_pad (rtpbin, rtp_sink);
- gst_object_unref (rtp_sink);
-
- /* pad should be gone now */
- g_mutex_lock (data.lock);
- while (data.pad_added)
- g_cond_wait (data.cond, data.lock);
- g_mutex_unlock (data.lock);
-
- /* nothing left anymore now */
- fail_unless (rtpbin->numsinkpads == 0);
- fail_unless (rtpbin->numsrcpads == 0);
- }
-
- ret = gst_element_set_state (rtpbin, GST_STATE_NULL);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
-
- gst_object_unref (rtpbin);
-
- clean_data (&data);
-}
-
-GST_END_TEST;
-
-GST_START_TEST (test_cleanup_recv2)
-{
- GstElement *rtpbin;
- GstPad *rtp_sink;
- CleanupData data;
- GstStateChangeReturn ret;
- GstFlowReturn res;
- GstBuffer *buffer;
- gint count = 2;
-
- init_data (&data);
-
- rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
-
- g_signal_connect (rtpbin, "pad-added", (GCallback) pad_added_cb, &data);
- g_signal_connect (rtpbin, "pad-removed", (GCallback) pad_removed_cb, &data);
-
- ret = gst_element_set_state (rtpbin, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
-
- /* request session 0 */
- rtp_sink = gst_element_get_request_pad (rtpbin, "recv_rtp_sink_0");
- fail_unless (rtp_sink != NULL);
- ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2);
-
- while (count--) {
- /* no sourcepads are created yet */
- fail_unless (rtpbin->numsinkpads == 1);
- fail_unless (rtpbin->numsrcpads == 0);
-
- buffer = make_rtp_packet (&data);
- res = gst_pad_chain (rtp_sink, buffer);
- GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res));
- fail_unless (res == GST_FLOW_OK);
-
- buffer = make_rtp_packet (&data);
- res = gst_pad_chain (rtp_sink, buffer);
- GST_DEBUG ("res %d, %s\n", res, gst_flow_get_name (res));
- fail_unless (res == GST_FLOW_OK);
-
- /* we wait for the new pad to appear now */
- g_mutex_lock (data.lock);
- while (!data.pad_added)
- g_cond_wait (data.cond, data.lock);
- g_mutex_unlock (data.lock);
-
- /* sourcepad created now */
- fail_unless (rtpbin->numsinkpads == 1);
- fail_unless (rtpbin->numsrcpads == 1);
-
- /* change state */
- ret = gst_element_set_state (rtpbin, GST_STATE_NULL);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
-
- /* pad should be gone now */
- g_mutex_lock (data.lock);
- while (data.pad_added)
- g_cond_wait (data.cond, data.lock);
- g_mutex_unlock (data.lock);
-
- /* back to playing for the next round */
- ret = gst_element_set_state (rtpbin, GST_STATE_PLAYING);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
- }
-
- /* remove the session */
- gst_element_release_request_pad (rtpbin, rtp_sink);
- gst_object_unref (rtp_sink);
-
- /* nothing left anymore now */
- fail_unless (rtpbin->numsinkpads == 0);
- fail_unless (rtpbin->numsrcpads == 0);
-
- ret = gst_element_set_state (rtpbin, GST_STATE_NULL);
- fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
-
- gst_object_unref (rtpbin);
-
- clean_data (&data);
-}
-
-GST_END_TEST;
-
-Suite *
-gstrtpbin_suite (void)
-{
- Suite *s = suite_create ("gstrtpbin");
- TCase *tc_chain = tcase_create ("general");
-
- suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_cleanup_send);
- tcase_add_test (tc_chain, test_cleanup_recv);
- tcase_add_test (tc_chain, test_cleanup_recv2);
-
- return s;
-}
-
-int
-main (int argc, char **argv)
-{
- int nf;
-
- Suite *s = gstrtpbin_suite ();
- SRunner *sr = srunner_create (s);
-
- gst_check_init (&argc, &argv);
-
- srunner_run_all (sr, CK_NORMAL);
- nf = srunner_ntests_failed (sr);
- srunner_free (sr);
-
- return nf;
-}
diff --git a/tests/check/elements/rtpbin_buffer_list.c b/tests/check/elements/rtpbin_buffer_list.c
deleted file mode 100644
index af4003dd..00000000
--- a/tests/check/elements/rtpbin_buffer_list.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* GStreamer
- *
- * Unit test for gstrtpbin sending rtp packets using GstBufferList.
- * Copyright (C) 2009 Branko Subasic <branko dot subasic at axis dot 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/rtp/gstrtpbuffer.h>
-
-
-
-/* This test makes sure that RTP packets sent as buffer lists are sent through
- * the rtpbin as they are supposed to, and not corrupted in any way.
- */
-
-
-#define TEST_CAPS \
- "application/x-rtp, " \
- "media=(string)video, " \
- "clock-rate=(int)90000, " \
- "encoding-name=(string)H264, " \
- "profile-level-id=(string)4d4015, " \
- "payload=(int)96, " \
- "ssrc=(guint)2633237432, " \
- "clock-base=(guint)1868267015, " \
- "seqnum-base=(guint)54229"
-
-
-/* RTP headers and the first 2 bytes of the payload (FU indicator and FU header)
- */
-static const guint8 rtp_header[2][14] = {
- {0x80, 0x60, 0xbb, 0xb7, 0x5c, 0xe9, 0x09,
- 0x0d, 0xf5, 0x9c, 0x43, 0x55, 0x1c, 0x86},
- {0x80, 0x60, 0xbb, 0xb8, 0x5c, 0xe9, 0x09,
- 0x0d, 0xf5, 0x9c, 0x43, 0x55, 0x1c, 0x46}
-};
-
-static const guint rtp_header_len[] = {
- sizeof rtp_header[0],
- sizeof rtp_header[1]
-};
-
-static GstBuffer *header_buffer[2] = { NULL, NULL };
-
-
-/* Some payload.
- */
-static char *payload =
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF0123456789ABSDEF"
- "0123456789ABSDEF0123456";
-
-static const guint payload_offset[] = {
- 0, 498
-};
-
-static const guint payload_len[] = {
- 498, 5
-};
-
-
-static GstBuffer *original_buffer = NULL;
-
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-rtp"));
-
-static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("application/x-rtp"));
-
-
-static GstBuffer *
-_create_original_buffer (void)
-{
- GstCaps *caps;
-
- if (original_buffer != NULL)
- return original_buffer;
-
- original_buffer = gst_buffer_new ();
- fail_unless (original_buffer != NULL);
-
- gst_buffer_set_data (original_buffer, (guint8 *) payload, strlen (payload));
- GST_BUFFER_TIMESTAMP (original_buffer) =
- gst_clock_get_internal_time (gst_system_clock_obtain ());
-
- caps = gst_caps_from_string (TEST_CAPS);
- fail_unless (caps != NULL);
- gst_buffer_set_caps (original_buffer, caps);
- gst_caps_unref (caps);
-
- return original_buffer;
-}
-
-static GstBufferList *
-_create_buffer_list (void)
-{
- GstBufferList *list;
- GstBufferListIterator *it;
- GstBuffer *orig_buffer;
- GstBuffer *buffer;
-
- orig_buffer = _create_original_buffer ();
- fail_if (orig_buffer == NULL);
-
- list = gst_buffer_list_new ();
- fail_if (list == NULL);
-
- it = gst_buffer_list_iterate (list);
- fail_if (it == NULL);
-
- /*** First group, i.e. first packet. **/
- gst_buffer_list_iterator_add_group (it);
-
- /* Create buffer with RTP header and add it to the 1st group */
- buffer = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (buffer) = g_memdup (&rtp_header[0], rtp_header_len[0]);
- GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer);
- GST_BUFFER_SIZE (buffer) = rtp_header_len[0];
- gst_buffer_copy_metadata (buffer, orig_buffer, GST_BUFFER_COPY_ALL);
- header_buffer[0] = buffer;
- gst_buffer_list_iterator_add (it, buffer);
-
- /* Create the payload buffer and add it to the 1st group
- */
- buffer =
- gst_buffer_create_sub (orig_buffer, payload_offset[0], payload_len[0]);
- fail_if (buffer == NULL);
- gst_buffer_list_iterator_add (it, buffer);
-
-
- /*** Second group, i.e. second packet. ***/
-
- /* Create a new group to hold the rtp header and the payload */
- gst_buffer_list_iterator_add_group (it);
-
- /* Create buffer with RTP header and add it to the 2nd group */
- buffer = gst_buffer_new ();
- GST_BUFFER_MALLOCDATA (buffer) = g_memdup (&rtp_header[1], rtp_header_len[1]);
- GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer);
- GST_BUFFER_SIZE (buffer) = rtp_header_len[1];
- gst_buffer_copy_metadata (buffer, orig_buffer, GST_BUFFER_COPY_ALL);
- header_buffer[1] = buffer;
-
- /* Add the rtp header to the buffer list */
- gst_buffer_list_iterator_add (it, buffer);
-
- /* Create the payload buffer and add it to the 2d group
- */
- buffer =
- gst_buffer_create_sub (orig_buffer, payload_offset[1], payload_len[1]);
- fail_if (buffer == NULL);
- gst_buffer_list_iterator_add (it, buffer);
-
- gst_buffer_list_iterator_free (it);
-
- return list;
-}
-
-
-static void
-_check_header (GstBuffer * buffer, guint index)
-{
- guint8 *data;
-
- fail_if (buffer == NULL);
- fail_unless (index < 2);
-
- fail_unless (GST_BUFFER_SIZE (buffer) == rtp_header_len[index]);
-
- /* Can't do a memcmp() on the whole header, cause the SSRC (bytes 8-11) will
- * most likely be changed in gstrtpbin.
- */
- fail_unless ((data = GST_BUFFER_DATA (buffer)) != NULL);
- fail_unless_equals_uint64 (*(guint64 *) data, *(guint64 *) rtp_header[index]);
- fail_unless (*(guint16 *) (data + 12) ==
- *(guint16 *) (rtp_header[index] + 12));
-}
-
-
-static void
-_check_payload (GstBuffer * buffer, guint index)
-{
- fail_if (buffer == NULL);
- fail_unless (index < 2);
-
- fail_unless (GST_BUFFER_SIZE (buffer) == payload_len[index]);
- fail_if (GST_BUFFER_DATA (buffer) !=
- (gpointer) (payload + payload_offset[index]));
- fail_if (memcmp (GST_BUFFER_DATA (buffer), payload + payload_offset[index],
- payload_len[index]));
-}
-
-
-static void
-_check_group (GstBufferListIterator * it, guint index, GstCaps * caps)
-{
- GstBuffer *buffer;
-
- fail_unless (it != NULL);
- fail_unless (gst_buffer_list_iterator_n_buffers (it) == 2);
- fail_unless (caps != NULL);
-
- fail_unless ((buffer = gst_buffer_list_iterator_next (it)) != NULL);
-
- fail_unless (GST_BUFFER_TIMESTAMP (buffer) ==
- GST_BUFFER_TIMESTAMP (original_buffer));
-
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (original_buffer),
- GST_BUFFER_CAPS (buffer)));
-
- _check_header (buffer, index);
-
- fail_unless ((buffer = gst_buffer_list_iterator_next (it)) != NULL);
- _check_payload (buffer, index);
-}
-
-
-static GstFlowReturn
-_sink_chain_list (GstPad * pad, GstBufferList * list)
-{
- GstCaps *caps;
- GstBufferListIterator *it;
-
- caps = gst_caps_from_string (TEST_CAPS);
- fail_unless (caps != NULL);
-
- fail_unless (GST_IS_BUFFER_LIST (list));
- fail_unless (gst_buffer_list_n_groups (list) == 2);
-
- it = gst_buffer_list_iterate (list);
- fail_if (it == NULL);
-
- fail_unless (gst_buffer_list_iterator_next_group (it));
- _check_group (it, 0, caps);
-
- fail_unless (gst_buffer_list_iterator_next_group (it));
- _check_group (it, 1, caps);
-
- gst_caps_unref (caps);
- gst_buffer_list_iterator_free (it);
-
- gst_buffer_list_unref (list);
-
- return GST_FLOW_OK;
-}
-
-
-static void
-_set_chain_functions (GstPad * pad)
-{
- gst_pad_set_chain_list_function (pad, _sink_chain_list);
-}
-
-
-GST_START_TEST (test_bufferlist)
-{
- GstElement *rtpbin;
- GstPad *sinkpad;
- GstPad *srcpad;
- GstBufferList *list;
-
- list = _create_buffer_list ();
- fail_unless (list != NULL);
-
- rtpbin = gst_check_setup_element ("gstrtpbin");
-
- srcpad =
- gst_check_setup_src_pad_by_name (rtpbin, &srctemplate, "send_rtp_sink_0");
- fail_if (srcpad == NULL);
- sinkpad =
- gst_check_setup_sink_pad_by_name (rtpbin, &sinktemplate,
- "send_rtp_src_0");
- fail_if (sinkpad == NULL);
-
- _set_chain_functions (sinkpad);
-
- gst_pad_set_active (sinkpad, TRUE);
- gst_element_set_state (rtpbin, GST_STATE_PLAYING);
- fail_unless (gst_pad_push_list (srcpad, list) == GST_FLOW_OK);
- gst_pad_set_active (sinkpad, FALSE);
-
- gst_check_teardown_pad_by_name (rtpbin, "send_rtp_src_0");
- gst_check_teardown_pad_by_name (rtpbin, "send_rtp_sink_0");
- gst_check_teardown_element (rtpbin);
-}
-
-GST_END_TEST;
-
-
-
-static Suite *
-bufferlist_suite (void)
-{
- Suite *s = suite_create ("BufferList");
-
- TCase *tc_chain = tcase_create ("general");
-
- /* time out after 30s. */
- tcase_set_timeout (tc_chain, 10);
-
- suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_bufferlist);
-
- return s;
-}
-
-GST_CHECK_MAIN (bufferlist);