more memory API porting

This commit is contained in:
Wim Taymans 2012-01-24 14:38:58 +01:00
parent 583d39dd8d
commit b4630dd3e0
26 changed files with 249 additions and 238 deletions

View file

@ -358,10 +358,13 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{ {
GstCmmlDec *dec = GST_CMML_DEC (parent); GstCmmlDec *dec = GST_CMML_DEC (parent);
GstCmmlPacketType packet; GstCmmlPacketType packet;
GstMapInfo map;
guint8 *data; guint8 *data;
gsize size; gsize size;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
if (size == 0) { if (size == 0) {
/* the EOS page could be empty */ /* the EOS page could be empty */
@ -400,7 +403,7 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
} }
done: done:
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return dec->flow_return; return dec->flow_return;

View file

@ -598,23 +598,23 @@ gst_cmml_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{ {
GError *err = NULL; GError *err = NULL;
GstCmmlEnc *enc = GST_CMML_ENC (parent); GstCmmlEnc *enc = GST_CMML_ENC (parent);
gchar *data; GstMapInfo map;
gsize size;
/* the CMML handlers registered with enc->parser will override this when /* the CMML handlers registered with enc->parser will override this when
* encoding/pushing the buffers downstream * encoding/pushing the buffers downstream
*/ */
enc->flow_return = GST_FLOW_OK; enc->flow_return = GST_FLOW_OK;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
if (!gst_cmml_parser_parse_chunk (enc->parser, data, size, &err)) { if (!gst_cmml_parser_parse_chunk (enc->parser, (gchar *) map.data, map.size,
&err)) {
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message)); GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
g_error_free (err); g_error_free (err);
enc->flow_return = GST_FLOW_ERROR; enc->flow_return = GST_FLOW_ERROR;
} }
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return enc->flow_return; return enc->flow_return;
} }

View file

@ -536,8 +536,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
guint channels = frame->header.channels; guint channels = frame->header.channels;
guint samples = frame->header.blocksize; guint samples = frame->header.blocksize;
guint j, i; guint j, i;
gpointer data; GstMapInfo map;
gsize size;
gboolean caps_changed; gboolean caps_changed;
GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples); GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
@ -618,9 +617,9 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps"); GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0); outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0);
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
if (width == 8) { if (width == 8) {
gint8 *outbuffer = (gint8 *) data; gint8 *outbuffer = (gint8 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map; gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) { if (width != depth) {
@ -637,7 +636,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
} }
} }
} else if (width == 16) { } else if (width == 16) {
gint16 *outbuffer = (gint16 *) data; gint16 *outbuffer = (gint16 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map; gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) { if (width != depth) {
@ -655,7 +654,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
} }
} }
} else if (width == 32) { } else if (width == 32) {
gint32 *outbuffer = (gint32 *) data; gint32 *outbuffer = (gint32 *) map.data;
gint *reorder_map = flacdec->channel_reorder_map; gint *reorder_map = flacdec->channel_reorder_map;
if (width != depth) { if (width != depth) {
@ -675,7 +674,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
} else { } else {
g_assert_not_reached (); g_assert_not_reached ();
} }
gst_buffer_unmap (outbuf, data, size); gst_buffer_unmap (outbuf, &map);
GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples); GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples);
@ -743,17 +742,17 @@ gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf)
if (G_UNLIKELY (!dec->got_headers)) { if (G_UNLIKELY (!dec->got_headers)) {
gboolean got_audio_frame; gboolean got_audio_frame;
gint64 unused; gint64 unused;
guint8 *data; GstMapInfo map;
gsize size;
/* check if this is a flac audio frame (rather than a header or junk) */ /* check if this is a flac audio frame (rather than a header or junk) */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
got_audio_frame = gst_flac_dec_scan_got_frame (dec, data, size, &unused); got_audio_frame =
gst_buffer_unmap (buf, data, size); gst_flac_dec_scan_got_frame (dec, map.data, map.size, &unused);
gst_buffer_unmap (buf, &map);
if (!got_audio_frame) { if (!got_audio_frame) {
GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " " GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " "
"bytes", size); "bytes", map.size);
gst_audio_decoder_finish_frame (audio_dec, NULL, 1); gst_audio_decoder_finish_frame (audio_dec, NULL, 1);
return GST_FLOW_OK; return GST_FLOW_OK;
} }

View file

