}
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);
}
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);
&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);
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;
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);
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);
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 */
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 */
/* 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 */
/* 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);
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);
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 */
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 */
/* 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 */
/* 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);
GstEvent *event;
gchar *caps_string;
gint length;
+ guint8 *data;
+ gsize size;
guint16 crc_calculated, crc_read;
gdppay = setup_gdppay ();
/* 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;
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 */
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,