Commit 40dc12da authored by Wim Taymans's avatar Wim Taymans
Browse files

tests: work on porting the unit tests

parent d10602fb
......@@ -198,6 +198,8 @@ GST_END_TEST;
static GstBufferList *mylist;
static GstCaps *mycaps;
static gint values[] = { 1, 2, 4 };
static GstBufferList *
create_buffer_list (void)
{
......@@ -216,19 +218,19 @@ create_buffer_list (void)
gst_buffer_list_iterator_add_group (it);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
*(gint *) GST_BUFFER_DATA (buffer) = 1;
gst_buffer_fill (buffer, 0, &values[0], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
gst_buffer_list_iterator_add_group (it);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
*(gint *) GST_BUFFER_DATA (buffer) = 2;
gst_buffer_fill (buffer, 0, &values[1], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
buffer = gst_buffer_new_and_alloc (sizeof (gint));
*(gint *) GST_BUFFER_DATA (buffer) = 4;
gst_buffer_fill (buffer, 0, &values[2], sizeof (gint));
gst_buffer_set_caps (buffer, mycaps);
gst_buffer_list_iterator_add (it, buffer);
......@@ -254,7 +256,7 @@ check_buffer_list (GstBufferList * list)
fail_unless (gst_buffer_list_iterator_n_buffers (it) == 1);
buf = gst_buffer_list_iterator_next (it);
fail_if (buf == NULL);
fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 1);
gst_check_buffer_data (buf, &values[0], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
fail_unless (gst_caps_is_equal (caps, mycaps));
......@@ -264,14 +266,14 @@ check_buffer_list (GstBufferList * list)
fail_unless (gst_buffer_list_iterator_n_buffers (it) == 2);
buf = gst_buffer_list_iterator_next (it);
fail_if (buf == NULL);
fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 2);
gst_check_buffer_data (buf, &values[1], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
buf = gst_buffer_list_iterator_next (it);
fail_if (buf == NULL);
fail_unless (*(gint *) GST_BUFFER_DATA (buf) == 4);
gst_check_buffer_data (buf, &values[2], sizeof (gint));
caps = gst_buffer_get_caps (buf);
fail_unless (caps == mycaps);
gst_caps_unref (caps);
......@@ -329,13 +331,12 @@ callback_function_buffer (GstAppSink * appsink, gpointer p_counter)
/* buffer list has 3 buffers in two groups */
switch (*p_int_counter) {
case 0:
fail_unless_equals_int (GST_BUFFER_SIZE (buf), sizeof (gint));
fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[0]), 1);
fail_unless_equals_int (gst_buffer_get_size (buf), sizeof (gint));
gst_check_buffer_data (buf, &values[0], sizeof (gint));
break;
case 1:
fail_unless_equals_int (GST_BUFFER_SIZE (buf), 2 * sizeof (gint));
fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[0]), 2);
fail_unless_equals_int ((((gint *) GST_BUFFER_DATA (buf))[1]), 4);
fail_unless_equals_int (gst_buffer_get_size (buf), 2 * sizeof (gint));
gst_check_buffer_data (buf, &values[1], 2 * sizeof (gint));
break;
default:
g_warn_if_reached ();
......
......@@ -449,7 +449,7 @@ verify_convert (const gchar * which, void *in, int inlength,
GST_DEBUG ("Creating buffer of %d bytes", inlength);
inbuffer = gst_buffer_new_and_alloc (inlength);
memcpy (GST_BUFFER_DATA (inbuffer), in, inlength);
gst_buffer_fill (inbuffer, 0, in, inlength);
gst_buffer_set_caps (inbuffer, incaps);
ASSERT_CAPS_REFCOUNT (incaps, "incaps", 2);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
......@@ -467,8 +467,10 @@ verify_convert (const gchar * which, void *in, int inlength,
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), outlength);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), outlength);
gst_check_buffer_data (outbuffer, out, outlength);
#if 0
if (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) != 0) {
g_print ("\nInput data:\n");
gst_util_dump_mem (in, inlength);
......@@ -479,6 +481,7 @@ verify_convert (const gchar * which, void *in, int inlength,
}
fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), out, outlength) == 0,
"failed converting %s", which);
#endif
/* make sure that the channel positions are not lost */
{
......
......@@ -277,11 +277,12 @@ do_perfect_stream_test (guint rate, guint width, gdouble drop_probability,
}
/* check buffer size for sanity */
fail_unless_equals_int (GST_BUFFER_SIZE (buf) % (width / 8), 0);
fail_unless_equals_int (gst_buffer_get_size (buf) % (width / 8), 0);
/* check there is actually as much data as there should be */
num_samples = GST_BUFFER_OFFSET_END (buf) - GST_BUFFER_OFFSET (buf);
fail_unless_equals_int (GST_BUFFER_SIZE (buf), num_samples * (width / 8));
fail_unless_equals_int (gst_buffer_get_size (buf),
num_samples * (width / 8));
next_time = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
next_offset = GST_BUFFER_OFFSET_END (buf);
......
......@@ -175,9 +175,8 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
guint64 offset = 0;
int i, j;
gint16 *p;
gint16 *p, *data;
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
......@@ -198,7 +197,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
gst_buffer_set_caps (inbuffer, caps);
p = (gint16 *) GST_BUFFER_DATA (inbuffer);
p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
......@@ -207,6 +206,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
*p = -32767 + i * (65535 / samples);
++p;
}
gst_buffer_unmap (inbuffer, data, samples * 4);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
......@@ -261,7 +261,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
GstClockTime ints;
int i, j;
gint16 *p;
gint16 *p, *data;
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
......@@ -286,8 +286,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
gst_buffer_set_caps (inbuffer, caps);
p = (gint16 *) GST_BUFFER_DATA (inbuffer);
p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
......@@ -295,6 +294,7 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
*p = -32767 + i * (65535 / samples);
++p;
}
gst_buffer_unmap (inbuffer, data, samples * 4);
GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
......@@ -351,6 +351,7 @@ GST_START_TEST (test_reuse)
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
guint8 *data;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
......@@ -364,7 +365,9 @@ GST_START_TEST (test_reuse)
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
memset (data, 0, 9343 * 4);
gst_buffer_unmap (inbuffer, data, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
......@@ -388,7 +391,9 @@ GST_START_TEST (test_reuse)
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
memset (data, 0, 9343 * 4);
gst_buffer_unmap (inbuffer, data, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
......@@ -500,6 +505,7 @@ live_switch_push (int rate, GstCaps * caps)
GstBuffer *inbuffer;
GstCaps *desired;
GList *l;
guint8 *data;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
......@@ -516,7 +522,10 @@ live_switch_push (int rate, GstCaps * caps)
desired, GST_BUFFER_CAPS (inbuffer));
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
memset (data, 0, rate * 4);
gst_buffer_unmap (inbuffer, data, rate * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
......@@ -769,7 +778,7 @@ fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
ctx->out_buffer_count++;
if (ctx->latency == GST_CLOCK_TIME_NONE) {
ctx->latency = 1000 - GST_BUFFER_SIZE (buffer) / 8;
ctx->latency = 1000 - gst_buffer_get_size (buffer) / 8;
}
/* Check if we have a perfectly timestampped stream */
......@@ -781,10 +790,10 @@ fakesink_handoff_cb (GstElement * object, GstBuffer * buffer, GstPad * pad,
/* Check if we have a perfectly offsetted stream */
fail_unless (GST_BUFFER_OFFSET_END (buffer) ==
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
"expected offset end %" G_GUINT64_FORMAT " got offset end %"
G_GUINT64_FORMAT,
GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
GST_BUFFER_OFFSET_END (buffer));
if (ctx->next_out_off != GST_BUFFER_OFFSET_NONE) {
fail_unless (GST_BUFFER_OFFSET (buffer) == ctx->next_out_off,
......
......@@ -44,10 +44,12 @@ static const gchar dummytext[] =
static void
src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
{
GST_BUFFER_DATA (buf) = (guint8 *) dummytext;
GST_BUFFER_SIZE (buf) = sizeof (dummytext);
gst_buffer_take_memory (buf,
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
(gpointer) dummytext, NULL, sizeof (dummytext), 0,
sizeof (dummytext)));
GST_BUFFER_OFFSET (buf) = 0;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
}
static void
......
......@@ -44,10 +44,12 @@ static const gchar dummytext[] =
static void
src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
{
GST_BUFFER_DATA (buf) = (guint8 *) dummytext;
GST_BUFFER_SIZE (buf) = sizeof (dummytext);
gst_buffer_take_memory (buf,
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
(gpointer) dummytext, NULL, sizeof (dummytext), 0,
sizeof (dummytext)));
GST_BUFFER_OFFSET (buf) = 0;
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
}
static void
......
......@@ -313,6 +313,8 @@ GST_START_TEST (test_rgb_to_rgb)
GstStateChangeReturn state_ret;
RGBFormat *from = &conv->from_fmt;
RGBFormat *to = &conv->to_fmt;
guint8 *data;
gsize size;
/* trick compiler into thinking from is used, might throw warning
* otherwise if the debugging system is disabled */
......@@ -393,10 +395,12 @@ GST_START_TEST (test_rgb_to_rgb)
}
/* now check the top-left pixel */
check_rgb_buf (GST_BUFFER_DATA (buf), to->red_mask,
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
check_rgb_buf (data, to->red_mask,
to->green_mask, to->blue_mask, to->alpha_mask,
test_patterns[p].r_expected, test_patterns[p].g_expected,
test_patterns[p].b_expected, to->endianness, to->bpp, to->depth);
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
buf = NULL;
......
......@@ -94,14 +94,15 @@ cleanup_gdpdepay (GstElement * gdpdepay)
}
static void
gdpdepay_push_per_byte (const gchar * reason, guint8 * bytes, guint length)
gdpdepay_push_per_byte (const gchar * reason, const guint8 * bytes,
guint length)
{
int i;
GstBuffer *inbuffer;
for (i = 0; i < length; ++i) {
inbuffer = gst_buffer_new_and_alloc (1);
GST_BUFFER_DATA (inbuffer)[0] = bytes[i];
gst_buffer_fill (inbuffer, 0, &bytes[i], 1);
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK,
"%s: failed pushing byte buffer", reason);
}
......@@ -148,13 +149,13 @@ GST_START_TEST (test_audio_per_byte)
g_free (payload);
buffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
gst_buffer_fill (buffer, 0, "f00d", 4);
GST_BUFFER_TIMESTAMP (buffer) = GST_SECOND;
GST_BUFFER_DURATION (buffer) = GST_SECOND / 10;
fail_unless (pk->header_from_buffer (buffer, 0, &len, &header));
gdpdepay_push_per_byte ("buffer header", header, len);
fail_unless_equals_int (g_list_length (buffers), 0);
gdpdepay_push_per_byte ("buffer payload", GST_BUFFER_DATA (buffer),
gdpdepay_push_per_byte ("buffer payload", (const guint8 *) "f00d",
gst_dp_header_payload_length (header));
g_free (header);
gst_buffer_unref (buffer);
......@@ -214,21 +215,20 @@ GST_START_TEST (test_audio_in_one_buffer)
&caps_payload));
buffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
gst_buffer_fill (buffer, 0, "f00d", 4);
fail_unless (pk->header_from_buffer (buffer, 0, &header_len, &buf_header));
payload_len = gst_dp_header_payload_length (caps_header);
inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
payload_len + GST_BUFFER_SIZE (buffer));
memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
payload_len + gst_buffer_get_size (buffer));
gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
i = GST_DP_HEADER_LENGTH;
memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
i += payload_len;
memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
i += GST_DP_HEADER_LENGTH;
memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer));
gst_buffer_fill (inbuffer, i, "f00d", 4);
gst_caps_unref (caps);
gst_buffer_unref (buffer);
......@@ -287,7 +287,8 @@ GST_START_TEST (test_streamheader)
GstPad *srcpad;
GstElement *gdpdepay;
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
guint8 *caps_header, *caps_payload, *buf_header;
guint8 *caps_header, *caps_payload, *buf_header, *data;
gsize size;
guint header_len, payload_len;
guint i;
GstStructure *structure;
......@@ -315,7 +316,7 @@ GST_START_TEST (test_streamheader)
caps = gst_caps_from_string ("application/x-gst-test-streamheader");
structure = gst_caps_get_structure (caps, 0);
buffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buffer), "f00d", 4);
gst_buffer_fill (buffer, 0, "f00d", 4);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_IN_CAPS);
g_value_init (&array, GST_TYPE_ARRAY);
g_value_init (&value, GST_TYPE_BUFFER);
......@@ -338,16 +339,17 @@ GST_START_TEST (test_streamheader)
payload_len = gst_dp_header_payload_length (caps_header);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
payload_len + GST_BUFFER_SIZE (buffer));
memcpy (GST_BUFFER_DATA (inbuffer), caps_header, GST_DP_HEADER_LENGTH);
payload_len + size);
gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
i = GST_DP_HEADER_LENGTH;
memcpy (GST_BUFFER_DATA (inbuffer) + i, caps_payload, payload_len);
gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
i += payload_len;
memcpy (GST_BUFFER_DATA (inbuffer) + i, buf_header, GST_DP_HEADER_LENGTH);
gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
i += GST_DP_HEADER_LENGTH;
memcpy (GST_BUFFER_DATA (inbuffer) + i, GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer));
gst_buffer_fill (inbuffer, i, data, size);
gst_buffer_unmap (buffer, data, size);
gst_caps_unref (caps);
gst_buffer_unref (buffer);
......
......@@ -142,7 +142,7 @@ GST_START_TEST (test_audio)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* the third buffer is the GDP buffer for our pushed buffer */
......@@ -150,7 +150,7 @@ GST_START_TEST (test_audio)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* second buffer */
......@@ -170,7 +170,7 @@ GST_START_TEST (test_audio)
/* the third output buffer is data */
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* a third buffer without caps set explicitly; should work */
......@@ -189,7 +189,7 @@ GST_START_TEST (test_audio)
/* the fourth output buffer is data */
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
......@@ -263,7 +263,7 @@ GST_START_TEST (test_streamheader)
GST_DEBUG ("first buffer");
inbuffer = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (inbuffer), "head", 4);
gst_buffer_fill (inbuffer, 0, "head", 4);
caps = gst_caps_from_string ("application/x-gst-test-streamheader");
structure = gst_caps_get_structure (caps, 0);
GST_BUFFER_FLAG_SET (inbuffer, GST_BUFFER_FLAG_IN_CAPS);
......@@ -316,7 +316,7 @@ GST_START_TEST (test_streamheader)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* the third buffer is the GDP buffer for our pushed buffer */
......@@ -324,7 +324,7 @@ GST_START_TEST (test_streamheader)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* second buffer */
......@@ -344,7 +344,7 @@ GST_START_TEST (test_streamheader)
/* the third output buffer is data */
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* a third buffer without caps set explicitly; should work */
......@@ -363,7 +363,7 @@ GST_START_TEST (test_streamheader)
/* the fourth output buffer is data */
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
......@@ -464,6 +464,8 @@ GST_START_TEST (test_crc)
GstEvent *event;
gchar *caps_string;
gint length;
guint8 *data;
gsize size;
guint16 crc_calculated, crc_read;
gdppay = setup_gdppay ();
......@@ -503,16 +505,18 @@ GST_START_TEST (test_crc)
/* verify the header checksum */
/* CRC's start at 58 in the header */
crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
crc_read = GST_READ_UINT16_BE (GST_BUFFER_DATA (outbuffer) + 58);
data = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READWRITE);
crc_calculated = gst_dp_crc (data, 58);
crc_read = GST_READ_UINT16_BE (data + 58);
fail_unless_equals_int (crc_calculated, crc_read);
/* change a byte in the header and verify that the checksum now fails */
GST_BUFFER_DATA (outbuffer)[0] = 0xff;
crc_calculated = gst_dp_crc (GST_BUFFER_DATA (outbuffer), 58);
data[0] = 0xff;
crc_calculated = gst_dp_crc (data, 58);
fail_if (crc_calculated == crc_read,
"Introducing a byte error in the header should make the checksum fail");
gst_buffer_unmap (outbuffer, data, size);
gst_buffer_unref (outbuffer);
/* second buffer is the serialized caps;
......@@ -521,7 +525,7 @@ GST_START_TEST (test_crc)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 2);
length = GST_DP_HEADER_LENGTH + (strlen (caps_string) + 1);
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
/* the third buffer is the GDP buffer for our pushed buffer */
......@@ -529,7 +533,7 @@ GST_START_TEST (test_crc)
buffers = g_list_remove (buffers, outbuffer);
ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1);
length = GST_DP_HEADER_LENGTH + 4;
fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), length);
fail_unless_equals_int (gst_buffer_get_size (outbuffer), length);
gst_buffer_unref (outbuffer);
fail_unless (gst_element_set_state (gdppay,
......
......@@ -87,9 +87,12 @@ cleanup_gnomevfssink (GstElement * gnomevfssink)
G_STMT_START { \
GstBuffer *buf = gst_buffer_new_and_alloc(num_bytes); \
GRand *rand = g_rand_new_with_seed (num_bytes); \
guint i; \
gsize i; \
guint8 *data; \
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); \
for (i = 0; i < num_bytes; ++i) \
GST_BUFFER_DATA(buf)[i] = (g_rand_int (rand) >> 24) & 0xff; \
data[i] = (g_rand_int (rand) >> 24) & 0xff; \
gst_buffer_unmap (buf, data, num_bytes); \
fail_unless_equals_int (gst_pad_push (mysrcpad, buf), GST_FLOW_OK); \
g_rand_free (rand); \
} G_STMT_END
......
......@@ -121,7 +121,7 @@ GST_START_TEST (test_add_client)
buffer = gst_buffer_new_and_alloc (4);
gst_buffer_set_caps (buffer, caps);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
memcpy (GST_BUFFER_DATA (buffer), "dead", 4);
gst_buffer_fill (buffer, 0, "dead", 4);
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
GST_DEBUG ("reading");
......@@ -176,10 +176,10 @@ gst_multifdsink_create_streamheader (const gchar * data1,
* buffers */
*hbuf1 = gst_buffer_new_and_alloc (size1);
GST_BUFFER_FLAG_SET (*hbuf1, GST_BUFFER_FLAG_IN_CAPS);
memcpy (GST_BUFFER_DATA (*hbuf1), data1, size1);
gst_buffer_fill (*hbuf1, 0, data1, size1);
*hbuf2 = gst_buffer_new_and_alloc (size2);
GST_BUFFER_FLAG_SET (*hbuf2, GST_BUFFER_FLAG_IN_CAPS);
memcpy (GST_BUFFER_DATA (*hbuf2), data2, size2);
gst_buffer_fill (*hbuf2, 0, data2, size2);
g_value_init (&array, GST_TYPE_ARRAY);
......@@ -265,7 +265,7 @@ GST_START_TEST (test_streamheader)
/* push a non-IN_CAPS buffer, this should trigger the client receiving the
* first three buffers */
buf = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buf), "f00d", 4);
gst_buffer_fill (buf, 0, "f00d", 4);
gst_pad_push (mysrcpad, buf);
fail_unless_read ("first client", pfd1[0], 4, "babe");
......@@ -281,7 +281,7 @@ GST_START_TEST (test_streamheader)
/* now push another buffer, which will trigger streamheader for second
* client */
buf = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buf), "deaf", 4);
gst_buffer_fill (buf, 0, "deaf", 4);
gst_pad_push (mysrcpad, buf);
fail_unless_read ("first client", pfd1[0], 4, "deaf");
......@@ -360,7 +360,7 @@ GST_START_TEST (test_change_streamheader)
/* now push a buffer and read */
buf = gst_buffer_new_and_alloc (4);
memcpy (GST_BUFFER_DATA (buf), "f00d", 4);
gst_buffer_fill (buf, 0, "f00d", 4);
gst_pad_push (mysrcpad, buf);
fail_unless_read ("change: first client", pfd1[0], 5, "first");
......@@ -400,7 +400,7 @@ GST_START_TEST (test_change_streamheader)