summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-01-20 16:11:54 +0100
committerTim-Philipp Müller <tim@centricular.net>2012-09-11 01:54:44 +0100
commit33344dc2b9724408a7440602bd3b6a06a5e951b2 (patch)
tree03bc3c288fdf759a297ec3f87700b75438d0306a
parent0a817d23e68951664d196900a0b4dd0907ff95c7 (diff)
port to new map API
-rw-r--r--gst/gdp/dataprotocol.c11
-rw-r--r--gst/gdp/gstgdpdepay.c8
-rw-r--r--tests/check/elements/gdpdepay.c12
-rw-r--r--tests/check/elements/gdppay.c15
-rw-r--r--tests/check/pipelines/streamheader.c18
5 files changed, 30 insertions, 34 deletions
diff --git a/gst/gdp/dataprotocol.c b/gst/gdp/dataprotocol.c
index 0308df9a0..e17583db8 100644
--- a/gst/gdp/dataprotocol.c
+++ b/gst/gdp/dataprotocol.c
@@ -131,8 +131,7 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
{
guint8 *h;
guint16 flags_mask;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
g_return_val_if_fail (length, FALSE);
@@ -144,10 +143,10 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
/* version, flags, type */
GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_BUFFER);
- data = gst_buffer_map ((GstBuffer *) buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map ((GstBuffer *) buffer, &map, GST_MAP_READ);
/* buffer properties */
- GST_WRITE_UINT32_BE (h + 6, size);
+ GST_WRITE_UINT32_BE (h + 6, map.size);
GST_WRITE_UINT64_BE (h + 10, GST_BUFFER_TIMESTAMP (buffer));
GST_WRITE_UINT64_BE (h + 18, GST_BUFFER_DURATION (buffer));
GST_WRITE_UINT64_BE (h + 26, GST_BUFFER_OFFSET (buffer));
@@ -161,9 +160,9 @@ gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags,
GST_WRITE_UINT16_BE (h + 42, GST_BUFFER_FLAGS (buffer) & flags_mask);
- GST_DP_SET_CRC (h, flags, data, size);
+ GST_DP_SET_CRC (h, flags, map.data, map.size);
- gst_buffer_unmap ((GstBuffer *) buffer, data, size);
+ gst_buffer_unmap ((GstBuffer *) buffer, &map);
GST_LOG ("created header from buffer:");
gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH);
diff --git a/gst/gdp/gstgdpdepay.c b/gst/gdp/gstgdpdepay.c
index f397a3fe4..35a5c1610 100644
--- a/gst/gdp/gstgdpdepay.c
+++ b/gst/gdp/gstgdpdepay.c
@@ -308,11 +308,11 @@ gst_gdp_depay_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
/* now take the payload if there is any */
if (this->payload_length > 0) {
- guint8 *payload;
+ GstMapInfo map;
- payload = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- gst_adapter_copy (this->adapter, payload, 0, this->payload_length);
- gst_buffer_unmap (buf, payload, this->payload_length);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ gst_adapter_copy (this->adapter, map.data, 0, this->payload_length);
+ gst_buffer_unmap (buf, &map);
gst_adapter_flush (this->adapter, this->payload_length);
}
diff --git a/tests/check/elements/gdpdepay.c b/tests/check/elements/gdpdepay.c
index 5088668ed..a736d013e 100644
--- a/tests/check/elements/gdpdepay.c
+++ b/tests/check/elements/gdpdepay.c
@@ -284,8 +284,8 @@ GST_START_TEST (test_streamheader)
GstPad *srcpad;
GstElement *gdpdepay;
GstBuffer *buffer, *inbuffer, *outbuffer, *shbuffer;
- guint8 *caps_header, *caps_payload, *buf_header, *data;
- gsize size;
+ guint8 *caps_header, *caps_payload, *buf_header;
+ GstMapInfo map;
guint header_len, payload_len;
guint i;
GstStructure *structure;
@@ -334,17 +334,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);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
inbuffer = gst_buffer_new_and_alloc (2 * GST_DP_HEADER_LENGTH +
- payload_len + size);
+ payload_len + map.size);
gst_buffer_fill (inbuffer, 0, caps_header, GST_DP_HEADER_LENGTH);
i = GST_DP_HEADER_LENGTH;
gst_buffer_fill (inbuffer, i, caps_payload, payload_len);
i += payload_len;
gst_buffer_fill (inbuffer, i, buf_header, GST_DP_HEADER_LENGTH);
i += GST_DP_HEADER_LENGTH;
- gst_buffer_fill (inbuffer, i, data, size);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_fill (inbuffer, i, map.data, map.size);
+ gst_buffer_unmap (buffer, &map);
gst_caps_unref (caps);
gst_buffer_unref (buffer);
diff --git a/tests/check/elements/gdppay.c b/tests/check/elements/gdppay.c
index ea0f1bd0c..84384eaec 100644
--- a/tests/check/elements/gdppay.c
+++ b/tests/check/elements/gdppay.c
@@ -466,8 +466,7 @@ GST_START_TEST (test_crc)
GstEvent *event;
gchar *caps_string;
gint length;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
guint16 crc_calculated, crc_read;
gdppay = setup_gdppay ();
@@ -508,18 +507,18 @@ GST_START_TEST (test_crc)
/* verify the header checksum */
/* CRC's start at 58 in the header */
outbuffer = gst_buffer_make_writable (outbuffer);
- 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);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READWRITE);
+ crc_calculated = gst_dp_crc (map.data, 58);
+ crc_read = GST_READ_UINT16_BE (map.data + 58);
fail_unless_equals_int (crc_calculated, crc_read);
/* change a byte in the header and verify that the checksum now fails */
- data[0] = 0xff;
- crc_calculated = gst_dp_crc (data, 58);
+ map.data[0] = 0xff;
+ crc_calculated = gst_dp_crc (map.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_unmap (outbuffer, &map);
gst_buffer_unref (outbuffer);
/* second buffer is the serialized caps;
diff --git a/tests/check/pipelines/streamheader.c b/tests/check/pipelines/streamheader.c
index 052a3b47a..69dc29ae2 100644
--- a/tests/check/pipelines/streamheader.c
+++ b/tests/check/pipelines/streamheader.c
@@ -130,10 +130,9 @@ static GstPadProbeReturn
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
- guint8 *data;
- gsize size;
+ GstMapInfo map;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
GstCaps *caps;
@@ -155,27 +154,26 @@ buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
for (i = 0; i < 3; ++i) {
GValue *val;
- guint8 *data2;
- gsize size2;
+ GstMapInfo map2;
val = &g_array_index (buffers, GValue, i);
buf = g_value_peek_pointer (val);
fail_unless (GST_IS_BUFFER (buf));
- data2 = gst_buffer_map (buf, &size2, NULL, GST_MAP_READ);
- if (size2 == size) {
- if (memcmp (data2, data, size) == 0) {
+ gst_buffer_map (buf, &map2, GST_MAP_READ);
+ if (map2.size == map.size) {
+ if (memcmp (map2.data, map.data, map.size) == 0) {
found = TRUE;
}
}
- gst_buffer_unmap (buf, data2, size2);
+ gst_buffer_unmap (buf, &map2);
}
fail_unless (found, "Did not find incoming IN_CAPS buffer %p on caps",
buffer);
gst_caps_unref (caps);
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return TRUE;
}