@ -516,8 +516,7 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE; GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
#endif #endif
gint i; gint i;
guint8 *data; GstMapInfo map;
gsize size;
for (i = 0; i < n_images + n_preview_images; i++) { for (i = 0; i < n_images + n_preview_images; i++) {
if (i < n_images) { if (i < n_images) {
@ -545,10 +544,10 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
image_type = image_type + 2; image_type = image_type + 2;
#endif #endif
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
FLAC__metadata_object_picture_set_data (flacenc->meta[entries], FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
data, size, TRUE); map.data, map.size, TRUE);
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
#if 0 #if 0
/* FIXME: There's no way to set the picture type in libFLAC */ /* FIXME: There's no way to set the picture type in libFLAC */
@ -915,6 +914,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
for (l = enc->headers; l != NULL; l = l->next) { for (l = enc->headers; l != NULL; l = l->next) {
GstBuffer *buf; GstBuffer *buf;
GstMapInfo map;
guint8 *data; guint8 *data;
gsize size; gsize size;
@ -925,7 +925,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
buf = GST_BUFFER_CAST (l->data); buf = GST_BUFFER_CAST (l->data);
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
/* find initial 4-byte marker which we need to skip later on */ /* find initial 4-byte marker which we need to skip later on */
if (size == 4 && memcmp (data, "fLaC", 4) == 0) { if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
@ -936,7 +938,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
vorbiscomment = buf; vorbiscomment = buf;
} }
gst_buffer_unmap (buf, data, size); gst_buffer_unmap (buf, &map);
} }
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) { if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
@ -951,8 +953,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
{ {
GstBuffer *buf; GstBuffer *buf;
guint16 num; guint16 num;
GstMapInfo map;
guint8 *bdata; guint8 *bdata;
gsize bsize, slen; gsize slen;
/* minus one for the marker that is merged with streaminfo here */ /* minus one for the marker that is merged with streaminfo here */
num = g_list_length (enc->headers) - 1; num = g_list_length (enc->headers) - 1;
@ -960,7 +963,8 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
slen = gst_buffer_get_size (streaminfo); slen = gst_buffer_get_size (streaminfo);
buf = gst_buffer_new_and_alloc (13 + slen); buf = gst_buffer_new_and_alloc (13 + slen);
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_WRITE); gst_buffer_map (buf, &map, GST_MAP_WRITE);
bdata = map.data;
bdata[0] = 0x7f; bdata[0] = 0x7f;
memcpy (bdata + 1, "FLAC", 4); memcpy (bdata + 1, "FLAC", 4);
bdata[5] = 0x01; /* mapping version major */ bdata[5] = 0x01; /* mapping version major */
@ -969,7 +973,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
bdata[8] = (num & 0x00FF) >> 0; bdata[8] = (num & 0x00FF) >> 0;
memcpy (bdata + 9, "fLaC", 4); memcpy (bdata + 9, "fLaC", 4);
gst_buffer_extract (streaminfo, 0, bdata + 13, slen); gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
gst_buffer_unmap (buf, bdata, bsize); gst_buffer_unmap (buf, &map);
notgst_value_array_append_buffer (&array, buf); notgst_value_array_append_buffer (&array, buf);
gst_buffer_unref (buf); gst_buffer_unref (buf);
@ -1169,12 +1173,11 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
{ {
GstFlacEnc *flacenc; GstFlacEnc *flacenc;
FLAC__int32 *data; FLAC__int32 *data;
gsize bsize;
gint samples, width, channels; gint samples, width, channels;
gulong i; gulong i;
gint j; gint j;
FLAC__bool res; FLAC__bool res;
gpointer bdata; GstMapInfo map;
GstAudioInfo *info = GstAudioInfo *info =
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc)); gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
gint *reorder_map; gint *reorder_map;
@ -1202,28 +1205,28 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
return flacenc->last_flow; return flacenc->last_flow;
} }
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
samples = bsize / (width >> 3); samples = map.size / (width >> 3);
data = g_malloc (samples * sizeof (FLAC__int32)); data = g_malloc (samples * sizeof (FLAC__int32));
samples /= channels; samples /= channels;
if (width == 8) { if (width == 8) {
gint8 *indata = (gint8 *) bdata; gint8 *indata = (gint8 *) map.data;
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++) for (j = 0; j < channels; j++)
data[i * channels + reorder_map[j]] = data[i * channels + reorder_map[j]] =
(FLAC__int32) indata[i * channels + j]; (FLAC__int32) indata[i * channels + j];
} else if (width == 16) { } else if (width == 16) {
gint16 *indata = (gint16 *) bdata; gint16 *indata = (gint16 *) map.data;
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++) for (j = 0; j < channels; j++)
data[i * channels + reorder_map[j]] = data[i * channels + reorder_map[j]] =
(FLAC__int32) indata[i * channels + j]; (FLAC__int32) indata[i * channels + j];
} else if (width == 24) { } else if (width == 24) {
guint8 *indata = (guint8 *) bdata; guint8 *indata = (guint8 *) map.data;
guint32 val; guint32 val;
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
@ -1234,7 +1237,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
data[i * channels + reorder_map[j]] = (FLAC__int32) val; data[i * channels + reorder_map[j]] = (FLAC__int32) val;
} }
} else if (width == 32) { } else if (width == 32) {
gint32 *indata = (gint32 *) bdata; gint32 *indata = (gint32 *) map.data;
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
for (j = 0; j < channels; j++) for (j = 0; j < channels; j++)
@ -1243,7 +1246,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
} else { } else {
g_assert_not_reached (); g_assert_not_reached ();
} }
gst_buffer_unmap (buffer, bdata, bsize); gst_buffer_unmap (buffer, &map);
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder, res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
(const FLAC__int32 *) data, samples / channels); (const FLAC__int32 *) data, samples / channels);

View file

@ -191,7 +191,7 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{ {
GstFlacTag *tag; GstFlacTag *tag;
GstFlowReturn ret; GstFlowReturn ret;
guint8 *data; GstMapInfo map;
gsize size; gsize size;
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
@ -284,9 +284,9 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
/* clear the is-last flag, as the last metadata block will /* clear the is-last flag, as the last metadata block will
* be the vorbis comment block which we will build ourselves. * be the vorbis comment block which we will build ourselves.
*/ */
data = gst_buffer_map (metadata_buffer, &size, NULL, GST_MAP_READWRITE); gst_buffer_map (metadata_buffer, &map, GST_MAP_READWRITE);
data[0] &= (~0x80); map.data[0] &= (~0x80);
gst_buffer_unmap (metadata_buffer, data, size); gst_buffer_unmap (metadata_buffer, &map);
if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) { if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
GST_DEBUG_OBJECT (tag, "pushing metadata block buffer"); GST_DEBUG_OBJECT (tag, "pushing metadata block buffer");
@ -362,11 +362,11 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
if (buffer == NULL) if (buffer == NULL)
goto no_buffer; goto no_buffer;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE); gst_buffer_map (buffer, &map, GST_MAP_WRITE);
memset (data, 0, size); memset (map.data, 0, map.size);
data[0] = 0x81; /* 0x80 = Last metadata block, map.data[0] = 0x81; /* 0x80 = Last metadata block,
* 0x01 = padding block */ * 0x01 = padding block */
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
} else { } else {
guchar header[4]; guchar header[4];
guint8 fbit[1]; guint8 fbit[1];
@ -399,14 +399,14 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
/* The 4 byte metadata block header isn't accounted for in the total /* The 4 byte metadata block header isn't accounted for in the total
* size of the metadata block * size of the metadata block
*/ */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE); gst_buffer_map (buffer, &map, GST_MAP_WRITE);
data[1] = (((size - 4) & 0xFF0000) >> 16); map.data[1] = (((map.size - 4) & 0xFF0000) >> 16);
data[2] = (((size - 4) & 0x00FF00) >> 8); map.data[2] = (((map.size - 4) & 0x00FF00) >> 8);
data[3] = ((size - 4) & 0x0000FF); map.data[3] = ((map.size - 4) & 0x0000FF);
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment " GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment "
"buffer", size); "buffer", map.size);
ret = gst_pad_push (tag->srcpad, buffer); ret = gst_pad_push (tag->srcpad, buffer);
if (ret != GST_FLOW_OK) { if (ret != GST_FLOW_OK) {

View file

@ -159,10 +159,11 @@ static void
ensure_memory (GstJpegEnc * jpegenc) ensure_memory (GstJpegEnc * jpegenc)
{ {
GstMemory *new_memory; GstMemory *new_memory;
GstMapInfo map;
gsize old_size, desired_size, new_size; gsize old_size, desired_size, new_size;
guint8 *new_data; guint8 *new_data;
old_size = jpegenc->output_size; old_size = jpegenc->output_map.size;
if (old_size == 0) if (old_size == 0)
desired_size = jpegenc->bufsize; desired_size = jpegenc->bufsize;
else else
@ -171,19 +172,20 @@ ensure_memory (GstJpegEnc * jpegenc)
/* Our output memory wasn't big enough. /* Our output memory wasn't big enough.
* Make a new memory that's twice the size, */ * Make a new memory that's twice the size, */
new_memory = gst_allocator_alloc (NULL, desired_size, 3); new_memory = gst_allocator_alloc (NULL, desired_size, 3);
new_data = gst_memory_map (new_memory, &new_size, NULL, GST_MAP_READWRITE); gst_memory_map (new_memory, &map, GST_MAP_READWRITE);
new_data = map.data;
new_size = map.size;
/* copy previous data if any */ /* copy previous data if any */
if (jpegenc->output_mem) { if (jpegenc->output_mem) {
memcpy (new_data, jpegenc->output_data, old_size); memcpy (new_data, jpegenc->output_map.data, old_size);
gst_memory_unmap (jpegenc->output_mem); gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
gst_memory_unref (jpegenc->output_mem); gst_memory_unref (jpegenc->output_mem);
} }
/* drop it into place, */ /* drop it into place, */
jpegenc->output_mem = new_memory; jpegenc->output_mem = new_memory;
jpegenc->output_data = new_data; jpegenc->output_map = map;
jpegenc->output_size = new_size;
/* and last, update libjpeg on where to work. */ /* and last, update libjpeg on where to work. */
jpegenc->jdest.next_output_byte = new_data + old_size; jpegenc->jdest.next_output_byte = new_data + old_size;
@ -215,12 +217,12 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo)
GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data); GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source"); GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
gst_memory_unmap (jpegenc->output_mem); gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
/* Trim the buffer size. we will push it in the chain function */ /* Trim the buffer size. we will push it in the chain function */
gst_memory_resize (jpegenc->output_mem, 0, gst_memory_resize (jpegenc->output_mem, 0,
jpegenc->output_size - jpegenc->jdest.free_in_buffer); jpegenc->output_map.size - jpegenc->jdest.free_in_buffer);
jpegenc->output_data = NULL; jpegenc->output_map.data = NULL;
jpegenc->output_size = 0; jpegenc->output_map.size = 0;
} }
static void static void
@ -566,12 +568,10 @@ gst_jpegenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
} }
jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3); jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3);
jpegenc->output_data = gst_memory_map (jpegenc->output_mem, &jpegenc->output_map, GST_MAP_READWRITE);
gst_memory_map (jpegenc->output_mem, &jpegenc->output_size, NULL,
GST_MAP_READWRITE);
jpegenc->jdest.next_output_byte = jpegenc->output_data; jpegenc->jdest.next_output_byte = jpegenc->output_map.data;
jpegenc->jdest.free_in_buffer = jpegenc->output_size; jpegenc->jdest.free_in_buffer = jpegenc->output_map.size;
/* prepare for raw input */ /* prepare for raw input */
#if JPEG_LIB_VERSION >= 70 #if JPEG_LIB_VERSION >= 70

