gboolean need_skip;
const guint16 *data;
guint64 dist, timestamp;
- guint8 *outdata;
- gsize outsize;
+ GstMapInfo outmap;
GST_DEBUG_OBJECT (visual, "processing 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);
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;
/* 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);
offs += sizes[i];
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
return TRUE;
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;
}
}
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);
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)) {
/* 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) {
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,
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);
}
GstCaps *caps;
GstStructure *structure;
GstBuffer *hbuf;
- gsize size;
+ GstMapInfo map;
pad = (GstOggPadData *) walk->data;
thepad = pad->collect.pad;
}
/* 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");
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 */
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");
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;
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);
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))
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));
}
done:
- gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer);
return ret;
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);
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;
}
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
{
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:{
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) {
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;
}
/* 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
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);
GstFlowReturn ret;
GstBuffer *outbuf;
GstCaps *caps = NULL, *padcaps;
+ GstMapInfo map;
guint8 *data;
gsize size;
gint n;
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 &&
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);
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);
render->width * 4);
}
}
- gst_buffer_unmap (outbuf, data, size);
+ gst_buffer_unmap (outbuf, &map);
ret = gst_pad_push (render->srcpad, outbuf);
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;
ptr += psize;
offset += psize;
}
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &map);
}
}
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;
result = theora_handle_data_packet (dec, &packet, timestamp, duration);
}
done:
- gst_buffer_unmap (buf, packet.packet, size);
+ gst_buffer_unmap (buf, &map);
return result;
}
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);
}
}
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);
{
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;
}
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;
}
guint sample_count;
GstBuffer *out = NULL;
GstFlowReturn result;
- guint8 *data;
+ GstMapInfo map;
gsize size;
if (G_UNLIKELY (!vd->initialized)) {
/* 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))
#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 */
ogg_packet *packet;
ogg_packet_wrapper packet_wrapper;
GstFlowReturn result = GST_FLOW_OK;
+ GstMapInfo map;
GstVorbisDec *vd = GST_VORBIS_DEC (dec);
/* no draining etc */
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;
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;
}
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);
}
{
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;
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);
/* 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);
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));
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 */
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 */
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) {
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);
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;
}
gint64 diff, align;
guint64 ctime, cstop;
gsize offset;
- guint8 *data;
+ GstMapInfo info;
gsize size;
guint samples, written;
gint bpf, rate;
/* 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 */
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;
{
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:
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;
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);
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) {
guint16 valid_bits_per_sample;
guint32 channel_mask;
guint32 subformat_guid[4];
- guint8 *data;
+ GstMapInfo info;
gsize size;
channels_max = 8;
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);
{
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);
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",
{
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);
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);
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);
{
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;
}
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;
}
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);
{
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;
}
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);
/* 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);
{
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;
}
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);
/* 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,
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;
{
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;
}
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);
{
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;
}
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;
*_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);
*_taglist = NULL;
gst_tag_list_free (taglist);
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &info);
return;
}
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;
}
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;
gboolean
gst_rtcp_buffer_unmap (GstRTCPBuffer * rtcp)
{
- gboolean res;
GstRTCPPacket packet;
g_return_val_if_fail (rtcp != NULL, FALSE);
/* 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;
}
/**
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;
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
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;
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);
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;
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;
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;
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;
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;
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;
return FALSE;
/* move to SDES */
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
data += packet->offset;
/* move to item */
offset = packet->item_offset;
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;
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;
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;
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;
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;
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;
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);
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;
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;
if (roffset == 0)
return 0;
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
return data[roffset];
}
if (roffset == 0)
return NULL;
- data = packet->rtcp->data;
+ data = packet->rtcp->info.data;
/* get length of reason string */
len = data[roffset];
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);
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;
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;
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;
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;
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;
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;
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;
}
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);
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;
GstBuffer *buffer;
GstMapFlags flags;
- guint8 *data;
- gsize size;
- gsize maxsize;
+ GstMapInfo info;
};
#define GST_RTCP_BUFFER_INIT { NULL, 0, NULL, 0, 0 }
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));
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);
}
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;
}
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;
}
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;
{
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;
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))
guint8
gst_rtp_buffer_get_version (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_VERSION (rtp->data);
+ return GST_RTP_HEADER_VERSION (rtp->info.data);
}
/**
{
g_return_if_fail (version < 0x04);
- GST_RTP_HEADER_VERSION (rtp->data) = version;
+ GST_RTP_HEADER_VERSION (rtp->info.data) = version;
}
/**
gboolean
gst_rtp_buffer_get_padding (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_PADDING (rtp->data);
+ return GST_RTP_HEADER_PADDING (rtp->info.data);
}
/**
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;
}
/**
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
if (len > 0)
GST_RTP_HEADER_PADDING (data) = TRUE;
gboolean
gst_rtp_buffer_get_extension (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_EXTENSION (rtp->data);
+ return GST_RTP_HEADER_EXTENSION (rtp->info.data);
}
/**
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;
}
/**
guint len;
guint8 *pdata;
- pdata = rtp->data;
+ pdata = rtp->info.data;
if (!GST_RTP_HEADER_EXTENSION (pdata))
return FALSE;
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);
{
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;
}
}
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));
}
/**
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);
}
/**
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);
}
/**
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0);
{
guint8 *data;
- data = rtp->data;
+ data = rtp->info.data;
g_return_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data));
gboolean
gst_rtp_buffer_get_marker (GstRTPBuffer * rtp)
{
- return GST_RTP_HEADER_MARKER (rtp->data);
+ return GST_RTP_HEADER_MARKER (rtp->info.data);
}
/**
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;
}
/**
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);
}
/**
{
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;
}
/**
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));
}
/**
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);
}
/**
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));
}
/**
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);
}
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);
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);
}
/**
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));
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;
{
GstBuffer *buffer;
GstMapFlags flags;
- guint8 *data;
- gsize size;
- gsize maxsize;
+ GstMapInfo info;
};
#define GST_RTP_BUFFER_INIT {NULL,0,NULL,0,0}
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);
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));
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
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,
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);
}
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,
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);
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");
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;
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;
}
}
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;
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;
}
}
}
- 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;
}
}
{
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) {
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);
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);
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)) {
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);
gst_buffer_unref (subbuffer);
done:
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return taglist;
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);
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))
!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,
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;
}
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;
}
const gchar * vendor_string)
{
GstBuffer *buffer;
- guint8 *data, *odata;
+ GstMapInfo info;
+ guint8 *data;
guint i;
GList *l;
MyForEach my_data = { 0, 0, NULL };
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;
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;
}
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;
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];
}
g_free (part);
- gst_buffer_unmap (buffer, xps, len);
+ gst_buffer_unmap (buffer, &info);
return list;
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;
GST_DEBUG ("ID3v2 tag, size: %u bytes", result);
done:
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return result;
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;
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)
(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
g_free (uu_data);
- gst_buffer_unmap (buffer, data, size);
+ gst_buffer_unmap (buffer, &info);
return work.tags;
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;
}
}
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);
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);
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);
* gst_video_meta_map:
* @meta: a #GstVideoMeta
* @plane: a plane
+ * @info: a #GstMapInfo
* @stride: result stride
* @flags: @GstMapFlags
*
*
* 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];
* 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;
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);
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;
}
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);
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:
GstBuffer * buffer, gint id, GstMapFlags flags)
{
GstVideoMeta *meta;
- guint8 *data;
- gsize size;
gint i;
g_return_val_if_fail (frame != NULL, FALSE);
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
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;
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;
}
}
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]);
}
}
* @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()
*/
gint id;
gpointer data[GST_VIDEO_MAX_PLANES];
+ GstMapInfo map[GST_VIDEO_MAX_PLANES];
};
gboolean gst_video_frame_map (GstVideoFrame *frame, GstVideoInfo *info,
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;
* 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);
}
}
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 */
{
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;
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;
(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;
}
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);
guint out_len, out_processed;
gint err;
guint num, den;
- guint8 *data;
+ GstMapInfo map;
g_assert (resample->state != NULL);
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 */
/* 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
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",
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);
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;
&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 */
/* 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;
}
}
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));
gint64 next_sample, next_byte;
gint bytes, samples;
GstElementClass *eclass;
- guint8 *data;
+ GstMapInfo map;
gint samplerate, bpf;
src = GST_AUDIO_TEST_SRC (basesrc);
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))) {
{
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);
/* 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));
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);
/* 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);
}
{
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;
}
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;
* 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);
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");
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) {
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
GstSsaParse *parse = GST_SSA_PARSE (parent);
GstClockTime ts;
gchar *txt;
- gchar *data;
- gsize size;
+ GstMapInfo map;
if (G_UNLIKELY (!parse->framed))
goto not_framed;
}
/* 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;
{
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;
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.. */
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;
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;
{
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");
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;
}
GstFlowReturn ret = GST_FLOW_OK;
gssize rret;
GError *err = NULL;
- guint8 *data;
+ GstMapInfo map;
gssize avail, read;
src = GST_TCP_CLIENT_SRC (psrc);
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;
}
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;
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 %"
gssize rret, avail;
gsize read;
GError *err = NULL;
- guint8 *data;
+ GstMapInfo map;
src = GST_TCP_SERVER_SRC (psrc);
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;
}
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;
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 %"
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);
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) {
{
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))
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");
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;
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;
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;
}
}
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);
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) {
*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);
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);
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);
*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:%"
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
- guint8 *data;
GstSegment segment;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
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;
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;
} \
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); \
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); \
#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; \
} \
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;
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);
GstEvent *event;
gchar *caps_string;
gint length;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
guint16 crc_calculated, crc_read;
gdppay = setup_gdppay ();
/* 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;
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;
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;
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);
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);
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);
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);
{
GstStructure *s;
gint x, y, w, h;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
fail_unless (buf != NULL);
fail_unless (caps != NULL);
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) {
}
}
}
- gst_buffer_unmap (buf, data, size);
+ gst_buffer_unmap (buf, &map);
return TRUE;
}
GstStructure *s;
GstBuffer *buffer;
gint w, h, size;
- guint8 *data;
fail_unless (caps != NULL);
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));
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);
/* 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);
}
/* 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;
#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,
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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]);
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);
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]);
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);
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]);
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);
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]);
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);
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]);
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);
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[2] = { 16384, -256 };
- gint16 *res;
- gsize size;
+ GstMapInfo map;
volume = setup_volume ();
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);
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;
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);
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) {
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) {
GstSegment s;
GstBuffer *buf;
GstBuffer *ret;
- guint8 *data, *sdata;
- gsize ssize;
+ GstMapInfo map;
+ guint8 *data;
/* Clip start and end */
buf = gst_buffer_new ();
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);
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);
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);
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);
GstSegment s;
GstBuffer *buf;
GstBuffer *ret;
- guint8 *data, *sdata;
- gsize ssize;
+ GstMapInfo map;
+ guint8 *data;
/* Clip start and end */
buf = gst_buffer_new ();
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);
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);
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);
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);
};
gint i;
GstBuffer *buf;
- gint32 *data;
- gsize size;
+ GstMapInfo map;
for (i = 0; i < G_N_ELEMENTS (tests); i++) {
buf =
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);
}
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;
}
GST_START_TEST (test_rtp_buffer)
{
GstBuffer *buf;
+ GstMapInfo map;
guint8 *data;
gsize size;
GstRTPBuffer rtp = { NULL, };
/* 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);
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);
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);
}
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);
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);
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);
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);
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);
}
/* 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"));
(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);
{
GstTagList *list;
GstBuffer *buf;
+ GstMapInfo map;
const gchar *text;
gsize len;
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);
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);
GstBuffer *buf = NULL;
gint i;
GstTagList *taglist;
+ GstMapInfo map;
guint8 *data;
gst_tag_register_musicbrainz_tags ();
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,
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);
GstBuffer *from_buffer;
GstSample *from_sample;
gint i;
- guint8 *data;
+ GstMapInfo map;
GMainLoop *loop;
ConvertFrameContext cf_data = { NULL, NULL, NULL };
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);
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;
}
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;
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;
}
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);
}
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
/* 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);
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
/* 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);
gint64 duration, position;
GstStateChangeReturn ret;
gboolean res;
- guint8 *data;
- gsize size;
+ GstMapInfo map;
gst_init (&argc, &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);
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;
", 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);
}
}