summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/libvisual/visual.c9
-rw-r--r--ext/ogg/gstoggaviparse.c15
-rw-r--r--ext/ogg/gstoggmux.c53
-rw-r--r--ext/ogg/gstoggparse.c6
-rw-r--r--ext/ogg/gstoggstream.c14
-rw-r--r--ext/ogg/gstogmparse.c28
-rw-r--r--ext/pango/gstbasetextoverlay.c18
-rw-r--r--ext/pango/gsttextrender.c14
-rw-r--r--ext/theora/gsttheoradec.c22
-rw-r--r--ext/theora/gsttheoraenc.c12
-rw-r--r--ext/theora/gsttheoraparse.c21
-rw-r--r--ext/vorbis/gstvorbisdec.c24
-rw-r--r--ext/vorbis/gstvorbisdeclib.h13
-rw-r--r--ext/vorbis/gstvorbisenc.c13
-rw-r--r--ext/vorbis/gstvorbisparse.c43
-rw-r--r--ext/vorbis/gstvorbistag.c9
-rw-r--r--gst-libs/gst/audio/audio.c11
-rw-r--r--gst-libs/gst/audio/gstaudiobasesink.c10
-rw-r--r--gst-libs/gst/audio/gstaudiobasesrc.c8
-rw-r--r--gst-libs/gst/riff/riff-media.c18
-rw-r--r--gst-libs/gst/riff/riff-read.c133
-rw-r--r--gst-libs/gst/rtp/gstrtcpbuffer.c100
-rw-r--r--gst-libs/gst/rtp/gstrtcpbuffer.h4
-rw-r--r--gst-libs/gst/rtp/gstrtpbuffer.c121
-rw-r--r--gst-libs/gst/rtp/gstrtpbuffer.h4
-rw-r--r--gst-libs/gst/tag/gstexiftag.c123
-rw-r--r--gst-libs/gst/tag/gstvorbistag.c19
-rw-r--r--gst-libs/gst/tag/gstxmptag.c7
-rw-r--r--gst-libs/gst/tag/id3v2.c40
-rw-r--r--gst-libs/gst/tag/tags.c16
-rw-r--r--gst-libs/gst/video/gstvideometa.c40
-rw-r--r--gst-libs/gst/video/gstvideometa.h10
-rw-r--r--gst-libs/gst/video/video.c25
-rw-r--r--gst-libs/gst/video/video.h2
-rw-r--r--gst/adder/gstadder.c20
-rw-r--r--gst/audioconvert/gstaudioconvert.c22
-rw-r--r--gst/audiorate/gstaudiorate.c5
-rw-r--r--gst/audioresample/gstaudioresample.c49
-rw-r--r--gst/audiotestsrc/gstaudiotestsrc.c8
-rw-r--r--gst/gdp/dataprotocol.c11
-rw-r--r--gst/gdp/gstgdpdepay.c8
-rw-r--r--gst/gio/gstgiobasesink.c18
-rw-r--r--gst/gio/gstgiobasesrc.c8
-rw-r--r--gst/subparse/gstssaparse.c52
-rw-r--r--gst/subparse/gstsubparse.c11
-rw-r--r--gst/tcp/gstmultisocketsink.c13
-rw-r--r--gst/tcp/gsttcpclientsink.c21
-rw-r--r--gst/tcp/gsttcpclientsrc.c14
-rw-r--r--gst/tcp/gsttcpserversrc.c14
-rw-r--r--gst/videoconvert/gstvideoconvert.c8
-rw-r--r--gst/volume/gstvolume.c22
-rw-r--r--tests/check/elements/audioresample.c57
-rw-r--r--tests/check/elements/gdpdepay.c12
-rw-r--r--tests/check/elements/gdppay.c15
-rw-r--r--tests/check/elements/playbin.c17
-rw-r--r--tests/check/elements/subparse.c34
-rw-r--r--tests/check/elements/textoverlay.c15
-rw-r--r--tests/check/elements/videoscale.c17
-rw-r--r--tests/check/elements/videotestsrc.c9
-rw-r--r--tests/check/elements/volume.c404
-rw-r--r--tests/check/elements/vorbistag.c12
-rw-r--r--tests/check/gst/typefindfunctions.c22
-rw-r--r--tests/check/libs/audio.c83
-rw-r--r--tests/check/libs/audiocdsrc.c5
-rw-r--r--tests/check/libs/rtp.c35
-rw-r--r--tests/check/libs/tag.c26
-rw-r--r--tests/check/libs/video.c28
-rw-r--r--tests/check/libs/xmpwriter.c15
-rw-r--r--tests/check/pipelines/streamheader.c18
-rw-r--r--tests/examples/app/appsrc_ex.c10
-rw-r--r--tests/examples/seek/jsseek.c9
-rw-r--r--tests/examples/seek/seek.c9
-rw-r--r--tests/examples/snapshot/snapshot.c9
-rw-r--r--tests/icles/playbin-text.c9
74 files changed, 1081 insertions, 1098 deletions
diff --git a/ext/libvisual/visual.c b/ext/libvisual/visual.c
index 93ce60082..bacd80e8a 100644
--- a/ext/libvisual/visual.c
+++ b/ext/libvisual/visual.c
@@ -716,8 +716,7 @@ gst_visual_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
gboolean need_skip;
const guint16 *data;
guint64 dist, timestamp;
- guint8 *outdata;
- gsize outsize;
+ GstMapInfo outmap;
GST_DEBUG_OBJECT (visual, "processing buffer");
@@ -855,12 +854,12 @@ gst_visual_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
goto beach;
}
}
- outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
- visual_video_set_buffer (visual->video, outdata);
+ gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
+ visual_video_set_buffer (visual->video, outmap.data);
visual_audio_analyze (visual->audio);
visual_actor_run (visual->actor, visual->audio);
visual_video_set_buffer (visual->video, NULL);
- gst_buffer_unmap (outbuf, outdata, outsize);
+ gst_buffer_unmap (outbuf, &outmap);
GST_DEBUG_OBJECT (visual, "rendered one frame");
gst_adapter_unmap (visual->adapter);
diff --git a/ext/ogg/gstoggaviparse.c b/ext/ogg/gstoggaviparse.c
index 0d635d212..cd5e95ab3 100644
--- a/ext/ogg/gstoggaviparse.c
+++ b/ext/ogg/gstoggaviparse.c
@@ -197,8 +197,9 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
GstStructure *structure;
const GValue *codec_data;
GstBuffer *buffer;
- guint8 *data, *ptr;
- gsize size, left;
+ GstMapInfo map;
+ guint8 *ptr;
+ gsize left;
guint32 sizes[3];
GstCaps *outcaps;
gint i, offs;
@@ -222,10 +223,10 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
/* first 22 bytes are bits_per_sample, channel_mask, GUID
* Then we get 3 LE guint32 with the 3 header sizes
* then we get the bytes of the 3 headers. */
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
- ptr = data;
- left = size;
+ ptr = map.data;
+ left = map.size;
GST_LOG_OBJECT (ogg, "configuring codec_data of size %" G_GSIZE_FORMAT, left);
@@ -267,7 +268,7 @@ gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps)
offs += sizes[i];
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return TRUE;
@@ -285,7 +286,7 @@ wrong_format:
buffer_too_small:
{
GST_DEBUG_OBJECT (ogg, "codec_data is too small");
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return FALSE;
}
}
diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c
index 9a614500f..f56a90618 100644
--- a/ext/ogg/gstoggmux.c
+++ b/ext/ogg/gstoggmux.c
@@ -790,8 +790,8 @@ gst_ogg_mux_decorate_buffer (GstOggMux * ogg_mux, GstOggPadData * pad,
gint64 duration, granule, limit;
GstClockTime next_time;
GstClockTimeDiff diff;
+ GstMapInfo map;
ogg_packet packet;
- gsize size;
/* ensure messing with metadata is ok */
buf = gst_buffer_make_writable (buf);
@@ -813,10 +813,11 @@ gst_ogg_mux_decorate_buffer (GstOggMux * ogg_mux, GstOggPadData * pad,
pad->map.granulerate_n <= 0 || pad->map.granulerate_d <= 0)
goto no_granule;
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
duration = gst_ogg_stream_get_packet_duration (&pad->map, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
/* give up if no duration can be determined, relying on upstream */
if (G_UNLIKELY (duration < 0)) {
@@ -946,10 +947,11 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux, gboolean * popped)
/* and we have one */
ogg_packet packet;
gboolean is_header;
- gsize size;
+ GstMapInfo map;
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
/* if we're not yet in data mode, ensure we're setup on the first packet */
if (!pad->have_type) {
@@ -989,7 +991,7 @@ gst_ogg_mux_queue_pads (GstOggMux * ogg_mux, gboolean * popped)
else /* fallback (FIXME 0.11: remove IN_CAPS hack) */
is_header = GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
if (is_header) {
GST_DEBUG_OBJECT (ogg_mux,
@@ -1160,12 +1162,14 @@ gst_ogg_mux_submit_skeleton_header_packet (GstOggMux * mux,
ogg_stream_state * os, GstBuffer * buf, gboolean bos, gboolean eos)
{
ogg_packet packet;
- gsize size;
+ GstMapInfo map;
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
gst_ogg_mux_create_header_packet_with_flags (&packet, bos, eos);
ogg_stream_packetin (os, &packet);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
}
@@ -1354,7 +1358,7 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstCaps *caps;
GstStructure *structure;
GstBuffer *hbuf;
- gsize size;
+ GstMapInfo map;
pad = (GstOggPadData *) walk->data;
thepad = pad->collect.pad;
@@ -1383,15 +1387,16 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
}
/* create a packet from the buffer */
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
gst_ogg_mux_create_header_packet (&packet, pad);
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
GST_LOG_OBJECT (thepad, "flushing out BOS page");
@@ -1452,19 +1457,20 @@ gst_ogg_mux_send_headers (GstOggMux * mux)
GstBuffer *buf = GST_BUFFER (hwalk->data);
ogg_packet packet;
ogg_page page;
- gsize size;
+ GstMapInfo map;
hwalk = hwalk->next;
/* create a packet from the buffer */
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
gst_ogg_mux_create_header_packet (&packet, pad);
/* swap the packet in */
ogg_stream_packetin (&pad->map.stream, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
/* if last header, flush page */
@@ -1655,7 +1661,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GstOggPadData *pad = ogg_mux->pulling;
gint64 duration;
gboolean force_flush;
- gsize size;
+ GstMapInfo map;
GST_LOG_OBJECT (ogg_mux->pulling->collect.pad, "pulling from pad");
@@ -1679,8 +1685,9 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
}
/* create a packet from the buffer */
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
if (packet.granulepos == -1)
packet.granulepos = 0;
@@ -1770,7 +1777,7 @@ gst_ogg_mux_process_best_pad (GstOggMux * ogg_mux, GstOggPadData * best)
GST_DEBUG_OBJECT (pad->collect.pad, "swapping in BOS packet");
ogg_stream_packetin (&pad->map.stream, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
pad->data_pushed = TRUE;
gp_time = GST_BUFFER_OFFSET (pad->buffer);
diff --git a/ext/ogg/gstoggparse.c b/ext/ogg/gstoggparse.c
index eb8e0b988..a0e9cfb3c 100644
--- a/ext/ogg/gstoggparse.c
+++ b/ext/ogg/gstoggparse.c
@@ -288,11 +288,10 @@ static GstFlowReturn
gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
{
gsize size;
- guint8 *data;
gchar *oggbuffer;
GstFlowReturn ret = GST_FLOW_OK;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ size = gst_buffer_get_size (buffer);
GST_DEBUG_OBJECT (ogg, "submitting %" G_GSIZE_FORMAT " bytes", size);
if (G_UNLIKELY (size == 0))
@@ -306,7 +305,7 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
goto done;
}
- memcpy (oggbuffer, data, size);
+ size = gst_buffer_extract (buffer, 0, oggbuffer, size);
if (G_UNLIKELY (ogg_sync_wrote (&ogg->sync, size) < 0)) {
GST_ELEMENT_ERROR (ogg, STREAM, DECODE, (NULL),
("failed to write %" G_GSIZE_FORMAT " bytes to the sync buffer", size));
@@ -314,7 +313,6 @@ gst_ogg_parse_submit_buffer (GstOggParse * ogg, GstBuffer * buffer)
}
done:
- gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c
index 2811fc63a..44af167fe 100644
--- a/ext/ogg/gstoggstream.c
+++ b/ext/ogg/gstoggstream.c
@@ -2188,8 +2188,7 @@ gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
const GValue *streamheader;
const GValue *first_element;
ogg_packet packet;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gboolean ret;
GST_INFO ("Checking streamheader on caps %" GST_PTR_FORMAT, caps);
@@ -2228,21 +2227,20 @@ gst_ogg_stream_setup_map_from_caps_headers (GstOggStream * pad,
return FALSE;
}
- data = gst_buffer_map (buf, &size, 0, GST_MAP_READ);
- if (data == NULL || size == 0) {
+ if (!gst_buffer_map (buf, &map, GST_MAP_READ) || map.size == 0) {
GST_ERROR ("invalid first streamheader buffer");
return FALSE;
}
- GST_MEMDUMP ("streamheader", data, size);
+ GST_MEMDUMP ("streamheader", map.data, map.size);
- packet.packet = data;
- packet.bytes = size;
+ packet.packet = map.data;
+ packet.bytes = map.size;
GST_INFO ("Found headers on caps, using those to determine type");
ret = gst_ogg_stream_setup_map (pad, &packet);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
return ret;
}
diff --git a/ext/ogg/gstogmparse.c b/ext/ogg/gstogmparse.c
index 2d2115b24..2dd880550 100644
--- a/ext/ogg/gstogmparse.c
+++ b/ext/ogg/gstogmparse.c
@@ -717,17 +717,18 @@ gst_ogm_parse_comment_packet (GstOgmParse * ogm, GstBuffer * buf)
static void
gst_ogm_text_parse_strip_trailing_zeroes (GstOgmParse * ogm, GstBuffer * buf)
{
- guint8 *data;
+ GstMapInfo map;
gsize size;
g_assert (gst_buffer_is_writable (buf));
/* zeroes are not valid UTF-8 characters, so strip them from output */
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
- while (size > 0 && data[size - 1] == '\0') {
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ size = map.size;
+ while (size > 0 && map.data[size - 1] == '\0') {
--size;
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
}
static GstFlowReturn
@@ -845,18 +846,17 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstOgmParse *ogm = GST_OGM_PARSE (parent);
- guint8 *data;
- gsize size;
+ GstMapInfo map;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size < 1)
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ if (map.size < 1)
goto buffer_too_small;
- GST_LOG_OBJECT (ogm, "Packet with start code 0x%02x", data[0]);
+ GST_LOG_OBJECT (ogm, "Packet with start code 0x%02x", map.data[0]);
- switch (data[0]) {
+ switch (map.data[0]) {
case 0x01:{
- ret = gst_ogm_parse_stream_header (ogm, data + 1, size - 1);
+ ret = gst_ogm_parse_stream_header (ogm, map.data + 1, map.size - 1);
break;
}
case 0x03:{
@@ -864,12 +864,12 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
break;
}
default:{
- ret = gst_ogm_parse_data_packet (ogm, buf, data, size);
+ ret = gst_ogm_parse_data_packet (ogm, buf, map.data, map.size);
break;
}
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
if (ret != GST_FLOW_OK) {
@@ -882,7 +882,7 @@ gst_ogm_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
buffer_too_small:
{
GST_ELEMENT_ERROR (ogm, STREAM, DECODE, (NULL), ("buffer too small"));
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c
index 848348e75..e96669d9a 100644
--- a/ext/pango/gstbasetextoverlay.c
+++ b/ext/pango/gstbasetextoverlay.c
@@ -2612,13 +2612,13 @@ wait_for_text_buf:
/* Push the video frame */
ret = gst_pad_push (overlay->srcpad, buffer);
} else {
- gchar *in_text, *otext;
- gsize in_size, osize;
+ GstMapInfo map;
+ gchar *in_text;
+ gsize in_size;
- otext =
- gst_buffer_map (overlay->text_buffer, &osize, NULL, GST_MAP_READ);
- in_text = otext;
- in_size = osize;
+ gst_buffer_map (overlay->text_buffer, &map, GST_MAP_READ);
+ in_text = (gchar *) map.data;
+ in_size = map.size;
/* g_markup_escape_text() absolutely requires valid UTF8 input, it
* might crash otherwise. We don't fall back on GST_SUBTITLE_ENCODING
@@ -2652,11 +2652,11 @@ wait_for_text_buf:
GST_DEBUG_OBJECT (overlay, "No text to render (empty buffer)");
gst_base_text_overlay_render_text (overlay, " ", 1);
}
- gst_buffer_unmap (overlay->text_buffer, otext, osize);
-
- if (in_text != otext)
+ if (in_text != (gchar *) map.data)
g_free (in_text);
+ gst_buffer_unmap (overlay->text_buffer, &map);
+
GST_OBJECT_UNLOCK (overlay);
ret = gst_base_text_overlay_push_frame (overlay, buffer);
diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c
index a2b0b7c17..8c60c099a 100644
--- a/ext/pango/gsttextrender.c
+++ b/ext/pango/gsttextrender.c
@@ -471,6 +471,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
GstFlowReturn ret;
GstBuffer *outbuf;
GstCaps *caps = NULL, *padcaps;
+ GstMapInfo map;
guint8 *data;
gsize size;
gint n;
@@ -478,7 +479,9 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
render = GST_TEXT_RENDER (parent);
- data = gst_buffer_map (inbuf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (inbuf, &map, GST_MAP_READ);
+ data = map.data;
+ size = map.size;
/* somehow pango barfs over "\0" buffers... */
while (size > 0 &&
@@ -491,7 +494,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
GST_DEBUG ("rendering '%*s'", (gint) size, data);
pango_layout_set_markup (render->layout, (gchar *) data, size);
gst_text_render_render_pangocairo (render);
- gst_buffer_unmap (inbuf, data, size);
+ gst_buffer_unmap (inbuf, &map);
gst_text_render_check_argb (render);
@@ -517,7 +520,10 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
outbuf = gst_buffer_new_and_alloc (render->width * render->height * 4);
gst_buffer_copy_into (outbuf, inbuf, GST_BUFFER_COPY_TIMESTAMPS, 0, -1);
- data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
+
+ gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+ data = map.data;
+ size = map.size;
if (render->use_ARGB) {
memset (data, 0, render->width * render->height * 4);
@@ -566,7 +572,7 @@ gst_text_render_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
render->width * 4);
}
}
- gst_buffer_unmap (outbuf, data, size);
+ gst_buffer_unmap (outbuf, &map);
ret = gst_pad_push (render->srcpad, outbuf);
diff --git a/ext/theora/gsttheoradec.c b/ext/theora/gsttheoradec.c
index 5370c3b0a..d15738bf1 100644
--- a/ext/theora/gsttheoradec.c
+++ b/ext/theora/gsttheoradec.c
@@ -691,17 +691,18 @@ theora_dec_setcaps (GstTheoraDec * dec, GstCaps * caps)
if ((codec_data = gst_structure_get_value (s, "codec_data"))) {
if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
GstBuffer *buffer;
- guint8 *data, *ptr;
- gsize size, left;
+ GstMapInfo map;
+ guint8 *ptr;
+ gsize left;
guint offset;
buffer = gst_value_get_buffer (codec_data);
offset = 0;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
- ptr = data;
- left = size;
+ ptr = map.data;
+ left = map.size;
while (left > 2) {
guint psize;
@@ -731,7 +732,7 @@ theora_dec_setcaps (GstTheoraDec * dec, GstCaps * caps)
ptr += psize;
offset += psize;
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
}
}
@@ -1354,11 +1355,12 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
ogg_packet packet;
GstFlowReturn result = GST_FLOW_OK;
GstClockTime timestamp, duration;
- gsize size;
+ GstMapInfo map;
/* make ogg_packet out of the buffer */
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
packet.granulepos = -1;
packet.packetno = 0; /* we don't really care */
packet.b_o_s = dec->have_header ? 0 : 1;
@@ -1387,7 +1389,7 @@ theora_dec_decode_buffer (GstTheoraDec * dec, GstBuffer * buf)
result = theora_handle_data_packet (dec, &packet, timestamp, duration);
}
done:
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
return result;
}
diff --git a/ext/theora/gsttheoraenc.c b/ext/theora/gsttheoraenc.c
index 1d5012889..00ecd6952 100644
--- a/ext/theora/gsttheoraenc.c
+++ b/ext/theora/gsttheoraenc.c
@@ -1086,21 +1086,21 @@ theora_enc_read_multipass_cache (GstTheoraEnc * enc)
while (!done) {
if (gst_adapter_available (enc->multipass_cache_adapter) == 0) {
- guint8 *data;
- gsize size;
+ GstMapInfo map;
cache_buf = gst_buffer_new_and_alloc (512);
- data = gst_buffer_map (cache_buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (cache_buf, &map, GST_MAP_READ);
stat = g_io_channel_read_chars (enc->multipass_cache_fd,
- (gchar *) data, size, &bytes_read, NULL);
+ (gchar *) map.data, map.size, &bytes_read, NULL);
if (bytes_read <= 0) {
- gst_buffer_unmap (cache_buf, data, 0);
+ gst_buffer_unmap (cache_buf, &map);
gst_buffer_unref (cache_buf);
break;
} else {
- gst_buffer_unmap (cache_buf, data, bytes_read);
+ gst_buffer_unmap (cache_buf, &map);
+ gst_buffer_resize (cache_buf, 0, bytes_read);
gst_adapter_push (enc->multipass_cache_adapter, cache_buf);
}
}
diff --git a/ext/theora/gsttheoraparse.c b/ext/theora/gsttheoraparse.c
index d3314dc94..b3d1d8ac3 100644
--- a/ext/theora/gsttheoraparse.c
+++ b/ext/theora/gsttheoraparse.c
@@ -300,20 +300,21 @@ theora_parse_set_streamheader (GstTheoraParse * parse)
ogg_packet packet;
GstBuffer *buf;
int ret;
- gsize size;
+ GstMapInfo map;
buf = parse->streamheader[i];
if (buf == NULL)
continue;
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
packet.packetno = i + 1;
packet.e_o_s = 0;
packet.b_o_s = (i == 0);
ret = th_decode_headerin (&parse->info, &parse->comment, &setup, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
if (ret < 0) {
GST_WARNING_OBJECT (parse, "Failed to decode Theora header %d: %d\n",
i + 1, ret);
@@ -645,19 +646,19 @@ theora_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstFlowReturn ret;
GstTheoraParse *parse;
- guint8 *data, header;
- gsize size;
+ GstMapInfo map;
+ guint8 header;
gboolean have_header;
parse = GST_THEORA_PARSE (parent);
have_header = FALSE;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- header = data[0];
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ header = map.data[0];
+ gst_buffer_unmap (buffer, &map);
- if (size >= 1) {
+ if (map.size >= 1) {
if (header & 0x80)
have_header = TRUE;
}
diff --git a/ext/vorbis/gstvorbisdec.c b/ext/vorbis/gstvorbisdec.c
index cb4313d71..8c5a3284e 100644
--- a/ext/vorbis/gstvorbisdec.c
+++ b/ext/vorbis/gstvorbisdec.c
@@ -442,13 +442,14 @@ vorbis_dec_handle_header_buffer (GstVorbisDec * vd, GstBuffer * buffer)
ogg_packet *packet;
ogg_packet_wrapper packet_wrapper;
GstFlowReturn ret;
+ GstMapInfo map;
- gst_ogg_packet_wrapper_map (&packet_wrapper, buffer);
+ gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map);
packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
ret = vorbis_handle_header_packet (vd, packet);
- gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
+ gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map);
return ret;
}
@@ -518,7 +519,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
guint sample_count;
GstBuffer *out = NULL;
GstFlowReturn result;
- guint8 *data;
+ GstMapInfo map;
gsize size;
if (G_UNLIKELY (!vd->initialized)) {
@@ -563,10 +564,10 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
/* alloc buffer for it */
out = gst_buffer_new_allocate (NULL, size, 0);
- data = gst_buffer_map (out, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (out, &map, GST_MAP_WRITE);
/* get samples ready for reading now, should be sample_count */
#ifdef USE_TREMOLO
- if (G_UNLIKELY (vorbis_dsp_pcmout (&vd->vd, data, sample_count) !=
+ if (G_UNLIKELY (vorbis_dsp_pcmout (&vd->vd, map.data, sample_count) !=
sample_count))
#else
if (G_UNLIKELY (vorbis_synthesis_pcmout (&vd->vd, &pcm) != sample_count))
@@ -575,17 +576,17 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet,
#ifdef USE_TREMOLO
if (vd->info.channels < 9)
- gst_audio_reorder_channels (data, size, GST_VORBIS_AUDIO_FORMAT,
+ gst_audio_reorder_channels (map.data, map.size, GST_VORBIS_AUDIO_FORMAT,
vd->info.channels, gst_vorbis_channel_positions[vd->info.channels - 1],
gst_vorbis_default_channel_positions[vd->info.channels - 1]);
#else
/* copy samples in buffer */
- vd->copy_samples ((vorbis_sample_t *) data, pcm,
+ vd->copy_samples ((vorbis_sample_t *) map.data, pcm,
sample_count, vd->info.channels);
#endif
- GST_LOG_OBJECT (vd, "setting output size to %" G_GSIZE_FORMAT, size);
- gst_buffer_unmap (out, data, size);
+ GST_LOG_OBJECT (vd, "have output size of %" G_GSIZE_FORMAT, size);
+ gst_buffer_unmap (out, &map);
done:
/* whether or not data produced, consume one frame and advance time */
@@ -633,6 +634,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
ogg_packet *packet;
ogg_packet_wrapper packet_wrapper;
GstFlowReturn result = GST_FLOW_OK;
+ GstMapInfo map;
GstVorbisDec *vd = GST_VORBIS_DEC (dec);
/* no draining etc */
@@ -641,7 +643,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
GST_LOG_OBJECT (vd, "got buffer %p", buffer);
/* make ogg_packet out of the buffer */
- gst_ogg_packet_wrapper_map (&packet_wrapper, buffer);
+ gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map);
packet = gst_ogg_packet_from_wrapper (&packet_wrapper);
/* set some more stuff */
packet->granulepos = -1;
@@ -680,7 +682,7 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
done:
GST_LOG_OBJECT (vd, "unmap buffer %p", buffer);
- gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer);
+ gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map);
return result;
diff --git a/ext/vorbis/gstvorbisdeclib.h b/ext/vorbis/gstvorbisdeclib.h
index 21dbaaca2..e8e644509 100644
--- a/ext/vorbis/gstvorbisdeclib.h
+++ b/ext/vorbis/gstvorbisdeclib.h
@@ -63,19 +63,18 @@ gst_ogg_packet_size (ogg_packet * p)
}
static inline void
-gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer)
+gst_ogg_packet_wrapper_map (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
{
- gsize size;
-
gst_buffer_ref (buffer);
- packet->packet = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- packet->bytes = size;
+ gst_buffer_map (buffer, map, GST_MAP_READ);
+ packet->packet = map->data;
+ packet->bytes = map->size;
}
static inline void
-gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer)
+gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
{
- gst_buffer_unmap (buffer, packet->packet, packet->bytes);
+ gst_buffer_unmap (buffer, map);
gst_buffer_unref (buffer);
}
diff --git a/ext/vorbis/gstvorbisenc.c b/ext/vorbis/gstvorbisenc.c
index e95d15df8..caf249e5e 100644
--- a/ext/vorbis/gstvorbisenc.c
+++ b/ext/vorbis/gstvorbisenc.c
@@ -678,9 +678,9 @@ gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
{
GstVorbisEnc *vorbisenc;
GstFlowReturn ret = GST_FLOW_OK;
- gfloat *data, *ptr;
+ GstMapInfo map;
+ gfloat *ptr;
gulong size;
- gsize bsize;
gulong i, j;
float **vorbis_buffer;
GstBuffer *buf1, *buf2, *buf3;
@@ -747,12 +747,11 @@ gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
if (!buffer)
return gst_vorbis_enc_clear (vorbisenc);
- data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buffer, &map, GST_MAP_WRITE);
/* data to encode */
- size = bsize / (vorbisenc->channels * sizeof (float));
-
- ptr = data;
+ size = map.size / (vorbisenc->channels * sizeof (float));
+ ptr = (gfloat *) map.data;
/* expose the buffer to submit data */
vorbis_buffer = vorbis_analysis_buffer (&vorbisenc->vd, size);
@@ -779,7 +778,7 @@ gst_vorbis_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
/* tell the library how much we actually submitted */
vorbis_analysis_wrote (&vorbisenc->vd, size);
- gst_buffer_unmap (buffer, data, bsize);
+ gst_buffer_unmap (buffer, &map);
GST_LOG_OBJECT (vorbisenc, "wrote %lu samples to vorbis", size);
diff --git a/ext/vorbis/gstvorbisparse.c b/ext/vorbis/gstvorbisparse.c
index 7de09a993..c992c6d54 100644
--- a/ext/vorbis/gstvorbisparse.c
+++ b/ext/vorbis/gstvorbisparse.c
@@ -187,7 +187,7 @@ vorbis_parse_push_headers (GstVorbisParse * parse)
GstCaps *caps;
GstBuffer *outbuf, *outbuf1, *outbuf2, *outbuf3;
ogg_packet packet;
- gsize size;
+ GstMapInfo map;
/* get the headers into the caps, passing them to vorbis as we go */
caps = gst_caps_make_writable (gst_pad_query_caps (parse->srcpad, NULL));
@@ -197,37 +197,39 @@ vorbis_parse_push_headers (GstVorbisParse * parse)
gst_caps_unref (caps);
outbuf = GST_BUFFER_CAST (parse->streamheader->data);
- packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (outbuf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
packet.packetno = 1;
packet.e_o_s = 0;
packet.b_o_s = 1;
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
- gst_buffer_unmap (outbuf, packet.packet, size);
+ gst_buffer_unmap (outbuf, &map);
parse->sample_rate = parse->vi.rate;
outbuf1 = outbuf;
outbuf = GST_BUFFER_CAST (parse->streamheader->next->data);
- packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (outbuf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
packet.packetno = 2;
packet.e_o_s = 0;
packet.b_o_s = 0;
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
- gst_buffer_unmap (outbuf, packet.packet, size);
+ gst_buffer_unmap (outbuf, &map);
outbuf2 = outbuf;
outbuf = GST_BUFFER_CAST (parse->streamheader->next->next->data);
- packet.packet = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (outbuf, &map, GST_MAP_READ);
+ packet.packet = map.data;
packet.granulepos = GST_BUFFER_OFFSET_END (outbuf);
packet.packetno = 3;
packet.e_o_s = 0;
packet.b_o_s = 0;
vorbis_synthesis_headerin (&parse->vi, &parse->vc, &packet);
- gst_buffer_unmap (outbuf, packet.packet, size);
+ gst_buffer_unmap (outbuf, &map);
outbuf3 = outbuf;
/* first process queued events */
@@ -350,18 +352,20 @@ vorbis_parse_queue_buffer (GstVorbisParse * parse, GstBuffer * buf)
GstFlowReturn ret = GST_FLOW_OK;
long blocksize;
ogg_packet packet;
- gsize size;
+ GstMapInfo map;
buf = gst_buffer_make_writable (buf);
- packet.packet = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- packet.bytes = size;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ packet.packet = map.data;
+ packet.bytes = map.size;
+ GST_DEBUG ("%p, %d", map.data, map.size);
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
packet.packetno = parse->packetno + parse->buffer_queue->length;
packet.e_o_s = 0;
blocksize = vorbis_packet_blocksize (&parse->vi, &packet);
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
/* temporarily store the sample count in OFFSET -- we overwrite this later */
@@ -384,19 +388,18 @@ static GstFlowReturn
vorbis_parse_parse_packet (GstVorbisParse * parse, GstBuffer * buf)
{
GstFlowReturn ret;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gboolean have_header;
parse->packetno++;
have_header = FALSE;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size >= 1) {
- if (data[0] >= 0x01 && data[0] <= 0x05)
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ if (map.size >= 1) {
+ if (map.data[0] >= 0x01 && map.data[0] <= 0x05)
have_header = TRUE;
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
if (have_header) {
if (!parse->streamheader_sent) {
diff --git a/ext/vorbis/gstvorbistag.c b/ext/vorbis/gstvorbistag.c
index 60dc48544..9dd203860 100644
--- a/ext/vorbis/gstvorbistag.c
+++ b/ext/vorbis/gstvorbistag.c
@@ -95,15 +95,14 @@ gst_vorbis_tag_parse_packet (GstVorbisParse * parse, GstBuffer * buffer)
GstVorbisTag *tagger;
gchar *encoder = NULL;
GstBuffer *new_buf;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gboolean do_parse = FALSE;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
/* just pass everything except the comments packet */
- if (size >= 1 && data[0] != 0x03)
+ if (map.size >= 1 && map.data[0] != 0x03)
do_parse = TRUE;
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
if (do_parse) {
return GST_VORBIS_PARSE_CLASS (parent_class)->parse_packet (parse, buffer);
diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c
index cdf39d4f9..646e24cc8 100644
--- a/gst-libs/gst/audio/audio.c
+++ b/gst-libs/gst/audio/audio.c
@@ -1067,18 +1067,19 @@ gst_audio_buffer_reorder_channels (GstBuffer * buffer,
GstAudioFormat format, gint channels,
const GstAudioChannelPosition * from, const GstAudioChannelPosition * to)
{
- gsize size;
- guint8 *data;
+ GstMapInfo info;
gboolean ret;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
g_return_val_if_fail (gst_buffer_is_writable (buffer), FALSE);
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ | GST_MAP_WRITE);
+ gst_buffer_map (buffer, &info, GST_MAP_READWRITE);
- ret = gst_audio_reorder_channels (data, size, format, channels, from, to);
+ ret =
+ gst_audio_reorder_channels (info.data, info.size, format, channels, from,
+ to);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return ret;
}
diff --git a/gst-libs/gst/audio/gstaudiobasesink.c b/gst-libs/gst/audio/gstaudiobasesink.c
index 60f463631..97bc71972 100644
--- a/gst-libs/gst/audio/gstaudiobasesink.c
+++ b/gst-libs/gst/audio/gstaudiobasesink.c
@@ -1563,7 +1563,7 @@ gst_audio_base_sink_render (GstBaseSink * bsink, GstBuffer * buf)
gint64 diff, align;
guint64 ctime, cstop;
gsize offset;
- guint8 *data;
+ GstMapInfo info;
gsize size;
guint samples, written;
gint bpf, rate;
@@ -1850,11 +1850,11 @@ no_align:
/* we need to accumulate over different runs for when we get interrupted */
accum = 0;
align_next = TRUE;
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &info, GST_MAP_READ);
do {
written =
gst_audio_ring_buffer_commit (ringbuf, &sample_offset,
- data + offset, samples, out_samples, &accum);
+ info.data + offset, samples, out_samples, &accum);
GST_DEBUG_OBJECT (sink, "wrote %u of %u", written, samples);
/* if we wrote all, we're done */
@@ -1880,7 +1880,7 @@ no_align:
samples -= written;
offset += written * bpf;
} while (TRUE);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
if (align_next)
sink->next_sample = sample_offset;
@@ -1946,7 +1946,7 @@ stopping:
{
GST_DEBUG_OBJECT (sink, "preroll got interrupted: %d (%s)", ret,
gst_flow_get_name (ret));
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
goto done;
}
sync_latency_failed:
diff --git a/gst-libs/gst/audio/gstaudiobasesrc.c b/gst-libs/gst/audio/gstaudiobasesrc.c
index 3b729812a..90206c62c 100644
--- a/gst-libs/gst/audio/gstaudiobasesrc.c
+++ b/gst-libs/gst/audio/gstaudiobasesrc.c
@@ -758,7 +758,8 @@ gst_audio_base_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
GstFlowReturn ret;
GstAudioBaseSrc *src = GST_AUDIO_BASE_SRC (bsrc);
GstBuffer *buf;
- guint8 *data, *ptr;
+ GstMapInfo info;
+ guint8 *ptr;
guint samples, total_samples;
guint64 sample;
gint bpf, rate;
@@ -808,7 +809,8 @@ gst_audio_base_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
if (G_UNLIKELY (ret != GST_FLOW_OK))
goto alloc_failed;
- data = ptr = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ ptr = info.data;
do {
read = gst_audio_ring_buffer_read (ringbuffer, sample, ptr, samples);
GST_DEBUG_OBJECT (src, "read %u of %u", read, samples);
@@ -828,7 +830,7 @@ gst_audio_base_src_create (GstBaseSrc * bsrc, guint64 offset, guint length,
samples -= read;
ptr += read * bpf;
} while (TRUE);
- gst_buffer_unmap (buf, data, length);
+ gst_buffer_unmap (buf, &info);
/* mark discontinuity if needed */
if (G_UNLIKELY (sample != src->next_sample) && src->next_sample != -1) {
diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c
index f3630af68..2672a00e1 100644
--- a/gst-libs/gst/riff/riff-media.c
+++ b/gst-libs/gst/riff/riff-media.c
@@ -1493,7 +1493,7 @@ gst_riff_create_audio_caps (guint16 codec_id,
guint16 valid_bits_per_sample;
guint32 channel_mask;
guint32 subformat_guid[4];
- guint8 *data;
+ GstMapInfo info;
gsize size;
channels_max = 8;
@@ -1507,14 +1507,14 @@ gst_riff_create_audio_caps (guint16 codec_id,
return NULL;
}
- data = gst_buffer_map (strf_data, &size, NULL, GST_MAP_READ);
- valid_bits_per_sample = GST_READ_UINT16_LE (data);
- channel_mask = GST_READ_UINT32_LE (data + 2);
- subformat_guid[0] = GST_READ_UINT32_LE (data + 6);
- subformat_guid[1] = GST_READ_UINT32_LE (data + 10);
- subformat_guid[2] = GST_READ_UINT32_LE (data + 14);
- subformat_guid[3] = GST_READ_UINT32_LE (data + 18);
- gst_buffer_unmap (strf_data, data, size);
+ gst_buffer_map (strf_data, &info, GST_MAP_READ);
+ valid_bits_per_sample = GST_READ_UINT16_LE (info.data);
+ channel_mask = GST_READ_UINT32_LE (info.data + 2);
+ subformat_guid[0] = GST_READ_UINT32_LE (info.data + 6);
+ subformat_guid[1] = GST_READ_UINT32_LE (info.data + 10);
+ subformat_guid[2] = GST_READ_UINT32_LE (info.data + 14);
+ subformat_guid[3] = GST_READ_UINT32_LE (info.data + 18);
+ gst_buffer_unmap (strf_data, &info);
GST_DEBUG ("valid bps = %u", valid_bits_per_sample);
GST_DEBUG ("channel mask = 0x%08x", channel_mask);
diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c
index b3ac371ec..70baa52c2 100644
--- a/gst-libs/gst/riff/riff-read.c
+++ b/gst-libs/gst/riff/riff-read.c
@@ -52,10 +52,9 @@ gst_riff_read_chunk (GstElement * element,
{
GstBuffer *buf;
GstFlowReturn res;
- guint8 *data;
+ GstMapInfo info;
guint size;
guint64 offset = *_offset;
- gsize bsize;
g_return_val_if_fail (element != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
@@ -70,10 +69,10 @@ skip_junk:
else if (gst_buffer_get_size (buf) < size)
goto too_small;
- data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- *tag = GST_READ_UINT32_LE (data);
- size = GST_READ_UINT32_LE (data + 4);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ *tag = GST_READ_UINT32_LE (info.data);
+ size = GST_READ_UINT32_LE (info.data + 4);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
@@ -129,8 +128,8 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
{
guint size, bufsize;
guint32 fourcc;
- guint8 *data, *ptr;
- gsize bsize;
+ guint8 *ptr;
+ GstMapInfo info;
guint offset = *_offset;
g_return_val_if_fail (element != NULL, FALSE);
@@ -151,11 +150,11 @@ gst_riff_parse_chunk (GstElement * element, GstBuffer * buf,
goto too_small;
/* read header */
- data = ptr = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- ptr += offset;
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ ptr = info.data + offset;
fourcc = GST_READ_UINT32_LE (ptr);
size = GST_READ_UINT32_LE (ptr + 4);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_unmap (buf, &info);
GST_DEBUG_OBJECT (element, "fourcc=%" GST_FOURCC_FORMAT ", size=%u",
GST_FOURCC_ARGS (fourcc), size);
@@ -223,23 +222,22 @@ gboolean
gst_riff_parse_file_header (GstElement * element,
GstBuffer * buf, guint32 * doctype)
{
- guint8 *data;
+ GstMapInfo info;
guint32 tag;
- gsize size;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (doctype != NULL, FALSE);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size < 12)
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ if (info.size < 12)
goto too_small;
- tag = GST_READ_UINT32_LE (data);
+ tag = GST_READ_UINT32_LE (info.data);
if (tag != GST_RIFF_TAG_RIFF && tag != GST_RIFF_TAG_AVF0)
goto not_riff;
- *doctype = GST_READ_UINT32_LE (data + 8);
- gst_buffer_unmap (buf, data, size);
+ *doctype = GST_READ_UINT32_LE (info.data + 8);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
@@ -250,8 +248,8 @@ too_small:
{
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
("Not enough data to parse RIFF header (%" G_GSIZE_FORMAT " available,"
- " %d needed)", size, 12));
- gst_buffer_unmap (buf, data, size);
+ " %d needed)", info.size, 12));
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -260,7 +258,7 @@ not_riff:
GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL),
("Stream is no RIFF stream: %" GST_FOURCC_FORMAT,
GST_FOURCC_ARGS (tag)));
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -284,18 +282,17 @@ gst_riff_parse_strh (GstElement * element,
GstBuffer * buf, gst_riff_strh ** _strh)
{
gst_riff_strh *strh;
- guint8 *data;
- gsize size;
+ GstMapInfo info;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strh != NULL, FALSE);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size < sizeof (gst_riff_strh))
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ if (info.size < sizeof (gst_riff_strh))
goto too_small;
- strh = g_memdup (data, size);
- gst_buffer_unmap (buf, data, size);
+ strh = g_memdup (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
@@ -346,8 +343,8 @@ too_small:
{
GST_ERROR_OBJECT (element,
"Too small strh (%" G_GSIZE_FORMAT " available, %d needed)",
- size, (int) sizeof (gst_riff_strh));
- gst_buffer_unmap (buf, data, size);
+ info.size, (int) sizeof (gst_riff_strh));
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -375,19 +372,18 @@ gst_riff_parse_strf_vids (GstElement * element,
GstBuffer * buf, gst_riff_strf_vids ** _strf, GstBuffer ** data)
{
gst_riff_strf_vids *strf;
- guint8 *bdata;
- gsize size;
+ GstMapInfo info;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strf != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
- bdata = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- if (size < sizeof (gst_riff_strf_vids))
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ if (info.size < sizeof (gst_riff_strf_vids))
goto too_small;
- strf = g_memdup (bdata, size);
- gst_buffer_unmap (buf, bdata, size);
+ strf = g_memdup (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strf->size = GUINT32_FROM_LE (strf->size);
@@ -405,16 +401,16 @@ gst_riff_parse_strf_vids (GstElement * element,
/* size checking */
*data = NULL;
- if (strf->size > size) {
+ if (strf->size > info.size) {
GST_WARNING_OBJECT (element,
"strf_vids header gave %d bytes data, only %" G_GSIZE_FORMAT
- " available", strf->size, size);
- strf->size = size;
+ " available", strf->size, info.size);
+ strf->size = info.size;
}
- if (sizeof (gst_riff_strf_vids) < size) {
+ if (sizeof (gst_riff_strf_vids) < info.size) {
*data =
gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL,
- sizeof (gst_riff_strf_vids), size - sizeof (gst_riff_strf_vids));
+ sizeof (gst_riff_strf_vids), info.size - sizeof (gst_riff_strf_vids));
}
gst_buffer_unref (buf);
@@ -445,8 +441,8 @@ too_small:
{
GST_ERROR_OBJECT (element,
"Too small strf_vids (%" G_GSIZE_FORMAT " available, %d needed)",
- size, (int) sizeof (gst_riff_strf_vids));
- gst_buffer_unmap (buf, data, size);
+ info.size, (int) sizeof (gst_riff_strf_vids));
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -474,18 +470,17 @@ gst_riff_parse_strf_auds (GstElement * element,
GstBuffer * buf, gst_riff_strf_auds ** _strf, GstBuffer ** data)
{
gst_riff_strf_auds *strf;
- gsize bsize;
- guint8 *bdata;
+ GstMapInfo info;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strf != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
- bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- if (bsize < sizeof (gst_riff_strf_auds))
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ if (info.size < sizeof (gst_riff_strf_auds))
goto too_small;
- strf = g_memdup (bdata, bsize);
+ strf = g_memdup (info.data, info.size);
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
strf->format = GUINT16_FROM_LE (strf->format);
@@ -498,15 +493,15 @@ gst_riff_parse_strf_auds (GstElement * element,
/* size checking */
*data = NULL;
- if (bsize > sizeof (gst_riff_strf_auds) + 2) {
+ if (info.size > sizeof (gst_riff_strf_auds) + 2) {
gint len;
len = GST_READ_UINT16_LE (&data[16]);
- if (len + 2 + sizeof (gst_riff_strf_auds) > bsize) {
+ if (len + 2 + sizeof (gst_riff_strf_auds) > info.size) {
GST_WARNING_OBJECT (element,
"Extradata indicated %d bytes, but only %" G_GSSIZE_FORMAT
- " available", len, bsize - 2 - sizeof (gst_riff_strf_auds));
- len = bsize - 2 - sizeof (gst_riff_strf_auds);
+ " available", len, info.size - 2 - sizeof (gst_riff_strf_auds));
+ len = info.size - 2 - sizeof (gst_riff_strf_auds);
}
if (len)
*data = gst_buffer_copy_region (buf, GST_BUFFER_COPY_ALL,
@@ -525,7 +520,7 @@ gst_riff_parse_strf_auds (GstElement * element,
GST_INFO_OBJECT (element, " %" G_GSIZE_FORMAT " bytes extradata",
gst_buffer_get_size (*data));
- gst_buffer_unmap (buf, bdata, bsize);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
*_strf = strf;
@@ -537,8 +532,9 @@ too_small:
{
GST_ERROR_OBJECT (element,
"Too small strf_auds (%" G_GSIZE_FORMAT " available"
- ", %" G_GSSIZE_FORMAT " needed)", bsize, sizeof (gst_riff_strf_auds));
- gst_buffer_unmap (buf, bdata, bsize);
+ ", %" G_GSSIZE_FORMAT " needed)", info.size,
+ sizeof (gst_riff_strf_auds));
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -566,19 +562,18 @@ gst_riff_parse_strf_iavs (GstElement * element,
GstBuffer * buf, gst_riff_strf_iavs ** _strf, GstBuffer ** data)
{
gst_riff_strf_iavs *strf;
- gsize bsize;
- guint8 *bdata;
+ GstMapInfo info;
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (_strf != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
- bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- if (bsize < sizeof (gst_riff_strf_iavs))
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ if (info.size < sizeof (gst_riff_strf_iavs))
goto too_small;
- strf = g_memdup (bdata, bsize);
- gst_buffer_unmap (buf, bdata, bsize);
+ strf = g_memdup (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
@@ -614,8 +609,9 @@ too_small:
{
GST_ERROR_OBJECT (element,
"Too small strf_iavs (%" G_GSIZE_FORMAT "available"
- ", %" G_GSSIZE_FORMAT " needed)", bsize, sizeof (gst_riff_strf_iavs));
- gst_buffer_unmap (buf, bdata, bsize);
+ ", %" G_GSSIZE_FORMAT " needed)", info.size,
+ sizeof (gst_riff_strf_iavs));
+ gst_buffer_unmap (buf, &info);
gst_buffer_unref (buf);
return FALSE;
}
@@ -635,8 +631,9 @@ void
gst_riff_parse_info (GstElement * element,
GstBuffer * buf, GstTagList ** _taglist)
{
- guint8 *data, *ptr;
- gsize size, left;
+ GstMapInfo info;
+ guint8 *ptr;
+ gsize left;
guint tsize;
guint32 tag;
const gchar *type;
@@ -648,12 +645,12 @@ gst_riff_parse_info (GstElement * element,
*_taglist = NULL;
return;
}
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &info, GST_MAP_READ);
taglist = gst_tag_list_new_empty ();
- ptr = data;
- left = size;
+ ptr = info.data;
+ left = info.size;
while (left > 8) {
tag = GST_READ_UINT32_LE (ptr);
@@ -782,7 +779,7 @@ gst_riff_parse_info (GstElement * element,
*_taglist = NULL;
gst_tag_list_free (taglist);
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
return;
}
diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c
index c3b2ebbb4..4356fd7cd 100644
--- a/gst-libs/gst/rtp/gstrtcpbuffer.c
+++ b/gst-libs/gst/rtp/gstrtcpbuffer.c
@@ -204,14 +204,13 @@ gboolean
gst_rtcp_buffer_validate (GstBuffer * buffer)
{
gboolean res;
- guint8 *data;
- gsize len;
+ GstMapInfo info;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
- data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
- res = gst_rtcp_buffer_validate_data (data, len);
- gst_buffer_unmap (buffer, data, len);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
+ res = gst_rtcp_buffer_validate_data (info.data, info.size);
+ gst_buffer_unmap (buffer, &info);
return res;
}
@@ -258,12 +257,12 @@ gst_rtcp_buffer_map (GstBuffer * buffer, GstMapFlags flags,
rtcp->buffer = buffer;
rtcp->flags = flags;
- rtcp->data = gst_buffer_map (buffer, &rtcp->size, &rtcp->maxsize, flags);
+ gst_buffer_map (buffer, &rtcp->info, flags);
/* allow for expansion, e.g. adding packets, if needed */
if ((flags & GST_MAP_WRITE) != 0) {
/* adjust to max available */
- rtcp->size = rtcp->maxsize;
+ rtcp->info.size = rtcp->info.maxsize;
}
return TRUE;
@@ -282,7 +281,6 @@ gst_rtcp_buffer_map (GstBuffer * buffer, GstMapFlags flags,
gboolean
gst_rtcp_buffer_unmap (GstRTCPBuffer * rtcp)
{
- gboolean res;
GstRTCPPacket packet;
g_return_val_if_fail (rtcp != NULL, FALSE);
@@ -294,10 +292,10 @@ gst_rtcp_buffer_unmap (GstRTCPBuffer * rtcp)
/* shrink size */
gst_buffer_resize (rtcp->buffer, 0, packet.offset);
- res = gst_buffer_unmap (rtcp->buffer, rtcp->data, packet.offset);
+ gst_buffer_unmap (rtcp->buffer, &rtcp->info);
rtcp->buffer = NULL;
- return res;
+ return TRUE;
}
/**
@@ -344,8 +342,8 @@ read_packet_header (GstRTCPPacket * packet)
g_return_val_if_fail (packet != NULL, FALSE);
- data = packet->rtcp->data;
- size = packet->rtcp->size;
+ data = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
offset = packet->offset;
@@ -464,7 +462,7 @@ gst_rtcp_buffer_add_packet (GstRTCPBuffer * rtcp, GstRTCPType type,
if (gst_rtcp_buffer_get_first_packet (rtcp, packet))
while (gst_rtcp_packet_move_to_next (packet));
- size = rtcp->size;
+ size = rtcp->info.size;
/* packet->offset is now pointing to the next free offset in the buffer to
* start a compount packet. Next we figure out if we have enough free space in
@@ -497,7 +495,7 @@ gst_rtcp_buffer_add_packet (GstRTCPBuffer * rtcp, GstRTCPType type,
if (packet->offset + len >= size)
goto no_space;
- data = rtcp->data + packet->offset;
+ data = rtcp->info.data + packet->offset;
data[0] = (GST_RTCP_VERSION << 6);
data[1] = type;
@@ -546,8 +544,8 @@ gst_rtcp_packet_remove (GstRTCPPacket * packet)
offset = packet->offset + (packet->length << 2) + 4;
/* Overwrite this packet with the rest of the data */
- memmove (packet->rtcp->data + packet->offset,
- packet->rtcp->data + offset, packet->rtcp->size - offset);
+ memmove (packet->rtcp->info.data + packet->offset,
+ packet->rtcp->info.data + offset, packet->rtcp->info.size - offset);
/* try to read next header */
ret = read_packet_header (packet);
@@ -648,7 +646,7 @@ gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket * packet, guint32 * ssrc,
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_SR);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -688,7 +686,7 @@ gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket * packet, guint32 ssrc,
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_SR);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -720,7 +718,7 @@ gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket * packet)
g_return_val_if_fail (packet != NULL, 0);
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RR, 0);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -744,7 +742,7 @@ gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket * packet, guint32 ssrc)
g_return_if_fail (packet != NULL);
g_return_if_fail (packet->type == GST_RTCP_TYPE_RR);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -796,7 +794,7 @@ gst_rtcp_packet_get_rb (GstRTCPPacket * packet, guint nth, guint32 * ssrc,
g_return_if_fail (packet->type == GST_RTCP_TYPE_RR ||
packet->type == GST_RTCP_TYPE_SR);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -868,8 +866,8 @@ gst_rtcp_packet_add_rb (GstRTCPPacket * packet, guint32 ssrc,
if (packet->count >= GST_RTCP_MAX_RB_COUNT)
goto no_space;
- data = packet->rtcp->data;
- size = packet->rtcp->size;
+ data = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
/* skip header */
offset = packet->offset + 4;
@@ -1008,7 +1006,7 @@ gst_rtcp_packet_sdes_next_item (GstRTCPPacket * packet)
return FALSE;
/* move to SDES */
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += packet->offset;
/* move to item */
offset = packet->item_offset;
@@ -1054,7 +1052,7 @@ gst_rtcp_packet_sdes_get_ssrc (GstRTCPPacket * packet)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, 0);
/* move to SDES */
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += packet->offset;
/* move to item */
data += packet->item_offset;
@@ -1082,7 +1080,7 @@ gst_rtcp_packet_sdes_first_entry (GstRTCPPacket * packet)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
/* move to SDES */
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += packet->offset;
/* move to item */
offset = packet->item_offset;
@@ -1120,7 +1118,7 @@ gst_rtcp_packet_sdes_next_entry (GstRTCPPacket * packet)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
/* move to SDES */
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += packet->offset;
/* move to item */
offset = packet->item_offset;
@@ -1173,7 +1171,7 @@ gst_rtcp_packet_sdes_get_entry (GstRTCPPacket * packet,
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
/* move to SDES */
- bdata = packet->rtcp->data;
+ bdata = packet->rtcp->info.data;
bdata += packet->offset;
/* move to item */
offset = packet->item_offset;
@@ -1256,8 +1254,8 @@ gst_rtcp_packet_sdes_add_item (GstRTCPPacket * packet, guint32 ssrc)
gst_rtcp_packet_sdes_next_item (packet);
/* move to SDES */
- data = packet->rtcp->data;
- size = packet->rtcp->size;
+ data = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
data += packet->offset;
/* move to current item */
offset = packet->item_offset;
@@ -1315,8 +1313,8 @@ gst_rtcp_packet_sdes_add_entry (GstRTCPPacket * packet, GstRTCPSDESType type,
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_SDES, FALSE);
/* move to SDES */
- bdata = packet->rtcp->data;
- size = packet->rtcp->size;
+ bdata = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
bdata += packet->offset;
/* move to item */
offset = packet->item_offset;
@@ -1405,10 +1403,10 @@ gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket * packet, guint nth)
offset += packet->offset;
/* check if the packet is valid */
- if (offset + 4 > packet->rtcp->size)
+ if (offset + 4 > packet->rtcp->info.size)
return 0;
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += offset;
ssrc = GST_READ_UINT32_BE (data);
@@ -1439,8 +1437,8 @@ gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket * packet, guint32 ssrc)
if (packet->count >= GST_RTCP_MAX_BYE_SSRC_COUNT)
goto no_space;
- data = packet->rtcp->data;
- size = packet->rtcp->size;
+ data = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
/* skip header */
offset = packet->offset + 4;
@@ -1518,7 +1516,7 @@ get_reason_offset (GstRTCPPacket * packet)
offset += packet->offset;
/* check if the packet is valid */
- if (offset + 1 > packet->rtcp->size)
+ if (offset + 1 > packet->rtcp->info.size)
return 0;
return offset;
@@ -1546,7 +1544,7 @@ gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket * packet)
if (roffset == 0)
return 0;
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
return data[roffset];
}
@@ -1574,7 +1572,7 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet)
if (roffset == 0)
return NULL;
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* get length of reason string */
len = data[roffset];
@@ -1585,7 +1583,7 @@ gst_rtcp_packet_bye_get_reason (GstRTCPPacket * packet)
roffset += 1;
/* check if enough data to copy */
- if (roffset + len > packet->rtcp->size)
+ if (roffset + len > packet->rtcp->info.size)
return NULL;
return g_strndup ((gconstpointer) (data + roffset), len);
@@ -1624,8 +1622,8 @@ gst_rtcp_packet_bye_set_reason (GstRTCPPacket * packet, const gchar * reason)
if (roffset == 0)
goto no_space;
- data = packet->rtcp->data;
- size = packet->rtcp->size;
+ data = packet->rtcp->info.data;
+ size = packet->rtcp->info.size;
/* we have 1 byte length and we need to pad to 4 bytes */
padded = ((len + 1) + 3) & ~3;
@@ -1672,7 +1670,7 @@ gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket * packet)
g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB), 0);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -1699,7 +1697,7 @@ gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket * packet, guint32 ssrc)
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header */
data += packet->offset + 4;
@@ -1726,7 +1724,7 @@ gst_rtcp_packet_fb_get_media_ssrc (GstRTCPPacket * packet)
g_return_val_if_fail ((packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB), 0);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header and sender ssrc */
data += packet->offset + 8;
@@ -1753,7 +1751,7 @@ gst_rtcp_packet_fb_set_media_ssrc (GstRTCPPacket * packet, guint32 ssrc)
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* skip header and sender ssrc */
data += packet->offset + 8;
@@ -1798,7 +1796,7 @@ gst_rtcp_packet_fb_set_type (GstRTCPPacket * packet, GstRTCPFBType type)
g_return_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB);
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data[packet->offset] = (data[packet->offset] & 0xe0) | type;
packet->count = type;
@@ -1970,7 +1968,7 @@ gst_rtcp_packet_fb_get_fci_length (GstRTCPPacket * packet)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB, 0);
- data = packet->rtcp->data + packet->offset + 2;
+ data = packet->rtcp->info.data + packet->offset + 2;
return GST_READ_UINT16_BE (data) - 2;
}
@@ -1996,10 +1994,10 @@ gst_rtcp_packet_fb_set_fci_length (GstRTCPPacket * packet, guint16 wordlen)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB, FALSE);
- if (packet->rtcp->size < packet->offset + ((wordlen + 3) * 4))
+ if (packet->rtcp->info.size < packet->offset + ((wordlen + 3) * 4))
return FALSE;
- data = packet->rtcp->data + packet->offset + 2;
+ data = packet->rtcp->info.data + packet->offset + 2;
wordlen += 2;
GST_WRITE_UINT16_BE (data, wordlen);
@@ -2025,7 +2023,7 @@ gst_rtcp_packet_fb_get_fci (GstRTCPPacket * packet)
g_return_val_if_fail (packet->type == GST_RTCP_TYPE_RTPFB ||
packet->type == GST_RTCP_TYPE_PSFB, NULL);
- data = packet->rtcp->data + packet->offset;
+ data = packet->rtcp->info.data + packet->offset;
if (GST_READ_UINT16_BE (data + 2) <= 2)
return NULL;
diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.h b/gst-libs/gst/rtp/gstrtcpbuffer.h
index 6ac6cbeb3..613d62eef 100644
--- a/gst-libs/gst/rtp/gstrtcpbuffer.h
+++ b/gst-libs/gst/rtp/gstrtcpbuffer.h
@@ -179,9 +179,7 @@ struct _GstRTCPBuffer
GstBuffer *buffer;
GstMapFlags flags;
- guint8 *data;
- gsize size;
- gsize maxsize;
+ GstMapInfo info;
};
#define GST_RTCP_BUFFER_INIT { NULL, 0, NULL, 0, 0 }
diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c
index 724c2d331..30d3b235b 100644
--- a/gst-libs/gst/rtp/gstrtpbuffer.c
+++ b/gst-libs/gst/rtp/gstrtpbuffer.c
@@ -99,9 +99,9 @@ void
gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
guint8 pad_len, guint8 csrc_count)
{
- guint len;
- guint8 *data;
+ GstMapInfo info;
GstMemory *mem;
+ gsize len;
g_return_if_fail (csrc_count <= 15);
g_return_if_fail (GST_IS_BUFFER (buffer));
@@ -111,20 +111,20 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len,
mem = gst_allocator_alloc (NULL, len, 0);
- data = gst_memory_map (mem, NULL, NULL, GST_MAP_WRITE);
+ gst_memory_map (mem, &info, GST_MAP_WRITE);
/* fill in defaults */
- GST_RTP_HEADER_VERSION (data) = GST_RTP_VERSION;
- GST_RTP_HEADER_PADDING (data) = FALSE;
- GST_RTP_HEADER_EXTENSION (data) = FALSE;
- GST_RTP_HEADER_CSRC_COUNT (data) = csrc_count;
- memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, 0), 0,
+ GST_RTP_HEADER_VERSION (info.data) = GST_RTP_VERSION;
+ GST_RTP_HEADER_PADDING (info.data) = FALSE;
+ GST_RTP_HEADER_EXTENSION (info.data) = FALSE;
+ GST_RTP_HEADER_CSRC_COUNT (info.data) = csrc_count;
+ memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (info.data, 0), 0,
csrc_count * sizeof (guint32));
- GST_RTP_HEADER_MARKER (data) = FALSE;
- GST_RTP_HEADER_PAYLOAD_TYPE (data) = 0;
- GST_RTP_HEADER_SEQ (data) = 0;
- GST_RTP_HEADER_TIMESTAMP (data) = 0;
- GST_RTP_HEADER_SSRC (data) = 0;
- gst_memory_unmap (mem);
+ GST_RTP_HEADER_MARKER (info.data) = FALSE;
+ GST_RTP_HEADER_PAYLOAD_TYPE (info.data) = 0;
+ GST_RTP_HEADER_SEQ (info.data) = 0;
+ GST_RTP_HEADER_TIMESTAMP (info.data) = 0;
+ GST_RTP_HEADER_SSRC (info.data) = 0;
+ gst_memory_unmap (mem, &info);
gst_buffer_take_memory (buffer, -1, mem);
}
@@ -411,14 +411,13 @@ gboolean
gst_rtp_buffer_validate (GstBuffer * buffer)
{
gboolean res;
- guint8 *data;
- gsize len;
+ GstMapInfo info;
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
- data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
- res = validate_data (data, len, NULL, 0);
- gst_buffer_unmap (buffer, data, len);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
+ res = validate_data (info.data, info.size, NULL, 0);
+ gst_buffer_unmap (buffer, &info);
return res;
}
@@ -426,22 +425,15 @@ gst_rtp_buffer_validate (GstBuffer * buffer)
gboolean
gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp)
{
- guint8 *data;
- gsize size, maxsize;
-
g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE);
g_return_val_if_fail (rtp != NULL, FALSE);
g_return_val_if_fail (rtp->buffer == NULL, FALSE);
- data = gst_buffer_map (buffer, &size, &maxsize, flags);
- if (data == NULL)
+ if (!gst_buffer_map (buffer, &rtp->info, flags))
return FALSE;
rtp->buffer = buffer;
rtp->flags = flags;
- rtp->data = data;
- rtp->size = size;
- rtp->maxsize = maxsize;
return TRUE;
}
@@ -452,8 +444,7 @@ gst_rtp_buffer_unmap (GstRTPBuffer * rtp)
g_return_val_if_fail (rtp != NULL, FALSE);
g_return_val_if_fail (rtp->buffer != NULL, FALSE);
- gst_buffer_unmap (rtp->buffer, rtp->data, rtp->size);
-
+ gst_buffer_unmap (rtp->buffer, &rtp->info);
rtp->buffer = NULL;
return TRUE;
@@ -473,15 +464,15 @@ gst_rtp_buffer_set_packet_len (GstRTPBuffer * rtp, guint len)
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
- if (rtp->maxsize <= len) {
+ if (rtp->info.maxsize <= len) {
/* FIXME, realloc bigger space */
g_warning ("not implemented");
}
gst_buffer_set_size (rtp->buffer, len);
- rtp->size = len;
+ rtp->info.size = len;
/* remove any padding */
GST_RTP_HEADER_PADDING (data) = FALSE;
@@ -516,7 +507,7 @@ gst_rtp_buffer_get_header_len (GstRTPBuffer * rtp)
guint len;
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
len = GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data);
if (GST_RTP_HEADER_EXTENSION (data))
@@ -536,7 +527,7 @@ gst_rtp_buffer_get_header_len (GstRTPBuffer * rtp)
guint8
gst_rtp_buffer_get_version (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_VERSION (rtp->data);
+ return GST_RTP_HEADER_VERSION (rtp->info.data);
}
/**
@@ -551,7 +542,7 @@ gst_rtp_buffer_set_version (GstRTPBuffer * rtp, guint8 version)
{
g_return_if_fail (version < 0x04);
- GST_RTP_HEADER_VERSION (rtp->data) = version;
+ GST_RTP_HEADER_VERSION (rtp->info.data) = version;
}
/**
@@ -565,7 +556,7 @@ gst_rtp_buffer_set_version (GstRTPBuffer * rtp, guint8 version)
gboolean
gst_rtp_buffer_get_padding (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_PADDING (rtp->data);
+ return GST_RTP_HEADER_PADDING (rtp->info.data);
}
/**
@@ -578,7 +569,7 @@ gst_rtp_buffer_get_padding (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_padding (GstRTPBuffer * rtp, gboolean padding)
{
- GST_RTP_HEADER_PADDING (rtp->data) = padding;
+ GST_RTP_HEADER_PADDING (rtp->info.data) = padding;
}
/**
@@ -596,7 +587,7 @@ gst_rtp_buffer_pad_to (GstRTPBuffer * rtp, guint len)
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
if (len > 0)
GST_RTP_HEADER_PADDING (data) = TRUE;
@@ -617,7 +608,7 @@ gst_rtp_buffer_pad_to (GstRTPBuffer * rtp, guint len)
gboolean
gst_rtp_buffer_get_extension (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_EXTENSION (rtp->data);
+ return GST_RTP_HEADER_EXTENSION (rtp->info.data);
}
/**
@@ -630,7 +621,7 @@ gst_rtp_buffer_get_extension (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_extension (GstRTPBuffer * rtp, gboolean extension)
{
- GST_RTP_HEADER_EXTENSION (rtp->data) = extension;
+ GST_RTP_HEADER_EXTENSION (rtp->info.data) = extension;
}
/**
@@ -658,7 +649,7 @@ gst_rtp_buffer_get_extension_data (GstRTPBuffer * rtp, guint16 * bits,
guint len;
guint8 *pdata;
- pdata = rtp->data;
+ pdata = rtp->info.data;
if (!GST_RTP_HEADER_EXTENSION (pdata))
return FALSE;
@@ -700,17 +691,17 @@ gst_rtp_buffer_set_extension_data (GstRTPBuffer * rtp, guint16 bits,
guint32 min_size = 0;
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
/* check if the buffer is big enough to hold the extension */
min_size =
GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data) + 4 +
length * sizeof (guint32);
- if (G_UNLIKELY (min_size > rtp->size))
+ if (G_UNLIKELY (min_size > rtp->info.size))
goto too_small;
/* now we can set the extension bit */
- GST_RTP_HEADER_EXTENSION (rtp->data) = TRUE;
+ GST_RTP_HEADER_EXTENSION (rtp->info.data) = TRUE;
data += GST_RTP_HEADER_LEN + GST_RTP_HEADER_CSRC_SIZE (data);
GST_WRITE_UINT16_BE (data, bits);
@@ -723,7 +714,7 @@ too_small:
{
g_warning
("rtp buffer too small: need more than %d bytes but only have %"
- G_GSIZE_FORMAT " bytes", min_size, rtp->size);
+ G_GSIZE_FORMAT " bytes", min_size, rtp->info.size);
return FALSE;
}
}
@@ -739,7 +730,7 @@ too_small:
guint32
gst_rtp_buffer_get_ssrc (GstRTPBuffer * rtp)
{
- return g_ntohl (GST_RTP_HEADER_SSRC (rtp->data));
+ return g_ntohl (GST_RTP_HEADER_SSRC (rtp->info.data));
}
/**
@@ -752,7 +743,7 @@ gst_rtp_buffer_get_ssrc (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_ssrc (GstRTPBuffer * rtp, guint32 ssrc)
{
- GST_RTP_HEADER_SSRC (rtp->data) = g_htonl (ssrc);
+ GST_RTP_HEADER_SSRC (rtp->info.data) = g_htonl (ssrc);
}
/**
@@ -766,7 +757,7 @@ gst_rtp_buffer_set_ssrc (GstRTPBuffer * rtp, guint32 ssrc)
guint8
gst_rtp_buffer_get_csrc_count (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_CSRC_COUNT (rtp->data);
+ return GST_RTP_HEADER_CSRC_COUNT (rtp->info.data);
}
/**
@@ -783,7 +774,7 @@ gst_rtp_buffer_get_csrc (GstRTPBuffer * rtp, guint8 idx)
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0);
@@ -803,7 +794,7 @@ gst_rtp_buffer_set_csrc (GstRTPBuffer * rtp, guint8 idx, guint32 csrc)
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data));
@@ -821,7 +812,7 @@ gst_rtp_buffer_set_csrc (GstRTPBuffer * rtp, guint8 idx, guint32 csrc)
gboolean
gst_rtp_buffer_get_marker (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_MARKER (rtp->data);
+ return GST_RTP_HEADER_MARKER (rtp->info.data);
}
/**
@@ -834,7 +825,7 @@ gst_rtp_buffer_get_marker (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_marker (GstRTPBuffer * rtp, gboolean marker)
{
- GST_RTP_HEADER_MARKER (rtp->data) = marker;
+ GST_RTP_HEADER_MARKER (rtp->info.data) = marker;
}
/**
@@ -848,7 +839,7 @@ gst_rtp_buffer_set_marker (GstRTPBuffer * rtp, gboolean marker)
guint8
gst_rtp_buffer_get_payload_type (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_PAYLOAD_TYPE (rtp->data);
+ return GST_RTP_HEADER_PAYLOAD_TYPE (rtp->info.data);
}
/**
@@ -863,7 +854,7 @@ gst_rtp_buffer_set_payload_type (GstRTPBuffer * rtp, guint8 payload_type)
{
g_return_if_fail (payload_type < 0x80);
- GST_RTP_HEADER_PAYLOAD_TYPE (rtp->data) = payload_type;
+ GST_RTP_HEADER_PAYLOAD_TYPE (rtp->info.data) = payload_type;
}
/**
@@ -877,7 +868,7 @@ gst_rtp_buffer_set_payload_type (GstRTPBuffer * rtp, guint8 payload_type)
guint16
gst_rtp_buffer_get_seq (GstRTPBuffer * rtp)
{
- return g_ntohs (GST_RTP_HEADER_SEQ (rtp->data));
+ return g_ntohs (GST_RTP_HEADER_SEQ (rtp->info.data));
}
/**
@@ -890,7 +881,7 @@ gst_rtp_buffer_get_seq (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_seq (GstRTPBuffer * rtp, guint16 seq)
{
- GST_RTP_HEADER_SEQ (rtp->data) = g_htons (seq);
+ GST_RTP_HEADER_SEQ (rtp->info.data) = g_htons (seq);
}
/**
@@ -904,7 +895,7 @@ gst_rtp_buffer_set_seq (GstRTPBuffer * rtp, guint16 seq)
guint32
gst_rtp_buffer_get_timestamp (GstRTPBuffer * rtp)
{
- return g_ntohl (GST_RTP_HEADER_TIMESTAMP (rtp->data));
+ return g_ntohl (GST_RTP_HEADER_TIMESTAMP (rtp->info.data));
}
/**
@@ -917,7 +908,7 @@ gst_rtp_buffer_get_timestamp (GstRTPBuffer * rtp)
void
gst_rtp_buffer_set_timestamp (GstRTPBuffer * rtp, guint32 timestamp)
{
- GST_RTP_HEADER_TIMESTAMP (rtp->data) = g_htonl (timestamp);
+ GST_RTP_HEADER_TIMESTAMP (rtp->info.data) = g_htonl (timestamp);
}
@@ -995,8 +986,8 @@ gst_rtp_buffer_get_payload_len (GstRTPBuffer * rtp)
guint len, size;
guint8 *data;
- size = rtp->size;
- data = rtp->data;
+ size = rtp->info.size;
+ data = rtp->info.data;
len = size - gst_rtp_buffer_get_header_len (rtp);
@@ -1018,7 +1009,7 @@ gst_rtp_buffer_get_payload_len (GstRTPBuffer * rtp)
gpointer
gst_rtp_buffer_get_payload (GstRTPBuffer * rtp)
{
- return rtp->data + gst_rtp_buffer_get_header_len (rtp);
+ return rtp->info.data + gst_rtp_buffer_get_header_len (rtp);
}
/**
@@ -1358,10 +1349,10 @@ gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer * rtp, guint8 id,
return FALSE;
nextext = pdata + offset;
- offset = nextext - rtp->data;
+ offset = nextext - rtp->info.data;
/* Don't add extra header if there isn't enough space */
- if (rtp->size < offset + size + 1)
+ if (rtp->info.size < offset + size + 1)
return FALSE;
nextext[0] = (id << 4) | (0x0F & (size - 1));
@@ -1478,10 +1469,10 @@ gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer * rtp,
nextext = pdata + offset;
- offset = nextext - rtp->data;
+ offset = nextext - rtp->info.data;
/* Don't add extra header if there isn't enough space */
- if (rtp->size < offset + size + 2)
+ if (rtp->info.size < offset + size + 2)
return FALSE;
nextext[0] = id;
diff --git a/gst-libs/gst/rtp/gstrtpbuffer.h b/gst-libs/gst/rtp/gstrtpbuffer.h
index c1e49e0db..a9d9b3008 100644
--- a/gst-libs/gst/rtp/gstrtpbuffer.h
+++ b/gst-libs/gst/rtp/gstrtpbuffer.h
@@ -50,9 +50,7 @@ struct _GstRTPBuffer
{
GstBuffer *buffer;
GstMapFlags flags;
- guint8 *data;
- gsize size;
- gsize maxsize;
+ GstMapInfo info;
};
#define GST_RTP_BUFFER_INIT {NULL,0,NULL,0,0}
diff --git a/gst-libs/gst/tag/gstexiftag.c b/gst-libs/gst/tag/gstexiftag.c
index 0393cc251..f143f1d8d 100644
--- a/gst-libs/gst/tag/gstexiftag.c
+++ b/gst-libs/gst/tag/gstexiftag.c
@@ -875,6 +875,7 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
const GstTagList * taglist, const GstExifTagMatch * exiftag)
{
const GValue *value;
+ GstMapInfo info;
guint8 *data = NULL;
gsize size = 0;
gint tag_size = gst_tag_list_get_tag_size (taglist, exiftag->gst_tag);
@@ -896,7 +897,9 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
default:
if (G_VALUE_TYPE (value) == GST_TYPE_BUFFER) {
buf = gst_value_get_buffer (value);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &info, GST_MAP_READ);
+ data = info.data;
+ size = info.size;
} else {
GST_WARNING ("Conversion from %s to raw data not supported",
G_VALUE_TYPE_NAME (value));
@@ -908,7 +911,7 @@ write_exif_undefined_tag_from_taglist (GstExifWriter * writer,
write_exif_undefined_tag (writer, exiftag->exif_tag, data, size);
if (buf)
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
}
static void
@@ -1188,8 +1191,7 @@ parse_exif_ascii_tag (GstExifReader * reader, const GstExifTagMatch * tag,
GError *error = NULL;
if (count > 4) {
- guint8 *data;
- gsize size;
+ GstMapInfo info;
if (offset < reader->base_offset) {
GST_WARNING ("Offset is smaller (%u) than base offset (%u)", offset,
@@ -1199,16 +1201,16 @@ parse_exif_ascii_tag (GstExifReader * reader, const GstExifTagMatch * tag,
real_offset = offset - reader->base_offset;
- data = gst_buffer_map (reader->buffer, &size, NULL, GST_MAP_READ);
- if (real_offset >= size) {
+ gst_buffer_map (reader->buffer, &info, GST_MAP_READ);
+ if (real_offset >= info.size) {
GST_WARNING ("Invalid offset %u for buffer of size %" G_GSIZE_FORMAT
- ", not adding tag %s", real_offset, size, tag->gst_tag);
- gst_buffer_unmap (reader->buffer, data, size);
+ ", not adding tag %s", real_offset, info.size, tag->gst_tag);
+ gst_buffer_unmap (reader->buffer, &info);
return;
}
- str = g_strndup ((gchar *) (data + real_offset), count);
- gst_buffer_unmap (reader->buffer, data, size);
+ str = g_strndup ((gchar *) (info.data + real_offset), count);
+ gst_buffer_unmap (reader->buffer, &info);
} else {
str = g_strndup ((gchar *) offset_as_data, count);
}
@@ -1288,8 +1290,7 @@ parse_exif_undefined_tag (GstExifReader * reader, const GstExifTagMatch * tag,
guint32 real_offset;
if (count > 4) {
- guint8 *bdata;
- gsize bsize;
+ GstMapInfo info;
if (offset < reader->base_offset) {
GST_WARNING ("Offset is smaller (%u) than base offset (%u)", offset,
@@ -1299,21 +1300,21 @@ parse_exif_undefined_tag (GstExifReader * reader, const GstExifTagMatch * tag,
real_offset = offset - reader->base_offset;
- bdata = gst_buffer_map (reader->buffer, &bsize, NULL, GST_MAP_READ);
+ gst_buffer_map (reader->buffer, &info, GST_MAP_READ);
- if (real_offset >= bsize) {
+ if (real_offset >= info.size) {
GST_WARNING ("Invalid offset %u for buffer of size %" G_GSIZE_FORMAT
- ", not adding tag %s", real_offset, bsize, tag->gst_tag);
- gst_buffer_unmap (reader->buffer, bdata, bsize);
+ ", not adding tag %s", real_offset, info.size, tag->gst_tag);
+ gst_buffer_unmap (reader->buffer, &info);
return;
}
/* +1 because it could be a string without the \0 */
data = malloc (sizeof (guint8) * count + 1);
- memcpy (data, bdata + real_offset, count);
+ memcpy (data, info.data + real_offset, count);
data[count] = 0;
- gst_buffer_unmap (reader->buffer, bdata, bsize);
+ gst_buffer_unmap (reader->buffer, &info);
} else {
data = malloc (sizeof (guint8) * count + 1);
memcpy (data, (guint8 *) offset_as_data, count);
@@ -1352,8 +1353,7 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
guint32 real_offset;
gint32 frac_n = 0;
gint32 frac_d = 0;
- guint8 *data;
- gsize size;
+ GstMapInfo info;
if (count > 1) {
GST_WARNING ("Rationals with multiple entries are not supported");
@@ -1366,15 +1366,15 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
real_offset = offset - exif_reader->base_offset;
- data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (exif_reader->buffer, &info, GST_MAP_READ);
- if (real_offset >= size) {
+ if (real_offset >= info.size) {
GST_WARNING ("Invalid offset %u for buffer of size %" G_GSIZE_FORMAT,
- real_offset, size);
+ real_offset, info.size);
goto reader_fail;
}
- gst_byte_reader_init (&data_reader, data, size);
+ gst_byte_reader_init (&data_reader, info.data, info.size);
if (!gst_byte_reader_set_pos (&data_reader, real_offset))
goto reader_fail;
@@ -1408,13 +1408,13 @@ exif_reader_read_rational_tag (GstExifReader * exif_reader,
if (_frac_d)
*_frac_d = frac_d;
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
return TRUE;
reader_fail:
GST_WARNING ("Failed to read from byte reader. (Buffer too short?)");
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
return FALSE;
}
@@ -1514,17 +1514,16 @@ write_exif_ifd (const GstTagList * taglist, guint byte_order,
}
if (inner_ifd) {
- guint8 *data;
- gsize size;
+ GstMapInfo info;
GST_DEBUG ("Adding inner ifd: %x", tag_map[i].exif_tag);
gst_exif_writer_write_tag_header (&writer, tag_map[i].exif_tag,
EXIF_TYPE_LONG, 1,
gst_byte_writer_get_size (&writer.datawriter), NULL);
- data = gst_buffer_map (inner_ifd, &size, NULL, GST_MAP_READ);
- gst_byte_writer_put_data (&writer.datawriter, data, size);
- gst_buffer_unmap (inner_ifd, data, size);
+ gst_buffer_map (inner_ifd, &info, GST_MAP_READ);
+ gst_byte_writer_put_data (&writer.datawriter, info.data, info.size);
+ gst_buffer_unmap (inner_ifd, &info);
gst_buffer_unref (inner_ifd);
}
continue;
@@ -1594,15 +1593,14 @@ parse_exif_ifd (GstExifReader * exif_reader, gint buf_offset,
GstByteReader reader;
guint16 entries = 0;
guint16 i;
- guint8 *data;
- gsize size;
+ GstMapInfo info;
g_return_val_if_fail (exif_reader->byte_order == G_LITTLE_ENDIAN
|| exif_reader->byte_order == G_BIG_ENDIAN, FALSE);
- data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (exif_reader->buffer, &info, GST_MAP_READ);
- gst_byte_reader_init (&reader, data, size);
+ gst_byte_reader_init (&reader, info.data, info.size);
if (!gst_byte_reader_set_pos (&reader, buf_offset))
goto invalid_offset;
@@ -1715,20 +1713,20 @@ parse_exif_ifd (GstExifReader * exif_reader, gint buf_offset,
}
}
}
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
return TRUE;
invalid_offset:
{
GST_WARNING ("Buffer offset invalid when parsing exif ifd");
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
return FALSE;
}
read_error:
{
GST_WARNING ("Failed to parse the exif ifd");
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
return FALSE;
}
}
@@ -1769,8 +1767,7 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
{
GstBuffer *ifd;
GstByteWriter writer;
- gsize size;
- guint8 *data;
+ GstMapInfo info;
ifd = gst_tag_list_to_exif_buffer (taglist, G_BYTE_ORDER, 8);
if (ifd == NULL) {
@@ -1778,12 +1775,10 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
return NULL;
}
- data = gst_buffer_map (ifd, &size, NULL, GST_MAP_READ);
-
- size += TIFF_HEADER_SIZE;
+ gst_buffer_map (ifd, &info, GST_MAP_READ);
/* TODO what is the correct endianness here? */
- gst_byte_writer_init_with_size (&writer, size, FALSE);
+ gst_byte_writer_init_with_size (&writer, info.size + TIFF_HEADER_SIZE, FALSE);
/* TIFF header */
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
gst_byte_writer_put_uint16_le (&writer, TIFF_LITTLE_ENDIAN);
@@ -1794,17 +1789,17 @@ gst_tag_list_to_exif_buffer_with_tiff_header (const GstTagList * taglist)
gst_byte_writer_put_uint16_be (&writer, 42);
gst_byte_writer_put_uint32_be (&writer, 8);
}
- if (!gst_byte_writer_put_data (&writer, data, size)) {
+ if (!gst_byte_writer_put_data (&writer, info.data, info.size)) {
GST_WARNING ("Byte writer size mismatch");
/* reaching here is a programming error because we should have a buffer
* large enough */
g_assert_not_reached ();
- gst_buffer_unmap (ifd, data, size);
+ gst_buffer_unmap (ifd, &info);
gst_buffer_unref (ifd);
gst_byte_writer_reset (&writer);
return NULL;
}
- gst_buffer_unmap (ifd, data, size);
+ gst_buffer_unmap (ifd, &info);
gst_buffer_unref (ifd);
return gst_byte_writer_reset_and_get_buffer (&writer);
@@ -1867,14 +1862,14 @@ gst_tag_list_from_exif_buffer_with_tiff_header (GstBuffer * buffer)
guint32 offset;
GstTagList *taglist = NULL;
GstBuffer *subbuffer;
- guint8 *data, *sdata;
- gsize size, ssize;
+ GstMapInfo info, sinfo;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
- GST_LOG ("Parsing exif tags with tiff header of size %" G_GSIZE_FORMAT, size);
+ GST_LOG ("Parsing exif tags with tiff header of size %" G_GSIZE_FORMAT,
+ info.size);
- gst_byte_reader_init (&reader, data, size);
+ gst_byte_reader_init (&reader, info.data, info.size);
GST_LOG ("Parsing the tiff header");
if (!gst_byte_reader_get_uint16_be (&reader, &endianness)) {
@@ -1895,11 +1890,12 @@ gst_tag_list_from_exif_buffer_with_tiff_header (GstBuffer * buffer)
if (fortytwo != 42)
goto invalid_magic;
- subbuffer = gst_buffer_new_and_alloc (size - (TIFF_HEADER_SIZE - 2));
+ subbuffer = gst_buffer_new_and_alloc (info.size - (TIFF_HEADER_SIZE - 2));
- sdata = gst_buffer_map (subbuffer, &ssize, NULL, GST_MAP_WRITE);
- memcpy (sdata, data + TIFF_HEADER_SIZE, size - TIFF_HEADER_SIZE);
- gst_buffer_unmap (subbuffer, sdata, ssize);
+ gst_buffer_map (subbuffer, &sinfo, GST_MAP_WRITE);
+ memcpy (sinfo.data, info.data + TIFF_HEADER_SIZE,
+ info.size - TIFF_HEADER_SIZE);
+ gst_buffer_unmap (subbuffer, &sinfo);
taglist = gst_tag_list_from_exif_buffer (subbuffer,
endianness == TIFF_LITTLE_ENDIAN ? G_LITTLE_ENDIAN : G_BIG_ENDIAN, 8);
@@ -1907,7 +1903,7 @@ gst_tag_list_from_exif_buffer_with_tiff_header (GstBuffer * buffer)
gst_buffer_unref (subbuffer);
done:
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return taglist;
@@ -2024,8 +2020,7 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
gdouble degrees;
gdouble minutes;
gdouble seconds;
- guint8 *data = NULL;
- gsize size = 0;
+ GstMapInfo info = { NULL };
GST_LOG ("Starting to parse %s tag in exif 0x%x", exiftag->gst_tag,
exiftag->exif_tag);
@@ -2082,10 +2077,10 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
return ret;
}
- data = gst_buffer_map (exif_reader->buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (exif_reader->buffer, &info, GST_MAP_READ);
/* now parse the fractions */
- gst_byte_reader_init (&fractions_reader, data, size);
+ gst_byte_reader_init (&fractions_reader, info.data, info.size);
if (!gst_byte_reader_set_pos (&fractions_reader,
next_tagdata.offset - exif_reader->base_offset))
@@ -2108,7 +2103,7 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
!gst_byte_reader_get_uint32_be (&fractions_reader, &seconds_d))
goto reader_fail;
}
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ gst_buffer_unmap (exif_reader->buffer, &info);
GST_DEBUG ("Read degrees fraction for tag %s: %u/%u %u/%u %u/%u",
exiftag->gst_tag, degrees_n, degrees_d, minutes_n, minutes_d,
@@ -2130,8 +2125,8 @@ deserialize_geo_coordinate (GstExifReader * exif_reader,
reader_fail:
GST_WARNING ("Failed to read fields from buffer (too short?)");
- if (data)
- gst_buffer_unmap (exif_reader->buffer, data, size);
+ if (info.data)
+ gst_buffer_unmap (exif_reader->buffer, &info);
return ret;
}
diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c
index 63ea2f640..caf0c0ea1 100644
--- a/gst-libs/gst/tag/gstvorbistag.c
+++ b/gst-libs/gst/tag/gstvorbistag.c
@@ -532,14 +532,13 @@ gst_tag_list_from_vorbiscomment_buffer (GstBuffer * buffer,
const guint8 * id_data, const guint id_data_length, gchar ** vendor_string)
{
GstTagList *res;
- guint8 *data;
- gsize size;
+ GstMapInfo info;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ g_assert (gst_buffer_map (buffer, &info, GST_MAP_READ));
res =
- gst_tag_list_from_vorbiscomment (data, size, id_data, id_data_length,
- vendor_string);
- gst_buffer_unmap (buffer, data, size);
+ gst_tag_list_from_vorbiscomment (info.data, info.size, id_data,
+ id_data_length, vendor_string);
+ gst_buffer_unmap (buffer, &info);
return res;
}
@@ -791,7 +790,8 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
const gchar * vendor_string)
{
GstBuffer *buffer;
- guint8 *data, *odata;
+ GstMapInfo info;
+ guint8 *data;
guint i;
GList *l;
MyForEach my_data = { 0, 0, NULL };
@@ -809,7 +809,8 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
required_size += 4 * my_data.count + my_data.data_count;
buffer = gst_buffer_new_and_alloc (required_size);
- odata = data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buffer, &info, GST_MAP_WRITE);
+ data = info.data;
if (id_data_length > 0) {
memcpy (data, id_data, id_data_length);
data += id_data_length;
@@ -837,7 +838,7 @@ gst_tag_list_to_vorbiscomment_buffer (const GstTagList * list,
g_list_foreach (my_data.entries, (GFunc) g_free, NULL);
g_list_free (my_data.entries);
*data = 1;
- gst_buffer_unmap (buffer, odata, required_size);
+ gst_buffer_unmap (buffer, &info);
return buffer;
}
diff --git a/gst-libs/gst/tag/gstxmptag.c b/gst-libs/gst/tag/gstxmptag.c
index 0c363c0d8..545fc29d1 100644
--- a/gst-libs/gst/tag/gstxmptag.c
+++ b/gst-libs/gst/tag/gstxmptag.c
@@ -1275,6 +1275,7 @@ GstTagList *
gst_tag_list_from_xmp_buffer (GstBuffer * buffer)
{
GstTagList *list = NULL;
+ GstMapInfo info;
gchar *xps, *xp1, *xp2, *xpe, *ns, *ne;
gsize len, max_ft_len;
gboolean in_tag;
@@ -1310,7 +1311,9 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer)
GST_LOG ("Starting xmp parsing");
- xps = gst_buffer_map (buffer, &len, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
+ xps = (gchar *) info.data;
+ len = info.size;
g_return_val_if_fail (len > 0, NULL);
xpe = &xps[len + 1];
@@ -1577,7 +1580,7 @@ gst_tag_list_from_xmp_buffer (GstBuffer * buffer)
}
g_free (part);
- gst_buffer_unmap (buffer, xps, len);
+ gst_buffer_unmap (buffer, &info);
return list;
diff --git a/gst-libs/gst/tag/id3v2.c b/gst-libs/gst/tag/id3v2.c
index f5c4076e9..aaf7fb83f 100644
--- a/gst-libs/gst/tag/id3v2.c
+++ b/gst-libs/gst/tag/id3v2.c
@@ -95,26 +95,26 @@ id3v2_read_synch_uint (const guint8 * data, guint size)
guint
gst_tag_get_id3v2_tag_size (GstBuffer * buffer)
{
- guint8 *data, flags;
- gsize size;
+ GstMapInfo info;
+ guint8 flags;
guint result = 0;
g_return_val_if_fail (buffer != NULL, 0);
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
- if (size < ID3V2_HDR_SIZE)
+ if (info.size < ID3V2_HDR_SIZE)
goto too_small;
/* Check for 'ID3' string at start of buffer */
- if (data[0] != 'I' || data[1] != 'D' || data[2] != '3')
+ if (info.data[0] != 'I' || info.data[1] != 'D' || info.data[2] != '3')
goto no_tag;
/* Read the flags */
- flags = data[5];
+ flags = info.data[5];
/* Read the size from the header */
- result = id3v2_read_synch_uint (data + 6, 4);
+ result = id3v2_read_synch_uint (info.data + 6, 4);
if (result == 0)
goto empty;
@@ -127,7 +127,7 @@ gst_tag_get_id3v2_tag_size (GstBuffer * buffer)
GST_DEBUG ("ID3v2 tag, size: %u bytes", result);
done:
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return result;
@@ -192,9 +192,9 @@ id3v2_ununsync_data (const guint8 * unsync_data, guint32 * size)
GstTagList *
gst_tag_list_from_id3v2_tag (GstBuffer * buffer)
{
- guint8 *data, *uu_data = NULL;
+ GstMapInfo info;
+ guint8 *uu_data = NULL;
guint read_size;
- gsize size;
ID3TagsWorking work;
guint8 flags;
guint16 version;
@@ -205,13 +205,13 @@ gst_tag_list_from_id3v2_tag (GstBuffer * buffer)
if (read_size < ID3V2_HDR_SIZE)
return NULL;
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &info, GST_MAP_READ);
/* Read the version */
- version = GST_READ_UINT16_BE (data + 3);
+ version = GST_READ_UINT16_BE (info.data + 3);
/* Read the flags */
- flags = data[5];
+ flags = info.data[5];
/* Validate the version. At the moment, we only support up to 2.4.0 */
if (ID3V2_VER_MAJOR (version) > 4 || ID3V2_VER_MINOR (version) > 0)
@@ -224,20 +224,20 @@ gst_tag_list_from_id3v2_tag (GstBuffer * buffer)
(flags & ID3V2_HDR_FLAG_FOOTER) ? "FOOTER" : "");
/* This shouldn't really happen! Caller should have checked first */
- if (size < read_size)
+ if (info.size < read_size)
goto not_enough_data;
GST_DEBUG ("Reading ID3v2 tag with revision 2.%d.%d of size %u", version >> 8,
version & 0xff, read_size);
- GST_MEMDUMP ("ID3v2 tag", data, read_size);
+ GST_MEMDUMP ("ID3v2 tag", info.data, read_size);
memset (&work, 0, sizeof (ID3TagsWorking));
work.buffer = buffer;
work.hdr.version = version;
work.hdr.size = read_size;
work.hdr.flags = flags;
- work.hdr.frame_data = data + ID3V2_HDR_SIZE;
+ work.hdr.frame_data = info.data + ID3V2_HDR_SIZE;
if (flags & ID3V2_HDR_FLAG_FOOTER)
work.hdr.frame_data_size = read_size - ID3V2_HDR_SIZE - 10;
else
@@ -258,7 +258,7 @@ gst_tag_list_from_id3v2_tag (GstBuffer * buffer)
g_free (uu_data);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return work.tags;
@@ -268,15 +268,15 @@ wrong_version:
GST_WARNING ("ID3v2 tag is from revision 2.%d.%d, "
"but decoder only supports 2.%d.%d. Ignoring as per spec.",
version >> 8, version & 0xff, ID3V2_VERSION >> 8, ID3V2_VERSION & 0xff);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return NULL;
}
not_enough_data:
{
GST_DEBUG
("Found ID3v2 tag with revision 2.%d.%d - need %u more bytes to read",
- version >> 8, version & 0xff, (guint) (read_size - size));
- gst_buffer_unmap (buffer, data, size);
+ version >> 8, version & 0xff, (guint) (read_size - info.size));
+ gst_buffer_unmap (buffer, &info);
return NULL;
}
}
diff --git a/gst-libs/gst/tag/tags.c b/gst-libs/gst/tag/tags.c
index 8c31b8c1b..dad7ea33f 100644
--- a/gst-libs/gst/tag/tags.c
+++ b/gst-libs/gst/tag/tags.c
@@ -570,8 +570,8 @@ gst_tag_image_data_to_image_sample (const guint8 * image_data,
GstBuffer *image;
GstSample *sample;
GstCaps *caps;
- guint8 *data;
- GstStructure *info = NULL;
+ GstMapInfo info;
+ GstStructure *image_info = NULL;
g_return_val_if_fail (image_data != NULL, NULL);
g_return_val_if_fail (image_data_len > 0, NULL);
@@ -584,10 +584,10 @@ gst_tag_image_data_to_image_sample (const guint8 * image_data,
if (image == NULL)
goto alloc_failed;
- data = gst_buffer_map (image, NULL, NULL, GST_MAP_WRITE);
- memcpy (data, image_data, image_data_len);
- data[image_data_len] = '\0';
- gst_buffer_unmap (image, data, image_data_len + 1);
+ gst_buffer_map (image, &info, GST_MAP_WRITE);
+ memcpy (info.data, image_data, image_data_len);
+ info.data[image_data_len] = '\0';
+ gst_buffer_unmap (image, &info);
/* Find GStreamer media type, can't trust declared type */
caps = gst_type_find_helper_for_buffer (NULL, image, NULL);
@@ -615,10 +615,10 @@ gst_tag_image_data_to_image_sample (const guint8 * image_data,
if (image_type != GST_TAG_IMAGE_TYPE_NONE) {
GST_LOG ("Setting image type: %d", image_type);
- info = gst_structure_new ("GstTagImageInfo",
+ image_info = gst_structure_new ("GstTagImageInfo",
"image-type", GST_TYPE_TAG_IMAGE_TYPE, image_type, NULL);
}
- sample = gst_sample_new (image, caps, NULL, info);
+ sample = gst_sample_new (image, caps, NULL, image_info);
gst_buffer_unref (image);
gst_caps_unref (caps);
diff --git a/gst-libs/gst/video/gstvideometa.c b/gst-libs/gst/video/gstvideometa.c
index 5e90c5efc..fe40031e5 100644
--- a/gst-libs/gst/video/gstvideometa.c
+++ b/gst-libs/gst/video/gstvideometa.c
@@ -191,6 +191,7 @@ find_mem_for_offset (GstBuffer * buffer, guint * offset, GstMapFlags flags)
* gst_video_meta_map:
* @meta: a #GstVideoMeta
* @plane: a plane
+ * @info: a #GstMapInfo
* @stride: result stride
* @flags: @GstMapFlags
*
@@ -199,25 +200,25 @@ find_mem_for_offset (GstBuffer * buffer, guint * offset, GstMapFlags flags)
*
* Returns: a pointer to the first byte of the plane data
*/
-gpointer
-gst_video_meta_map (GstVideoMeta * meta, guint plane, gint * stride,
- GstMapFlags flags)
+gboolean
+gst_video_meta_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
+ gint * stride, GstMapFlags flags)
{
guint offset;
- gboolean write;
+ gboolean write, res;
GstBuffer *buffer;
GstMemory *mem;
- guint8 *base;
- g_return_val_if_fail (meta != NULL, NULL);
- g_return_val_if_fail (plane < meta->n_planes, NULL);
- g_return_val_if_fail (stride != NULL, NULL);
+ g_return_val_if_fail (meta != NULL, FALSE);
+ g_return_val_if_fail (plane < meta->n_planes, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (stride != NULL, FALSE);
buffer = meta->buffer;
- g_return_val_if_fail (buffer != NULL, NULL);
+ g_return_val_if_fail (buffer != NULL, FALSE);
write = (flags & GST_MAP_WRITE) != 0;
- g_return_val_if_fail (!write || gst_buffer_is_writable (buffer), NULL);
+ g_return_val_if_fail (!write || gst_buffer_is_writable (buffer), FALSE);
offset = meta->offset[plane];
*stride = meta->stride[plane];
@@ -225,23 +226,28 @@ gst_video_meta_map (GstVideoMeta * meta, guint plane, gint * stride,
* the plane offset */
mem = find_mem_for_offset (buffer, &offset, flags);
- base = gst_memory_map (mem, NULL, NULL, flags);
+ res = gst_memory_map (mem, info, flags);
/* move to the right offset inside the block */
- return base + offset;
+ info->data += offset;
+ info->size -= offset;
+ info->maxsize -= offset;
+
+ return res;
}
/**
* gst_video_meta_unmap:
* @meta: a #GstVideoMeta
* @plane: a plane
+ * @info: a #GstMapInfo
*
* Unmap a previously mapped plane with gst_video_meta_map().
*
* Returns: TRUE if the memory was successfully unmapped.
*/
gboolean
-gst_video_meta_unmap (GstVideoMeta * meta, guint plane)
+gst_video_meta_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info)
{
guint offset;
GstBuffer *buffer;
@@ -249,6 +255,7 @@ gst_video_meta_unmap (GstVideoMeta * meta, guint plane)
g_return_val_if_fail (meta != NULL, FALSE);
g_return_val_if_fail (plane < meta->n_planes, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
buffer = meta->buffer;
g_return_val_if_fail (buffer != NULL, FALSE);
@@ -256,7 +263,12 @@ gst_video_meta_unmap (GstVideoMeta * meta, guint plane)
offset = meta->offset[plane];
mem = find_mem_for_offset (buffer, &offset, GST_MAP_READ);
- gst_memory_unmap (mem);
+ /* move to the right offset inside the block */
+ info->data -= offset;
+ info->size += offset;
+ info->maxsize += offset;
+
+ gst_memory_unmap (mem, info);
return TRUE;
}
diff --git a/gst-libs/gst/video/gstvideometa.h b/gst-libs/gst/video/gstvideometa.h
index d9b9a0faa..32fbffd38 100644
--- a/gst-libs/gst/video/gstvideometa.h
+++ b/gst-libs/gst/video/gstvideometa.h
@@ -66,9 +66,9 @@ struct _GstVideoMeta {
gsize offset[GST_VIDEO_MAX_PLANES];
gint stride[GST_VIDEO_MAX_PLANES];
- gpointer (*map) (GstVideoMeta *meta, guint plane, gint *stride,
+ gboolean (*map) (GstVideoMeta *meta, guint plane, GstMapInfo *info, gint *stride,
GstMapFlags flags);
- gboolean (*unmap) (GstVideoMeta *meta, guint plane);
+ gboolean (*unmap) (GstVideoMeta *meta, guint plane, GstMapInfo *info);
};
const GstMetaInfo * gst_video_meta_get_info (void);
@@ -83,9 +83,9 @@ GstVideoMeta * gst_buffer_add_video_meta_full (GstBuffer *buffer, GstVideoFlags
guint n_planes, gsize offset[GST_VIDEO_MAX_PLANES],
gint stride[GST_VIDEO_MAX_PLANES]);
-gpointer gst_video_meta_map (GstVideoMeta *meta, guint plane, gint *stride,
- GstMapFlags flags);
-gboolean gst_video_meta_unmap (GstVideoMeta *meta, guint plane);
+gboolean gst_video_meta_map (GstVideoMeta *meta, guint plane, GstMapInfo *info,
+ gint *stride, GstMapFlags flags);
+gboolean gst_video_meta_unmap (GstVideoMeta *meta, guint plane, GstMapInfo *info);
/**
* GstVideoCropMeta:
diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c
index cda2e5627..f050487d0 100644
--- a/gst-libs/gst/video/video.c
+++ b/gst-libs/gst/video/video.c
@@ -1001,8 +1001,6 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
GstBuffer * buffer, gint id, GstMapFlags flags)
{
GstVideoMeta *meta;
- guint8 *data;
- gsize size;
gint i;
g_return_val_if_fail (frame != NULL, FALSE);
@@ -1025,8 +1023,9 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
frame->id = meta->id;
for (i = 0; i < info->finfo->n_planes; i++) {
- frame->data[i] =
- gst_video_meta_map (meta, i, &frame->info.stride[i], flags);
+ gst_video_meta_map (meta, i, &frame->map[i], &frame->info.stride[i],
+ flags);
+ frame->data[i] = frame->map[i].data;
}
} else {
/* no metadata, we really need to have the metadata when the id is
@@ -1038,15 +1037,15 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
frame->info = *info;
frame->id = id;
- data = gst_buffer_map (buffer, &size, NULL, flags);
+ gst_buffer_map (buffer, &frame->map[0], flags);
/* do some sanity checks */
- if (size < info->size)
+ if (frame->map[0].size < info->size)
goto invalid_size;
/* set up pointers */
for (i = 0; i < info->finfo->n_planes; i++) {
- frame->data[i] = data + info->offset[i];
+ frame->data[i] = frame->map[0].data + info->offset[i];
}
}
return TRUE;
@@ -1060,8 +1059,8 @@ no_metadata:
invalid_size:
{
GST_ERROR ("invalid buffer size %" G_GSIZE_FORMAT " < %" G_GSIZE_FORMAT,
- size, info->size);
- gst_buffer_unmap (buffer, data, size);
+ frame->map[0].size, info->size);
+ gst_buffer_unmap (buffer, &frame->map[0]);
return FALSE;
}
}
@@ -1107,14 +1106,10 @@ gst_video_frame_unmap (GstVideoFrame * frame)
if (meta) {
for (i = 0; i < frame->info.finfo->n_planes; i++) {
- gst_video_meta_unmap (meta, i);
+ gst_video_meta_unmap (meta, i, &frame->map[i]);
}
} else {
- guint8 *data;
-
- data = frame->data[0];
- data -= frame->info.offset[0];
- gst_buffer_unmap (buffer, data, -1);
+ gst_buffer_unmap (buffer, &frame->map[0]);
}
}
diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h
index d4dd5f03a..55eea6c4f 100644
--- a/gst-libs/gst/video/video.h
+++ b/gst-libs/gst/video/video.h
@@ -608,6 +608,7 @@ gboolean gst_video_info_convert (GstVideoInfo *info,
* @id: id of the mapped frame. the id can for example be used to
* indentify the frame in case of multiview video.
* @data: pointers to the plane data
+ * @map: mappings of the planes
*
* A video frame obtained from gst_video_frame_map()
*/
@@ -619,6 +620,7 @@ struct _GstVideoFrame {
gint id;
gpointer data[GST_VIDEO_MAX_PLANES];
+ GstMapInfo map[GST_VIDEO_MAX_PLANES];
};
gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c
index f2b40b469..47e58ad03 100644
--- a/gst/adder/gstadder.c
+++ b/gst/adder/gstadder.c
@@ -1070,7 +1070,7 @@ gst_adder_collected (GstCollectPads2 * pads, gpointer user_data)
GSList *collected, *next = NULL;
GstFlowReturn ret;
GstBuffer *outbuf = NULL, *gapbuf = NULL;
- gpointer outdata = NULL;
+ GstMapInfo outmap = { NULL };
guint outsize;
gint64 next_offset;
gint64 next_timestamp;
@@ -1148,25 +1148,25 @@ gst_adder_collected (GstCollectPads2 * pads, gpointer user_data)
* are the only one referencing this buffer. If this is the last (and
* only) GAP buffer, it will automatically copy the GAP flag. */
outbuf = gst_buffer_make_writable (inbuf);
- outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
} else {
if (!is_gap) {
/* we had a previous output buffer, mix this non-GAP buffer */
- guint8 *indata;
- gsize insize;
+ GstMapInfo inmap;
- indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
+ gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
/* all buffers should have outsize, there are no short buffers because we
* asked for the max size above */
- g_assert (insize == outsize);
+ g_assert (inmap.size == outmap.size);
GST_LOG_OBJECT (adder, "channel %p: mixing %" G_GSIZE_FORMAT " bytes"
- " from data %p", collect_data, insize, indata);
+ " from data %p", collect_data, inmap.size, inmap.data);
/* further buffers, need to add them */
- adder->func ((gpointer) outdata, (gpointer) indata, insize / bps);
- gst_buffer_unmap (inbuf, indata, insize);
+ adder->func ((gpointer) outmap.data, (gpointer) inmap.data,
+ inmap.size / bps);
+ gst_buffer_unmap (inbuf, &inmap);
} else {
/* skip gap buffer */
GST_LOG_OBJECT (adder, "channel %p: skipping GAP buffer", collect_data);
@@ -1175,7 +1175,7 @@ gst_adder_collected (GstCollectPads2 * pads, gpointer user_data)
}
}
if (outbuf)
- gst_buffer_unmap (outbuf, outdata, outsize);
+ gst_buffer_unmap (outbuf, &outmap);
if (outbuf == NULL) {
/* no output buffer, reuse one of the GAP buffers then if we have one */
diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c
index a96bf05be..76b868cdb 100644
--- a/gst/audioconvert/gstaudioconvert.c
+++ b/gst/audioconvert/gstaudioconvert.c
@@ -671,10 +671,10 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
{
GstFlowReturn ret;
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
- gsize srcsize, dstsize;
+ GstMapInfo srcmap, dstmap;
gint insize, outsize;
+
gint samples;
- gpointer src, dst;
/* get amount of samples to convert. */
samples = gst_buffer_get_size (inbuf) / this->ctx.in.bpf;
@@ -688,29 +688,29 @@ gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
return GST_FLOW_OK;
/* get src and dst data */
- src = gst_buffer_map (inbuf, &srcsize, NULL, GST_MAP_READ);
- dst = gst_buffer_map (outbuf, &dstsize, NULL, GST_MAP_WRITE);
+ gst_buffer_map (inbuf, &srcmap, GST_MAP_READ);
+ gst_buffer_map (outbuf, &dstmap, GST_MAP_WRITE);
/* check in and outsize */
- if (srcsize < insize)
+ if (srcmap.size < insize)
goto wrong_size;
- if (dstsize < outsize)
+ if (dstmap.size < outsize)
goto wrong_size;
/* and convert the samples */
if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
- if (!audio_convert_convert (&this->ctx, src, dst,
+ if (!audio_convert_convert (&this->ctx, srcmap.data, dstmap.data,
samples, gst_buffer_is_writable (inbuf)))
goto convert_error;
} else {
/* Create silence buffer */
- gst_audio_format_fill_silence (this->ctx.out.finfo, dst, outsize);
+ gst_audio_format_fill_silence (this->ctx.out.finfo, dstmap.data, outsize);
}
ret = GST_FLOW_OK;
done:
- gst_buffer_unmap (outbuf, dst, outsize);
- gst_buffer_unmap (inbuf, src, srcsize);
+ gst_buffer_unmap (outbuf, &dstmap);
+ gst_buffer_unmap (inbuf, &srcmap);
return ret;
@@ -727,7 +727,7 @@ wrong_size:
(NULL),
("input/output buffers are of wrong size in: %" G_GSIZE_FORMAT " < %d"
" or out: %" G_GSIZE_FORMAT " < %d",
- srcsize, insize, dstsize, outsize));
+ srcmap.size, insize, dstmap.size, outsize));
ret = GST_FLOW_ERROR;
goto done;
}
diff --git a/gst/audiorate/gstaudiorate.c b/gst/audiorate/gstaudiorate.c
index ba5c54bf4..9907633c8 100644
--- a/gst/audiorate/gstaudiorate.c
+++ b/gst/audiorate/gstaudiorate.c
@@ -518,17 +518,14 @@ gst_audio_rate_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
while (fillsamples > 0) {
guint64 cursamples = MIN (fillsamples, rate);
- guint8 *data;
fillsamples -= cursamples;
fillsize = cursamples * bpf;
fill = gst_buffer_new_and_alloc (fillsize);
- data = gst_buffer_map (fill, NULL, NULL, GST_MAP_WRITE);
/* FIXME, 0 might not be the silence byte for the negotiated format. */
- memset (data, 0, fillsize);
- gst_buffer_unmap (fill, data, fillsize);
+ gst_buffer_memset (fill, 0, 0, fillsize);
GST_DEBUG_OBJECT (audiorate, "inserting %" G_GUINT64_FORMAT " samples",
cursamples);
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 95f457554..dc653f476 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -755,7 +755,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
guint out_len, out_processed;
gint err;
guint num, den;
- guint8 *data;
+ GstMapInfo map;
g_assert (resample->state != NULL);
@@ -775,7 +775,7 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
outbuf = gst_buffer_new_and_alloc (outsize);
- data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
if (resample->funcs->width != resample->width) {
/* need to convert data format; allocate workspace */
@@ -792,11 +792,11 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
/* convert output format */
gst_audio_resample_convert_buffer (resample, resample->tmp_out,
- data, out_processed, TRUE);
+ map.data, out_processed, TRUE);
} else {
/* don't need to convert data format; process */
err = resample->funcs->process (resample->state, NULL, &in_processed,
- data, &out_processed);
+ map.data, &out_processed);
}
/* If we wrote more than allocated something is really wrong now
@@ -804,7 +804,8 @@ gst_audio_resample_push_drain (GstAudioResample * resample, guint history_len)
g_assert (out_len >= out_processed);
outsize = out_processed * resample->channels * (resample->width / 8);
- gst_buffer_unmap (outbuf, data, outsize);
+ gst_buffer_unmap (outbuf, &map);
+ gst_buffer_resize (outbuf, 0, outsize);
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
GST_WARNING_OBJECT (resample, "Failed to process drain: %s",
@@ -951,17 +952,17 @@ static GstFlowReturn
gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
GstBuffer * outbuf)
{
- gsize in_size, out_size;
- guint8 *in_data, *out_data;
+ GstMapInfo in_map, out_map;
+ gsize outsize;
guint32 in_len, in_processed;
guint32 out_len, out_processed;
guint filt_len = resample->funcs->get_filt_len (resample->state);
- in_data = gst_buffer_map (inbuf, &in_size, NULL, GST_MAP_READ);
- out_data = gst_buffer_map (outbuf, &out_size, NULL, GST_MAP_WRITE);
+ gst_buffer_map (inbuf, &in_map, GST_MAP_READ);
+ gst_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
- in_len = in_size / resample->channels;
- out_len = out_size / resample->channels;
+ in_len = in_map.size / resample->channels;
+ out_len = out_map.size / resample->channels;
in_len /= (resample->width / 8);
out_len /= (resample->width / 8);
@@ -993,7 +994,7 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
else
out_processed = 0;
- memset (out_data, 0, out_size);
+ memset (out_map.data, 0, out_map.size);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
resample->num_gap_samples += in_len;
in_processed = in_len;
@@ -1026,13 +1027,13 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
&resample->tmp_out_size, out_len * resample->channels *
(resample->funcs->width / 8))) {
GST_ERROR_OBJECT (resample, "failed to allocate workspace");
- gst_buffer_unmap (inbuf, in_data, in_size);
- gst_buffer_unmap (outbuf, out_data, out_size);
+ gst_buffer_unmap (inbuf, &in_map);
+ gst_buffer_unmap (outbuf, &out_map);
return GST_FLOW_ERROR;
}
/* convert input */
- gst_audio_resample_convert_buffer (resample, in_data,
+ gst_audio_resample_convert_buffer (resample, in_map.data,
resample->tmp_in, in_len, FALSE);
/* process */
@@ -1041,18 +1042,18 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
/* convert output */
gst_audio_resample_convert_buffer (resample, resample->tmp_out,
- out_data, out_processed, TRUE);
+ out_map.data, out_processed, TRUE);
} else {
/* no format conversion required; process */
err = resample->funcs->process (resample->state,
- in_data, &in_processed, out_data, &out_processed);
+ in_map.data, &in_processed, out_map.data, &out_processed);
}
if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) {
GST_ERROR_OBJECT (resample, "Failed to convert data: %s",
resample->funcs->strerror (err));
- gst_buffer_unmap (inbuf, in_data, in_size);
- gst_buffer_unmap (outbuf, out_data, out_size);
+ gst_buffer_unmap (inbuf, &in_map);
+ gst_buffer_unmap (outbuf, &out_map);
return GST_FLOW_ERROR;
}
}
@@ -1090,15 +1091,17 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
resample->samples_out += out_processed;
resample->samples_in += in_len;
- out_size = out_processed * resample->channels * (resample->width / 8);
- gst_buffer_unmap (inbuf, in_data, in_size);
- gst_buffer_unmap (outbuf, out_data, out_size);
+ gst_buffer_unmap (inbuf, &in_map);
+ gst_buffer_unmap (outbuf, &out_map);
+
+ outsize = out_processed * resample->channels * (resample->width / 8);
+ gst_buffer_resize (outbuf, 0, outsize);
GST_LOG_OBJECT (resample,
"Converted to buffer of %" G_GUINT32_FORMAT
" samples (%" G_GSIZE_FORMAT " bytes) with timestamp %" GST_TIME_FORMAT
", duration %" GST_TIME_FORMAT ", offset %" G_GUINT64_FORMAT
- ", offset_end %" G_GUINT64_FORMAT, out_processed, out_size,
+ ", offset_end %" G_GUINT64_FORMAT, out_processed, outsize,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)),
GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf));
diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c
index 1a900bed4..822af1f63 100644
--- a/gst/audiotestsrc/gstaudiotestsrc.c
+++ b/gst/audiotestsrc/gstaudiotestsrc.c
@@ -1113,7 +1113,7 @@ gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
- guint8 *data;
+ GstMapInfo map;
gint samplerate, bpf;
src = GST_AUDIO_TEST_SRC (basesrc);
@@ -1206,9 +1206,9 @@ gst_audio_test_src_fill (GstBaseSrc * basesrc, guint64 offset,
src->generate_samples_per_buffer,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
- data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
- src->process (src, data);
- gst_buffer_unmap (buffer, data, bytes);
+ gst_buffer_map (buffer, &map, GST_MAP_WRITE);
+ src->process (src, map.data);
+ gst_buffer_unmap (buffer, &map);
if (G_UNLIKELY ((src->wave == GST_AUDIO_TEST_SRC_WAVE_SILENCE)
|| (src->volume == 0.0))) {
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/gst/gio/gstgiobasesink.c b/gst/gio/gstgiobasesink.c
index 7c6f5f6c3..606d3fc48 100644
--- a/gst/gio/gstgiobasesink.c
+++ b/gst/gio/gstgiobasesink.c
@@ -262,32 +262,32 @@ gst_gio_base_sink_render (GstBaseSink * base_sink, GstBuffer * buffer)
{
GstGioBaseSink *sink = GST_GIO_BASE_SINK (base_sink);
gssize written;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gboolean success;
GError *err = NULL;
g_return_val_if_fail (G_IS_OUTPUT_STREAM (sink->stream), GST_FLOW_ERROR);
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
GST_LOG_OBJECT (sink,
- "writing %" G_GSIZE_FORMAT " bytes to offset %" G_GUINT64_FORMAT, size,
- sink->position);
+ "writing %" G_GSIZE_FORMAT " bytes to offset %" G_GUINT64_FORMAT,
+ map.size, sink->position);
written =
- g_output_stream_write (sink->stream, data, size, sink->cancel, &err);
- gst_buffer_unmap (buffer, data, size);
+ g_output_stream_write (sink->stream, map.data, map.size, sink->cancel,
+ &err);
+ gst_buffer_unmap (buffer, &map);
success = (written >= 0);
- if (G_UNLIKELY (success && written < size)) {
+ if (G_UNLIKELY (success && written < map.size)) {
/* FIXME: Can this happen? Should we handle it gracefully? gnomevfssink
* doesn't... */
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
("Could not write to stream: (short write, only %"
G_GSSIZE_FORMAT " bytes of %" G_GSIZE_FORMAT " bytes written)",
- written, size));
+ written, map.size));
return GST_FLOW_ERROR;
}
diff --git a/gst/gio/gstgiobasesrc.c b/gst/gio/gstgiobasesrc.c
index 94a079b91..9fd3b7cc3 100644
--- a/gst/gio/gstgiobasesrc.c
+++ b/gst/gio/gstgiobasesrc.c
@@ -319,7 +319,7 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
GST_BUFFER_OFFSET_END (buf) = offset + size;
} else {
guint cachesize = MAX (4096, size);
- guint8 *bdata;
+ GstMapInfo map;
gssize read, res;
gboolean success, eos;
GError *err = NULL;
@@ -356,14 +356,14 @@ gst_gio_base_src_create (GstBaseSrc * base_src, guint64 offset, guint size,
* supports reads up to 64k. So we loop here until we get at
* at least the requested amount of bytes or a read returns
* nothing. */
- bdata = gst_buffer_map (src->cache, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (src->cache, &map, GST_MAP_WRITE);
read = 0;
while (size - read > 0 && (res =
g_input_stream_read (G_INPUT_STREAM (src->stream),
- bdata + read, cachesize - read, src->cancel, &err)) > 0) {
+ map.data + read, cachesize - read, src->cancel, &err)) > 0) {
read += res;
}
- gst_buffer_unmap (src->cache, bdata, read);
+ gst_buffer_unmap (src->cache, &map);
success = (read >= 0);
eos = (cachesize > 0 && read == 0);
diff --git a/gst/subparse/gstssaparse.c b/gst/subparse/gstssaparse.c
index f94153d6b..55a5cd799 100644
--- a/gst/subparse/gstssaparse.c
+++ b/gst/subparse/gstssaparse.c
@@ -150,8 +150,9 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
GstStructure *s;
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
GstBuffer *priv;
- gchar *data, *ptr;
- gsize size, left;
+ GstMapInfo map;
+ gchar *ptr;
+ gsize left;
s = gst_caps_get_structure (caps, 0);
val = gst_structure_get_value (s, "codec_data");
@@ -169,10 +170,10 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
gst_buffer_ref (priv);
- data = gst_buffer_map (priv, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (priv, &map, GST_MAP_READ);
- ptr = data;
- left = size;
+ ptr = (gchar *) map.data;
+ left = map.size;
/* skip UTF-8 BOM */
if (left >= 3 && memcmp (ptr, bom_utf8, 3) == 0) {
@@ -180,26 +181,36 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
left -= 3;
}
- if (!strstr (data, "[Script Info]")) {
- GST_WARNING_OBJECT (parse, "Invalid Init section - no Script Info header");
- gst_buffer_unref (priv);
- return FALSE;
- }
+ if (!strstr (ptr, "[Script Info]"))
+ goto invalid_init;
- if (!g_utf8_validate (ptr, left, NULL)) {
- GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
- gst_buffer_unref (priv);
- return FALSE;
- }
+ if (!g_utf8_validate (ptr, left, NULL))
+ goto invalid_utf8;
/* FIXME: parse initial section */
parse->ini = g_strndup (ptr, left);
GST_LOG_OBJECT (parse, "Init section:\n%s", parse->ini);
- gst_buffer_unmap (priv, data, size);
+ gst_buffer_unmap (priv, &map);
gst_buffer_unref (priv);
return TRUE;
+
+ /* ERRORS */
+invalid_init:
+ {
+ GST_WARNING_OBJECT (parse, "Invalid Init section - no Script Info header");
+ gst_buffer_unmap (priv, &map);
+ gst_buffer_unref (priv);
+ return FALSE;
+ }
+invalid_utf8:
+ {
+ GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
+ gst_buffer_unmap (priv, &map);
+ gst_buffer_unref (priv);
+ return FALSE;
+ }
}
static gboolean
@@ -313,8 +324,7 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * buf)
GstSsaParse *parse = GST_SSA_PARSE (parent);
GstClockTime ts;
gchar *txt;
- gchar *data;
- gsize size;
+ GstMapInfo map;
if (G_UNLIKELY (!parse->framed))
goto not_framed;
@@ -330,9 +340,9 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * buf)
}
/* make double-sure it's 0-terminated and all */
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- txt = g_strndup (data, size);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ txt = g_strndup ((gchar *) map.data, map.size);
+ gst_buffer_unmap (buf, &map);
if (txt == NULL)
goto empty_text;
diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c
index 404be726a..55f5f194c 100644
--- a/gst/subparse/gstsubparse.c
+++ b/gst/subparse/gstsubparse.c
@@ -1435,13 +1435,14 @@ handle_buffer (GstSubParse * self, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
GstCaps *caps = NULL;
- gchar *line, *subtitle, *data;
- gsize size;
+ gchar *line, *subtitle;
if (self->first_buffer) {
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- self->detected_encoding = detect_encoding (data, size);
- gst_buffer_unmap (buf, data, size);
+ GstMapInfo map;
+
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ self->detected_encoding = detect_encoding ((gchar *) map.data, map.size);
+ gst_buffer_unmap (buf, &map);
self->first_buffer = FALSE;
self->state.fps_n = self->fps_n;
self->state.fps_d = self->fps_d;
diff --git a/gst/tcp/gstmultisocketsink.c b/gst/tcp/gstmultisocketsink.c
index aa328e265..16d5180bd 100644
--- a/gst/tcp/gstmultisocketsink.c
+++ b/gst/tcp/gstmultisocketsink.c
@@ -1895,21 +1895,20 @@ gst_multi_socket_sink_handle_client_write (GstMultiSocketSink * sink,
if (client->sending) {
gssize wrote;
GstBuffer *head;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
/* pick first buffer from list */
head = GST_BUFFER (client->sending->data);
- data = gst_buffer_map (head, &size, NULL, GST_MAP_READ);
- maxsize = size - client->bufoffset;
+ gst_buffer_map (head, &map, GST_MAP_READ);
+ maxsize = map.size - client->bufoffset;
/* try to write the complete buffer */
wrote =
- g_socket_send (socket, (gchar *) data + client->bufoffset, maxsize,
- sink->cancellable, &err);
- gst_buffer_unmap (head, data, size);
+ g_socket_send (socket, (gchar *) map.data + client->bufoffset,
+ maxsize, sink->cancellable, &err);
+ gst_buffer_unmap (head, &map);
if (wrote < 0) {
/* hmm error.. */
diff --git a/gst/tcp/gsttcpclientsink.c b/gst/tcp/gsttcpclientsink.c
index a28c03dbc..16097b622 100644
--- a/gst/tcp/gsttcpclientsink.c
+++ b/gst/tcp/gsttcpclientsink.c
@@ -172,8 +172,8 @@ static GstFlowReturn
gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstTCPClientSink *sink;
- guint8 *data;
- gsize size, written = 0;
+ GstMapInfo map;
+ gsize written = 0;
gssize rret;
GError *err = NULL;
@@ -182,20 +182,20 @@ gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_TCP_CLIENT_SINK_OPEN),
GST_FLOW_WRONG_STATE);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
GST_LOG_OBJECT (sink, "writing %" G_GSIZE_FORMAT " bytes for buffer data",
- size);
+ map.size);
/* write buffer data */
- while (written < size) {
+ while (written < map.size) {
rret =
- g_socket_send (sink->socket, (gchar *) data + written, size - written,
- sink->cancellable, &err);
+ g_socket_send (sink->socket, (gchar *) map.data + written,
+ map.size - written, sink->cancellable, &err);
if (rret < 0)
goto write_error;
written += rret;
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
sink->data_written += written;
@@ -206,8 +206,6 @@ write_error:
{
GstFlowReturn ret;
- gst_buffer_unmap (buf, data, size);
-
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
ret = GST_FLOW_WRONG_STATE;
GST_DEBUG_OBJECT (sink, "Cancelled reading from socket");
@@ -215,9 +213,10 @@ write_error:
GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
(_("Error while sending data to \"%s:%d\"."), sink->host, sink->port),
("Only %" G_GSIZE_FORMAT " of %" G_GSIZE_FORMAT " bytes written: %s",
- written, size, err->message));
+ written, map.size, err->message));
ret = GST_FLOW_ERROR;
}
+ gst_buffer_unmap (buf, &map);
g_clear_error (&err);
return ret;
}
diff --git a/gst/tcp/gsttcpclientsrc.c b/gst/tcp/gsttcpclientsrc.c
index 6b906f364..7cd63d635 100644
--- a/gst/tcp/gsttcpclientsrc.c
+++ b/gst/tcp/gsttcpclientsrc.c
@@ -179,7 +179,7 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GstFlowReturn ret = GST_FLOW_OK;
gssize rret;
GError *err = NULL;
- guint8 *data;
+ GstMapInfo map;
gssize avail, read;
src = GST_TCP_CLIENT_SRC (psrc);
@@ -224,14 +224,13 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
if (avail > 0) {
read = MIN (avail, MAX_READ_SIZE);
*outbuf = gst_buffer_new_and_alloc (read);
- data = gst_buffer_map (*outbuf, NULL, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (*outbuf, &map, GST_MAP_READWRITE);
rret =
- g_socket_receive (src->socket, (gchar *) data, read,
+ g_socket_receive (src->socket, (gchar *) map.data, read,
src->cancellable, &err);
} else {
/* Connection closed */
*outbuf = NULL;
- data = NULL;
read = 0;
rret = 0;
}
@@ -240,7 +239,7 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_DEBUG_OBJECT (src, "Connection closed");
ret = GST_FLOW_EOS;
if (*outbuf) {
- gst_buffer_unmap (*outbuf, data, read);
+ gst_buffer_unmap (*outbuf, &map);
gst_buffer_unref (*outbuf);
}
*outbuf = NULL;
@@ -253,12 +252,13 @@ gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Failed to read from socket: %s", err->message));
}
- gst_buffer_unmap (*outbuf, data, read);
+ gst_buffer_unmap (*outbuf, &map);
gst_buffer_unref (*outbuf);
*outbuf = NULL;
} else {
ret = GST_FLOW_OK;
- gst_buffer_unmap (*outbuf, data, rret);
+ gst_buffer_unmap (*outbuf, &map);
+ gst_buffer_resize (*outbuf, 0, rret);
GST_LOG_OBJECT (src,
"Returning buffer from _get of size %" G_GSIZE_FORMAT ", ts %"
diff --git a/gst/tcp/gsttcpserversrc.c b/gst/tcp/gsttcpserversrc.c
index d983094b8..93e1afa96 100644
--- a/gst/tcp/gsttcpserversrc.c
+++ b/gst/tcp/gsttcpserversrc.c
@@ -165,7 +165,7 @@ gst_tcp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
gssize rret, avail;
gsize read;
GError *err = NULL;
- guint8 *data;
+ GstMapInfo map;
src = GST_TCP_SERVER_SRC (psrc);
@@ -219,15 +219,14 @@ gst_tcp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
if (avail > 0) {
read = MIN (avail, MAX_READ_SIZE);
*outbuf = gst_buffer_new_and_alloc (read);
- data = gst_buffer_map (*outbuf, NULL, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (*outbuf, &map, GST_MAP_READWRITE);
rret =
- g_socket_receive (src->client_socket, (gchar *) data, read,
+ g_socket_receive (src->client_socket, (gchar *) map.data, read,
src->cancellable, &err);
} else {
/* Connection closed */
rret = 0;
*outbuf = NULL;
- data = NULL;
read = 0;
}
@@ -235,7 +234,7 @@ gst_tcp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_DEBUG_OBJECT (src, "Connection closed");
ret = GST_FLOW_EOS;
if (*outbuf) {
- gst_buffer_unmap (*outbuf, data, MAX_READ_SIZE);
+ gst_buffer_unmap (*outbuf, &map);
gst_buffer_unref (*outbuf);
}
*outbuf = NULL;
@@ -248,12 +247,13 @@ gst_tcp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Failed to read from socket: %s", err->message));
}
- gst_buffer_unmap (*outbuf, data, MAX_READ_SIZE);
+ gst_buffer_unmap (*outbuf, &map);
gst_buffer_unref (*outbuf);
*outbuf = NULL;
} else {
ret = GST_FLOW_OK;
- gst_buffer_unmap (*outbuf, data, rret);
+ gst_buffer_unmap (*outbuf, &map);
+ gst_buffer_resize (*outbuf, 0, rret);
GST_LOG_OBJECT (src,
"Returning buffer from _get of size %" G_GSIZE_FORMAT ", ts %"
diff --git a/gst/videoconvert/gstvideoconvert.c b/gst/videoconvert/gstvideoconvert.c
index 0167cf75d..69646bf50 100644
--- a/gst/videoconvert/gstvideoconvert.c
+++ b/gst/videoconvert/gstvideoconvert.c
@@ -232,7 +232,7 @@ gst_video_convert_set_info (GstVideoFilter * filter,
goto format_mismatch;
} else if (GST_VIDEO_INFO_FORMAT (in_info) == GST_VIDEO_FORMAT_RGB8_PALETTED) {
GstBuffer *palette;
- guint32 *data;
+ GstMapInfo map;
palette = gst_video_parse_caps_palette (incaps);
@@ -242,9 +242,9 @@ gst_video_convert_set_info (GstVideoFilter * filter,
goto invalid_palette;
}
- data = gst_buffer_map (palette, NULL, NULL, GST_MAP_READ);
- videoconvert_convert_set_palette (space->convert, data);
- gst_buffer_unmap (palette, data, -1);
+ gst_buffer_map (palette, &map, GST_MAP_READ);
+ videoconvert_convert_set_palette (space->convert, (guint32 *) map.data);
+ gst_buffer_unmap (palette, &map);
gst_buffer_unref (palette);
} else if (GST_VIDEO_INFO_FORMAT (out_info) == GST_VIDEO_FORMAT_RGB8_PALETTED) {
diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c
index 97b7fb0f8..e79f9ef70 100644
--- a/gst/volume/gstvolume.c
+++ b/gst/volume/gstvolume.c
@@ -799,8 +799,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
{
GstAudioFilter *filter = GST_AUDIO_FILTER_CAST (base);
GstVolume *self = GST_VOLUME (base);
- guint8 *data;
- gsize size;
+ GstMapInfo map;
GstControlBinding *mute_cb, *volume_cb;
if (G_UNLIKELY (!self->negotiated))
@@ -811,7 +810,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
GST_BUFFER_FLAG_IS_SET (outbuf, GST_BUFFER_FLAG_GAP))
return GST_FLOW_OK;
- data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
mute_cb = gst_object_get_control_binding (GST_OBJECT (self), "mute");
volume_cb = gst_object_get_control_binding (GST_OBJECT (self), "volume");
@@ -820,7 +819,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
gint rate = GST_AUDIO_INFO_RATE (&filter->info);
gint width = GST_AUDIO_FORMAT_INFO_WIDTH (filter->info.finfo) / 8;
gint channels = GST_AUDIO_INFO_CHANNELS (&filter->info);
- guint nsamples = size / (width * channels);
+ guint nsamples = map.size / (width * channels);
GstClockTime interval = gst_util_uint64_scale_int (1, GST_SECOND, rate);
GstClockTime ts = GST_BUFFER_TIMESTAMP (outbuf);
gboolean use_mutes = FALSE;
@@ -864,20 +863,23 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf)
orc_prepare_volumes (self->volumes, self->mutes, nsamples);
}
- self->process_controlled (self, data, self->volumes, channels, size);
+ self->process_controlled (self, map.data, self->volumes, channels,
+ map.size);
- return GST_FLOW_OK;
+ goto done;
} else if (volume_cb) {
gst_object_unref (volume_cb);
}
if (self->current_volume == 0.0 || self->current_mute) {
- orc_memset (data, 0, size);
+ orc_memset (map.data, 0, map.size);
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
} else if (self->current_volume != 1.0) {
- self->process (self, data, size);
+ self->process (self, map.data, map.size);
}
- gst_buffer_unmap (outbuf, data, size);
+
+done:
+ gst_buffer_unmap (outbuf, &map);
return GST_FLOW_OK;
@@ -897,7 +899,7 @@ controller_failure:
GST_ELEMENT_ERROR (self, CORE, FAILED,
("Failed to get values from controller"), (NULL));
- gst_buffer_unmap (outbuf, data, size);
+ gst_buffer_unmap (outbuf, &map);
return GST_FLOW_ERROR;
}
}
diff --git a/tests/check/elements/audioresample.c b/tests/check/elements/audioresample.c
index c05bd0faf..b489b9914 100644
--- a/tests/check/elements/audioresample.c
+++ b/tests/check/elements/audioresample.c
@@ -186,7 +186,8 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
GstCaps *caps;
guint64 offset = 0;
int i, j;
- gint16 *p, *data;
+ GstMapInfo map;
+ gint16 *p;
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_current_caps (mysrcpad);
@@ -205,7 +206,8 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
offset += samples;
GST_BUFFER_OFFSET_END (inbuffer) = offset;
- p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
+ p = (gint16 *) map.data;
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
@@ -214,7 +216,7 @@ test_perfect_stream_instance (int inrate, int outrate, int samples,
*p = -32767 + i * (65535 / samples);
++p;
}
- gst_buffer_unmap (inbuffer, data, samples * 4);
+ gst_buffer_unmap (inbuffer, &map);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
@@ -269,7 +271,8 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
GstClockTime ints;
int i, j;
- gint16 *p, *data;
+ GstMapInfo map;
+ gint16 *p;
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
@@ -292,7 +295,8 @@ test_discont_stream_instance (int inrate, int outrate, int samples,
GST_BUFFER_OFFSET (inbuffer) = (j - 1) * 2 * samples;
GST_BUFFER_OFFSET_END (inbuffer) = j * 2 * samples + samples;
- p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
+ p = (gint16 *) map.data;
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
@@ -300,7 +304,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_buffer_unmap (inbuffer, &map);
GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
@@ -357,7 +361,6 @@ GST_START_TEST (test_reuse)
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
- guint8 *data;
GstSegment segment;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
@@ -373,9 +376,7 @@ GST_START_TEST (test_reuse)
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
- data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
- memset (data, 0, 9343 * 4);
- gst_buffer_unmap (inbuffer, data, 9343 * 4);
+ gst_buffer_memset (inbuffer, 0, 0, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
@@ -398,9 +399,7 @@ GST_START_TEST (test_reuse)
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
- data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
- memset (data, 0, 9343 * 4);
- gst_buffer_unmap (inbuffer, data, 9343 * 4);
+ gst_buffer_memset (inbuffer, 0, 0, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
@@ -946,29 +945,28 @@ static gboolean is_zero_except_##ffttag (const GstFFT##ffttag##Complex *v, int e
} \
static void compare_ffts_##ffttag (GstBuffer *inbuffer, GstBuffer *outbuffer) \
{ \
- gsize insize, outsize; \
- gpointer indata, outdata; \
+ GstMapInfo inmap, outmap; \
int insamples, outsamples; \
gdouble inspot, outspot; \
GstFFT##ffttag *inctx, *outctx; \
GstFFT##ffttag##Complex *in, *out; \
\
- indata = gst_buffer_map (inbuffer, &insize, NULL, GST_MAP_READ); \
- outdata = gst_buffer_map (outbuffer, &outsize, NULL, GST_MAP_READWRITE); \
+ gst_buffer_map (inbuffer, &inmap, GST_MAP_READ); \
+ gst_buffer_map (outbuffer, &outmap, GST_MAP_READWRITE); \
\
- insamples = insize / sizeof(type) & ~1; \
- outsamples = outsize / sizeof(type) & ~1; \
+ insamples = inmap.size / sizeof(type) & ~1; \
+ outsamples = outmap.size / sizeof(type) & ~1; \
inctx = gst_fft_##ffttag2##_new (insamples, FALSE); \
outctx = gst_fft_##ffttag2##_new (outsamples, FALSE); \
in = g_new (GstFFT##ffttag##Complex, insamples / 2 + 1); \
out = g_new (GstFFT##ffttag##Complex, outsamples / 2 + 1); \
\
- gst_fft_##ffttag2##_window (inctx, (type*)indata, \
+ gst_fft_##ffttag2##_window (inctx, (type*)inmap.data, \
GST_FFT_WINDOW_HAMMING); \
- gst_fft_##ffttag2##_fft (inctx, (type*)indata, in); \
- gst_fft_##ffttag2##_window (outctx, (type*)outdata, \
+ gst_fft_##ffttag2##_fft (inctx, (type*)inmap.data, in); \
+ gst_fft_##ffttag2##_window (outctx, (type*)outmap.data, \
GST_FFT_WINDOW_HAMMING); \
- gst_fft_##ffttag2##_fft (outctx, (type*)outdata, out); \
+ gst_fft_##ffttag2##_fft (outctx, (type*)outmap.data, out); \
\
inspot = find_main_frequency_spot_##ffttag (in, insamples / 2 + 1); \
outspot = find_main_frequency_spot_##ffttag (out, outsamples / 2 + 1); \
@@ -977,8 +975,8 @@ static void compare_ffts_##ffttag (GstBuffer *inbuffer, GstBuffer *outbuffer)
fail_unless (is_zero_except_##ffttag (in, insamples / 2 + 1, inspot)); \
fail_unless (is_zero_except_##ffttag (out, outsamples / 2 + 1, outspot)); \
\
- gst_buffer_unmap (inbuffer, indata, insize); \
- gst_buffer_unmap (outbuffer, outdata, outsize); \
+ gst_buffer_unmap (inbuffer, &inmap); \
+ gst_buffer_unmap (outbuffer, &outmap); \
\
gst_fft_##ffttag2##_free (inctx); \
gst_fft_##ffttag2##_free (outctx); \
@@ -993,9 +991,12 @@ FFT_HELPERS (gint32, S32, s32, 2147483647.0);
#define FILL_BUFFER(type, desc, value); \
static void init_##type##_##desc (GstBuffer *buffer) \
{ \
- gsize size; \
- type *ptr = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE); \
- int i, nsamples = size / sizeof (type); \
+ GstMapInfo map; \
+ type *ptr; \
+ int i, nsamples; \
+ gst_buffer_map (buffer, &map, GST_MAP_WRITE); \
+ ptr = (type *)map.data; \
+ nsamples = map.size / sizeof (type); \
for (i = 0; i < nsamples; ++i) { \
*ptr++ = value; \
} \
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/elements/playbin.c b/tests/check/elements/playbin.c
index d3758ebd1..9c307cc66 100644
--- a/tests/check/elements/playbin.c
+++ b/tests/check/elements/playbin.c
@@ -568,17 +568,17 @@ static GstFlowReturn
gst_red_video_src_create (GstPushSrc * src, GstBuffer ** p_buf)
{
GstBuffer *buf;
- guint8 *data;
+ GstMapInfo map;
guint w = 64, h = 64;
guint size;
size = w * h * 3 / 2;
buf = gst_buffer_new_and_alloc (size);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- memset (data, 76, w * h);
- memset (data + (w * h), 85, (w * h) / 4);
- memset (data + (w * h) + ((w * h) / 4), 255, (w * h) / 4);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ memset (map.data, 76, w * h);
+ memset (map.data + (w * h), 85, (w * h) / 4);
+ memset (map.data + (w * h) + ((w * h) / 4), 255, (w * h) / 4);
+ gst_buffer_unmap (buf, &map);
*p_buf = buf;
return GST_FLOW_OK;
@@ -681,12 +681,9 @@ static GstFlowReturn
gst_codec_src_create (GstPushSrc * src, GstBuffer ** p_buf)
{
GstBuffer *buf;
- guint8 *data;
buf = gst_buffer_new_and_alloc (20);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- memset (data, 0, 20);
- gst_buffer_unmap (buf, data, 20);
+ gst_buffer_memset (buf, 0, 0, 20);
*p_buf = buf;
return GST_FLOW_OK;
diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c
index fc15a11cd..b0f43ba86 100644
--- a/tests/check/elements/subparse.c
+++ b/tests/check/elements/subparse.c
@@ -214,8 +214,7 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
for (n = start_idx; n < start_idx + num; ++n) {
const GstStructure *buffer_caps_struct;
GstBuffer *buf;
- gchar *out;
- gsize out_size;
+ GstMapInfo map;
buf = g_list_nth_data (buffers, n - start_idx);
fail_unless (buf != NULL);
@@ -225,19 +224,19 @@ test_srt_do_test (SubParseInputChunk * input, guint start_idx, guint num)
fail_unless_equals_uint64 (GST_BUFFER_DURATION (buf),
input[n].to_ts - input[n].from_ts);
- out = gst_buffer_map (buf, &out_size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
/* can be NULL */
- if (out != NULL) {
+ if (map.data != NULL) {
/* shouldn't have trailing newline characters */
- fail_if (out_size > 0 && out[out_size - 1] == '\n');
+ fail_if (map.size > 0 && map.data[map.size - 1] == '\n');
/* shouldn't include NUL-terminator in data size */
- fail_if (out_size > 0 && out[out_size - 1] == '\0');
+ fail_if (map.size > 0 && map.data[map.size - 1] == '\0');
/* but should still have a NUL-terminator behind the declared data */
- fail_unless_equals_int (out[out_size], '\0');
+ fail_unless_equals_int (map.data[map.size], '\0');
/* make sure out string matches expected string */
- fail_unless_equals_string (out, input[n].out);
+ fail_unless_equals_string ((gchar *) map.data, input[n].out);
}
- gst_buffer_unmap (buf, out, out_size);
+ gst_buffer_unmap (buf, &map);
/* check caps */
fail_unless (outcaps != NULL);
buffer_caps_struct = gst_caps_get_structure (outcaps, 0);
@@ -301,8 +300,7 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
for (n = 0; n < num; ++n) {
const GstStructure *buffer_caps_struct;
GstBuffer *buf;
- gchar *out;
- gsize out_size;
+ GstMapInfo map;
buf = g_list_nth_data (buffers, n);
fail_unless (buf != NULL);
@@ -319,19 +317,19 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type)
input[n].to_ts - input[n].from_ts);
}
- out = gst_buffer_map (buf, &out_size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
/* can be NULL */
- if (out != NULL) {
+ if (map.data != NULL) {
/* shouldn't have trailing newline characters */
- fail_if (out_size > 0 && out[out_size - 1] == '\n');
+ fail_if (map.size > 0 && map.data[map.size - 1] == '\n');
/* shouldn't include NUL-terminator in data size */
- fail_if (out_size > 0 && out[out_size - 1] == '\0');
+ fail_if (map.size > 0 && map.data[map.size - 1] == '\0');
/* but should still have a NUL-terminator behind the declared data */
- fail_unless_equals_int (out[out_size], '\0');
+ fail_unless_equals_int (map.data[map.size], '\0');
/* make sure out string matches expected string */
- fail_unless_equals_string (out, input[n].out);
+ fail_unless_equals_string ((gchar *) map.data, input[n].out);
}
- gst_buffer_unmap (buf, out, out_size);
+ gst_buffer_unmap (buf, &map);
/* check caps */
fail_unless (outcaps != NULL);
buffer_caps_struct = gst_caps_get_structure (outcaps, 0);
diff --git a/tests/check/elements/textoverlay.c b/tests/check/elements/textoverlay.c
index 597565057..e015a64cc 100644
--- a/tests/check/elements/textoverlay.c
+++ b/tests/check/elements/textoverlay.c
@@ -164,8 +164,7 @@ buffer_is_all_black (GstBuffer * buf, GstCaps * caps)
{
GstStructure *s;
gint x, y, w, h;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
fail_unless (buf != NULL);
fail_unless (caps != NULL);
@@ -174,9 +173,9 @@ buffer_is_all_black (GstBuffer * buf, GstCaps * caps)
fail_unless (gst_structure_get_int (s, "width", &w));
fail_unless (gst_structure_get_int (s, "height", &h));
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
for (y = 0; y < h; ++y) {
- guint8 *ptr = data + (y * GST_ROUND_UP_4 (w));
+ guint8 *ptr = map.data + (y * GST_ROUND_UP_4 (w));
for (x = 0; x < w; ++x) {
if (ptr[x] != 0x00) {
@@ -185,7 +184,7 @@ buffer_is_all_black (GstBuffer * buf, GstCaps * caps)
}
}
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
return TRUE;
}
@@ -208,7 +207,6 @@ create_black_buffer (GstCaps * caps)
GstStructure *s;
GstBuffer *buffer;
gint w, h, size;
- guint8 *data;
fail_unless (caps != NULL);
@@ -220,12 +218,9 @@ create_black_buffer (GstCaps * caps)
size = I420_SIZE (w, h);
buffer = gst_buffer_new_and_alloc (size);
-
- data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
/* we're only checking the Y plane later, so just zero it all out,
* even if it's not the blackest black there is */
- memset (data, 0, size);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_memset (buffer, 0, 0, size);
/* double check to make sure it's been created right */
fail_unless (buffer_is_all_black (buffer, caps));
diff --git a/tests/check/elements/videoscale.c b/tests/check/elements/videoscale.c
index 3c67b4088..6f270307d 100644
--- a/tests/check/elements/videoscale.c
+++ b/tests/check/elements/videoscale.c
@@ -240,15 +240,14 @@ GST_START_TEST (test_passthrough)
l1 = l1->next, l2 = l2->next) {
GstBuffer *a = l1->data;
GstBuffer *b = l2->data;
- gsize sa, sb;
- guint8 *pa, *pb;
-
- pa = gst_buffer_map (a, &sa, NULL, GST_MAP_READ);
- pb = gst_buffer_map (b, &sb, NULL, GST_MAP_READ);
- fail_unless_equals_int (sa, sb);
- fail_unless (pa == pb);
- gst_buffer_unmap (b, pb, sb);
- gst_buffer_unmap (a, pa, sa);
+ GstMapInfo mapa, mapb;
+
+ gst_buffer_map (a, &mapa, GST_MAP_READ);
+ gst_buffer_map (b, &mapb, GST_MAP_READ);
+ fail_unless_equals_int (mapa.size, mapb.size);
+ fail_unless (mapa.data == mapb.data);
+ gst_buffer_unmap (b, &mapb);
+ gst_buffer_unmap (a, &mapa);
gst_buffer_unref (a);
gst_buffer_unref (b);
diff --git a/tests/check/elements/videotestsrc.c b/tests/check/elements/videotestsrc.c
index 88a760b5e..82cc0ea19 100644
--- a/tests/check/elements/videotestsrc.c
+++ b/tests/check/elements/videotestsrc.c
@@ -288,8 +288,7 @@ GST_START_TEST (test_rgb_formats)
/* caps are supported, let's run some tests then ... */
for (p = 0; p < G_N_ELEMENTS (test_patterns); ++p) {
GstStateChangeReturn state_ret;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
g_object_set (src, "pattern", test_patterns[p].pattern_enum, NULL);
@@ -329,13 +328,13 @@ GST_START_TEST (test_rgb_formats)
}
/* now check the first pixel */
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- check_rgb_buf (data, rgb_formats[i].red_mask,
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ check_rgb_buf (map.data, rgb_formats[i].red_mask,
rgb_formats[i].green_mask, rgb_formats[i].blue_mask,
rgb_formats[i].alpha_mask, test_patterns[p].r_expected,
test_patterns[p].g_expected, test_patterns[p].b_expected,
rgb_formats[i].bpp, rgb_formats[i].depth);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
buf = NULL;
diff --git a/tests/check/elements/volume.c b/tests/check/elements/volume.c
index d692b598b..ce108e965 100644
--- a/tests/check/elements/volume.c
+++ b/tests/check/elements/volume.c
@@ -26,6 +26,7 @@
#include <gst/check/gstcheck.h>
#include <gst/audio/streamvolume.h>
#include <gst/controller/gstinterpolationcontrolsource.h>
+#include <gst/controller/gstcontrolbindingdirect.h>
/* 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,
@@ -178,8 +179,7 @@ GST_START_TEST (test_unity_s8)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint8 in[2] = { 64, -16 };
- gint8 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
@@ -200,10 +200,11 @@ GST_START_TEST (test_unity_s8)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
- fail_unless (memcmp (res, in, 2) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, in, 2) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -219,8 +220,7 @@ GST_START_TEST (test_half_s8)
GstCaps *caps;
gint8 in[2] = { 64, -16 };
gint8 out[2] = { 32, -8 };
- gint8 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -247,11 +247,11 @@ GST_START_TEST (test_half_s8)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 2) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 2) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -267,8 +267,7 @@ GST_START_TEST (test_double_s8)
GstCaps *caps;
gint8 in[2] = { 64, -16 };
gint8 out[2] = { 127, -32 }; /* notice the clamped sample */
- gint8 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -295,11 +294,11 @@ GST_START_TEST (test_double_s8)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 2) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 2) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -315,8 +314,7 @@ GST_START_TEST (test_ten_s8)
GstCaps *caps;
gint8 in[2] = { 64, -10 };
gint8 out[2] = { 127, -100 }; /* notice the clamped sample */
- gint8 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@@ -344,11 +342,11 @@ GST_START_TEST (test_ten_s8)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 2) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 2) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -364,8 +362,7 @@ GST_START_TEST (test_mute_s8)
GstCaps *caps;
gint8 in[2] = { 64, -16 };
gint8 out[2] = { 0, 0 };
- gint8 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -392,11 +389,11 @@ GST_START_TEST (test_mute_s8)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 2) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 2) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -410,8 +407,7 @@ GST_START_TEST (test_unity_s16)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
@@ -432,10 +428,11 @@ GST_START_TEST (test_unity_s16)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
- fail_unless (memcmp (res, in, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, in, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -451,8 +448,7 @@ GST_START_TEST (test_half_s16)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[2] = { 8192, -128 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -479,11 +475,11 @@ GST_START_TEST (test_half_s16)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -499,8 +495,7 @@ GST_START_TEST (test_double_s16)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[2] = { 32767, -512 }; /* notice the clamped sample */
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -527,11 +522,11 @@ GST_START_TEST (test_double_s16)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -547,8 +542,7 @@ GST_START_TEST (test_ten_s16)
GstCaps *caps;
gint16 in[2] = { 16384, -10 };
gint16 out[2] = { 32767, -100 }; /* notice the clamped sample */
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@@ -576,11 +570,11 @@ GST_START_TEST (test_ten_s16)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -597,8 +591,7 @@ GST_START_TEST (test_mute_s16)
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
gint16 out[2] = { 0, 0 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -625,11 +618,11 @@ GST_START_TEST (test_mute_s16)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -652,9 +645,8 @@ GST_START_TEST (test_unity_s24)
GstCaps *caps;
gint32 in_32[2] = { 4194304, -4096 };
guint8 in[6];
- guint8 *res;
+ GstMapInfo map;
gint32 res_32[2];
- gsize size;
write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]);
@@ -678,15 +670,15 @@ GST_START_TEST (test_unity_s24)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
- res_32[0] = get_unaligned_i24 (res);
- res_32[1] = get_unaligned_i24 ((res + 3));
+ res_32[0] = get_unaligned_i24 (map.data);
+ res_32[1] = get_unaligned_i24 ((map.data + 3));
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in_32[0], in_32[1], res_32[0],
res_32[1]);
- fail_unless (memcmp (res, in, 6) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ fail_unless (memcmp (map.data, in, 6) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -702,10 +694,9 @@ GST_START_TEST (test_half_s24)
GstCaps *caps;
gint32 in_32[2] = { 4194304, -4096 };
guint8 in[6];
- guint8 *res;
+ GstMapInfo map;
gint32 res_32[2];
gint32 out_32[2] = { 2097152, -2048 };
- gsize size;
write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]);
@@ -735,15 +726,15 @@ GST_START_TEST (test_half_s24)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
- res_32[0] = get_unaligned_i24 (res);
- res_32[1] = get_unaligned_i24 ((res + 3));
+ res_32[0] = get_unaligned_i24 (map.data);
+ res_32[1] = get_unaligned_i24 ((map.data + 3));
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
res_32[0], res_32[1]);
fail_unless (memcmp (res_32, out_32, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -759,10 +750,9 @@ GST_START_TEST (test_double_s24)
GstCaps *caps;
gint32 in_32[2] = { 4194304, -4096 };
guint8 in[6];
- guint8 *res;
+ GstMapInfo map;
gint32 res_32[2];
gint32 out_32[2] = { 8388607, -8192 }; /* notice the clamped sample */
- gsize size;
write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]);
@@ -792,15 +782,15 @@ GST_START_TEST (test_double_s24)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
- res_32[0] = get_unaligned_i24 (res);
- res_32[1] = get_unaligned_i24 ((res + 3));
+ res_32[0] = get_unaligned_i24 (map.data);
+ res_32[1] = get_unaligned_i24 ((map.data + 3));
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
res_32[0], res_32[1]);
fail_unless (memcmp (res_32, out_32, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -816,10 +806,9 @@ GST_START_TEST (test_ten_s24)
GstCaps *caps;
gint32 in_32[2] = { 4194304, -10 };
guint8 in[6];
- guint8 *res;
+ GstMapInfo map;
gint32 res_32[2];
gint32 out_32[2] = { 8388607, -100 }; /* notice the clamped sample */
- gsize size;
write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]);
@@ -850,15 +839,15 @@ GST_START_TEST (test_ten_s24)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
- res_32[0] = get_unaligned_i24 (res);
- res_32[1] = get_unaligned_i24 ((res + 3));
+ res_32[0] = get_unaligned_i24 (map.data);
+ res_32[1] = get_unaligned_i24 ((map.data + 3));
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
res_32[0], res_32[1]);
fail_unless (memcmp (res_32, out_32, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -874,10 +863,9 @@ GST_START_TEST (test_mute_s24)
GstCaps *caps;
gint32 in_32[2] = { 4194304, -4096 };
guint8 in[6];
- guint8 *res;
+ GstMapInfo map;
gint32 res_32[2];
gint32 out_32[2] = { 0, 0 }; /* notice the clamped sample */
- gsize size;
write_unaligned_u24 (in, in_32[0]);
write_unaligned_u24 (in + 3, in_32[1]);
@@ -908,15 +896,15 @@ GST_START_TEST (test_mute_s24)
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
- res_32[0] = get_unaligned_i24 (res);
- res_32[1] = get_unaligned_i24 ((res + 3));
+ res_32[0] = get_unaligned_i24 (map.data);
+ res_32[1] = get_unaligned_i24 ((map.data + 3));
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
res_32[0], res_32[1]);
fail_unless (memcmp (res_32, out_32, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -930,8 +918,7 @@ GST_START_TEST (test_unity_s32)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint32 in[2] = { 1073741824, -65536 };
- gint32 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
@@ -952,10 +939,11 @@ GST_START_TEST (test_unity_s32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
- fail_unless (memcmp (res, in, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, in, 8) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -971,8 +959,7 @@ GST_START_TEST (test_half_s32)
GstCaps *caps;
gint32 in[2] = { 1073741824, -65536 };
gint32 out[2] = { 536870912, -32768 };
- gint32 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -999,11 +986,11 @@ GST_START_TEST (test_half_s32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 8) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1019,8 +1006,7 @@ GST_START_TEST (test_double_s32)
GstCaps *caps;
gint32 in[2] = { 1073741824, -65536 };
gint32 out[2] = { 2147483647, -131072 }; /* notice the clamped sample */
- gint32 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -1047,11 +1033,11 @@ GST_START_TEST (test_double_s32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 8) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1067,8 +1053,7 @@ GST_START_TEST (test_ten_s32)
GstCaps *caps;
gint32 in[2] = { 1073741824, -10 };
gint32 out[2] = { 2147483647, -100 }; /* notice the clamped sample */
- gint32 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@@ -1096,11 +1081,11 @@ GST_START_TEST (test_ten_s32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 8) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1116,8 +1101,7 @@ GST_START_TEST (test_mute_s32)
GstCaps *caps;
gint32 in[2] = { 1073741824, -65536 };
gint32 out[2] = { 0, 0 };
- gint32 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -1144,11 +1128,11 @@ GST_START_TEST (test_mute_s32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
- res[1]);
- fail_unless (memcmp (res, out, 8) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, out, 8) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1162,8 +1146,7 @@ GST_START_TEST (test_unity_f32)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
- gfloat *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
@@ -1184,11 +1167,11 @@ GST_START_TEST (test_unity_f32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1], res[0],
- res[1]);
- fail_unless_equals_float (res[0], in[0]);
- fail_unless_equals_float (res[1], in[1]);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1],
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], in[0]);
+ fail_unless_equals_float (map.data[1], in[1]);
/* cleanup */
cleanup_volume (volume);
@@ -1204,8 +1187,7 @@ GST_START_TEST (test_half_f32)
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
gfloat out[2] = { 0.375, -0.125 };
- gfloat *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -1232,12 +1214,12 @@ GST_START_TEST (test_half_f32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1253,8 +1235,7 @@ GST_START_TEST (test_double_f32)
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
gfloat out[2] = { 1.5, -0.5 }; /* nothing is clamped */
- gfloat *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -1281,12 +1262,12 @@ GST_START_TEST (test_double_f32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1302,8 +1283,7 @@ GST_START_TEST (test_ten_f32)
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
gfloat out[2] = { 7.5, -2.5 }; /* nothing is clamped */
- gfloat *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@@ -1331,12 +1311,12 @@ GST_START_TEST (test_ten_f32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1353,8 +1333,7 @@ GST_START_TEST (test_mute_f32)
GstCaps *caps;
gfloat in[2] = { 0.75, -0.25 };
gfloat out[2] = { 0, 0 };
- gfloat *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -1381,12 +1360,12 @@ GST_START_TEST (test_mute_f32)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1400,8 +1379,7 @@ GST_START_TEST (test_unity_f64)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
- gdouble *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
fail_unless (gst_element_set_state (volume,
@@ -1422,11 +1400,11 @@ GST_START_TEST (test_unity_f64)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1], res[0],
- res[1]);
- fail_unless_equals_float (res[0], in[0]);
- fail_unless_equals_float (res[1], in[1]);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1],
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], in[0]);
+ fail_unless_equals_float (map.data[1], in[1]);
/* cleanup */
cleanup_volume (volume);
@@ -1442,8 +1420,7 @@ GST_START_TEST (test_half_f64)
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
gdouble out[2] = { 0.375, -0.125 };
- gdouble *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
@@ -1470,12 +1447,12 @@ GST_START_TEST (test_half_f64)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1491,8 +1468,7 @@ GST_START_TEST (test_double_f64)
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
gdouble out[2] = { 1.5, -0.5 }; /* nothing is clamped */
- gdouble *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
@@ -1519,12 +1495,12 @@ GST_START_TEST (test_double_f64)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1540,8 +1516,7 @@ GST_START_TEST (test_ten_f64)
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
gdouble out[2] = { 7.5, -2.5 }; /* nothing is clamped */
- gdouble *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
@@ -1569,12 +1544,12 @@ GST_START_TEST (test_ten_f64)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1591,8 +1566,7 @@ GST_START_TEST (test_mute_f64)
GstCaps *caps;
gdouble in[2] = { 0.75, -0.25 };
gdouble out[2] = { 0, 0 };
- gdouble *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
@@ -1619,12 +1593,12 @@ GST_START_TEST (test_mute_f64)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
- res[0], res[1]);
- fail_unless_equals_float (res[0], out[0]);
- fail_unless_equals_float (res[1], out[1]);
- gst_buffer_unmap (outbuffer, res, size);
+ map.data[0], map.data[1]);
+ fail_unless_equals_float (map.data[0], out[0]);
+ fail_unless_equals_float (map.data[1], out[1]);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1685,8 +1659,7 @@ GST_START_TEST (test_passthrough)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
g_object_set (G_OBJECT (volume), "volume", 1.0, NULL);
@@ -1708,10 +1681,11 @@ GST_START_TEST (test_passthrough)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
- fail_unless (memcmp (res, in, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, in, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
/* cleanup */
cleanup_volume (volume);
@@ -1753,8 +1727,7 @@ GST_START_TEST (test_controller_processing)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
@@ -1783,10 +1756,11 @@ GST_START_TEST (test_controller_processing)
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
fail_unless (inbuffer == outbuffer);
- res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
- GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
- fail_unless (memcmp (res, in, 4) == 0);
- gst_buffer_unmap (outbuffer, res, size);
+ gst_buffer_map (outbuffer, &map, GST_MAP_READ);
+ GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], map.data[0],
+ map.data[1]);
+ fail_unless (memcmp (map.data, in, 4) == 0);
+ gst_buffer_unmap (outbuffer, &map);
gst_object_unref (csource);
cleanup_volume (volume);
diff --git a/tests/check/elements/vorbistag.c b/tests/check/elements/vorbistag.c
index d89d2e0a3..eb1a3dc7c 100644
--- a/tests/check/elements/vorbistag.c
+++ b/tests/check/elements/vorbistag.c
@@ -167,13 +167,12 @@ stop_pipeline (GstElement * element)
static void
compare_buffer (GstBuffer * buf, const guint8 * data, gsize size)
{
- guint8 *bdata;
- gsize bsize;
+ GstMapInfo map;
- bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
- fail_unless_equals_int (bsize, size);
- fail_unless_equals_int (memcmp (bdata, data, size), 0);
- gst_buffer_unmap (buf, bdata, bsize);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ fail_unless_equals_int (map.size, size);
+ fail_unless_equals_int (memcmp (map.data, data, size), 0);
+ gst_buffer_unmap (buf, &map);
}
static vorbis_comment vc;
@@ -218,6 +217,7 @@ _create_audio_buffer (void)
vorbis_bitrate_flushpacket (&vd, &packet);
buffer = gst_buffer_new_and_alloc (packet.bytes);
gst_buffer_fill (buffer, 0, packet.packet, packet.bytes);
+ GST_DEBUG ("%p %d", packet.packet, packet.bytes);
vorbis_comment_clear (&vc);
vorbis_block_clear (&vb);
diff --git a/tests/check/gst/typefindfunctions.c b/tests/check/gst/typefindfunctions.c
index c9d8a3363..218fe7689 100644
--- a/tests/check/gst/typefindfunctions.c
+++ b/tests/check/gst/typefindfunctions.c
@@ -230,14 +230,15 @@ GST_START_TEST (test_ac3)
GstBuffer *buf;
GstCaps *caps = NULL;
guint bsid;
- guint8 *data;
for (bsid = 0; bsid < 32; bsid++) {
+ GstMapInfo map;
+
buf = gst_buffer_new_and_alloc ((256 + 640) * 2);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- make_ac3_packet (data, 256 * 2, bsid);
- make_ac3_packet (data + 256 * 2, 640 * 2, bsid);
- gst_buffer_unmap (buf, data, (256 + 640) * 2);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ make_ac3_packet (map.data, 256 * 2, bsid);
+ make_ac3_packet (map.data + 256 * 2, 640 * 2, bsid);
+ gst_buffer_unmap (buf, &map);
caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
if (bsid <= 8) {
@@ -292,14 +293,15 @@ GST_START_TEST (test_eac3)
GstBuffer *buf;
GstCaps *caps = NULL;
guint bsid;
- guint8 *data;
for (bsid = 0; bsid <= 32; bsid++) {
+ GstMapInfo map;
+
buf = gst_buffer_new_and_alloc (558 + 384);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- make_eac3_packet (data, 558, bsid);
- make_eac3_packet (data + 558, 384, bsid);
- gst_buffer_unmap (buf, data, 558 + 384);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ make_eac3_packet (map.data, 558, bsid);
+ make_eac3_packet (map.data + 558, 384, bsid);
+ gst_buffer_unmap (buf, &map);
caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
if (bsid > 10 && bsid <= 16) {
diff --git a/tests/check/libs/audio.c b/tests/check/libs/audio.c
index 09550818a..745a0a61a 100644
--- a/tests/check/libs/audio.c
+++ b/tests/check/libs/audio.c
@@ -35,8 +35,8 @@ GST_START_TEST (test_buffer_clipping_time)
GstSegment s;
GstBuffer *buf;
GstBuffer *ret;
- guint8 *data, *sdata;
- gsize ssize;
+ GstMapInfo map;
+ guint8 *data;
/* Clip start and end */
buf = gst_buffer_new ();
@@ -61,10 +61,10 @@ GST_START_TEST (test_buffer_clipping_time)
fail_unless (GST_BUFFER_DURATION (ret) == 4 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 800);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 400);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 400);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -91,10 +91,10 @@ GST_START_TEST (test_buffer_clipping_time)
fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 1200);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 800);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 800);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -121,10 +121,10 @@ GST_START_TEST (test_buffer_clipping_time)
fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 200);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 1000);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data);
- fail_unless (ssize == 800);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data);
+ fail_unless (map.size == 800);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -170,10 +170,10 @@ GST_START_TEST (test_buffer_clipping_time)
fail_unless (GST_BUFFER_DURATION (ret) == GST_CLOCK_TIME_NONE);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == GST_BUFFER_OFFSET_NONE);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 400);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 400);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -233,8 +233,8 @@ GST_START_TEST (test_buffer_clipping_samples)
GstSegment s;
GstBuffer *buf;
GstBuffer *ret;
- guint8 *data, *sdata;
- gsize ssize;
+ GstMapInfo map;
+ guint8 *data;
/* Clip start and end */
buf = gst_buffer_new ();
@@ -259,10 +259,10 @@ GST_START_TEST (test_buffer_clipping_samples)
fail_unless (GST_BUFFER_DURATION (ret) == 4 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 800);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 400);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 400);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -289,10 +289,10 @@ GST_START_TEST (test_buffer_clipping_samples)
fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 1200);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 800);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 800);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -319,10 +319,10 @@ GST_START_TEST (test_buffer_clipping_samples)
fail_unless (GST_BUFFER_DURATION (ret) == 8 * GST_SECOND);
fail_unless (GST_BUFFER_OFFSET (ret) == 200);
fail_unless (GST_BUFFER_OFFSET_END (ret) == 1000);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data);
- fail_unless (ssize == 800);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data);
+ fail_unless (map.size == 800);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -368,10 +368,10 @@ GST_START_TEST (test_buffer_clipping_samples)
fail_unless (GST_BUFFER_DURATION (ret) == GST_CLOCK_TIME_NONE);
fail_unless (GST_BUFFER_OFFSET (ret) == 400);
fail_unless (GST_BUFFER_OFFSET_END (ret) == GST_BUFFER_OFFSET_NONE);
- sdata = gst_buffer_map (ret, &ssize, NULL, GST_MAP_READ);
- fail_unless (sdata == data + 200);
- fail_unless (ssize == 400);
- gst_buffer_unmap (ret, sdata, ssize);
+ gst_buffer_map (ret, &map, GST_MAP_READ);
+ fail_unless (map.data == data + 200);
+ fail_unless (map.size == 400);
+ gst_buffer_unmap (ret, &map);
gst_buffer_unref (ret);
@@ -553,8 +553,7 @@ GST_START_TEST (test_multichannel_reorder)
};
gint i;
GstBuffer *buf;
- gint32 *data;
- gsize size;
+ GstMapInfo map;
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
buf =
@@ -568,10 +567,10 @@ GST_START_TEST (test_multichannel_reorder)
fail_unless (gst_audio_buffer_reorder_channels (buf, GST_AUDIO_FORMAT_S32,
tests[i].channels, tests[i].from, tests[i].to));
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
- fail_unless_equals_int (size, sizeof (tests[i].in));
- fail_unless (memcmp (tests[i].out, data, size) == 0);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ fail_unless_equals_int (map.size, sizeof (tests[i].in));
+ fail_unless (memcmp (tests[i].out, map.data, map.size) == 0);
+ gst_buffer_unmap (buf, &map);
}
gst_buffer_unref (buf);
}
diff --git a/tests/check/libs/audiocdsrc.c b/tests/check/libs/audiocdsrc.c
index f55481a93..2bb2b3ec3 100644
--- a/tests/check/libs/audiocdsrc.c
+++ b/tests/check/libs/audiocdsrc.c
@@ -258,12 +258,9 @@ static GstBuffer *
gst_cd_foo_src_read_sector (GstAudioCdSrc * audiocdsrc, gint sector)
{
GstBuffer *buf;
- guint8 *data;
buf = gst_buffer_new_and_alloc (CD_FRAMESIZE_RAW);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- memset (data, 0, CD_FRAMESIZE_RAW);
- gst_buffer_unmap (buf, data, CD_FRAMESIZE_RAW);
+ gst_buffer_memset (buf, 0, 0, CD_FRAMESIZE_RAW);
return buf;
}
diff --git a/tests/check/libs/rtp.c b/tests/check/libs/rtp.c
index d58227e1b..392fbc5a8 100644
--- a/tests/check/libs/rtp.c
+++ b/tests/check/libs/rtp.c
@@ -33,6 +33,7 @@
GST_START_TEST (test_rtp_buffer)
{
GstBuffer *buf;
+ GstMapInfo map;
guint8 *data;
gsize size;
GstRTPBuffer rtp = { NULL, };
@@ -40,7 +41,9 @@ GST_START_TEST (test_rtp_buffer)
/* check GstRTPHeader structure alignment and packing */
buf = gst_rtp_buffer_new_allocate (16, 4, 0);
fail_unless (buf != NULL);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
+ size = map.size;
fail_unless_equals_int (size, RTP_HEADER_LEN + 16 + 4);
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
@@ -108,13 +111,15 @@ GST_START_TEST (test_rtp_buffer)
fail_unless_equals_int (data[0] & 0xf, 0);
gst_rtp_buffer_unmap (&rtp);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
/* and again, this time with CSRCs */
buf = gst_rtp_buffer_new_allocate (16, 4, 3);
fail_unless (buf != NULL);
- data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
+ size = map.size;
fail_unless_equals_int (size, RTP_HEADER_LEN + 16 + 4 + 4 * 3);
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
@@ -136,7 +141,7 @@ GST_START_TEST (test_rtp_buffer)
ASSERT_CRITICAL (gst_rtp_buffer_set_csrc (&rtp, 3, 0xf123));
gst_rtp_buffer_unmap (&rtp);
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
}
@@ -218,18 +223,19 @@ GST_END_TEST;
GST_START_TEST (test_rtp_buffer_set_extension_data)
{
GstBuffer *buf;
+ GstMapInfo map;
guint8 *data;
guint16 bits;
guint size;
guint8 misc_data[4] = { 1, 2, 3, 4 };
gpointer pointer;
guint8 appbits;
- gsize bsize;
GstRTPBuffer rtp = { NULL, };
/* check GstRTPHeader structure alignment and packing */
buf = gst_rtp_buffer_new_allocate (4, 0, 0);
- data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
@@ -248,12 +254,13 @@ GST_START_TEST (test_rtp_buffer_set_extension_data)
pointer = gst_rtp_buffer_get_payload (&rtp);
fail_unless (pointer == data + 16);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_unmap (buf, &map);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unref (buf);
buf = gst_rtp_buffer_new_allocate (20, 0, 0);
- data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
@@ -266,13 +273,14 @@ GST_START_TEST (test_rtp_buffer_set_extension_data)
pointer = gst_rtp_buffer_get_payload (&rtp);
fail_unless (pointer == data + 24);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_unmap (buf, &map);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unref (buf);
/* Test header extensions with a one byte header */
buf = gst_rtp_buffer_new_allocate (20, 0, 0);
- data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
@@ -330,13 +338,14 @@ GST_START_TEST (test_rtp_buffer_set_extension_data)
fail_unless (size == 2);
fail_unless (memcmp (pointer, misc_data, 2) == 0);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_unmap (buf, &map);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unref (buf);
/* Test header extensions with a two bytes header */
buf = gst_rtp_buffer_new_allocate (20, 0, 0);
- data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READWRITE);
+ gst_buffer_map (buf, &map, GST_MAP_READWRITE);
+ data = map.data;
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
fail_unless (gst_rtp_buffer_get_extension (&rtp) == FALSE);
@@ -395,7 +404,7 @@ GST_START_TEST (test_rtp_buffer_set_extension_data)
fail_unless (size == 2);
fail_unless (memcmp (pointer, misc_data, 2) == 0);
- gst_buffer_unmap (buf, data, bsize);
+ gst_buffer_unmap (buf, &map);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unref (buf);
}
diff --git a/tests/check/libs/tag.c b/tests/check/libs/tag.c
index 7dfd9c010..b03987c6f 100644
--- a/tests/check/libs/tag.c
+++ b/tests/check/libs/tag.c
@@ -408,8 +408,7 @@ GST_START_TEST (test_vorbis_tags)
/* now, while we still have a taglist, test _to_vorbiscomment_buffer() */
{
GstBuffer *buf1, *buf2;
- guint8 *data1, *data2;
- gsize size1, size2;
+ GstMapInfo map1, map2;
ASSERT_CRITICAL (gst_tag_list_to_vorbiscomment_buffer (NULL,
(const guint8 *) "x", 1, "x"));
@@ -421,13 +420,13 @@ GST_START_TEST (test_vorbis_tags)
(const guint8 *) "foo", 3, NULL);
fail_unless (buf2 != NULL);
- data1 = gst_buffer_map (buf1, &size1, NULL, GST_MAP_READ);
- data2 = gst_buffer_map (buf2, &size2, NULL, GST_MAP_READ);
+ gst_buffer_map (buf1, &map1, GST_MAP_READ);
+ gst_buffer_map (buf2, &map2, GST_MAP_READ);
- fail_unless (memcmp (data1, data2 + 3, size1) == 0);
+ fail_unless (memcmp (map1.data, map2.data + 3, map1.size) == 0);
- gst_buffer_unmap (buf2, data2, size2);
- gst_buffer_unmap (buf1, data1, size1);
+ gst_buffer_unmap (buf2, &map2);
+ gst_buffer_unmap (buf1, &map1);
gst_buffer_unref (buf1);
gst_buffer_unref (buf2);
@@ -963,6 +962,7 @@ GST_START_TEST (test_xmp_formatting)
{
GstTagList *list;
GstBuffer *buf;
+ GstMapInfo map;
const gchar *text;
gsize len;
@@ -974,7 +974,9 @@ GST_START_TEST (test_xmp_formatting)
buf = gst_tag_list_to_xmp_buffer (list, FALSE);
fail_unless (buf != NULL);
- text = gst_buffer_map (buf, &len, NULL, GST_MAP_READ);
+ gst_buffer_map (buf, &map, GST_MAP_READ);
+ text = (gchar *) map.data;
+ len = map.size;
/* check the content */
fail_unless (g_strrstr_len (text, len, "<?xpacket begin") == text);
@@ -983,7 +985,7 @@ GST_START_TEST (test_xmp_formatting)
fail_unless (g_strrstr_len (text, len, ">keyword1<") != NULL);
fail_unless (g_strrstr_len (text, len, ">keyword2<") != NULL);
fail_unless (g_strrstr_len (text, len, "<?xpacket end") != NULL);
- gst_buffer_unmap (buf, (gpointer) text, len);
+ gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf);
gst_tag_list_free (list);
@@ -1430,6 +1432,7 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
GstBuffer *buf = NULL;
gint i;
GstTagList *taglist;
+ GstMapInfo map;
guint8 *data;
gst_tag_register_musicbrainz_tags ();
@@ -1741,10 +1744,11 @@ GST_START_TEST (test_exif_tags_serialization_deserialization)
g_value_init (&value, GST_TYPE_BUFFER);
buf = gst_buffer_new_and_alloc (1024);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ data = map.data;
for (i = 0; i < 1024; i++)
data[i] = i % 255;
- gst_buffer_unmap (buf, data, 1024);
+ gst_buffer_unmap (buf, &map);
gst_value_set_buffer (&value, buf);
gst_buffer_unref (buf);
do_simple_exif_tag_serialization_deserialization (GST_TAG_APPLICATION_DATA,
diff --git a/tests/check/libs/video.c b/tests/check/libs/video.c
index 5245a24f5..5678eb35b 100644
--- a/tests/check/libs/video.c
+++ b/tests/check/libs/video.c
@@ -678,20 +678,20 @@ GST_START_TEST (test_convert_frame)
GstSample *from_sample, *to_sample;
GError *error = NULL;
gint i;
- guint8 *data;
+ GstMapInfo map;
gst_debug_set_threshold_for_name ("default", GST_LEVEL_NONE);
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
- data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (from_buffer, &map, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
- data[4 * i + 0] = 0; /* x */
- data[4 * i + 1] = 255; /* R */
- data[4 * i + 2] = 0; /* G */
- data[4 * i + 3] = 0; /* B */
+ map.data[4 * i + 0] = 0; /* x */
+ map.data[4 * i + 1] = 255; /* R */
+ map.data[4 * i + 2] = 0; /* G */
+ map.data[4 * i + 3] = 0; /* B */
}
- gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
+ gst_buffer_unmap (from_buffer, &map);
gst_video_info_init (&vinfo);
gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 480);
@@ -762,7 +762,7 @@ GST_START_TEST (test_convert_frame_async)
GstBuffer *from_buffer;
GstSample *from_sample;
gint i;
- guint8 *data;
+ GstMapInfo map;
GMainLoop *loop;
ConvertFrameContext cf_data = { NULL, NULL, NULL };
@@ -770,14 +770,14 @@ GST_START_TEST (test_convert_frame_async)
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
- data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
+ gst_buffer_map (from_buffer, &map, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
- data[4 * i + 0] = 0; /* x */
- data[4 * i + 1] = 255; /* R */
- data[4 * i + 2] = 0; /* G */
- data[4 * i + 3] = 0; /* B */
+ map.data[4 * i + 0] = 0; /* x */
+ map.data[4 * i + 1] = 255; /* R */
+ map.data[4 * i + 2] = 0; /* G */
+ map.data[4 * i + 3] = 0; /* B */
}
- gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
+ gst_buffer_unmap (from_buffer, &map);
gst_video_info_init (&vinfo);
gst_video_info_set_format (&vinfo, GST_VIDEO_FORMAT_xRGB, 640, 470);
diff --git a/tests/check/libs/xmpwriter.c b/tests/check/libs/xmpwriter.c
index 7e1a544a2..ba0e642bb 100644
--- a/tests/check/libs/xmpwriter.c
+++ b/tests/check/libs/xmpwriter.c
@@ -80,19 +80,18 @@ static gboolean
gst_buffer_equals (GstBuffer * buf_a, GstBuffer * buf_b)
{
gboolean res;
- gpointer data1, data2;
- gsize size1, size2;
+ GstMapInfo map1, map2;
- data1 = gst_buffer_map (buf_a, &size1, NULL, GST_MAP_READ);
- data2 = gst_buffer_map (buf_b, &size2, NULL, GST_MAP_READ);
+ gst_buffer_map (buf_a, &map1, GST_MAP_READ);
+ gst_buffer_map (buf_b, &map2, GST_MAP_READ);
- if (size1 == size2) {
- res = memcmp (data1, data2, size1) == 0;
+ if (map1.size == map2.size) {
+ res = memcmp (map1.data, map2.data, map1.size) == 0;
} else {
res = FALSE;
}
- gst_buffer_unmap (buf_a, data1, size1);
- gst_buffer_unmap (buf_b, data2, size2);
+ gst_buffer_unmap (buf_a, &map1);
+ gst_buffer_unmap (buf_b, &map2);
return res;
}
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;
}
diff --git a/tests/examples/app/appsrc_ex.c b/tests/examples/app/appsrc_ex.c
index 7dacbbb55..7490613a2 100644
--- a/tests/examples/app/appsrc_ex.c
+++ b/tests/examples/app/appsrc_ex.c
@@ -54,14 +54,14 @@ main (int argc, char *argv[])
for (i = 0; i < 10; i++) {
GstBuffer *buf;
- void *data;
+ GstMapInfo map;
buf = gst_buffer_new_and_alloc (100);
- data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
- memset (data, i, 100);
- gst_buffer_unmap (buf, data, 100);
+ gst_buffer_map (buf, &map, GST_MAP_WRITE);
+ memset (map.data, i, 100);
+ gst_buffer_unmap (buf, &map);
- printf ("%d: pushing buffer for pointer %p, %p\n", i, data, buf);
+ printf ("%d: pushing buffer for pointer %p, %p\n", i, map.data, buf);
gst_app_src_push_buffer (GST_APP_SRC (app->src), buf);
}
diff --git a/tests/examples/seek/jsseek.c b/tests/examples/seek/jsseek.c
index eab3c85bf..2e2beb86f 100644
--- a/tests/examples/seek/jsseek.c
+++ b/tests/examples/seek/jsseek.c
@@ -2021,8 +2021,7 @@ shot_cb (GtkButton * button, gpointer data)
gint width, height;
GdkPixbuf *pixbuf;
GError *error = NULL;
- gsize size;
- guint8 *data;
+ GstMapInfo map;
/* get the snapshot buffer format now. We set the caps on the appsink so
* that it can only be an rgb buffer. The only thing we have not specified
@@ -2049,14 +2048,14 @@ shot_cb (GtkButton * button, gpointer data)
/* create pixmap from buffer and save, gstreamer video buffers have a stride
* that is rounded up to the nearest multiple of 4 */
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- pixbuf = gdk_pixbuf_new_from_data (data,
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ pixbuf = gdk_pixbuf_new_from_data (map.data,
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
GST_ROUND_UP_4 (width * 3), NULL, NULL);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c
index 8ead8ea1d..e556c6417 100644
--- a/tests/examples/seek/seek.c
+++ b/tests/examples/seek/seek.c
@@ -1167,8 +1167,7 @@ shot_cb (GtkButton * button, gpointer data)
gint width, height;
GdkPixbuf *pixbuf;
GError *error = NULL;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
/* get the snapshot buffer format now. We set the caps on the appsink so
* that it can only be an rgb buffer. The only thing we have not specified
@@ -1192,14 +1191,14 @@ shot_cb (GtkButton * button, gpointer data)
/* create pixmap from buffer and save, gstreamer video buffers have a stride
* that is rounded up to the nearest multiple of 4 */
buffer = gst_sample_get_buffer (sample);
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- pixbuf = gdk_pixbuf_new_from_data (data,
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ pixbuf = gdk_pixbuf_new_from_data (map.data,
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
GST_ROUND_UP_4 (width * 3), NULL, NULL);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
done:
gst_sample_unref (sample);
diff --git a/tests/examples/snapshot/snapshot.c b/tests/examples/snapshot/snapshot.c
index 6f9755ea7..a63c783fc 100644
--- a/tests/examples/snapshot/snapshot.c
+++ b/tests/examples/snapshot/snapshot.c
@@ -36,8 +36,7 @@ main (int argc, char *argv[])
gint64 duration, position;
GstStateChangeReturn ret;
gboolean res;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gst_init (&argc, &argv);
@@ -137,14 +136,14 @@ main (int argc, char *argv[])
/* create pixmap from buffer and save, gstreamer video buffers have a stride
* that is rounded up to the nearest multiple of 4 */
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- pixbuf = gdk_pixbuf_new_from_data (data,
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ pixbuf = gdk_pixbuf_new_from_data (map.data,
GDK_COLORSPACE_RGB, FALSE, 8, width, height,
GST_ROUND_UP_4 (width * 3), NULL, NULL);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
/* save the pixbuf */
gdk_pixbuf_save (pixbuf, "snapshot.png", "png", &error, NULL);
diff --git a/tests/icles/playbin-text.c b/tests/icles/playbin-text.c
index a7c473655..a0d4f8259 100644
--- a/tests/icles/playbin-text.c
+++ b/tests/icles/playbin-text.c
@@ -93,8 +93,7 @@ have_subtitle (GstElement * appsink, App * app)
g_signal_emit_by_name (appsink, "pull-buffer", &buffer);
if (buffer) {
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gint64 position;
GstClock *clock;
GstClockTime base_time, running_time;
@@ -112,9 +111,9 @@ have_subtitle (GstElement * appsink, App * app)
", running_time %" GST_TIME_FORMAT, GST_TIME_ARGS (position),
GST_TIME_ARGS (running_time));
- data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
- gst_util_dump_mem (data, size);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_map (buffer, &map, GST_MAP_READ);
+ gst_util_dump_mem (map.data, map.size);
+ gst_buffer_unmap (buffer, &map);
}
}