View file

@ -86,8 +86,7 @@ struct _GstJpegEnc
GstFlowReturn last_ret; GstFlowReturn last_ret;
GstMemory *output_mem; GstMemory *output_mem;
gpointer output_data; GstMapInfo output_map;
gsize output_size;
}; };
struct _GstJpegEncClass struct _GstJpegEncClass

View file

@ -1737,8 +1737,7 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
/* FIXME: alloc memory from PA if possible */ /* FIXME: alloc memory from PA if possible */
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec); gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
GstBuffer *out; GstBuffer *out;
guint8 *indata, *outdata; GstMapInfo inmap, outmap;
gsize insize, outsize;
gboolean res; gboolean res;
if (framesize <= 0) if (framesize <= 0)
@ -1746,14 +1745,14 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
out = gst_buffer_new_and_alloc (framesize); out = gst_buffer_new_and_alloc (framesize);
indata = gst_buffer_map (buf, &insize, NULL, GST_MAP_READ); gst_buffer_map (buf, &inmap, GST_MAP_READ);
outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE); gst_buffer_map (out, &outmap, GST_MAP_WRITE);
res = gst_audio_iec61937_payload (indata, insize, res = gst_audio_iec61937_payload (inmap.data, inmap.size,
outdata, outsize, &sink->ringbuffer->spec); outmap.data, outmap.size, &sink->ringbuffer->spec);
gst_buffer_unmap (buf, indata, insize); gst_buffer_unmap (buf, &inmap);
gst_buffer_unmap (out, outdata, outsize); gst_buffer_unmap (out, &outmap);
if (!res) { if (!res) {
gst_buffer_unref (out); gst_buffer_unref (out);

View file

@ -623,30 +623,28 @@ send_message_locked (GstSoupHttpClientSink * souphttpsink)
if (souphttpsink->offset == 0) { if (souphttpsink->offset == 0) {
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) { for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data; GstBuffer *buffer = g->data;
gpointer data; GstMapInfo map;
gsize size;
/* FIXME, lifetime of the buffer? */ /* FIXME, lifetime of the buffer? */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body, soup_message_body_append (souphttpsink->message->request_body,
SOUP_MEMORY_STATIC, data, size); SOUP_MEMORY_STATIC, map.data, map.size);
n += size; n += map.size;
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
} }
} }
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) { for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
GstBuffer *buffer = g->data; GstBuffer *buffer = g->data;
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) { if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
gpointer data; GstMapInfo map;
gsize size;
/* FIXME, lifetime of the buffer? */ /* FIXME, lifetime of the buffer? */
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
soup_message_body_append (souphttpsink->message->request_body, soup_message_body_append (souphttpsink->message->request_body,
SOUP_MEMORY_STATIC, data, size); SOUP_MEMORY_STATIC, map.data, map.size);
n += size; n += map.size;
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
} }
} }

View file

@ -876,7 +876,7 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
typedef struct typedef struct
{ {
GstBuffer *buffer; GstBuffer *buffer;
gpointer data; GstMapInfo map;
} SoupGstChunk; } SoupGstChunk;
static void static void
@ -884,7 +884,7 @@ gst_soup_http_src_chunk_free (gpointer user_data)
{ {
SoupGstChunk *chunk = (SoupGstChunk *) user_data; SoupGstChunk *chunk = (SoupGstChunk *) user_data;
gst_buffer_unmap (chunk->buffer, chunk->data, -1); gst_buffer_unmap (chunk->buffer, &chunk->map);
gst_buffer_unref (chunk->buffer); gst_buffer_unref (chunk->buffer);
g_slice_free (SoupGstChunk, chunk); g_slice_free (SoupGstChunk, chunk);
} }
@ -919,9 +919,9 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
chunk = g_slice_new0 (SoupGstChunk); chunk = g_slice_new0 (SoupGstChunk);
chunk->buffer = gstbuf; chunk->buffer = gstbuf;
chunk->data = gst_buffer_map (gstbuf, &length, NULL, GST_MAP_READWRITE); gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
soupbuf = soup_buffer_new_with_owner (chunk->data, length, soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
chunk, gst_soup_http_src_chunk_free); chunk, gst_soup_http_src_chunk_free);
return soupbuf; return soupbuf;

