mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
tests: port and enable more unit tests
This commit is contained in:
parent
2d7150414b
commit
12ce1cb319
3 changed files with 53 additions and 50 deletions
|
@ -23,6 +23,8 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#undef GST_CAT_DEFAULT
|
||||
#include "../../gst/gdp/dataprotocol.c"
|
||||
|
||||
/* For ease of programming we use globals to keep refs for our floating
|
||||
|
@ -63,8 +65,8 @@ setup_gdpdepay (void)
|
|||
|
||||
GST_DEBUG ("setup_gdpdepay");
|
||||
gdpdepay = gst_check_setup_element ("gdpdepay");
|
||||
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate, NULL);
|
||||
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdpdepay, &sinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
|
@ -122,10 +124,10 @@ GST_START_TEST (test_audio_per_byte)
|
|||
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
||||
"could not set to playing");
|
||||
|
||||
caps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_pad_query_caps (srcpad, NULL);
|
||||
fail_unless (gst_caps_is_any (caps));
|
||||
gst_caps_unref (caps);
|
||||
fail_if (gst_pad_get_negotiated_caps (srcpad));
|
||||
fail_if (gst_pad_get_current_caps (srcpad));
|
||||
|
||||
/* create caps and buffer packets and push them */
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
|
@ -136,7 +138,7 @@ GST_START_TEST (test_audio_per_byte)
|
|||
gdpdepay_push_per_byte ("caps payload", payload,
|
||||
gst_dp_header_payload_length (header));
|
||||
fail_unless_equals_int (g_list_length (buffers), 0);
|
||||
caps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_pad_query_caps (srcpad, NULL);
|
||||
fail_if (gst_caps_is_any (caps));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
|
@ -199,10 +201,10 @@ GST_START_TEST (test_audio_in_one_buffer)
|
|||
"could not set to playing");
|
||||
|
||||
/* make sure no caps are set yet */
|
||||
caps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_pad_query_caps (srcpad, NULL);
|
||||
fail_unless (gst_caps_is_any (caps));
|
||||
gst_caps_unref (caps);
|
||||
fail_if (gst_pad_get_negotiated_caps (srcpad));
|
||||
fail_if (gst_pad_get_current_caps (srcpad));
|
||||
|
||||
/* create caps and buffer packets and push them as one buffer */
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
|
@ -266,8 +268,8 @@ setup_gdpdepay_streamheader (void)
|
|||
|
||||
GST_DEBUG ("setup_gdpdepay");
|
||||
gdpdepay = gst_check_setup_element ("gdpdepay");
|
||||
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate, NULL);
|
||||
myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate, NULL);
|
||||
mysrcpad = gst_check_setup_src_pad (gdpdepay, &srctemplate);
|
||||
myshsinkpad = gst_check_setup_sink_pad (gdpdepay, &shsinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (myshsinkpad, TRUE);
|
||||
|
||||
|
@ -278,7 +280,7 @@ setup_gdpdepay_streamheader (void)
|
|||
* have a streamheader set */
|
||||
GST_START_TEST (test_streamheader)
|
||||
{
|
||||
GstCaps *caps, *padcaps;
|
||||
GstCaps *caps;
|
||||
GstPad *srcpad;
|
||||
GstElement *gdpdepay;
|
||||
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
|
||||
|
@ -302,10 +304,10 @@ GST_START_TEST (test_streamheader)
|
|||
"could not set to playing");
|
||||
|
||||
/* make sure no caps are set yet */
|
||||
caps = gst_pad_get_caps (srcpad);
|
||||
caps = gst_pad_query_caps (srcpad, NULL);
|
||||
fail_unless (gst_caps_is_any (caps));
|
||||
gst_caps_unref (caps);
|
||||
fail_if (gst_pad_get_negotiated_caps (srcpad));
|
||||
fail_if (gst_pad_get_current_caps (srcpad));
|
||||
|
||||
/* create a streamheader buffer and the caps containing it */
|
||||
caps = gst_caps_from_string ("application/x-gst-test-streamheader");
|
||||
|
@ -323,8 +325,6 @@ GST_START_TEST (test_streamheader)
|
|||
gst_structure_set_value (structure, "streamheader", &array);
|
||||
g_value_unset (&array);
|
||||
|
||||
gst_buffer_set_caps (buffer, caps);
|
||||
|
||||
/* create GDP packets for the caps and the buffer, and put them in one
|
||||
* GDP buffer */
|
||||
fail_unless (pk->packet_from_caps (caps, 0, &header_len, &caps_header,
|
||||
|
@ -364,17 +364,8 @@ GST_START_TEST (test_streamheader)
|
|||
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
|
||||
fail_unless (GST_BUFFER_FLAG_IS_SET (outbuffer, GST_BUFFER_FLAG_IN_CAPS));
|
||||
|
||||
padcaps = gst_pad_get_negotiated_caps (myshsinkpad);
|
||||
caps = gst_buffer_get_caps (outbuffer);
|
||||
fail_if (caps == NULL);
|
||||
fail_if (padcaps == NULL);
|
||||
GST_DEBUG ("caps: %" GST_PTR_FORMAT ", padcaps: %" GST_PTR_FORMAT, caps,
|
||||
padcaps);
|
||||
fail_unless (gst_caps_is_equal (padcaps, caps));
|
||||
|
||||
/* FIXME: get streamheader, compare data with buffer */
|
||||
gst_buffer_unref (outbuffer);
|
||||
gst_caps_unref (padcaps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
/* clean up */
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#undef GST_CAT_DEFAULT
|
||||
#include "../../gst/gdp/dataprotocol.c"
|
||||
|
||||
/* For ease of programming we use globals to keep refs for our floating
|
||||
|
@ -63,8 +66,8 @@ setup_gdppay (void)
|
|||
|
||||
GST_DEBUG ("setup_gdppay");
|
||||
gdppay = gst_check_setup_element ("gdppay");
|
||||
mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL);
|
||||
mysrcpad = gst_check_setup_src_pad (gdppay, &srctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate);
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
|
@ -93,6 +96,7 @@ GST_START_TEST (test_audio)
|
|||
GstCaps *caps;
|
||||
GstElement *gdppay;
|
||||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstSegment segment;
|
||||
GstEvent *event;
|
||||
gchar *caps_string;
|
||||
gint length;
|
||||
|
@ -104,8 +108,9 @@ GST_START_TEST (test_audio)
|
|||
"could not set to playing");
|
||||
|
||||
GST_DEBUG ("new segment");
|
||||
event =
|
||||
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
|
||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||
segment.stop = GST_SECOND;
|
||||
event = gst_event_new_segment (&segment);
|
||||
fail_unless (gst_pad_push_event (mysrcpad, event));
|
||||
|
||||
/* no buffer should be pushed yet, waiting for caps */
|
||||
|
@ -114,7 +119,7 @@ GST_START_TEST (test_audio)
|
|||
GST_DEBUG ("first buffer");
|
||||
inbuffer = gst_buffer_new_and_alloc (4);
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
caps_string = gst_caps_to_string (caps);
|
||||
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
@ -152,7 +157,6 @@ GST_START_TEST (test_audio)
|
|||
/* second buffer */
|
||||
GST_DEBUG ("second buffer");
|
||||
inbuffer = gst_buffer_new_and_alloc (4);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -217,8 +221,8 @@ setup_gdppay_streamheader (void)
|
|||
|
||||
GST_DEBUG ("setup_gdppay");
|
||||
gdppay = gst_check_setup_element ("gdppay");
|
||||
myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate, NULL);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate, NULL);
|
||||
myshsrcpad = gst_check_setup_src_pad (gdppay, &shsrctemplate);
|
||||
mysinkpad = gst_check_setup_sink_pad (gdppay, &sinktemplate);
|
||||
gst_pad_set_active (myshsrcpad, TRUE);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
|
@ -233,6 +237,7 @@ GST_START_TEST (test_streamheader)
|
|||
GstCaps *caps, *sinkcaps;
|
||||
GstElement *gdppay;
|
||||
GstBuffer *inbuffer, *outbuffer, *shbuffer;
|
||||
GstSegment segment;
|
||||
GstEvent *event;
|
||||
gchar *caps_string;
|
||||
gint length;
|
||||
|
@ -250,8 +255,9 @@ GST_START_TEST (test_streamheader)
|
|||
"could not set to playing");
|
||||
|
||||
GST_DEBUG ("new segment");
|
||||
event =
|
||||
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
|
||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||
segment.stop = GST_SECOND;
|
||||
event = gst_event_new_segment (&segment);
|
||||
fail_unless (gst_pad_push_event (myshsrcpad, event));
|
||||
|
||||
/* no buffer should be pushed yet, still waiting for caps */
|
||||
|
@ -274,7 +280,7 @@ GST_START_TEST (test_streamheader)
|
|||
g_value_unset (&array);
|
||||
caps_string = gst_caps_to_string (caps);
|
||||
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (myshsrcpad, caps);
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
/* pushing gives away my reference */
|
||||
|
@ -285,7 +291,7 @@ GST_START_TEST (test_streamheader)
|
|||
|
||||
/* our sink pad should now have GDP caps with a streamheader that includes
|
||||
* GDP wrappings of our streamheader */
|
||||
sinkcaps = gst_pad_get_negotiated_caps (mysinkpad);
|
||||
sinkcaps = gst_pad_get_current_caps (mysinkpad);
|
||||
structure = gst_caps_get_structure (sinkcaps, 0);
|
||||
fail_unless_equals_string ((gchar *) gst_structure_get_name (structure),
|
||||
"application/x-gdp");
|
||||
|
@ -326,7 +332,6 @@ GST_START_TEST (test_streamheader)
|
|||
/* second buffer */
|
||||
GST_DEBUG ("second buffer");
|
||||
inbuffer = gst_buffer_new_and_alloc (4);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
||||
|
@ -427,7 +432,7 @@ GST_START_TEST (test_first_no_new_segment)
|
|||
GST_DEBUG ("first buffer");
|
||||
inbuffer = gst_buffer_new_and_alloc (4);
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
@ -457,6 +462,7 @@ GST_START_TEST (test_crc)
|
|||
GstCaps *caps;
|
||||
GstElement *gdppay;
|
||||
GstBuffer *inbuffer, *outbuffer;
|
||||
GstSegment segment;
|
||||
GstEvent *event;
|
||||
gchar *caps_string;
|
||||
gint length;
|
||||
|
@ -472,8 +478,8 @@ GST_START_TEST (test_crc)
|
|||
"could not set to playing");
|
||||
|
||||
GST_DEBUG ("new segment");
|
||||
event =
|
||||
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0);
|
||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||
event = gst_event_new_segment (&segment);
|
||||
fail_unless (gst_pad_push_event (mysrcpad, event));
|
||||
|
||||
/* no buffer should be pushed yet, waiting for caps */
|
||||
|
@ -482,7 +488,7 @@ GST_START_TEST (test_crc)
|
|||
GST_DEBUG ("first buffer");
|
||||
inbuffer = gst_buffer_new_and_alloc (4);
|
||||
caps = gst_caps_from_string (AUDIO_CAPS_STRING);
|
||||
gst_buffer_set_caps (inbuffer, caps);
|
||||
gst_pad_set_caps (mysrcpad, caps);
|
||||
caps_string = gst_caps_to_string (caps);
|
||||
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
|
|
|
@ -36,9 +36,12 @@
|
|||
|
||||
static int n_tags = 0;
|
||||
|
||||
static gboolean
|
||||
tag_event_probe_cb (GstPad * pad, GstEvent * event, GMainLoop * loop)
|
||||
static GstPadProbeReturn
|
||||
tag_event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||
{
|
||||
GMainLoop *loop = user_data;
|
||||
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_TAG:
|
||||
{
|
||||
|
@ -55,7 +58,7 @@ tag_event_probe_cb (GstPad * pad, GstEvent * event, GMainLoop * loop)
|
|||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_multifdsink_gdp_tag)
|
||||
|
@ -95,7 +98,8 @@ GST_START_TEST (test_multifdsink_gdp_tag)
|
|||
fail_unless (pad != NULL, "Could not get pad out of depay");
|
||||
gst_object_unref (depay);
|
||||
|
||||
gst_pad_add_event_probe (pad, G_CALLBACK (tag_event_probe_cb), loop);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
||||
tag_event_probe_cb, loop, NULL);
|
||||
|
||||
gst_element_set_state (p1, GST_STATE_PLAYING);
|
||||
gst_element_set_state (p2, GST_STATE_PLAYING);
|
||||
|
@ -119,9 +123,10 @@ GST_END_TEST;
|
|||
|
||||
static int n_in_caps = 0;
|
||||
|
||||
static gboolean
|
||||
buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
|
||||
static GstPadProbeReturn
|
||||
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
|
||||
{
|
||||
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
|
@ -138,14 +143,13 @@ buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
|
|||
|
||||
n_in_caps++;
|
||||
|
||||
caps = gst_buffer_get_caps (buffer);
|
||||
caps = gst_pad_get_current_caps (pad);
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
fail_unless (gst_structure_has_field (s, "streamheader"));
|
||||
sh = gst_structure_get_value (s, "streamheader");
|
||||
buffers = g_value_peek_pointer (sh);
|
||||
assert_equals_int (buffers->len, 3);
|
||||
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
GValue *val;
|
||||
guint8 *data2;
|
||||
|
@ -210,8 +214,10 @@ GST_START_TEST (test_multifdsink_gdp_vorbisenc)
|
|||
fail_unless (pad != NULL, "Could not get pad out of depay");
|
||||
gst_object_unref (depay);
|
||||
|
||||
gst_pad_add_event_probe (pad, G_CALLBACK (tag_event_probe_cb), loop);
|
||||
gst_pad_add_buffer_probe (pad, G_CALLBACK (buffer_probe_cb), NULL);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
|
||||
tag_event_probe_cb, loop, NULL);
|
||||
gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, buffer_probe_cb, NULL,
|
||||
NULL);
|
||||
|
||||
gst_element_set_state (p1, GST_STATE_PLAYING);
|
||||
gst_element_set_state (p2, GST_STATE_PLAYING);
|
||||
|
|
Loading…
Reference in a new issue