matroskamux: adjust unit test to modified behaviour

This commit is contained in:
Mark Nauwelaerts 2010-05-21 11:21:58 +02:00
parent b8fd1a91f1
commit 4e5c985ba4
2 changed files with 37 additions and 51 deletions

View file

@ -194,6 +194,8 @@ elements_imagefreeze_LDADD = $(GST_BASE_LIBS) $(LDADD) -lgstvideo-0.10
elements_level_LDADD = $(LDADD) $(LIBM) elements_level_LDADD = $(LDADD) $(LIBM)
elements_matroskamux_LDADD = $(GST_BASE_LIBS) $(LDADD) $(LIBM)
elements_rtpbin_buffer_list_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ elements_rtpbin_buffer_list_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \
$(WARNING_CFLAGS) $(ERROR_CFLAGS) $(GST_CHECK_CFLAGS) $(WARNING_CFLAGS) $(ERROR_CFLAGS) $(GST_CHECK_CFLAGS)
elements_rtpbin_buffer_list_LDADD = $(GST_PLUGINS_BASE_LIBS) \ elements_rtpbin_buffer_list_LDADD = $(GST_PLUGINS_BASE_LIBS) \

View file

@ -23,6 +23,7 @@
#include <unistd.h> #include <unistd.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/base/gstadapter.h>
/* For ease of programming we use globals to keep refs for our floating /* For ease of programming we use globals to keep refs for our floating
* src and sink pads we create; otherwise we always have to do get_pad, * src and sink pads we create; otherwise we always have to do get_pad,
@ -194,19 +195,16 @@ GST_START_TEST (test_ebml_header)
{ {
GstElement *matroskamux; GstElement *matroskamux;
GstBuffer *inbuffer, *outbuffer; GstBuffer *inbuffer, *outbuffer;
GstAdapter *adapter;
int num_buffers; int num_buffers;
int i; int i;
guint8 data0[12] = gint available;
{ 0x1a, 0x45, 0xdf, 0xa3, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, guint8 data[] =
0xff { 0x1a, 0x45, 0xdf, 0xa3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
0x42, 0x82, 0x89, 0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61, 0x00,
0x42, 0x87, 0x81, 0x01,
0x42, 0x85, 0x81, 0x01
}; };
guint8 data1[12] =
{ 0x42, 0x82, 0x89, 0x6d, 0x61, 0x74, 0x72, 0x6f, 0x73, 0x6b, 0x61,
0x00
};
guint8 data2[4] = { 0x42, 0x87, 0x81, 0x01 };
guint8 data3[4] = { 0x42, 0x85, 0x81, 0x01 };
guint8 data4[8] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14 };
matroskamux = setup_matroskamux (&srcac3template); matroskamux = setup_matroskamux (&srcac3template);
fail_unless (gst_element_set_state (matroskamux, fail_unless (gst_element_set_state (matroskamux,
@ -217,39 +215,28 @@ GST_START_TEST (test_ebml_header)
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
num_buffers = g_list_length (buffers); num_buffers = g_list_length (buffers);
fail_unless (num_buffers >= 5, fail_unless (num_buffers >= 1,
"expected at least 5 buffers, but got only %d", num_buffers); "expected at least 5 buffers, but got only %d", num_buffers);
adapter = gst_adapter_new ();
for (i = 0; i < num_buffers; ++i) { for (i = 0; i < num_buffers; ++i) {
outbuffer = GST_BUFFER (buffers->data); outbuffer = GST_BUFFER (buffers->data);
fail_if (outbuffer == NULL); fail_if (outbuffer == NULL);
buffers = g_list_remove (buffers, outbuffer); buffers = g_list_remove (buffers, outbuffer);
switch (i) {
case 0:
check_buffer_data (outbuffer, data0, sizeof (data0));
break;
case 1:
check_buffer_data (outbuffer, data1, sizeof (data1));
break;
case 2:
check_buffer_data (outbuffer, data2, sizeof (data2));
break;
case 3:
check_buffer_data (outbuffer, data3, sizeof (data3));
break;
case 4:
check_buffer_data (outbuffer, data4, sizeof (data4));
break;
default:
break;
}
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
gst_buffer_unref (outbuffer);
outbuffer = NULL; gst_adapter_push (adapter, outbuffer);
} }
available = gst_adapter_available (adapter);
fail_unless (available >= sizeof (data));
outbuffer = gst_adapter_take_buffer (adapter, sizeof (data));
g_object_unref (adapter);
check_buffer_data (outbuffer, data, sizeof (data));
gst_buffer_unref (outbuffer);
cleanup_matroskamux (matroskamux); cleanup_matroskamux (matroskamux);
g_list_free (buffers); g_list_free (buffers);
buffers = NULL; buffers = NULL;
@ -286,13 +273,19 @@ GST_START_TEST (test_vorbis_header)
num_buffers = g_list_length (buffers); num_buffers = g_list_length (buffers);
for (i = 0; i < num_buffers; ++i) { for (i = 0; i < num_buffers; ++i) {
gint j;
outbuffer = GST_BUFFER (buffers->data); outbuffer = GST_BUFFER (buffers->data);
fail_if (outbuffer == NULL); fail_if (outbuffer == NULL);
buffers = g_list_remove (buffers, outbuffer); buffers = g_list_remove (buffers, outbuffer);
if (!vorbis_header_found && GST_BUFFER_SIZE (outbuffer) == sizeof (data)) { if (!vorbis_header_found && GST_BUFFER_SIZE (outbuffer) >= sizeof (data)) {
vorbis_header_found = for (j = 0; j <= GST_BUFFER_SIZE (outbuffer) - sizeof (data); j++) {
memcmp (GST_BUFFER_DATA (outbuffer), data, sizeof (data)); if (memcmp (GST_BUFFER_DATA (outbuffer) + j, data, sizeof (data)) == 0) {
vorbis_header_found = TRUE;
break;
}
}
} }
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
@ -317,11 +310,11 @@ GST_START_TEST (test_block_group)
GstCaps *caps; GstCaps *caps;
int num_buffers; int num_buffers;
int i; int i;
guint8 data0[9] = { 0xa0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; guint8 data0[] = { 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
guint8 data1[2] = { 0xa1, 0x85 }; 0xa1, 0x85,
guint8 data2[4] = { 0x81, 0x00, 0x01, 0x00 }; 0x81, 0x00, 0x01, 0x00
guint8 data3[1] = { 0x42 }; };
guint8 data4[8] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07 }; guint8 data1[] = { 0x42 };
matroskamux = setup_matroskamux (&srcac3template); matroskamux = setup_matroskamux (&srcac3template);
fail_unless (gst_element_set_state (matroskamux, fail_unless (gst_element_set_state (matroskamux,
@ -363,7 +356,7 @@ GST_START_TEST (test_block_group)
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
num_buffers = g_list_length (buffers); num_buffers = g_list_length (buffers);
fail_unless (num_buffers >= 5); fail_unless (num_buffers >= 2);
for (i = 0; i < num_buffers; ++i) { for (i = 0; i < num_buffers; ++i) {
outbuffer = GST_BUFFER (buffers->data); outbuffer = GST_BUFFER (buffers->data);
@ -377,15 +370,6 @@ GST_START_TEST (test_block_group)
case 1: case 1:
check_buffer_data (outbuffer, data1, sizeof (data1)); check_buffer_data (outbuffer, data1, sizeof (data1));
break; break;
case 2:
check_buffer_data (outbuffer, data2, sizeof (data2));
break;
case 3:
check_buffer_data (outbuffer, data3, sizeof (data3));
break;
case 4:
check_buffer_data (outbuffer, data4, sizeof (data4));
break;
default: default:
break; break;
} }