View file

@ -190,13 +190,12 @@ static GstFlowReturn
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf) gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
{ {
GstCaps *caps; GstCaps *caps;
char *data; GstMapInfo map;
gsize size;
/* get the header */ /* get the header */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
dec->header = speex_packet_to_header (data, size); dec->header = speex_packet_to_header ((gchar *) map.data, map.size);
gst_buffer_unmap (buf, data, size); gst_buffer_unmap (buf, &map);
if (!dec->header) if (!dec->header)
goto no_header; goto no_header;
@ -368,23 +367,22 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
GstFlowReturn res = GST_FLOW_OK; GstFlowReturn res = GST_FLOW_OK;
gint i, fpp; gint i, fpp;
SpeexBits *bits; SpeexBits *bits;
gsize size; GstMapInfo map;
char *data;
if (!dec->frame_duration) if (!dec->frame_duration)
goto not_negotiated; goto not_negotiated;
if (G_LIKELY (gst_buffer_get_size (buf))) { if (G_LIKELY (gst_buffer_get_size (buf))) {
/* send data to the bitstream */ /* send data to the bitstream */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
speex_bits_read_from (&dec->bits, data, size); speex_bits_read_from (&dec->bits, (gchar *) map.data, map.size);
gst_buffer_unmap (buf, data, size); gst_buffer_unmap (buf, &map);
fpp = dec->header->frames_per_packet; fpp = dec->header->frames_per_packet;
bits = &dec->bits; bits = &dec->bits;
GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT
", fpp %d, %d bits", size, fpp, speex_bits_remaining (bits)); ", fpp %d, %d bits", map.size, fpp, speex_bits_remaining (bits));
} else { } else {
/* FIXME ? actually consider how much concealment is needed */ /* FIXME ? actually consider how much concealment is needed */
/* concealment data, pass NULL as the bits parameters */ /* concealment data, pass NULL as the bits parameters */
@ -396,7 +394,6 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
/* now decode each frame, catering for unknown number of them (e.g. rtp) */ /* now decode each frame, catering for unknown number of them (e.g. rtp) */
for (i = 0; i < fpp; i++) { for (i = 0; i < fpp; i++) {
GstBuffer *outbuf; GstBuffer *outbuf;
gint16 *out_data;
gint ret; gint ret;
GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp, GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp,
@ -418,9 +415,8 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
gst_buffer_new_allocate (NULL, gst_buffer_new_allocate (NULL,
dec->frame_size * dec->header->nb_channels * 2, 0); dec->frame_size * dec->header->nb_channels * 2, 0);
out_data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
ret = speex_decode_int (dec->state, bits, out_data); ret = speex_decode_int (dec->state, bits, (spx_int16_t *) map.data);
gst_buffer_unmap (outbuf, out_data, size);
if (ret == -1) { if (ret == -1) {
/* uh? end of stream */ /* uh? end of stream */
@ -445,7 +441,10 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
gst_buffer_unref (outbuf); gst_buffer_unref (outbuf);
} }
if (dec->header->nb_channels == 2) if (dec->header->nb_channels == 2)
speex_decode_stereo_int (out_data, dec->frame_size, dec->stereo); speex_decode_stereo_int ((spx_int16_t *) map.data, dec->frame_size,
dec->stereo);
gst_buffer_unmap (outbuf, &map);
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1); res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
@ -469,8 +468,8 @@ not_negotiated:
static gboolean static gboolean
memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2) memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
{ {
GstMapInfo map;
gsize size1, size2; gsize size1, size2;
gpointer data1;
gboolean res; gboolean res;
size1 = gst_buffer_get_size (buf1); size1 = gst_buffer_get_size (buf1);
@ -479,9 +478,9 @@ memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
if (size1 != size2) if (size1 != size2)
return FALSE; return FALSE;
data1 = gst_buffer_map (buf1, NULL, NULL, GST_MAP_READ); gst_buffer_map (buf1, &map, GST_MAP_READ);
res = gst_buffer_memcmp (buf2, 0, data1, size1) == 0; res = gst_buffer_memcmp (buf2, 0, map.data, map.size) == 0;
gst_buffer_unmap (buf1, data1, size1); gst_buffer_unmap (buf1, &map);
return res; return res;
} }

View file

@ -539,13 +539,16 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
gint frame_size = enc->frame_size; gint frame_size = enc->frame_size;
gint bytes = frame_size * 2 * enc->channels, samples; gint bytes = frame_size * 2 * enc->channels, samples;
gint outsize, written, dtx_ret = 0; gint outsize, written, dtx_ret = 0;
guint8 *data, *data0 = NULL, *bdata, *outdata; GstMapInfo map;
guint8 *data, *data0 = NULL, *bdata;
gsize bsize, size; gsize bsize, size;
GstBuffer *outbuf; GstBuffer *outbuf;
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
if (G_LIKELY (buf)) { if (G_LIKELY (buf)) {
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
bdata = map.data;
bsize = map.size;
if (G_UNLIKELY (bsize % bytes)) { if (G_UNLIKELY (bsize % bytes)) {
GST_DEBUG_OBJECT (enc, "draining; adding silence samples"); GST_DEBUG_OBJECT (enc, "draining; adding silence samples");
@ -553,7 +556,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
size = ((bsize / bytes) + 1) * bytes; size = ((bsize / bytes) + 1) * bytes;
data0 = data = g_malloc0 (size); data0 = data = g_malloc0 (size);
memcpy (data, bdata, bsize); memcpy (data, bdata, bsize);
gst_buffer_unmap (buf, bdata, bsize); gst_buffer_unmap (buf, &map);
bdata = NULL; bdata = NULL;
} else { } else {
data = bdata; data = bdata;
@ -585,7 +588,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
outsize = speex_bits_nbytes (&enc->bits); outsize = speex_bits_nbytes (&enc->bits);
if (bdata) if (bdata)
gst_buffer_unmap (buf, bdata, bsize); gst_buffer_unmap (buf, &map);
#if 0 #if 0
ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc),
@ -596,9 +599,9 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
goto done; goto done;
#endif #endif
outbuf = gst_buffer_new_allocate (NULL, outsize, 0); outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
written = speex_bits_write (&enc->bits, (gchar *) outdata, outsize); written = speex_bits_write (&enc->bits, (gchar *) map.data, outsize);
if (G_UNLIKELY (written < outsize)) { if (G_UNLIKELY (written < outsize)) {
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize); GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
@ -606,7 +609,8 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize); GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize);
written = outsize; written = outsize;
} }
gst_buffer_unmap (outbuf, outdata, written); gst_buffer_unmap (outbuf, &map);
gst_buffer_resize (outbuf, 0, written);
if (!dtx_ret) if (!dtx_ret)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP); GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);

View file

@ -152,12 +152,15 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
{ {
GstBuffer *buf; GstBuffer *buf;
guint32 num_headers; guint32 num_headers;
guint8 *data, *bdata; GstMapInfo map;
guint8 *data;
gsize size; gsize size;
guint offset; guint offset;
gint i, j; gint i, j;
bdata = data = gst_buffer_map (confbuf, &size, NULL, GST_MAP_READ); gst_buffer_map (confbuf, &map, GST_MAP_READ);
data = map.data;
size = map.size;
GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size); GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size);
@ -295,7 +298,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf); rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
} }
gst_buffer_unmap (confbuf, bdata, -1); gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf); gst_buffer_unref (confbuf);
return TRUE; return TRUE;
@ -304,7 +307,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
too_small: too_small:
{ {
GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small"); GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
gst_buffer_unmap (confbuf, bdata, -1); gst_buffer_unmap (confbuf, &map);
gst_buffer_unref (confbuf); gst_buffer_unref (confbuf);
return FALSE; return FALSE;
} }
@ -316,23 +319,23 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
guint length) guint length)
{ {
GstBuffer *confbuf; GstBuffer *confbuf;
guint8 *conf; GstMapInfo map;
if (G_UNLIKELY (size < 4)) if (G_UNLIKELY (size < 4))
return FALSE; return FALSE;
/* transform inline to out-of-band and parse that one */ /* transform inline to out-of-band and parse that one */
confbuf = gst_buffer_new_and_alloc (size + 9); confbuf = gst_buffer_new_and_alloc (size + 9);
conf = gst_buffer_map (confbuf, NULL, NULL, -1); gst_buffer_map (confbuf, &map, GST_MAP_WRITE);
/* 1 header */ /* 1 header */
GST_WRITE_UINT32_BE (conf, 1); GST_WRITE_UINT32_BE (map.data, 1);
/* write Ident */ /* write Ident */
GST_WRITE_UINT24_BE (conf + 4, ident); GST_WRITE_UINT24_BE (map.data + 4, ident);
/* write sort-of-length */ /* write sort-of-length */
GST_WRITE_UINT16_BE (conf + 7, length); GST_WRITE_UINT16_BE (map.data + 7, length);
/* copy remainder */ /* copy remainder */
memcpy (conf + 9, configuration, size); memcpy (map.data + 9, configuration, size);
gst_buffer_unmap (confbuf, conf, -1); gst_buffer_unmap (confbuf, &map);
return gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf); return gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf);
} }
@ -595,12 +598,8 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
(payload - to_free) + length, payload - to_free, length)); (payload - to_free) + length, payload - to_free, length));
to_free = NULL; to_free = NULL;
} else { } else {
guint8 *data;
outbuf = gst_buffer_new_and_alloc (length); outbuf = gst_buffer_new_and_alloc (length);
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE); gst_buffer_fill (outbuf, 0, payload, length);
memcpy (data, payload, length);
gst_buffer_unmap (outbuf, data, -1);
} }
payload += length; payload += length;

View file

@ -291,10 +291,10 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
ident = fnv1_hash_32_new (); ident = fnv1_hash_32_new ();
for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) { for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
GstBuffer *buf = GST_BUFFER_CAST (walk->data); GstBuffer *buf = GST_BUFFER_CAST (walk->data);
guint bsize, osize; GstMapInfo map;
guint8 *data; guint bsize;
bsize = osize = gst_buffer_get_size (buf); bsize = gst_buffer_get_size (buf);
length += bsize; length += bsize;
n_headers++; n_headers++;
@ -307,9 +307,9 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
} while (bsize); } while (bsize);
} }
/* update hash */ /* update hash */
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
ident = fnv1_hash_32_update (ident, data, osize); ident = fnv1_hash_32_update (ident, map.data, map.size);
gst_buffer_unmap (buf, data, -1); gst_buffer_unmap (buf, &map);
} }
/* packet length is header size + packet length */ /* packet length is header size + packet length */
@ -475,6 +475,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstRtpVorbisPay *rtpvorbispay; GstRtpVorbisPay *rtpvorbispay;
GstFlowReturn ret; GstFlowReturn ret;
guint newsize; guint newsize;
GstMapInfo map;
gsize size; gsize size;
guint8 *data; guint8 *data;
guint packet_len; guint packet_len;
@ -488,7 +489,9 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload); rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
duration = GST_BUFFER_DURATION (buffer); duration = GST_BUFFER_DURATION (buffer);
timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = GST_BUFFER_TIMESTAMP (buffer);
@ -523,7 +526,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
if (VDT != 0) { if (VDT != 0) {
GST_DEBUG_OBJECT (rtpvorbispay, "collecting header"); GST_DEBUG_OBJECT (rtpvorbispay, "collecting header");
/* append header to the list of headers */ /* append header to the list of headers */
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer); rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer);
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
goto done; goto done;
@ -623,7 +626,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
if (rtp.buffer) if (rtp.buffer)
gst_rtp_buffer_unmap (&rtp); gst_rtp_buffer_unmap (&rtp);
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
done: done:
@ -635,13 +638,13 @@ wrong_size:
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 0xffff)", size), ("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 0xffff)", size),
(NULL)); (NULL));
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
parse_id_failed: parse_id_failed:
{ {
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
@ -649,7 +652,7 @@ unknown_header:
{ {
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
(NULL), ("Ignoring unknown header received")); (NULL), ("Ignoring unknown header received"));
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
@ -657,7 +660,7 @@ header_error:
{ {
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE, GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
(NULL), ("Error initializing header config")); (NULL), ("Error initializing header config"));
gst_buffer_unmap (buffer, data, -1); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} }

View file

@ -2233,7 +2233,8 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
if (fci_length > 0) { if (fci_length > 0) {
fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer, fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer,
GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->data, fci_length); GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->map.data,
fci_length);
GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time; GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time;
} }

View file

@ -2095,9 +2095,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GstRTSPSrc *src; GstRTSPSrc *src;
GstRTSPStream *stream; GstRTSPStream *stream;
GstFlowReturn res = GST_FLOW_OK; GstFlowReturn res = GST_FLOW_OK;
GstMapInfo map;
guint8 *data; guint8 *data;
guint size; guint size;
gsize bsize;
GstRTSPResult ret; GstRTSPResult ret;
GstRTSPMessage message = { 0 }; GstRTSPMessage message = { 0 };
GstRTSPConnection *conn; GstRTSPConnection *conn;
@ -2105,8 +2105,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
stream = (GstRTSPStream *) gst_pad_get_element_private (pad); stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
src = stream->parent; src = stream->parent;
data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
size = bsize; size = map.size;
data = map.data;
gst_rtsp_message_init_data (&message, stream->channel[1]); gst_rtsp_message_init_data (&message, stream->channel[1]);
@ -2127,7 +2128,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
gst_rtsp_message_steal_body (&message, &data, &size); gst_rtsp_message_steal_body (&message, &data, &size);
gst_rtsp_message_unset (&message); gst_rtsp_message_unset (&message);
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return res; return res;

View file

@ -857,14 +857,17 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
guint nfft = 2 * bands - 2; guint nfft = 2 * bands - 2;
guint input_pos; guint input_pos;
gfloat *input; gfloat *input;
const guint8 *data, *mdata; GstMapInfo map;
const guint8 *data;
gsize size; gsize size;
guint fft_todo, msg_todo, block_size; guint fft_todo, msg_todo, block_size;
gboolean have_full_interval; gboolean have_full_interval;
GstSpectrumChannel *cd; GstSpectrumChannel *cd;
GstSpectrumInputData input_data; GstSpectrumInputData input_data;
data = mdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
data = map.data;
size = map.size;
GST_LOG_OBJECT (spectrum, "input size: %" G_GSIZE_FORMAT " bytes", size); GST_LOG_OBJECT (spectrum, "input size: %" G_GSIZE_FORMAT " bytes", size);
@ -993,7 +996,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
spectrum->input_pos = input_pos; spectrum->input_pos = input_pos;
gst_buffer_unmap (buffer, (guint8 *) mdata, -1); gst_buffer_unmap (buffer, &map);
g_assert (size == 0); g_assert (size == 0);

View file

@ -167,8 +167,7 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
{ {
GstDynUDPSink *sink; GstDynUDPSink *sink;
gssize ret; gssize ret;
gsize size; GstMapInfo map;
guint8 *data;
GstNetAddressMeta *meta; GstNetAddressMeta *meta;
GSocketAddress *addr; GSocketAddress *addr;
GError *err = NULL; GError *err = NULL;
@ -190,9 +189,9 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
if (sink->family != family && family != G_SOCKET_FAMILY_IPV4) if (sink->family != family && family != G_SOCKET_FAMILY_IPV4)
goto invalid_family; goto invalid_family;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); gst_buffer_map (buffer, &map, GST_MAP_READ);
GST_DEBUG ("about to send %" G_GSIZE_FORMAT " bytes", size); GST_DEBUG ("about to send %" G_GSIZE_FORMAT " bytes", map.size);
#ifndef GST_DISABLE_GST_DEBUG #ifndef GST_DISABLE_GST_DEBUG
{ {
@ -201,16 +200,17 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
host = host =
g_inet_address_to_string (g_inet_socket_address_get_address g_inet_address_to_string (g_inet_socket_address_get_address
(G_INET_SOCKET_ADDRESS (addr))); (G_INET_SOCKET_ADDRESS (addr)));
GST_DEBUG ("sending %" G_GSIZE_FORMAT " bytes to client %s port %d", size, GST_DEBUG ("sending %" G_GSIZE_FORMAT " bytes to client %s port %d",
host, g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr))); map.size, host,
g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (addr)));
g_free (host); g_free (host);
} }
#endif #endif
ret = ret =
g_socket_send_to (sink->used_socket, addr, (gchar *) data, size, g_socket_send_to (sink->used_socket, addr, (gchar *) map.data, map.size,
sink->cancellable, &err); sink->cancellable, &err);
gst_buffer_unmap (buffer, data, size); gst_buffer_unmap (buffer, &map);
if (ret < 0) if (ret < 0)
goto send_error; goto send_error;

View file

@ -440,9 +440,9 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
GstMultiUDPSink *sink; GstMultiUDPSink *sink;
GList *clients; GList *clients;
GOutputVector *vec; GOutputVector *vec;
GstMapInfo *map;
guint n_mem, i; guint n_mem, i;
gpointer bdata; gsize size;
gsize bsize, size;
GstMemory *mem; GstMemory *mem;
gint num, no_clients; gint num, no_clients;
GError *err = NULL; GError *err = NULL;
@ -454,21 +454,22 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
goto no_data; goto no_data;
vec = g_new (GOutputVector, n_mem); vec = g_new (GOutputVector, n_mem);
map = g_new (GstMapInfo, n_mem);
size = 0; size = 0;
for (i = 0; i < n_mem; i++) { for (i = 0; i < n_mem; i++) {
mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ); mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ);
bdata = gst_memory_map (mem, &bsize, NULL, GST_MAP_READ); gst_memory_map (mem, &map[i], GST_MAP_READ);
if (bsize > UDP_MAX_SIZE) { if (map[i].size > UDP_MAX_SIZE) {
GST_WARNING ("Attempting to send a UDP packet larger than maximum " GST_WARNING ("Attempting to send a UDP packet larger than maximum "
"size (%" G_GSIZE_FORMAT " > %d)", bsize, UDP_MAX_SIZE); "size (%" G_GSIZE_FORMAT " > %d)", map[i].size, UDP_MAX_SIZE);
} }
vec[i].buffer = bdata; vec[i].buffer = map[i].data;
vec[i].size = bsize; vec[i].size = map[i].size;
size += bsize; size += map[i].size;
} }
sink->bytes_to_serve += size; sink->bytes_to_serve += size;
@ -509,11 +510,11 @@ gst_multiudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
g_mutex_unlock (&sink->client_lock); g_mutex_unlock (&sink->client_lock);
/* unmap all memory again */ /* unmap all memory again */
for (i = 0; i < n_mem; i++) { for (i = 0; i < n_mem; i++)
mem = gst_buffer_peek_memory (buffer, i, GST_MAP_READ); gst_memory_unmap (map[i].memory, &map[i]);
gst_memory_unmap (mem);
}
g_free (vec); g_free (vec);
g_free (map);
GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num, GST_LOG_OBJECT (sink, "sent %d bytes to %d (of %d) clients", size, num,
no_clients); no_clients);

View file

@ -308,18 +308,17 @@ static void
gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop, gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop,
GstBuffer * inbuf, GstBuffer * outbuf) GstBuffer * inbuf, GstBuffer * outbuf)
{ {
GstMapInfo in_map, out_map;
guint8 *in_data, *out_data; guint8 *in_data, *out_data;
gpointer in_bufdata, out_bufdata;
gsize insize, outsize;
guint i, dx; guint i, dx;
gint in_stride; gint in_stride;
gint out_stride; gint out_stride;
in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ); gst_buffer_map (inbuf, &in_map, GST_MAP_READ);
out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
in_data = in_bufdata; in_data = in_map.data;
out_data = out_bufdata; out_data = out_map.data;
in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0); in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0);
out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0); out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0);
@ -358,25 +357,24 @@ gst_video_crop_transform_packed_complex (GstVideoCrop * vcrop,
out_data += out_stride; out_data += out_stride;
} }
} }
gst_buffer_unmap (inbuf, in_bufdata, insize); gst_buffer_unmap (inbuf, &in_map);
gst_buffer_unmap (outbuf, out_bufdata, outsize); gst_buffer_unmap (outbuf, &out_map);
} }
static void static void
gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop, gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop,
GstBuffer * inbuf, GstBuffer * outbuf) GstBuffer * inbuf, GstBuffer * outbuf)
{ {
GstMapInfo in_map, out_map;
guint8 *in_data, *out_data; guint8 *in_data, *out_data;
gpointer in_bufdata, out_bufdata;
gsize insize, outsize;
guint i, dx; guint i, dx;
gint in_stride, out_stride; gint in_stride, out_stride;
in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ); gst_buffer_map (inbuf, &in_map, GST_MAP_READ);
out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
in_data = in_bufdata; in_data = in_map.data;
out_data = out_bufdata; out_data = out_map.data;
in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0); in_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, 0);
out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0); out_stride = GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 0);
@ -393,26 +391,25 @@ gst_video_crop_transform_packed_simple (GstVideoCrop * vcrop,
in_data += in_stride; in_data += in_stride;
out_data += out_stride; out_data += out_stride;
} }
gst_buffer_unmap (inbuf, in_bufdata, insize); gst_buffer_unmap (inbuf, &in_map);
gst_buffer_unmap (outbuf, out_bufdata, outsize); gst_buffer_unmap (outbuf, &out_map);
} }
static void static void
gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf, gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
GstBuffer * outbuf) GstBuffer * outbuf)
{ {
GstMapInfo in_map, out_map;
guint8 *y_out, *u_out, *v_out; guint8 *y_out, *u_out, *v_out;
guint8 *y_in, *u_in, *v_in; guint8 *y_in, *u_in, *v_in;
guint i, dx; guint i, dx;
gpointer in_bufdata, out_bufdata;
gsize insize, outsize;
in_bufdata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ); gst_buffer_map (inbuf, &in_map, GST_MAP_READ);
out_bufdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE); gst_buffer_map (outbuf, &out_map, GST_MAP_WRITE);
/* Y plane */ /* Y plane */
y_in = in_bufdata; y_in = in_map.data;
y_out = out_bufdata; y_out = out_map.data;
y_in += y_in +=
(vcrop->crop_top * GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info, (vcrop->crop_top * GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->in.info,
@ -427,9 +424,9 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
/* U + V planes */ /* U + V planes */
u_in = u_in =
(guint8 *) in_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 1); (guint8 *) in_map.data + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 1);
u_out = u_out =
(guint8 *) out_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info, (guint8 *) out_map.data + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info,
1); 1);
u_in += u_in +=
@ -437,9 +434,9 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
u_in += vcrop->crop_left / 2; u_in += vcrop->crop_left / 2;
v_in = v_in =
(guint8 *) in_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 2); (guint8 *) in_map.data + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->in.info, 2);
v_out = v_out =
(guint8 *) out_bufdata + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info, (guint8 *) out_map.data + GST_VIDEO_INFO_PLANE_OFFSET (&vcrop->out.info,
2); 2);
v_in += v_in +=
@ -458,8 +455,8 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, GstBuffer * inbuf,
v_out += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 2); v_out += GST_VIDEO_INFO_PLANE_STRIDE (&vcrop->out.info, 2);
} }
gst_buffer_unmap (inbuf, in_bufdata, insize); gst_buffer_unmap (inbuf, &in_map);
gst_buffer_unmap (outbuf, out_bufdata, outsize); gst_buffer_unmap (outbuf, &out_map);
} }
static GstFlowReturn static GstFlowReturn

View file

@ -169,10 +169,12 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
{ {
struct wave_header wave; struct wave_header wave;
GstBuffer *buf; GstBuffer *buf;
GstMapInfo map;
guint8 *header; guint8 *header;
buf = gst_buffer_new_and_alloc (WAV_HEADER_LEN); buf = gst_buffer_new_and_alloc (WAV_HEADER_LEN);
header = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); gst_buffer_map (buf, &map, GST_MAP_WRITE);
header = map.data;
memset (header, 0, WAV_HEADER_LEN); memset (header, 0, WAV_HEADER_LEN);
wave.common.wChannels = wavenc->channels; wave.common.wChannels = wavenc->channels;
@ -209,7 +211,7 @@ gst_wavenc_create_header_buf (GstWavEnc * wavenc, guint audio_data_size)
memcpy (header + 36, (char *) wave.data.id, 4); memcpy (header + 36, (char *) wave.data.id, 4);
GST_WRITE_UINT32_LE (header + 40, wave.data.len); GST_WRITE_UINT32_LE (header + 40, wave.data.len);
gst_buffer_unmap (buf, header, -1); gst_buffer_unmap (buf, &map);
return buf; return buf;
} }

View file

@ -1283,16 +1283,16 @@ gst_wavparse_stream_headers (GstWavParse * wav)
if (!gst_wavparse_peek_chunk_info (wav, &tag, &size)) if (!gst_wavparse_peek_chunk_info (wav, &tag, &size))
goto exit; goto exit;
} else { } else {
guint8 *data; GstMapInfo map;
if ((res = if ((res =
gst_pad_pull_range (wav->sinkpad, wav->offset, 8, gst_pad_pull_range (wav->sinkpad, wav->offset, 8,
&buf)) != GST_FLOW_OK) &buf)) != GST_FLOW_OK)
goto header_read_error; goto header_read_error;
data = gst_buffer_map (buf, NULL, NULL, -1); gst_buffer_map (buf, &map, GST_MAP_READ);
tag = GST_READ_UINT32_LE (data); tag = GST_READ_UINT32_LE (map.data);
size = GST_READ_UINT32_LE (data + 4); size = GST_READ_UINT32_LE (map.data + 4);
gst_buffer_unmap (buf, data, -1); gst_buffer_unmap (buf, &map);
} }
GST_INFO_OBJECT (wav, GST_INFO_OBJECT (wav,
@ -1409,15 +1409,16 @@ gst_wavparse_stream_headers (GstWavParse * wav)
tempo = acid->tempo; tempo = acid->tempo;
gst_adapter_unmap (wav->adapter); gst_adapter_unmap (wav->adapter);
} else { } else {
GstMapInfo map;
gst_buffer_unref (buf); gst_buffer_unref (buf);
if ((res = if ((res =
gst_pad_pull_range (wav->sinkpad, wav->offset + 8, gst_pad_pull_range (wav->sinkpad, wav->offset + 8,
size, &buf)) != GST_FLOW_OK) size, &buf)) != GST_FLOW_OK)
goto header_read_error; goto header_read_error;
acid = (const gst_riff_acid *) gst_buffer_map (buf, NULL, NULL, gst_buffer_map (buf, &map, GST_MAP_READ);
GST_MAP_READ); acid = (const gst_riff_acid *) map.data;
tempo = acid->tempo; tempo = acid->tempo;
gst_buffer_unmap (buf, (guint8 *) acid, -1); gst_buffer_unmap (buf, &map);
} }
/* send data as tags */ /* send data as tags */
if (!wav->tags) if (!wav->tags)

View file

@ -892,20 +892,20 @@ gst_v4l2_do_read (GstV4l2BufferPool * pool, GstBuffer * buf)
GstFlowReturn res; GstFlowReturn res;
GstV4l2Object *obj = pool->obj; GstV4l2Object *obj = pool->obj;
gint amount; gint amount;
gpointer data; GstMapInfo map;
gint toread; gint toread;
toread = obj->sizeimage; toread = obj->sizeimage;
GST_LOG_OBJECT (pool, "reading %d bytes into buffer %p", toread, buf); GST_LOG_OBJECT (pool, "reading %d bytes into buffer %p", toread, buf);
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE); gst_buffer_map (buf, &map, GST_MAP_WRITE);
do { do {
if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK) if ((res = gst_v4l2_object_poll (obj)) != GST_FLOW_OK)
goto poll_error; goto poll_error;
amount = v4l2_read (obj->video_fd, data, toread); amount = v4l2_read (obj->video_fd, map.data, toread);
if (amount == toread) { if (amount == toread) {
break; break;
@ -921,7 +921,8 @@ gst_v4l2_do_read (GstV4l2BufferPool * pool, GstBuffer * buf)
} while (TRUE); } while (TRUE);
GST_LOG_OBJECT (pool, "read %d bytes", amount); GST_LOG_OBJECT (pool, "read %d bytes", amount);
gst_buffer_unmap (buf, data, amount); gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, amount);
return GST_FLOW_OK; return GST_FLOW_OK;
@ -941,7 +942,8 @@ read_error:
} }
cleanup: cleanup:
{ {
gst_buffer_unmap (buf, data, 0); gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, 0);
return res; return res;
} }
} }

View file

@ -2579,9 +2579,6 @@ gboolean
gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest, gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
GstBuffer * src) GstBuffer * src)
{ {
guint8 *data;
gsize size;
if (v4l2object->info.finfo) { if (v4l2object->info.finfo) {
GstVideoFrame src_frame, dest_frame; GstVideoFrame src_frame, dest_frame;
@ -2602,10 +2599,12 @@ gst_v4l2_object_copy (GstV4l2Object * v4l2object, GstBuffer * dest,
gst_video_frame_unmap (&src_frame); gst_video_frame_unmap (&src_frame);
gst_video_frame_unmap (&dest_frame); gst_video_frame_unmap (&dest_frame);
} else { } else {
GstMapInfo map;
GST_DEBUG_OBJECT (v4l2object->element, "copy raw bytes"); GST_DEBUG_OBJECT (v4l2object->element, "copy raw bytes");
data = gst_buffer_map (src, &size, NULL, GST_MAP_READ); gst_buffer_map (src, &map, GST_MAP_READ);
gst_buffer_fill (dest, 0, data, size); gst_buffer_fill (dest, 0, map.data, map.size);
gst_buffer_unmap (src, data, size); gst_buffer_unmap (src, &map);
} }
GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element, GST_CAT_LOG_OBJECT (GST_CAT_PERFORMANCE, v4l2object->element,
"slow copy into buffer %p", dest); "slow copy into buffer %p", dest);

View file

@ -437,12 +437,11 @@ composite_pixel (GstXContext * xcontext, guchar * dest, guchar * src)
static void static void
copy_buffer (GstBuffer * dest, GstBuffer * src) copy_buffer (GstBuffer * dest, GstBuffer * src)
{ {
guint8 *data; GstMapInfo map;
gsize size;
data = gst_buffer_map (src, &size, NULL, GST_MAP_READ); gst_buffer_map (src, &map, GST_MAP_READ);
gst_buffer_fill (dest, 0, data, size); gst_buffer_fill (dest, 0, map.data, map.size);
gst_buffer_unmap (src, data, size); gst_buffer_unmap (src, &map);
} }
#endif #endif

View file

@ -69,15 +69,14 @@ buffer_new (const unsigned char *buffer_data, guint size)
gst_buffer_fill (buffer, 0, buffer_data, size); gst_buffer_fill (buffer, 0, buffer_data, size);
} else { } else {
guint i; guint i;
guint8 *data; GstMapInfo map;
gsize wantsize = size;
data = gst_buffer_map (buffer, &wantsize, NULL, GST_MAP_WRITE); gst_buffer_map (buffer, &map, GST_MAP_WRITE);
/* Create a recognizable pattern (loop 0x00 -> 0xff) in the data block */ /* Create a recognizable pattern (loop 0x00 -> 0xff) in the data block */
for (i = 0; i < wantsize; i++) { for (i = 0; i < map.size; i++) {
data[i] = i % 0x100; map.data[i] = i % 0x100;
} }
gst_buffer_unmap (buffer, data, wantsize); gst_buffer_unmap (buffer, &map);
} }
/* gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad)); */ /* gst_buffer_set_caps (buffer, GST_PAD_CAPS (srcpad)); */