mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
Merge branch '0.11' of ssh://git.freedesktop.org/git/gstreamer/gst-plugins-good into 0.11
This commit is contained in:
commit
0b517ce9fb
109 changed files with 1577 additions and 1576 deletions
|
@ -358,10 +358,13 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
{
|
||||
GstCmmlDec *dec = GST_CMML_DEC (parent);
|
||||
GstCmmlPacketType packet;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
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) {
|
||||
/* the EOS page could be empty */
|
||||
|
@ -400,7 +403,7 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
}
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return dec->flow_return;
|
||||
|
|
|
@ -598,23 +598,23 @@ gst_cmml_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
{
|
||||
GError *err = NULL;
|
||||
GstCmmlEnc *enc = GST_CMML_ENC (parent);
|
||||
gchar *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
/* the CMML handlers registered with enc->parser will override this when
|
||||
* encoding/pushing the buffers downstream
|
||||
*/
|
||||
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));
|
||||
g_error_free (err);
|
||||
enc->flow_return = GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return enc->flow_return;
|
||||
}
|
||||
|
|
|
@ -536,8 +536,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
|||
guint channels = frame->header.channels;
|
||||
guint samples = frame->header.blocksize;
|
||||
guint j, i;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gboolean caps_changed;
|
||||
|
||||
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");
|
||||
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) {
|
||||
gint8 *outbuffer = (gint8 *) data;
|
||||
gint8 *outbuffer = (gint8 *) map.data;
|
||||
gint *reorder_map = flacdec->channel_reorder_map;
|
||||
|
||||
if (width != depth) {
|
||||
|
@ -637,7 +636,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
|||
}
|
||||
}
|
||||
} else if (width == 16) {
|
||||
gint16 *outbuffer = (gint16 *) data;
|
||||
gint16 *outbuffer = (gint16 *) map.data;
|
||||
gint *reorder_map = flacdec->channel_reorder_map;
|
||||
|
||||
if (width != depth) {
|
||||
|
@ -655,7 +654,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
|||
}
|
||||
}
|
||||
} else if (width == 32) {
|
||||
gint32 *outbuffer = (gint32 *) data;
|
||||
gint32 *outbuffer = (gint32 *) map.data;
|
||||
gint *reorder_map = flacdec->channel_reorder_map;
|
||||
|
||||
if (width != depth) {
|
||||
|
@ -675,7 +674,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
|||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
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)) {
|
||||
gboolean got_audio_frame;
|
||||
gint64 unused;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
/* check if this is a flac audio frame (rather than a header or junk) */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
got_audio_frame = gst_flac_dec_scan_got_frame (dec, data, size, &unused);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
got_audio_frame =
|
||||
gst_flac_dec_scan_got_frame (dec, map.data, map.size, &unused);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
if (!got_audio_frame) {
|
||||
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);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -516,8 +516,7 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
|
|||
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
|
||||
#endif
|
||||
gint i;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
for (i = 0; i < n_images + n_preview_images; i++) {
|
||||
if (i < n_images) {
|
||||
|
@ -545,10 +544,10 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
|
|||
image_type = image_type + 2;
|
||||
#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],
|
||||
data, size, TRUE);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
map.data, map.size, TRUE);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
#if 0
|
||||
/* 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) {
|
||||
GstBuffer *buf;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
|
@ -925,7 +925,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
|||
buf = GST_BUFFER_CAST (l->data);
|
||||
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 */
|
||||
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
|
||||
|
@ -936,7 +938,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
|||
vorbiscomment = buf;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
||||
|
@ -951,8 +953,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
|||
{
|
||||
GstBuffer *buf;
|
||||
guint16 num;
|
||||
GstMapInfo map;
|
||||
guint8 *bdata;
|
||||
gsize bsize, slen;
|
||||
gsize slen;
|
||||
|
||||
/* minus one for the marker that is merged with streaminfo here */
|
||||
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);
|
||||
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;
|
||||
memcpy (bdata + 1, "FLAC", 4);
|
||||
bdata[5] = 0x01; /* mapping version major */
|
||||
|
@ -969,7 +973,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
|||
bdata[8] = (num & 0x00FF) >> 0;
|
||||
memcpy (bdata + 9, "fLaC", 4);
|
||||
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);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -1169,12 +1173,11 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
{
|
||||
GstFlacEnc *flacenc;
|
||||
FLAC__int32 *data;
|
||||
gsize bsize;
|
||||
gint samples, width, channels;
|
||||
gulong i;
|
||||
gint j;
|
||||
FLAC__bool res;
|
||||
gpointer bdata;
|
||||
GstMapInfo map;
|
||||
GstAudioInfo *info =
|
||||
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
|
||||
gint *reorder_map;
|
||||
|
@ -1202,28 +1205,28 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
return flacenc->last_flow;
|
||||
}
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
samples = bsize / (width >> 3);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
samples = map.size / (width >> 3);
|
||||
|
||||
data = g_malloc (samples * sizeof (FLAC__int32));
|
||||
|
||||
samples /= channels;
|
||||
if (width == 8) {
|
||||
gint8 *indata = (gint8 *) bdata;
|
||||
gint8 *indata = (gint8 *) map.data;
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
for (j = 0; j < channels; j++)
|
||||
data[i * channels + reorder_map[j]] =
|
||||
(FLAC__int32) indata[i * channels + j];
|
||||
} else if (width == 16) {
|
||||
gint16 *indata = (gint16 *) bdata;
|
||||
gint16 *indata = (gint16 *) map.data;
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
for (j = 0; j < channels; j++)
|
||||
data[i * channels + reorder_map[j]] =
|
||||
(FLAC__int32) indata[i * channels + j];
|
||||
} else if (width == 24) {
|
||||
guint8 *indata = (guint8 *) bdata;
|
||||
guint8 *indata = (guint8 *) map.data;
|
||||
guint32 val;
|
||||
|
||||
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;
|
||||
}
|
||||
} else if (width == 32) {
|
||||
gint32 *indata = (gint32 *) bdata;
|
||||
gint32 *indata = (gint32 *) map.data;
|
||||
|
||||
for (i = 0; i < samples; i++)
|
||||
for (j = 0; j < channels; j++)
|
||||
|
@ -1243,7 +1246,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
|||
} else {
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
|
||||
(const FLAC__int32 *) data, samples / channels);
|
||||
|
|
|
@ -191,7 +191,7 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
{
|
||||
GstFlacTag *tag;
|
||||
GstFlowReturn ret;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
|
||||
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
|
||||
* be the vorbis comment block which we will build ourselves.
|
||||
*/
|
||||
data = gst_buffer_map (metadata_buffer, &size, NULL, GST_MAP_READWRITE);
|
||||
data[0] &= (~0x80);
|
||||
gst_buffer_unmap (metadata_buffer, data, size);
|
||||
gst_buffer_map (metadata_buffer, &map, GST_MAP_READWRITE);
|
||||
map.data[0] &= (~0x80);
|
||||
gst_buffer_unmap (metadata_buffer, &map);
|
||||
|
||||
if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
|
||||
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)
|
||||
goto no_buffer;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
|
||||
memset (data, 0, size);
|
||||
data[0] = 0x81; /* 0x80 = Last metadata block,
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
memset (map.data, 0, map.size);
|
||||
map.data[0] = 0x81; /* 0x80 = Last metadata block,
|
||||
* 0x01 = padding block */
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
} else {
|
||||
guchar header[4];
|
||||
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
|
||||
* size of the metadata block
|
||||
*/
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
|
||||
data[1] = (((size - 4) & 0xFF0000) >> 16);
|
||||
data[2] = (((size - 4) & 0x00FF00) >> 8);
|
||||
data[3] = ((size - 4) & 0x0000FF);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
map.data[1] = (((map.size - 4) & 0xFF0000) >> 16);
|
||||
map.data[2] = (((map.size - 4) & 0x00FF00) >> 8);
|
||||
map.data[3] = ((map.size - 4) & 0x0000FF);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment "
|
||||
"buffer", size);
|
||||
"buffer", map.size);
|
||||
|
||||
ret = gst_pad_push (tag->srcpad, buffer);
|
||||
if (ret != GST_FLOW_OK) {
|
||||
|
|
|
@ -159,10 +159,11 @@ static void
|
|||
ensure_memory (GstJpegEnc * jpegenc)
|
||||
{
|
||||
GstMemory *new_memory;
|
||||
GstMapInfo map;
|
||||
gsize old_size, desired_size, new_size;
|
||||
guint8 *new_data;
|
||||
|
||||
old_size = jpegenc->output_size;
|
||||
old_size = jpegenc->output_map.size;
|
||||
if (old_size == 0)
|
||||
desired_size = jpegenc->bufsize;
|
||||
else
|
||||
|
@ -171,19 +172,20 @@ ensure_memory (GstJpegEnc * jpegenc)
|
|||
/* Our output memory wasn't big enough.
|
||||
* Make a new memory that's twice the size, */
|
||||
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 */
|
||||
if (jpegenc->output_mem) {
|
||||
memcpy (new_data, jpegenc->output_data, old_size);
|
||||
gst_memory_unmap (jpegenc->output_mem);
|
||||
memcpy (new_data, jpegenc->output_map.data, old_size);
|
||||
gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
|
||||
gst_memory_unref (jpegenc->output_mem);
|
||||
}
|
||||
|
||||
/* drop it into place, */
|
||||
jpegenc->output_mem = new_memory;
|
||||
jpegenc->output_data = new_data;
|
||||
jpegenc->output_size = new_size;
|
||||
jpegenc->output_map = map;
|
||||
|
||||
/* and last, update libjpeg on where to work. */
|
||||
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);
|
||||
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 */
|
||||
gst_memory_resize (jpegenc->output_mem, 0,
|
||||
jpegenc->output_size - jpegenc->jdest.free_in_buffer);
|
||||
jpegenc->output_data = NULL;
|
||||
jpegenc->output_size = 0;
|
||||
jpegenc->output_map.size - jpegenc->jdest.free_in_buffer);
|
||||
jpegenc->output_map.data = NULL;
|
||||
jpegenc->output_map.size = 0;
|
||||
}
|
||||
|
||||
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_data =
|
||||
gst_memory_map (jpegenc->output_mem, &jpegenc->output_size, NULL,
|
||||
GST_MAP_READWRITE);
|
||||
gst_memory_map (jpegenc->output_mem, &jpegenc->output_map, GST_MAP_READWRITE);
|
||||
|
||||
jpegenc->jdest.next_output_byte = jpegenc->output_data;
|
||||
jpegenc->jdest.free_in_buffer = jpegenc->output_size;
|
||||
jpegenc->jdest.next_output_byte = jpegenc->output_map.data;
|
||||
jpegenc->jdest.free_in_buffer = jpegenc->output_map.size;
|
||||
|
||||
/* prepare for raw input */
|
||||
#if JPEG_LIB_VERSION >= 70
|
||||
|
|
|
@ -86,8 +86,7 @@ struct _GstJpegEnc
|
|||
GstFlowReturn last_ret;
|
||||
|
||||
GstMemory *output_mem;
|
||||
gpointer output_data;
|
||||
gsize output_size;
|
||||
GstMapInfo output_map;
|
||||
};
|
||||
|
||||
struct _GstJpegEncClass
|
||||
|
|
|
@ -615,8 +615,7 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
{
|
||||
GstPngDec *pngdec;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *bdata = NULL;
|
||||
gsize size;
|
||||
GstMapInfo map = GST_MAP_INFO_INIT;
|
||||
|
||||
pngdec = GST_PNGDEC (parent);
|
||||
|
||||
|
@ -640,12 +639,12 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
pngdec->in_timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
pngdec->in_duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
GST_LOG_OBJECT (pngdec, "Got buffer, size=%d", (gint) size);
|
||||
GST_LOG_OBJECT (pngdec, "Got buffer, size=%d", (gint) map.size);
|
||||
|
||||
/* Progressive loading of the PNG image */
|
||||
png_process_data (pngdec->png, pngdec->info, bdata, size);
|
||||
png_process_data (pngdec->png, pngdec->info, map.data, map.size);
|
||||
|
||||
if (pngdec->image_ready) {
|
||||
if (pngdec->framed) {
|
||||
|
@ -666,8 +665,8 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
ret = pngdec->ret;
|
||||
|
||||
beach:
|
||||
if (G_LIKELY (bdata))
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
if (G_LIKELY (map.data))
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
/* And release the buffer */
|
||||
gst_buffer_unref (buffer);
|
||||
|
|
|
@ -231,14 +231,13 @@ static void
|
|||
user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||
{
|
||||
GstPngEnc *pngenc;
|
||||
gsize size;
|
||||
guint8 *bdata;
|
||||
GstMapInfo map;
|
||||
|
||||
pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr);
|
||||
|
||||
bdata = gst_buffer_map (pngenc->buffer_out, &size, NULL, GST_MAP_WRITE);
|
||||
if (pngenc->written + length >= size) {
|
||||
gst_buffer_unmap (pngenc->buffer_out, data, -1);
|
||||
gst_buffer_map (pngenc->buffer_out, &map, GST_MAP_WRITE);
|
||||
if (pngenc->written + length >= map.size) {
|
||||
gst_buffer_unmap (pngenc->buffer_out, &map);
|
||||
GST_ERROR_OBJECT (pngenc, "output buffer bigger than the input buffer!?");
|
||||
png_error (png_ptr, "output buffer bigger than the input buffer!?");
|
||||
|
||||
|
@ -248,8 +247,8 @@ user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
|
|||
|
||||
GST_DEBUG_OBJECT (pngenc, "writing %u bytes", (guint) length);
|
||||
|
||||
memcpy (bdata + pngenc->written, data, length);
|
||||
gst_buffer_unmap (pngenc->buffer_out, data, -1);
|
||||
memcpy (map.data + pngenc->written, data, length);
|
||||
gst_buffer_unmap (pngenc->buffer_out, &map);
|
||||
pngenc->written += length;
|
||||
}
|
||||
|
||||
|
|
|
@ -1737,8 +1737,7 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
|
|||
/* FIXME: alloc memory from PA if possible */
|
||||
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
|
||||
GstBuffer *out;
|
||||
guint8 *indata, *outdata;
|
||||
gsize insize, outsize;
|
||||
GstMapInfo inmap, outmap;
|
||||
gboolean res;
|
||||
|
||||
if (framesize <= 0)
|
||||
|
@ -1746,14 +1745,14 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
|
|||
|
||||
out = gst_buffer_new_and_alloc (framesize);
|
||||
|
||||
indata = gst_buffer_map (buf, &insize, NULL, GST_MAP_READ);
|
||||
outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &inmap, GST_MAP_READ);
|
||||
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||
|
||||
res = gst_audio_iec61937_payload (indata, insize,
|
||||
outdata, outsize, &sink->ringbuffer->spec);
|
||||
res = gst_audio_iec61937_payload (inmap.data, inmap.size,
|
||||
outmap.data, outmap.size, &sink->ringbuffer->spec);
|
||||
|
||||
gst_buffer_unmap (buf, indata, insize);
|
||||
gst_buffer_unmap (out, outdata, outsize);
|
||||
gst_buffer_unmap (buf, &inmap);
|
||||
gst_buffer_unmap (out, &outmap);
|
||||
|
||||
if (!res) {
|
||||
gst_buffer_unref (out);
|
||||
|
|
|
@ -623,30 +623,28 @@ send_message_locked (GstSoupHttpClientSink * souphttpsink)
|
|||
if (souphttpsink->offset == 0) {
|
||||
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
|
||||
GstBuffer *buffer = g->data;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
/* 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_MEMORY_STATIC, data, size);
|
||||
n += size;
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
SOUP_MEMORY_STATIC, map.data, map.size);
|
||||
n += map.size;
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
}
|
||||
|
||||
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
|
||||
GstBuffer *buffer = g->data;
|
||||
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
/* 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_MEMORY_STATIC, data, size);
|
||||
n += size;
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
SOUP_MEMORY_STATIC, map.data, map.size);
|
||||
n += map.size;
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -876,7 +876,7 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
|
|||
typedef struct
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
gpointer data;
|
||||
GstMapInfo map;
|
||||
} SoupGstChunk;
|
||||
|
||||
static void
|
||||
|
@ -884,7 +884,7 @@ gst_soup_http_src_chunk_free (gpointer 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);
|
||||
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->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);
|
||||
|
||||
return soupbuf;
|
||||
|
|
|
@ -190,13 +190,12 @@ static GstFlowReturn
|
|||
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
|
||||
{
|
||||
GstCaps *caps;
|
||||
char *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
/* get the header */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
dec->header = speex_packet_to_header (data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
dec->header = speex_packet_to_header ((gchar *) map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
if (!dec->header)
|
||||
goto no_header;
|
||||
|
@ -368,23 +367,22 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
|||
GstFlowReturn res = GST_FLOW_OK;
|
||||
gint i, fpp;
|
||||
SpeexBits *bits;
|
||||
gsize size;
|
||||
char *data;
|
||||
GstMapInfo map;
|
||||
|
||||
if (!dec->frame_duration)
|
||||
goto not_negotiated;
|
||||
|
||||
if (G_LIKELY (gst_buffer_get_size (buf))) {
|
||||
/* send data to the bitstream */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
speex_bits_read_from (&dec->bits, data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
speex_bits_read_from (&dec->bits, (gchar *) map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
fpp = dec->header->frames_per_packet;
|
||||
bits = &dec->bits;
|
||||
|
||||
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 {
|
||||
/* FIXME ? actually consider how much concealment is needed */
|
||||
/* 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) */
|
||||
for (i = 0; i < fpp; i++) {
|
||||
GstBuffer *outbuf;
|
||||
gint16 *out_data;
|
||||
gint ret;
|
||||
|
||||
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,
|
||||
dec->frame_size * dec->header->nb_channels * 2, 0);
|
||||
|
||||
out_data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
|
||||
ret = speex_decode_int (dec->state, bits, out_data);
|
||||
gst_buffer_unmap (outbuf, out_data, size);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
ret = speex_decode_int (dec->state, bits, (spx_int16_t *) map.data);
|
||||
|
||||
if (ret == -1) {
|
||||
/* uh? end of stream */
|
||||
|
@ -445,7 +441,10 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
|||
gst_buffer_unref (outbuf);
|
||||
}
|
||||
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);
|
||||
|
||||
|
@ -469,8 +468,8 @@ not_negotiated:
|
|||
static gboolean
|
||||
memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
|
||||
{
|
||||
GstMapInfo map;
|
||||
gsize size1, size2;
|
||||
gpointer data1;
|
||||
gboolean res;
|
||||
|
||||
size1 = gst_buffer_get_size (buf1);
|
||||
|
@ -479,9 +478,9 @@ memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
|
|||
if (size1 != size2)
|
||||
return FALSE;
|
||||
|
||||
data1 = gst_buffer_map (buf1, NULL, NULL, GST_MAP_READ);
|
||||
res = gst_buffer_memcmp (buf2, 0, data1, size1) == 0;
|
||||
gst_buffer_unmap (buf1, data1, size1);
|
||||
gst_buffer_map (buf1, &map, GST_MAP_READ);
|
||||
res = gst_buffer_memcmp (buf2, 0, map.data, map.size) == 0;
|
||||
gst_buffer_unmap (buf1, &map);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -539,13 +539,16 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
|||
gint frame_size = enc->frame_size;
|
||||
gint bytes = frame_size * 2 * enc->channels, samples;
|
||||
gint outsize, written, dtx_ret = 0;
|
||||
guint8 *data, *data0 = NULL, *bdata, *outdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data, *data0 = NULL, *bdata;
|
||||
gsize bsize, size;
|
||||
GstBuffer *outbuf;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
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)) {
|
||||
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;
|
||||
data0 = data = g_malloc0 (size);
|
||||
memcpy (data, bdata, bsize);
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
bdata = NULL;
|
||||
} else {
|
||||
data = bdata;
|
||||
|
@ -585,7 +588,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
|||
outsize = speex_bits_nbytes (&enc->bits);
|
||||
|
||||
if (bdata)
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
#if 0
|
||||
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;
|
||||
#endif
|
||||
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)) {
|
||||
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);
|
||||
written = outsize;
|
||||
}
|
||||
gst_buffer_unmap (outbuf, outdata, written);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_buffer_resize (outbuf, 0, written);
|
||||
|
||||
if (!dtx_ret)
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||
|
|
|
@ -328,24 +328,23 @@ static gboolean
|
|||
gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
|
||||
gboolean start_tag, guint * tag_size)
|
||||
{
|
||||
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 (memcmp (data, "APETAGEX", 8) != 0) {
|
||||
if (memcmp (map.data, "APETAGEX", 8) != 0) {
|
||||
GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
|
||||
(start_tag) ? "start" : "end");
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*tag_size = GST_READ_UINT32_LE (data + 12);
|
||||
*tag_size = GST_READ_UINT32_LE (map.data + 12);
|
||||
|
||||
/* size is without header, so add 32 to account for that */
|
||||
*tag_size += 32;
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -354,15 +353,18 @@ static GstTagDemuxResult
|
|||
gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
|
||||
gboolean start_tag, guint * tag_size, GstTagList ** tags)
|
||||
{
|
||||
guint8 *data_start, *data;
|
||||
guint8 *data;
|
||||
guint8 *footer;
|
||||
gboolean have_header;
|
||||
gboolean end_tag = !start_tag;
|
||||
GstCaps *sink_caps;
|
||||
guint version, footer_size;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
|
||||
data_start = data = 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 (demux, "Parsing buffer of size %" G_GSIZE_FORMAT, size);
|
||||
|
||||
|
@ -425,7 +427,7 @@ gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
|
|||
GST_TAG_CONTAINER_FORMAT, sink_caps);
|
||||
gst_caps_unref (sink_caps);
|
||||
|
||||
gst_buffer_unmap (buffer, data_start, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return GST_TAG_DEMUX_RESULT_OK;
|
||||
}
|
||||
|
|
|
@ -448,8 +448,7 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -465,12 +464,12 @@ gst_audio_amplify_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
|
||||
|
||||
filter->process (filter, data, num_samples);
|
||||
filter->process (filter, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -691,8 +691,7 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -708,12 +707,12 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
|
||||
|
||||
filter->process (filter, data, num_samples);
|
||||
filter->process (filter, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -359,8 +359,7 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
GstAudioEcho *self = GST_AUDIO_ECHO (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -393,12 +392,12 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
}
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (self);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (self);
|
||||
|
||||
self->process (self, data, num_samples);
|
||||
self->process (self, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -626,8 +626,8 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
|
|||
gint channels = GST_AUDIO_FILTER_CHANNELS (self);
|
||||
gint bps = GST_AUDIO_FILTER_BPS (self);
|
||||
gint outsize, outsamples;
|
||||
guint8 *in, *out, *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *in, *out;
|
||||
|
||||
if (channels == 0 || rate == 0 || self->nsamples_in == 0) {
|
||||
self->buffer_fill = 0;
|
||||
|
@ -668,16 +668,16 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
|
|||
|
||||
/* Convolve the residue with zeros to get the actual remaining data */
|
||||
in = g_new0 (guint8, outsize);
|
||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
|
||||
self->nsamples_out += self->process (self, in, data, outsamples);
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
|
||||
self->nsamples_out += self->process (self, in, map.data, outsamples);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
g_free (in);
|
||||
} else {
|
||||
guint gensamples = 0;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
|
||||
|
||||
while (gensamples < outsamples) {
|
||||
guint step_insamples = self->block_length - self->buffer_fill;
|
||||
|
@ -688,7 +688,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
|
|||
step_gensamples = self->process (self, zeroes, out, step_insamples);
|
||||
g_free (zeroes);
|
||||
|
||||
memcpy (data + gensamples * bps, out, MIN (step_gensamples,
|
||||
memcpy (map.data + gensamples * bps, out, MIN (step_gensamples,
|
||||
outsamples - gensamples) * bps);
|
||||
gensamples += MIN (step_gensamples, outsamples - gensamples);
|
||||
|
||||
|
@ -696,7 +696,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
|
|||
}
|
||||
self->nsamples_out += gensamples;
|
||||
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
}
|
||||
|
||||
/* Set timestamp, offset, etc from the values we
|
||||
|
@ -802,8 +802,7 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
|
|||
gint channels = GST_AUDIO_FILTER_CHANNELS (self);
|
||||
gint rate = GST_AUDIO_FILTER_RATE (self);
|
||||
gint bps = GST_AUDIO_FILTER_BPS (self);
|
||||
guint8 *indata, *outdata;
|
||||
gsize insize, outsize;
|
||||
GstMapInfo inmap, outmap;
|
||||
guint input_samples;
|
||||
guint output_samples;
|
||||
guint generated_samples;
|
||||
|
@ -858,18 +857,19 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
|
|||
self->start_off = GST_BUFFER_OFFSET (inbuf);
|
||||
}
|
||||
|
||||
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
|
||||
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
|
||||
input_samples = (insize / bps) / channels;
|
||||
output_samples = (outsize / bps) / channels;
|
||||
input_samples = (inmap.size / bps) / channels;
|
||||
output_samples = (outmap.size / bps) / channels;
|
||||
|
||||
self->nsamples_in += input_samples;
|
||||
|
||||
generated_samples = self->process (self, indata, outdata, input_samples);
|
||||
generated_samples =
|
||||
self->process (self, inmap.data, outmap.data, input_samples);
|
||||
|
||||
gst_buffer_unmap (inbuf, indata, insize);
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
gst_buffer_unmap (inbuf, &inmap);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
|
||||
g_assert (generated_samples <= output_samples);
|
||||
self->nsamples_out += generated_samples;
|
||||
|
|
|
@ -354,8 +354,7 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
|
|||
GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -372,12 +371,12 @@ gst_audio_fx_base_iir_filter_transform_ip (GstBaseTransform * base,
|
|||
|
||||
g_return_val_if_fail (filter->a != NULL, GST_FLOW_ERROR);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
|
||||
|
||||
filter->process (filter, data, num_samples);
|
||||
filter->process (filter, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -228,8 +228,7 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -245,12 +244,12 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
|
||||
|
||||
filter->process (filter, data, num_samples);
|
||||
filter->process (filter, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -331,8 +331,7 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
|
||||
guint num_samples;
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
stream_time =
|
||||
|
@ -348,12 +347,12 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
num_samples = map.size / GST_AUDIO_FILTER_BPS (filter);
|
||||
|
||||
filter->process (filter, data, num_samples);
|
||||
filter->process (filter, map.data, num_samples);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -626,8 +626,7 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
|||
{
|
||||
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
|
||||
GstClockTime timestamp, stream_time;
|
||||
guint8 *indata, *outdata;
|
||||
gsize insize, outsize;
|
||||
GstMapInfo inmap, outmap;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
||||
stream_time =
|
||||
|
@ -639,20 +638,20 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
|||
if (GST_CLOCK_TIME_IS_VALID (stream_time))
|
||||
gst_object_sync_values (GST_OBJECT (filter), stream_time);
|
||||
|
||||
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
|
||||
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
|
||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||
memset (outdata, 0, outsize);
|
||||
memset (outmap.data, 0, outmap.size);
|
||||
} else {
|
||||
guint num_samples = outsize / GST_AUDIO_INFO_BPF (&filter->info);
|
||||
guint num_samples = outmap.size / GST_AUDIO_INFO_BPF (&filter->info);
|
||||
|
||||
filter->process (filter, indata, outdata, num_samples);
|
||||
filter->process (filter, inmap.data, outmap.data, num_samples);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (inbuf, indata, insize);
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
gst_buffer_unmap (inbuf, &inmap);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -257,20 +257,19 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
|
|||
GstBuffer *buf = gst_value_get_buffer (value);
|
||||
|
||||
if (buf) {
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint sr_idx;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
sr_idx = ((data[0] & 0x07) << 1) | ((data[1] & 0x80) >> 7);
|
||||
aacparse->object_type = (data[0] & 0xf8) >> 3;
|
||||
sr_idx = ((map.data[0] & 0x07) << 1) | ((map.data[1] & 0x80) >> 7);
|
||||
aacparse->object_type = (map.data[0] & 0xf8) >> 3;
|
||||
aacparse->sample_rate = gst_aac_parse_get_sample_rate_from_index (sr_idx);
|
||||
aacparse->channels = (data[1] & 0x78) >> 3;
|
||||
aacparse->channels = (map.data[1] & 0x78) >> 3;
|
||||
aacparse->header_type = DSPAAC_HEADER_NONE;
|
||||
aacparse->mpegversion = 4;
|
||||
aacparse->frame_samples = (data[1] & 4) ? 960 : 1024;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
aacparse->frame_samples = (map.data[1] & 4) ? 960 : 1024;
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
|
||||
"samples=%d", aacparse->object_type, aacparse->sample_rate,
|
||||
|
@ -913,8 +912,7 @@ static gboolean
|
|||
gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
GstAacParse *aacparse;
|
||||
gboolean ret = FALSE;
|
||||
gboolean lost_sync;
|
||||
|
@ -923,25 +921,25 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
aacparse = GST_AAC_PARSE (parse);
|
||||
buffer = frame->buffer;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
lost_sync = GST_BASE_PARSE_LOST_SYNC (parse);
|
||||
|
||||
if (aacparse->header_type == DSPAAC_HEADER_ADIF ||
|
||||
aacparse->header_type == DSPAAC_HEADER_NONE) {
|
||||
/* There is nothing to parse */
|
||||
*framesize = size;
|
||||
*framesize = map.size;
|
||||
ret = TRUE;
|
||||
|
||||
} else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || lost_sync) {
|
||||
|
||||
ret = gst_aac_parse_detect_stream (aacparse, data, size,
|
||||
ret = gst_aac_parse_detect_stream (aacparse, map.data, map.size,
|
||||
GST_BASE_PARSE_DRAINING (parse), framesize, skipsize);
|
||||
|
||||
} else if (aacparse->header_type == DSPAAC_HEADER_ADTS) {
|
||||
guint needed_data = 1024;
|
||||
|
||||
ret = gst_aac_parse_check_adts_frame (aacparse, data, size,
|
||||
ret = gst_aac_parse_check_adts_frame (aacparse, map.data, map.size,
|
||||
GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
||||
|
||||
if (!ret) {
|
||||
|
@ -953,8 +951,8 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
} else if (aacparse->header_type == DSPAAC_HEADER_LOAS) {
|
||||
guint needed_data = 1024;
|
||||
|
||||
ret = gst_aac_parse_check_loas_frame (aacparse, data,
|
||||
size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
||||
ret = gst_aac_parse_check_loas_frame (aacparse, map.data,
|
||||
map.size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG ("buffer didn't contain valid frame");
|
||||
|
@ -967,7 +965,7 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
|
||||
ADTS_MAX_SIZE);
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1003,8 +1001,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
GstBuffer *buffer;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
gint rate, channels;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
aacparse = GST_AAC_PARSE (parse);
|
||||
buffer = frame->buffer;
|
||||
|
@ -1013,10 +1010,10 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
/* see above */
|
||||
frame->overhead = 7;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_aac_parse_parse_adts_header (aacparse, data,
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
gst_aac_parse_parse_adts_header (aacparse, map.data,
|
||||
&rate, &channels, NULL, NULL);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
GST_LOG_OBJECT (aacparse, "rate: %d, chans: %d", rate, channels);
|
||||
|
||||
|
@ -1043,9 +1040,9 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
/* see above */
|
||||
frame->overhead = 3;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
if (!gst_aac_parse_read_loas_config (aacparse, data, size, &rate, &channels,
|
||||
NULL)) {
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
if (!gst_aac_parse_read_loas_config (aacparse, map.data, map.size, &rate,
|
||||
&channels, NULL)) {
|
||||
GST_WARNING_OBJECT (aacparse, "Error reading LOAS config");
|
||||
} else if (G_UNLIKELY (rate != aacparse->sample_rate
|
||||
|| channels != aacparse->channels)) {
|
||||
|
@ -1055,7 +1052,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
GST_INFO_OBJECT (aacparse, "New LOAS config: %d Hz, %d channels", rate,
|
||||
channels);
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
/* We want to set caps both at start, and when rate/channels change.
|
||||
Since only some LOAS frames have that info, we may receive frames
|
||||
|
|
|
@ -298,15 +298,14 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
|||
guint * sid)
|
||||
{
|
||||
GstBitReader bits;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 fscod, frmsizcod, bsid, acmod, lfe_on, rate_scale;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
GST_LOG_OBJECT (ac3parse, "parsing ac3");
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, map.data, map.size);
|
||||
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
||||
|
||||
gst_bit_reader_skip_unchecked (&bits, 16 + 16);
|
||||
|
@ -360,7 +359,7 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
|||
ret = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -371,16 +370,15 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
|||
guint * sid)
|
||||
{
|
||||
GstBitReader bits;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint16 frmsiz, sample_rate, blocks;
|
||||
guint8 strmtyp, fscod, fscod2, acmod, lfe_on, strmid, numblkscod;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
GST_LOG_OBJECT (ac3parse, "parsing e-ac3");
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, map.data, map.size);
|
||||
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
||||
|
||||
gst_bit_reader_skip_unchecked (&bits, 16);
|
||||
|
@ -426,7 +424,7 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
|||
ret = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -439,14 +437,13 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
|
|||
GstBitReader bits;
|
||||
guint16 sync;
|
||||
guint8 bsid;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
gst_bit_reader_init (&bits, map.data, map.size);
|
||||
|
||||
GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", data, MIN (size, 16));
|
||||
GST_MEMDUMP_OBJECT (parse, "AC3 frame sync", map.data, MIN (map.size, 16));
|
||||
|
||||
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
||||
|
||||
|
@ -479,7 +476,7 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
|
|||
GST_DEBUG_OBJECT (parse, "unexpected bsid %d", bsid);
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -495,24 +492,23 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
|||
gboolean lost_sync, draining, eac, more = FALSE;
|
||||
guint frmsiz, blocks, sid;
|
||||
gint have_blocks = 0;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (G_UNLIKELY (size < 6))
|
||||
if (G_UNLIKELY (map.size < 6))
|
||||
goto cleanup;
|
||||
|
||||
gst_byte_reader_init (&reader, data, size);
|
||||
gst_byte_reader_init (&reader, map.data, map.size);
|
||||
off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000, 0x0b770000,
|
||||
0, size);
|
||||
0, map.size);
|
||||
|
||||
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
||||
|
||||
/* didn't find anything that looks like a sync word, skip */
|
||||
if (off < 0) {
|
||||
*skipsize = size - 3;
|
||||
*skipsize = map.size - 3;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -562,7 +558,8 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
|||
do {
|
||||
*framesize += frmsiz;
|
||||
|
||||
if (!gst_byte_reader_skip (&reader, frmsiz) || size < (*framesize + 6)) {
|
||||
if (!gst_byte_reader_skip (&reader, frmsiz)
|
||||
|| map.size < (*framesize + 6)) {
|
||||
more = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -605,7 +602,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
|||
ret = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -259,8 +259,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
|||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gint fsize, mode, dsize;
|
||||
GstAmrParse *amrparse;
|
||||
gboolean ret = FALSE;
|
||||
|
@ -268,14 +267,14 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
|||
amrparse = GST_AMR_PARSE (parse);
|
||||
buffer = frame->buffer;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
dsize = size;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
dsize = map.size;
|
||||
|
||||
GST_LOG ("buffer: %d bytes", dsize);
|
||||
|
||||
if (amrparse->need_header) {
|
||||
if (dsize >= AMR_MIME_HEADER_SIZE &&
|
||||
gst_amr_parse_parse_header (amrparse, data, skipsize)) {
|
||||
gst_amr_parse_parse_header (amrparse, map.data, skipsize)) {
|
||||
amrparse->need_header = FALSE;
|
||||
gst_base_parse_set_frame_rate (GST_BASE_PARSE (amrparse), 50, 1, 2, 2);
|
||||
} else {
|
||||
|
@ -287,9 +286,9 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
|||
}
|
||||
|
||||
/* Does this look like a possible frame header candidate? */
|
||||
if ((data[0] & 0x83) == 0) {
|
||||
if ((map.data[0] & 0x83) == 0) {
|
||||
/* Yep. Retrieve the frame size */
|
||||
mode = (data[0] >> 3) & 0x0F;
|
||||
mode = (map.data[0] >> 3) & 0x0F;
|
||||
fsize = amrparse->block_size[mode] + 1; /* +1 for the header byte */
|
||||
|
||||
/* We recognize this data as a valid frame when:
|
||||
|
@ -307,7 +306,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
|||
found = TRUE;
|
||||
} else if (dsize > fsize) {
|
||||
/* enough data, check for next sync */
|
||||
if ((data[fsize] & 0x83) == 0)
|
||||
if ((map.data[fsize] & 0x83) == 0)
|
||||
found = TRUE;
|
||||
} else if (GST_BASE_PARSE_DRAINING (parse)) {
|
||||
/* not enough, but draining, so ok */
|
||||
|
@ -326,7 +325,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
|||
GST_LOG ("sync lost");
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -318,31 +318,30 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
|||
guint32 sync = 0;
|
||||
guint size, rate, chans, num_blocks, samples_per_block;
|
||||
gint off = -1;
|
||||
gpointer data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (G_UNLIKELY (bufsize < 16))
|
||||
if (G_UNLIKELY (map.size < 16))
|
||||
goto cleanup;
|
||||
|
||||
parser_in_sync = !GST_BASE_PARSE_LOST_SYNC (parse);
|
||||
|
||||
gst_byte_reader_init (&r, data, bufsize);
|
||||
gst_byte_reader_init (&r, map.data, map.size);
|
||||
|
||||
if (G_LIKELY (parser_in_sync && dcaparse->last_sync != 0)) {
|
||||
off = gst_byte_reader_masked_scan_uint32 (&r, 0xffffffff,
|
||||
dcaparse->last_sync, 0, bufsize);
|
||||
dcaparse->last_sync, 0, map.size);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (off < 0)) {
|
||||
off = gst_dca_parse_find_sync (dcaparse, &r, bufsize, &sync);
|
||||
off = gst_dca_parse_find_sync (dcaparse, &r, map.size, &sync);
|
||||
}
|
||||
|
||||
/* didn't find anything that looks like a sync word, skip */
|
||||
if (off < 0) {
|
||||
*skipsize = bufsize - 3;
|
||||
*skipsize = map.size - 3;
|
||||
GST_DEBUG_OBJECT (dcaparse, "no sync, skipping %d bytes", *skipsize);
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -374,12 +373,12 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
|||
if (!parser_in_sync && !parser_draining) {
|
||||
/* check for second frame to be sure */
|
||||
GST_DEBUG_OBJECT (dcaparse, "resyncing; checking next frame syncword");
|
||||
if (bufsize >= (size + 16)) {
|
||||
if (map.size >= (size + 16)) {
|
||||
guint s2, r2, c2, n2, s3;
|
||||
gboolean t;
|
||||
|
||||
GST_MEMDUMP ("buf", data, size + 16);
|
||||
gst_byte_reader_init (&r, data, bufsize);
|
||||
GST_MEMDUMP ("buf", map.data, size + 16);
|
||||
gst_byte_reader_init (&r, map.data, map.size);
|
||||
gst_byte_reader_skip_unchecked (&r, size);
|
||||
|
||||
if (!gst_dca_parse_parse_header (dcaparse, &r, &s2, &r2, &c2, NULL, NULL,
|
||||
|
@ -395,7 +394,7 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
|||
/* FIXME: baseparse always seems to hand us buffers of min_frame_size
|
||||
* bytes, which is unhelpful here */
|
||||
GST_LOG_OBJECT (dcaparse,
|
||||
"next sync out of reach (%" G_GSIZE_FORMAT " < %u)", bufsize,
|
||||
"next sync out of reach (%" G_GSIZE_FORMAT " < %u)", map.size,
|
||||
size + 16);
|
||||
/* *skipsize = 0; */
|
||||
/* return FALSE; */
|
||||
|
@ -405,7 +404,7 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
|||
ret = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -418,11 +417,10 @@ gst_dca_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
guint size, rate, chans, depth, block_size, num_blocks, samples_per_block;
|
||||
gint endianness;
|
||||
gboolean terminator;
|
||||
gpointer data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_byte_reader_init (&r, data, bufsize);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
gst_byte_reader_init (&r, map.data, map.size);
|
||||
|
||||
if (!gst_dca_parse_parse_header (dcaparse, &r, &size, &rate, &chans, &depth,
|
||||
&endianness, &num_blocks, &samples_per_block, &terminator))
|
||||
|
@ -455,7 +453,7 @@ gst_dca_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
gst_base_parse_set_frame_rate (parse, rate, block_size, 0, 0);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -463,7 +461,7 @@ broken_header:
|
|||
{
|
||||
/* this really shouldn't ever happen */
|
||||
GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -616,8 +616,7 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
|||
GstBaseParseFrame * frame, guint * ret)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint max, remaining;
|
||||
guint i, search_start, search_end;
|
||||
FrameHeaderCheckReturn header_ret;
|
||||
|
@ -625,13 +624,13 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
|||
gboolean result = FALSE;
|
||||
|
||||
buffer = frame->buffer;
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
if (size < flacparse->min_framesize)
|
||||
if (map.size < flacparse->min_framesize)
|
||||
goto need_more;
|
||||
|
||||
header_ret =
|
||||
gst_flac_parse_frame_header_is_valid (flacparse, data, size, TRUE,
|
||||
gst_flac_parse_frame_header_is_valid (flacparse, map.data, map.size, TRUE,
|
||||
&block_size);
|
||||
if (header_ret == FRAME_HEADER_INVALID) {
|
||||
*ret = 0;
|
||||
|
@ -643,22 +642,22 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
|||
/* mind unknown framesize */
|
||||
search_start = MAX (2, flacparse->min_framesize);
|
||||
if (flacparse->max_framesize)
|
||||
search_end = MIN (size, flacparse->max_framesize + 9 + 2);
|
||||
search_end = MIN (map.size, flacparse->max_framesize + 9 + 2);
|
||||
else
|
||||
search_end = size;
|
||||
search_end = map.size;
|
||||
search_end -= 2;
|
||||
|
||||
remaining = size;
|
||||
remaining = map.size;
|
||||
|
||||
for (i = search_start; i < search_end; i++, remaining--) {
|
||||
if ((GST_READ_UINT16_BE (data + i) & 0xfffe) == 0xfff8) {
|
||||
if ((GST_READ_UINT16_BE (map.data + i) & 0xfffe) == 0xfff8) {
|
||||
header_ret =
|
||||
gst_flac_parse_frame_header_is_valid (flacparse, data + i, remaining,
|
||||
FALSE, NULL);
|
||||
gst_flac_parse_frame_header_is_valid (flacparse, map.data + i,
|
||||
remaining, FALSE, NULL);
|
||||
if (header_ret == FRAME_HEADER_VALID) {
|
||||
if (flacparse->check_frame_checksums) {
|
||||
guint16 actual_crc = gst_flac_calculate_crc16 (data, i - 2);
|
||||
guint16 expected_crc = GST_READ_UINT16_BE (data + i - 2);
|
||||
guint16 actual_crc = gst_flac_calculate_crc16 (map.data, i - 2);
|
||||
guint16 expected_crc = GST_READ_UINT16_BE (map.data + i - 2);
|
||||
|
||||
if (actual_crc != expected_crc)
|
||||
continue;
|
||||
|
@ -676,17 +675,17 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
|||
/* For the last frame output everything to the end */
|
||||
if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
|
||||
if (flacparse->check_frame_checksums) {
|
||||
guint16 actual_crc = gst_flac_calculate_crc16 (data, size - 2);
|
||||
guint16 expected_crc = GST_READ_UINT16_BE (data + size - 2);
|
||||
guint16 actual_crc = gst_flac_calculate_crc16 (map.data, map.size - 2);
|
||||
guint16 expected_crc = GST_READ_UINT16_BE (map.data + map.size - 2);
|
||||
|
||||
if (actual_crc == expected_crc) {
|
||||
*ret = size;
|
||||
*ret = map.size;
|
||||
flacparse->block_size = block_size;
|
||||
result = TRUE;
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
*ret = size;
|
||||
*ret = map.size;
|
||||
flacparse->block_size = block_size;
|
||||
result = TRUE;
|
||||
goto cleanup;
|
||||
|
@ -697,11 +696,11 @@ need_more:
|
|||
max = flacparse->max_framesize + 16;
|
||||
if (max == 16)
|
||||
max = 1 << 24;
|
||||
*ret = MIN (size + 4096, max);
|
||||
*ret = MIN (map.size + 4096, max);
|
||||
result = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -711,24 +710,23 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
{
|
||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||
GstBuffer *buffer = frame->buffer;
|
||||
guint8 *data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
gboolean result = TRUE;
|
||||
|
||||
data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
if (G_UNLIKELY (bufsize < 4)) {
|
||||
if (G_UNLIKELY (map.size < 4)) {
|
||||
result = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
|
||||
if (memcmp (data, "fLaC", 4) == 0) {
|
||||
if (memcmp (map.data, "fLaC", 4) == 0) {
|
||||
GST_DEBUG_OBJECT (flacparse, "fLaC marker found");
|
||||
*framesize = 4;
|
||||
goto cleanup;
|
||||
}
|
||||
if (data[0] == 0xff && (data[1] >> 2) == 0x3e) {
|
||||
if (map.data[0] == 0xff && (map.data[1] >> 2) == 0x3e) {
|
||||
GST_DEBUG_OBJECT (flacparse, "Found headerless FLAC");
|
||||
/* Minimal size of a frame header */
|
||||
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), 9);
|
||||
|
@ -743,14 +741,14 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
}
|
||||
|
||||
if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
|
||||
guint size = 4 + ((data[1] << 16) | (data[2] << 8) | (data[3]));
|
||||
guint size = 4 + ((map.data[1] << 16) | (map.data[2] << 8) | (map.data[3]));
|
||||
|
||||
GST_DEBUG_OBJECT (flacparse, "Found metadata block of size %u", size);
|
||||
*framesize = size;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((GST_READ_UINT16_BE (data) & 0xfffe) == 0xfff8) {
|
||||
if ((GST_READ_UINT16_BE (map.data) & 0xfffe) == 0xfff8) {
|
||||
gboolean ret;
|
||||
guint next;
|
||||
|
||||
|
@ -772,7 +770,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
}
|
||||
|
||||
if (next == 0) {
|
||||
} else if (next > bufsize) {
|
||||
} else if (next > map.size) {
|
||||
GST_DEBUG_OBJECT (flacparse, "Requesting %u bytes", next);
|
||||
*skipsize = 0;
|
||||
gst_base_parse_set_min_frame_size (parse, next);
|
||||
|
@ -780,7 +778,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
goto cleanup;
|
||||
} else {
|
||||
GST_ERROR_OBJECT (flacparse,
|
||||
"Giving up on invalid frame (%" G_GSIZE_FORMAT " bytes)", bufsize);
|
||||
"Giving up on invalid frame (%" G_GSIZE_FORMAT " bytes)", map.size);
|
||||
result = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -789,10 +787,10 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
GstByteReader reader;
|
||||
gint off;
|
||||
|
||||
gst_byte_reader_init (&reader, data, bufsize);
|
||||
gst_byte_reader_init (&reader, map.data, map.size);
|
||||
off =
|
||||
gst_byte_reader_masked_scan_uint32 (&reader, 0xfffc0000, 0xfff80000,
|
||||
0, bufsize);
|
||||
0, map.size);
|
||||
|
||||
if (off > 0) {
|
||||
GST_DEBUG_OBJECT (parse, "Possible sync at buffer offset %d", off);
|
||||
|
@ -801,7 +799,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
goto cleanup;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (flacparse, "Sync code not found");
|
||||
*skipsize = bufsize - 3;
|
||||
*skipsize = map.size - 3;
|
||||
result = FALSE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -810,7 +808,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
|||
result = FALSE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buffer, data, bufsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -818,15 +816,14 @@ static gboolean
|
|||
gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||
{
|
||||
GstBitReader reader;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_bit_reader_init (&reader, data, size);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
gst_bit_reader_init (&reader, map.data, map.size);
|
||||
|
||||
if (size != 4 + 34) {
|
||||
if (map.size != 4 + 34) {
|
||||
GST_ERROR_OBJECT (flacparse,
|
||||
"Invalid metablock size for STREAMINFO: %" G_GSIZE_FORMAT "", size);
|
||||
"Invalid metablock size for STREAMINFO: %" G_GSIZE_FORMAT "", map.size);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -879,7 +876,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
|||
GST_FORMAT_DEFAULT, flacparse->total_samples, 0);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
GST_DEBUG_OBJECT (flacparse, "STREAMINFO:\n"
|
||||
"\tmin/max blocksize: %u/%u,\n"
|
||||
|
@ -898,7 +895,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
|||
error:
|
||||
GST_ERROR_OBJECT (flacparse, "Failed to read data");
|
||||
failure:
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -906,13 +903,13 @@ static gboolean
|
|||
gst_flac_parse_handle_vorbiscomment (GstFlacParse * flacparse,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
flacparse->tags = gst_tag_list_from_vorbiscomment (data, size, data, 4, NULL);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
flacparse->tags =
|
||||
gst_tag_list_from_vorbiscomment (map.data, map.size, map.data, 4, NULL);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
if (flacparse->tags == NULL) {
|
||||
GST_ERROR_OBJECT (flacparse, "Invalid vorbiscomment block");
|
||||
|
@ -928,13 +925,12 @@ static gboolean
|
|||
gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||
{
|
||||
GstByteReader reader;
|
||||
guint8 *data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
guint32 img_len = 0, img_type = 0;
|
||||
guint32 img_mimetype_len = 0, img_description_len = 0;
|
||||
|
||||
data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_byte_reader_init (&reader, data, bufsize);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
gst_byte_reader_init (&reader, map.data, map.size);
|
||||
|
||||
if (!gst_byte_reader_skip (&reader, 4))
|
||||
goto error;
|
||||
|
@ -962,19 +958,19 @@ gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
|
|||
flacparse->tags = gst_tag_list_new_empty ();
|
||||
|
||||
gst_tag_list_add_id3_image (flacparse->tags,
|
||||
data + gst_byte_reader_get_pos (&reader), img_len, img_type);
|
||||
map.data + gst_byte_reader_get_pos (&reader), img_len, img_type);
|
||||
|
||||
if (gst_tag_list_is_empty (flacparse->tags)) {
|
||||
gst_tag_list_free (flacparse->tags);
|
||||
flacparse->tags = NULL;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, bufsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
GST_ERROR_OBJECT (flacparse, "Error reading data");
|
||||
gst_buffer_unmap (buffer, data, bufsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -995,8 +991,7 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
|||
{
|
||||
GstByteReader br;
|
||||
gint64 offset = 0, samples = 0;
|
||||
gpointer data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
|
||||
GST_DEBUG_OBJECT (flacparse,
|
||||
"parsing seektable; base offset %" G_GINT64_FORMAT, boffset);
|
||||
|
@ -1004,8 +999,8 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
|||
if (boffset <= 0)
|
||||
goto exit;
|
||||
|
||||
data = gst_buffer_map (flacparse->seektable, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_byte_reader_init (&br, data, bufsize);
|
||||
gst_buffer_map (flacparse->seektable, &map, GST_MAP_READ);
|
||||
gst_byte_reader_init (&br, map.data, map.size);
|
||||
|
||||
/* skip header */
|
||||
if (!gst_byte_reader_skip (&br, 4))
|
||||
|
@ -1032,7 +1027,7 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
|||
}
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (flacparse->seektable, data, bufsize);
|
||||
gst_buffer_unmap (flacparse->seektable, &map);
|
||||
exit:
|
||||
gst_buffer_unref (flacparse->seektable);
|
||||
flacparse->seektable = NULL;
|
||||
|
@ -1075,22 +1070,21 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
|
|||
|
||||
for (l = flacparse->headers; l; l = l->next) {
|
||||
GstBuffer *header = l->data;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (header, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (header, &map, GST_MAP_READ);
|
||||
|
||||
GST_BUFFER_FLAG_SET (header, GST_BUFFER_FLAG_IN_CAPS);
|
||||
|
||||
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
|
||||
if (map.size == 4 && memcmp (map.data, "fLaC", 4) == 0) {
|
||||
marker = header;
|
||||
} else if (size > 1 && (data[0] & 0x7f) == 0) {
|
||||
} else if (map.size > 1 && (map.data[0] & 0x7f) == 0) {
|
||||
streaminfo = header;
|
||||
} else if (size > 1 && (data[0] & 0x7f) == 4) {
|
||||
} else if (map.size > 1 && (map.data[0] & 0x7f) == 4) {
|
||||
vorbiscomment = header;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (header, data, size);
|
||||
gst_buffer_unmap (header, &map);
|
||||
}
|
||||
|
||||
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
||||
|
@ -1106,29 +1100,28 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
|
|||
{
|
||||
GstBuffer *buf;
|
||||
guint16 num;
|
||||
guint8 *sinfodata, *writedata;
|
||||
gsize sinfosize, writesize;
|
||||
GstMapInfo sinfomap, writemap;
|
||||
|
||||
sinfodata = gst_buffer_map (streaminfo, &sinfosize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (streaminfo, &sinfomap, GST_MAP_READ);
|
||||
|
||||
/* minus one for the marker that is merged with streaminfo here */
|
||||
num = g_list_length (flacparse->headers) - 1;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (13 + sinfosize);
|
||||
writedata = gst_buffer_map (buf, &writesize, NULL, GST_MAP_WRITE);
|
||||
buf = gst_buffer_new_and_alloc (13 + sinfomap.size);
|
||||
gst_buffer_map (buf, &writemap, GST_MAP_WRITE);
|
||||
|
||||
writedata[0] = 0x7f;
|
||||
memcpy (writedata + 1, "FLAC", 4);
|
||||
writedata[5] = 0x01; /* mapping version major */
|
||||
writedata[6] = 0x00; /* mapping version minor */
|
||||
writedata[7] = (num & 0xFF00) >> 8;
|
||||
writedata[8] = (num & 0x00FF) >> 0;
|
||||
memcpy (writedata + 9, "fLaC", 4);
|
||||
memcpy (writedata + 13, sinfodata, sinfosize);
|
||||
writemap.data[0] = 0x7f;
|
||||
memcpy (writemap.data + 1, "FLAC", 4);
|
||||
writemap.data[5] = 0x01; /* mapping version major */
|
||||
writemap.data[6] = 0x00; /* mapping version minor */
|
||||
writemap.data[7] = (num & 0xFF00) >> 8;
|
||||
writemap.data[8] = (num & 0x00FF) >> 0;
|
||||
memcpy (writemap.data + 9, "fLaC", 4);
|
||||
memcpy (writemap.data + 13, sinfomap.data, sinfomap.size);
|
||||
_value_array_append_buffer (&array, buf);
|
||||
|
||||
gst_buffer_unmap (streaminfo, sinfodata, sinfosize);
|
||||
gst_buffer_unmap (buf, writedata, writesize);
|
||||
gst_buffer_unmap (streaminfo, &sinfomap);
|
||||
gst_buffer_unmap (buf, &writemap);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
|
@ -1185,13 +1178,12 @@ static gboolean
|
|||
gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
||||
{
|
||||
GstBuffer *marker, *streaminfo, *vorbiscomment;
|
||||
guint8 *data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
|
||||
marker = gst_buffer_new_and_alloc (4);
|
||||
data = gst_buffer_map (marker, &bufsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (data, "fLaC", 4);
|
||||
gst_buffer_unmap (marker, data, bufsize);
|
||||
gst_buffer_map (marker, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data, "fLaC", 4);
|
||||
gst_buffer_unmap (marker, &map);
|
||||
GST_BUFFER_TIMESTAMP (marker) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_DURATION (marker) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_OFFSET (marker) = 0;
|
||||
|
@ -1199,37 +1191,37 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
|||
flacparse->headers = g_list_append (flacparse->headers, marker);
|
||||
|
||||
streaminfo = gst_buffer_new_and_alloc (4 + 34);
|
||||
data = gst_buffer_map (streaminfo, &bufsize, NULL, GST_MAP_WRITE);
|
||||
memset (data, 0, 4 + 34);
|
||||
gst_buffer_map (streaminfo, &map, GST_MAP_WRITE);
|
||||
memset (map.data, 0, 4 + 34);
|
||||
|
||||
/* metadata block header */
|
||||
data[0] = 0x00; /* is_last = 0; type = 0; */
|
||||
data[1] = 0x00; /* length = 34; */
|
||||
data[2] = 0x00;
|
||||
data[3] = 0x22;
|
||||
map.data[0] = 0x00; /* is_last = 0; type = 0; */
|
||||
map.data[1] = 0x00; /* length = 34; */
|
||||
map.data[2] = 0x00;
|
||||
map.data[3] = 0x22;
|
||||
|
||||
/* streaminfo */
|
||||
|
||||
data[4] = (flacparse->block_size >> 8) & 0xff; /* min blocksize = blocksize; */
|
||||
data[5] = (flacparse->block_size) & 0xff;
|
||||
data[6] = (flacparse->block_size >> 8) & 0xff; /* max blocksize = blocksize; */
|
||||
data[7] = (flacparse->block_size) & 0xff;
|
||||
map.data[4] = (flacparse->block_size >> 8) & 0xff; /* min blocksize = blocksize; */
|
||||
map.data[5] = (flacparse->block_size) & 0xff;
|
||||
map.data[6] = (flacparse->block_size >> 8) & 0xff; /* max blocksize = blocksize; */
|
||||
map.data[7] = (flacparse->block_size) & 0xff;
|
||||
|
||||
data[8] = 0x00; /* min framesize = 0; */
|
||||
data[9] = 0x00;
|
||||
data[10] = 0x00;
|
||||
data[11] = 0x00; /* max framesize = 0; */
|
||||
data[12] = 0x00;
|
||||
data[13] = 0x00;
|
||||
map.data[8] = 0x00; /* min framesize = 0; */
|
||||
map.data[9] = 0x00;
|
||||
map.data[10] = 0x00;
|
||||
map.data[11] = 0x00; /* max framesize = 0; */
|
||||
map.data[12] = 0x00;
|
||||
map.data[13] = 0x00;
|
||||
|
||||
data[14] = (flacparse->samplerate >> 12) & 0xff;
|
||||
data[15] = (flacparse->samplerate >> 4) & 0xff;
|
||||
data[16] = (flacparse->samplerate >> 0) & 0xf0;
|
||||
map.data[14] = (flacparse->samplerate >> 12) & 0xff;
|
||||
map.data[15] = (flacparse->samplerate >> 4) & 0xff;
|
||||
map.data[16] = (flacparse->samplerate >> 0) & 0xf0;
|
||||
|
||||
data[16] |= (flacparse->channels - 1) << 1;
|
||||
map.data[16] |= (flacparse->channels - 1) << 1;
|
||||
|
||||
data[16] |= ((flacparse->bps - 1) >> 4) & 0x01;
|
||||
data[17] = (((flacparse->bps - 1)) & 0x0f) << 4;
|
||||
map.data[16] |= ((flacparse->bps - 1) >> 4) & 0x01;
|
||||
map.data[17] = (((flacparse->bps - 1)) & 0x0f) << 4;
|
||||
|
||||
{
|
||||
gint64 duration;
|
||||
|
@ -1238,16 +1230,16 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
|||
GST_FORMAT_TIME, &duration)) {
|
||||
duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacparse->samplerate);
|
||||
|
||||
data[17] |= (duration >> 32) & 0xff;
|
||||
data[18] |= (duration >> 24) & 0xff;
|
||||
data[19] |= (duration >> 16) & 0xff;
|
||||
data[20] |= (duration >> 8) & 0xff;
|
||||
data[21] |= (duration >> 0) & 0xff;
|
||||
map.data[17] |= (duration >> 32) & 0xff;
|
||||
map.data[18] |= (duration >> 24) & 0xff;
|
||||
map.data[19] |= (duration >> 16) & 0xff;
|
||||
map.data[20] |= (duration >> 8) & 0xff;
|
||||
map.data[21] |= (duration >> 0) & 0xff;
|
||||
}
|
||||
}
|
||||
/* MD5 = 0; */
|
||||
|
||||
gst_buffer_unmap (streaminfo, data, bufsize);
|
||||
gst_buffer_unmap (streaminfo, &map);
|
||||
GST_BUFFER_TIMESTAMP (streaminfo) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_DURATION (streaminfo) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_OFFSET (streaminfo) = 0;
|
||||
|
@ -1267,27 +1259,27 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
|||
sizeof (header), NULL);
|
||||
gst_tag_list_free (taglist);
|
||||
|
||||
data = gst_buffer_map (vorbiscomment, &bufsize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (vorbiscomment, &map, GST_MAP_WRITE);
|
||||
|
||||
/* Get rid of framing bit */
|
||||
if (data[bufsize - 1] == 1) {
|
||||
if (map.data[map.size - 1] == 1) {
|
||||
GstBuffer *sub;
|
||||
|
||||
sub =
|
||||
gst_buffer_copy_region (vorbiscomment, GST_BUFFER_COPY_ALL, 0,
|
||||
bufsize - 1);
|
||||
gst_buffer_unmap (vorbiscomment, data, bufsize);
|
||||
map.size - 1);
|
||||
gst_buffer_unmap (vorbiscomment, &map);
|
||||
gst_buffer_unref (vorbiscomment);
|
||||
vorbiscomment = sub;
|
||||
data = gst_buffer_map (vorbiscomment, &bufsize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (vorbiscomment, &map, GST_MAP_WRITE);
|
||||
}
|
||||
|
||||
size = bufsize - 4;
|
||||
data[1] = ((size & 0xFF0000) >> 16);
|
||||
data[2] = ((size & 0x00FF00) >> 8);
|
||||
data[3] = (size & 0x0000FF);
|
||||
size = map.size - 4;
|
||||
map.data[1] = ((size & 0xFF0000) >> 16);
|
||||
map.data[2] = ((size & 0x00FF00) >> 8);
|
||||
map.data[3] = (size & 0x0000FF);
|
||||
gst_buffer_unmap (vorbiscomment, &map);
|
||||
|
||||
gst_buffer_unmap (vorbiscomment, data, bufsize);
|
||||
GST_BUFFER_TIMESTAMP (vorbiscomment) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_DURATION (vorbiscomment) = GST_CLOCK_TIME_NONE;
|
||||
GST_BUFFER_OFFSET (vorbiscomment) = 0;
|
||||
|
@ -1303,11 +1295,10 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
{
|
||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||
GstBuffer *buffer = frame->buffer;
|
||||
guint8 *data = NULL;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
GstFlowReturn res = GST_FLOW_ERROR;
|
||||
|
||||
data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
|
||||
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
|
||||
|
@ -1324,8 +1315,8 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
|
||||
res = GST_BASE_PARSE_FLOW_DROPPED;
|
||||
} else if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
|
||||
gboolean is_last = ((data[0] & 0x80) == 0x80);
|
||||
guint type = (data[0] & 0x7F);
|
||||
gboolean is_last = ((map.data[0] & 0x80) == 0x80);
|
||||
guint type = (map.data[0] & 0x7F);
|
||||
|
||||
if (type == 127) {
|
||||
GST_WARNING_OBJECT (flacparse, "Invalid metadata block type");
|
||||
|
@ -1386,7 +1377,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
flacparse->offset = GST_BUFFER_OFFSET (buffer);
|
||||
ret =
|
||||
gst_flac_parse_frame_header_is_valid (flacparse,
|
||||
data, bufsize, TRUE, NULL);
|
||||
map.data, map.size, TRUE, NULL);
|
||||
if (ret != FRAME_HEADER_VALID) {
|
||||
GST_ERROR_OBJECT (flacparse,
|
||||
"Baseclass didn't provide a complete frame");
|
||||
|
@ -1458,8 +1449,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
|||
}
|
||||
|
||||
cleanup:
|
||||
if (data)
|
||||
gst_buffer_unmap (buffer, data, bufsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -375,18 +375,17 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
|
|||
guint32 header, int bpf, gboolean at_eos, gint * valid)
|
||||
{
|
||||
guint32 next_header;
|
||||
guint8 *data;
|
||||
gsize available;
|
||||
GstMapInfo map;
|
||||
gboolean res = TRUE;
|
||||
int frames_found = 1;
|
||||
int offset = bpf;
|
||||
|
||||
data = gst_buffer_map (buf, &available, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
while (frames_found < MIN_RESYNC_FRAMES) {
|
||||
/* Check if we have enough data for all these frames, plus the next
|
||||
frame header. */
|
||||
if (available < offset + 4) {
|
||||
if (map.size < offset + 4) {
|
||||
if (at_eos) {
|
||||
/* Running out of data at EOS is fine; just accept it */
|
||||
*valid = TRUE;
|
||||
|
@ -398,7 +397,7 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
|
|||
}
|
||||
}
|
||||
|
||||
next_header = GST_READ_UINT32_BE (data + offset);
|
||||
next_header = GST_READ_UINT32_BE (map.data + offset);
|
||||
GST_DEBUG_OBJECT (mp3parse, "At %d: header=%08X, header2=%08X, bpf=%d",
|
||||
offset, (unsigned int) header, (unsigned int) next_header, bpf);
|
||||
|
||||
|
@ -435,7 +434,7 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
|
|||
*valid = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, available);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -497,24 +496,23 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
|
|||
gboolean lost_sync, draining, valid, caps_change;
|
||||
guint32 header;
|
||||
guint bitrate, layer, rate, channels, version, mode, crc;
|
||||
guint8 *data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
gboolean res = FALSE;
|
||||
|
||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
if (G_UNLIKELY (bufsize < 6))
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (G_UNLIKELY (map.size < 6))
|
||||
goto cleanup;
|
||||
|
||||
gst_byte_reader_init (&reader, data, bufsize);
|
||||
gst_byte_reader_init (&reader, map.data, map.size);
|
||||
|
||||
off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffe00000, 0xffe00000,
|
||||
0, bufsize);
|
||||
0, map.size);
|
||||
|
||||
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
||||
|
||||
/* didn't find anything that looks like a sync word, skip */
|
||||
if (off < 0) {
|
||||
*skipsize = bufsize - 3;
|
||||
*skipsize = map.size - 3;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -525,7 +523,7 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
|
|||
}
|
||||
|
||||
/* make sure the values in the frame header look sane */
|
||||
header = GST_READ_UINT32_BE (data);
|
||||
header = GST_READ_UINT32_BE (map.data);
|
||||
if (!gst_mpeg_audio_parse_head_check (mp3parse, header)) {
|
||||
*skipsize = 1;
|
||||
goto cleanup;
|
||||
|
@ -572,7 +570,7 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
|
|||
res = TRUE;
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -588,8 +586,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
|||
guint64 avail;
|
||||
gint64 upstream_total_bytes = 0;
|
||||
guint32 read_id_xing = 0, read_id_vbri = 0;
|
||||
guint8 *data, *origdata;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint bitrate;
|
||||
|
||||
if (mp3parse->sent_codec_tag)
|
||||
|
@ -616,8 +614,9 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
|||
offset_vbri += 4;
|
||||
|
||||
/* Check if we have enough data to read the Xing header */
|
||||
origdata = data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
avail = bufsize;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
avail = map.size;
|
||||
|
||||
if (avail >= offset_xing + 4) {
|
||||
read_id_xing = GST_READ_UINT32_BE (data + offset_xing);
|
||||
|
@ -899,7 +898,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
data = origdata;
|
||||
data = map.data;
|
||||
data += offset_vbri + 26;
|
||||
|
||||
/* VBRI seek table: frame/seek_frames -> byte */
|
||||
|
@ -975,7 +974,7 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
|||
gst_base_parse_set_average_bitrate (GST_BASE_PARSE (mp3parse), bitrate);
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buf, origdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -984,16 +983,15 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
|
|||
{
|
||||
GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);
|
||||
GstBuffer *buf = frame->buffer;
|
||||
guint8 *data;
|
||||
gsize bufsize;
|
||||
GstMapInfo map;
|
||||
guint bitrate, layer, rate, channels, version, mode, crc;
|
||||
|
||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
if (G_UNLIKELY (bufsize < 4))
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (G_UNLIKELY (map.size < 4))
|
||||
goto short_buffer;
|
||||
|
||||
if (!mp3_type_frame_length_from_header (mp3parse,
|
||||
GST_READ_UINT32_BE (data),
|
||||
GST_READ_UINT32_BE (map.data),
|
||||
&version, &layer, &channels, &bitrate, &rate, &mode, &crc))
|
||||
goto broken_header;
|
||||
|
||||
|
@ -1048,21 +1046,21 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
|
|||
mp3parse->last_crc = crc;
|
||||
mp3parse->last_mode = mode;
|
||||
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERRORS */
|
||||
broken_header:
|
||||
{
|
||||
/* this really shouldn't ever happen */
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
short_buffer:
|
||||
{
|
||||
gst_buffer_unmap (buf, data, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1198,6 +1198,7 @@ static gboolean
|
|||
gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
||||
GstBuffer * buf, guint64 ** _indexes)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint16 bpe = 16;
|
||||
guint32 num, i;
|
||||
|
@ -1207,7 +1208,9 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
|||
*_indexes = NULL;
|
||||
|
||||
if (buf) {
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
} else {
|
||||
data = NULL;
|
||||
size = 0;
|
||||
|
@ -1246,7 +1249,7 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
|||
indexes[i] = GST_BUFFER_OFFSET_NONE;
|
||||
*_indexes = indexes;
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1258,7 +1261,7 @@ too_small:
|
|||
"Not enough data to parse superindex (%" G_GSIZE_FORMAT
|
||||
" available, 24 needed)", size);
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1267,7 +1270,7 @@ invalid_params:
|
|||
{
|
||||
GST_ERROR_OBJECT (avi, "invalid index parameters (num = %d, bpe = %d)",
|
||||
num, bpe);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1469,18 +1472,20 @@ static gboolean
|
|||
gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
|
||||
GstBuffer * buf)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint16 bpe;
|
||||
guint32 num, i;
|
||||
guint64 baseoff;
|
||||
gsize size;
|
||||
|
||||
if (buf == NULL)
|
||||
return TRUE;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
|
||||
/* check size */
|
||||
if (size < 24)
|
||||
if (map.size < 24)
|
||||
goto too_small;
|
||||
|
||||
/* We don't support index-data yet */
|
||||
|
@ -1511,7 +1516,7 @@ gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
|
|||
for (i = 0; i < num; i++) {
|
||||
GstAviIndexEntry entry;
|
||||
|
||||
if (size < 24 + bpe * (i + 1))
|
||||
if (map.size < 24 + bpe * (i + 1))
|
||||
break;
|
||||
|
||||
/* fill in offset and size. offset contains the keyframe flag in the
|
||||
|
@ -1533,7 +1538,7 @@ gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
|
|||
goto out_of_mem;
|
||||
}
|
||||
done:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1543,14 +1548,14 @@ too_small:
|
|||
{
|
||||
GST_ERROR_OBJECT (avi,
|
||||
"Not enough data to parse subindex (%" G_GSIZE_FORMAT
|
||||
" available, 24 needed)", size);
|
||||
" available, 24 needed)", map.size);
|
||||
goto done; /* continue */
|
||||
}
|
||||
not_implemented:
|
||||
{
|
||||
GST_ELEMENT_ERROR (avi, STREAM, NOT_IMPLEMENTED, (NULL),
|
||||
("Subindex-is-data is not implemented"));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1565,7 +1570,7 @@ out_of_mem:
|
|||
("Cannot allocate memory for %u*%u=%u bytes",
|
||||
(guint) sizeof (GstAviIndexEntry), num,
|
||||
(guint) sizeof (GstAviIndexEntry) * num));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1868,17 +1873,17 @@ gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
|
|||
|
||||
if (G_UNLIKELY (size & 1)) {
|
||||
GstBuffer *obuf;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
GST_DEBUG_OBJECT (avi, "rounding up dubious list size %" G_GSIZE_FORMAT,
|
||||
size);
|
||||
obuf = gst_buffer_new_and_alloc (size + 1);
|
||||
|
||||
data = gst_buffer_map (obuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_extract (*buf, 0, data, size);
|
||||
gst_buffer_map (obuf, &map, GST_MAP_WRITE);
|
||||
gst_buffer_extract (*buf, 0, map.data, size);
|
||||
/* assume 0 padding, at least makes outcome deterministic */
|
||||
data[size] = 0;
|
||||
gst_buffer_unmap (obuf, data, size + 1);
|
||||
map.data[size] = 0;
|
||||
gst_buffer_unmap (obuf, &map);
|
||||
gst_buffer_replace (buf, obuf);
|
||||
}
|
||||
}
|
||||
|
@ -2103,12 +2108,11 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
|
|||
case GST_RIFF_TAG_strn:
|
||||
g_free (stream->name);
|
||||
if (sub != NULL) {
|
||||
gchar *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
bdata = gst_buffer_map (sub, &bsize, NULL, GST_MAP_READ);
|
||||
stream->name = g_strndup (bdata, bsize);
|
||||
gst_buffer_unmap (sub, bdata, bsize);
|
||||
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||
stream->name = g_strndup ((gchar *) map.data, map.size);
|
||||
gst_buffer_unmap (sub, &map);
|
||||
gst_buffer_unref (sub);
|
||||
sub = NULL;
|
||||
} else {
|
||||
|
@ -2343,26 +2347,25 @@ gst_avi_demux_parse_odml (GstAviDemux * avi, GstBuffer * buf)
|
|||
switch (tag) {
|
||||
case GST_RIFF_TAG_dmlh:{
|
||||
gst_riff_dmlh dmlh, *_dmlh;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
/* sub == NULL is possible and means an empty buffer */
|
||||
if (sub == NULL)
|
||||
goto next;
|
||||
|
||||
data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||
|
||||
/* check size */
|
||||
if (size < sizeof (gst_riff_dmlh)) {
|
||||
if (map.size < sizeof (gst_riff_dmlh)) {
|
||||
GST_ERROR_OBJECT (avi,
|
||||
"DMLH entry is too small (%" G_GSIZE_FORMAT " bytes, %d needed)",
|
||||
size, (int) sizeof (gst_riff_dmlh));
|
||||
gst_buffer_unmap (sub, data, size);
|
||||
map.size, (int) sizeof (gst_riff_dmlh));
|
||||
gst_buffer_unmap (sub, &map);
|
||||
goto next;
|
||||
}
|
||||
_dmlh = (gst_riff_dmlh *) data;
|
||||
_dmlh = (gst_riff_dmlh *) map.data;
|
||||
dmlh.totalframes = GST_READ_UINT32_LE (&_dmlh->totalframes);
|
||||
gst_buffer_unmap (sub, data, size);
|
||||
gst_buffer_unmap (sub, &map);
|
||||
|
||||
GST_INFO_OBJECT (avi, "dmlh tag found: totalframes: %u",
|
||||
dmlh.totalframes);
|
||||
|
@ -2539,8 +2542,7 @@ gst_avi_demux_stream_for_id (GstAviDemux * avi, guint32 id)
|
|||
static gboolean
|
||||
gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint i, num, n;
|
||||
gst_riff_index_entry *index;
|
||||
GstClockTime stamp;
|
||||
|
@ -2551,18 +2553,18 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
|||
if (!buf)
|
||||
return FALSE;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
stamp = gst_util_get_timestamp ();
|
||||
|
||||
/* see how many items in the index */
|
||||
num = size / sizeof (gst_riff_index_entry);
|
||||
num = map.size / sizeof (gst_riff_index_entry);
|
||||
if (num == 0)
|
||||
goto empty_list;
|
||||
|
||||
GST_INFO_OBJECT (avi, "Parsing index, nr_entries = %6d", num);
|
||||
|
||||
index = (gst_riff_index_entry *) data;
|
||||
index = (gst_riff_index_entry *) map.data;
|
||||
|
||||
/* figure out if the index is 0 based or relative to the MOVI start */
|
||||
entry.offset = GST_READ_UINT32_LE (&index[0].offset);
|
||||
|
@ -2613,7 +2615,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
|||
|
||||
n++;
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
/* get stream stats now */
|
||||
|
@ -2629,7 +2631,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
|||
empty_list:
|
||||
{
|
||||
GST_DEBUG_OBJECT (avi, "empty index");
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2639,7 +2641,7 @@ out_of_mem:
|
|||
("Cannot allocate memory for %u*%u=%u bytes",
|
||||
(guint) sizeof (GstAviIndexEntry), num,
|
||||
(guint) sizeof (GstAviIndexEntry) * num));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -2659,8 +2661,7 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
|
|||
GstBuffer *buf;
|
||||
guint32 tag;
|
||||
guint32 size;
|
||||
gsize bsize;
|
||||
guint8 *bdata;
|
||||
GstMapInfo map;
|
||||
|
||||
GST_DEBUG ("demux stream index at offset %" G_GUINT64_FORMAT, offset);
|
||||
|
||||
|
@ -2669,33 +2670,33 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
|
|||
if (res != GST_FLOW_OK)
|
||||
goto pull_failed;
|
||||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
if (bsize < 8)
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (map.size < 8)
|
||||
goto too_small;
|
||||
|
||||
/* check tag first before blindy trying to read 'size' bytes */
|
||||
tag = GST_READ_UINT32_LE (bdata);
|
||||
size = GST_READ_UINT32_LE (bdata + 4);
|
||||
tag = GST_READ_UINT32_LE (map.data);
|
||||
size = GST_READ_UINT32_LE (map.data + 4);
|
||||
if (tag == GST_RIFF_TAG_LIST) {
|
||||
/* this is the movi tag */
|
||||
GST_DEBUG_OBJECT (avi, "skip LIST chunk, size %" G_GUINT32_FORMAT,
|
||||
(8 + GST_ROUND_UP_2 (size)));
|
||||
offset += 8 + GST_ROUND_UP_2 (size);
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
||||
if (res != GST_FLOW_OK)
|
||||
goto pull_failed;
|
||||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
if (bsize < 8)
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (map.size < 8)
|
||||
goto too_small;
|
||||
|
||||
tag = GST_READ_UINT32_LE (bdata);
|
||||
size = GST_READ_UINT32_LE (bdata + 4);
|
||||
tag = GST_READ_UINT32_LE (map.data);
|
||||
size = GST_READ_UINT32_LE (map.data + 4);
|
||||
}
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
if (tag != GST_RIFF_TAG_idx1)
|
||||
|
@ -2740,7 +2741,7 @@ pull_failed:
|
|||
too_small:
|
||||
{
|
||||
GST_DEBUG_OBJECT (avi, "Buffer is too small");
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return;
|
||||
}
|
||||
|
@ -2852,26 +2853,25 @@ gst_avi_demux_peek_tag (GstAviDemux * avi, guint64 offset, guint32 * tag,
|
|||
{
|
||||
GstFlowReturn res = GST_FLOW_OK;
|
||||
GstBuffer *buf = NULL;
|
||||
gsize bufsize;
|
||||
guint8 *bufdata;
|
||||
GstMapInfo map;
|
||||
|
||||
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
||||
if (res != GST_FLOW_OK)
|
||||
goto pull_failed;
|
||||
|
||||
bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
||||
if (bufsize != 8)
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (map.size != 8)
|
||||
goto wrong_size;
|
||||
|
||||
*tag = GST_READ_UINT32_LE (bufdata);
|
||||
*size = GST_READ_UINT32_LE (bufdata + 4);
|
||||
*tag = GST_READ_UINT32_LE (map.data);
|
||||
*size = GST_READ_UINT32_LE (map.data + 4);
|
||||
|
||||
GST_LOG_OBJECT (avi, "Tag[%" GST_FOURCC_FORMAT "] (size:%d) %"
|
||||
G_GINT64_FORMAT " -- %" G_GINT64_FORMAT, GST_FOURCC_ARGS (*tag),
|
||||
*size, offset + 8, offset + 8 + (gint64) * size);
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return res;
|
||||
|
@ -2885,7 +2885,7 @@ pull_failed:
|
|||
wrong_size:
|
||||
{
|
||||
GST_DEBUG_OBJECT (avi, "got %" G_GSIZE_FORMAT " bytes which is <> 8 bytes",
|
||||
bufsize);
|
||||
map.size);
|
||||
res = GST_FLOW_ERROR;
|
||||
goto done;
|
||||
}
|
||||
|
@ -3512,11 +3512,12 @@ gst_avi_demux_parse_idit_text (GstAviDemux * avi, gchar * data)
|
|||
static void
|
||||
gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
||||
{
|
||||
gchar *data, *ptr;
|
||||
gsize size, left;
|
||||
GstMapInfo map;
|
||||
gchar *ptr;
|
||||
gsize left;
|
||||
gchar *safedata = NULL;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
/*
|
||||
* According to:
|
||||
* http://www.eden-foundation.org/products/code/film_date_stamp/index.html
|
||||
|
@ -3530,8 +3531,8 @@ gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
|||
*/
|
||||
|
||||
/* skip eventual initial whitespace */
|
||||
ptr = data;
|
||||
left = size;
|
||||
ptr = (gchar *) map.data;
|
||||
left = map.size;
|
||||
|
||||
while (left > 0 && g_ascii_isspace (ptr[0])) {
|
||||
ptr++;
|
||||
|
@ -3560,7 +3561,7 @@ gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
|||
|
||||
non_parsable:
|
||||
GST_WARNING_OBJECT (avi, "IDIT tag has no parsable info");
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3627,21 +3628,20 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
|
||||
/* now, read the elements from the header until the end */
|
||||
while (gst_riff_parse_chunk (element, buf, &offset, &tag, &sub)) {
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
/* sub can be NULL on empty tags */
|
||||
if (!sub)
|
||||
continue;
|
||||
|
||||
data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||
|
||||
switch (tag) {
|
||||
case GST_RIFF_TAG_LIST:
|
||||
if (size < 4)
|
||||
if (map.size < 4)
|
||||
goto next;
|
||||
|
||||
switch (GST_READ_UINT32_LE (data)) {
|
||||
switch (GST_READ_UINT32_LE (map.data)) {
|
||||
case GST_RIFF_LIST_strl:
|
||||
if (!(gst_avi_demux_parse_stream (avi, sub))) {
|
||||
GST_ELEMENT_WARNING (avi, STREAM, DEMUX, (NULL),
|
||||
|
@ -3670,8 +3670,8 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
default:
|
||||
GST_WARNING_OBJECT (avi,
|
||||
"Unknown list %" GST_FOURCC_FORMAT " in AVI header",
|
||||
GST_FOURCC_ARGS (GST_READ_UINT32_LE (data)));
|
||||
GST_MEMDUMP_OBJECT (avi, "Unknown list", data, size);
|
||||
GST_FOURCC_ARGS (GST_READ_UINT32_LE (map.data)));
|
||||
GST_MEMDUMP_OBJECT (avi, "Unknown list", map.data, map.size);
|
||||
/* fall-through */
|
||||
case GST_RIFF_TAG_JUNQ:
|
||||
case GST_RIFF_TAG_JUNK:
|
||||
|
@ -3685,13 +3685,13 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
GST_WARNING_OBJECT (avi,
|
||||
"Unknown tag %" GST_FOURCC_FORMAT " in AVI header at off %d",
|
||||
GST_FOURCC_ARGS (tag), offset);
|
||||
GST_MEMDUMP_OBJECT (avi, "Unknown tag", data, size);
|
||||
GST_MEMDUMP_OBJECT (avi, "Unknown tag", map.data, map.size);
|
||||
/* fall-through */
|
||||
case GST_RIFF_TAG_JUNQ:
|
||||
case GST_RIFF_TAG_JUNK:
|
||||
next:
|
||||
if (sub) {
|
||||
gst_buffer_unmap (sub, data, size);
|
||||
gst_buffer_unmap (sub, &map);
|
||||
gst_buffer_unref (sub);
|
||||
}
|
||||
sub = NULL;
|
||||
|
@ -3715,9 +3715,8 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
|
||||
/* Now, find the data (i.e. skip all junk between header and data) */
|
||||
do {
|
||||
GstMapInfo map;
|
||||
guint size;
|
||||
gsize bsize;
|
||||
guint8 *data;
|
||||
guint32 tag, ltag;
|
||||
|
||||
res = gst_pad_pull_range (avi->sinkpad, avi->offset, 12, &buf);
|
||||
|
@ -3732,15 +3731,15 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
tag = GST_READ_UINT32_LE (data);
|
||||
size = GST_READ_UINT32_LE (data + 4);
|
||||
ltag = GST_READ_UINT32_LE (data + 8);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
tag = GST_READ_UINT32_LE (map.data);
|
||||
size = GST_READ_UINT32_LE (map.data + 4);
|
||||
ltag = GST_READ_UINT32_LE (map.data + 8);
|
||||
|
||||
GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
|
||||
GST_FOURCC_ARGS (tag), size);
|
||||
GST_MEMDUMP ("Tag content", data, bsize);
|
||||
gst_buffer_unmap (buf, data, bsize);
|
||||
GST_MEMDUMP ("Tag content", map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
switch (tag) {
|
||||
|
@ -3806,9 +3805,9 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
|||
GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
|
||||
goto pull_range_failed;
|
||||
}
|
||||
data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
GST_MEMDUMP ("Junk", data, bsize);
|
||||
gst_buffer_unmap (buf, data, bsize);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
GST_MEMDUMP ("Junk", map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
avi->offset += 8 + GST_ROUND_UP_2 (size);
|
||||
|
@ -4410,8 +4409,8 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
|
|||
GstStructure *s;
|
||||
gint y, w, h;
|
||||
gint bpp, stride;
|
||||
guint8 *tmp = NULL, *data;
|
||||
gsize size;
|
||||
guint8 *tmp = NULL;
|
||||
GstMapInfo map;
|
||||
GstCaps *caps;
|
||||
|
||||
if (stream->strh->type != GST_RIFF_FCC_vids)
|
||||
|
@ -4441,22 +4440,23 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
|
|||
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
if (size < (stride * h)) {
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
if (map.size < (stride * h)) {
|
||||
GST_WARNING ("Buffer is smaller than reported Width x Height x Depth");
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return buf;
|
||||
}
|
||||
|
||||
tmp = g_malloc (stride);
|
||||
|
||||
for (y = 0; y < h / 2; y++) {
|
||||
swap_line (data + stride * y, data + stride * (h - 1 - y), tmp, stride);
|
||||
swap_line (map.data + stride * y, map.data + stride * (h - 1 - y), tmp,
|
||||
stride);
|
||||
}
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -629,19 +629,18 @@ static GstFlowReturn
|
|||
gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint spf;
|
||||
guint32 header;
|
||||
gulong layer;
|
||||
gulong version;
|
||||
gint lsf, mpg25;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
if (size < 4)
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
if (map.size < 4)
|
||||
goto not_parsed;
|
||||
|
||||
header = GST_READ_UINT32_BE (data);
|
||||
header = GST_READ_UINT32_BE (map.data);
|
||||
|
||||
if ((header & 0xffe00000) != 0xffe00000)
|
||||
goto not_parsed;
|
||||
|
@ -677,7 +676,7 @@ gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
|
|||
goto cbr_fallback;
|
||||
}
|
||||
done:
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
|
@ -1136,8 +1135,7 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
|
|||
GstByteWriter bw;
|
||||
GSList *node;
|
||||
guint avih, riff, hdrl;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
GST_DEBUG_OBJECT (avimux, "creating avi header, data_size %u, idx_size %u",
|
||||
avimux->data_size, avimux->idx_size);
|
||||
|
@ -1229,11 +1227,9 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
|
|||
gst_byte_writer_put_uint32_le (&bw, vidpad->vids.num_colors);
|
||||
gst_byte_writer_put_uint32_le (&bw, vidpad->vids.imp_colors);
|
||||
if (vidpad->vids_codec_data) {
|
||||
bdata =
|
||||
gst_buffer_map (vidpad->vids_codec_data, &bsize, NULL,
|
||||
GST_MAP_READ);
|
||||
gst_byte_writer_put_data (&bw, bdata, bsize);
|
||||
gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
|
||||
gst_buffer_map (vidpad->vids_codec_data, &map, GST_MAP_READ);
|
||||
gst_byte_writer_put_data (&bw, map.data, map.size);
|
||||
gst_buffer_unmap (vidpad->vids_codec_data, &map);
|
||||
}
|
||||
gst_avi_mux_end_chunk (&bw, strf);
|
||||
|
||||
|
@ -1287,11 +1283,9 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
|
|||
gst_byte_writer_put_uint16_le (&bw, audpad->auds.size);
|
||||
gst_byte_writer_put_uint16_le (&bw, codec_size);
|
||||
if (audpad->auds_codec_data) {
|
||||
bdata =
|
||||
gst_buffer_map (audpad->auds_codec_data, &bsize, NULL,
|
||||
GST_MAP_READ);
|
||||
gst_byte_writer_put_data (&bw, bdata, bsize);
|
||||
gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
|
||||
gst_buffer_map (audpad->auds_codec_data, &map, GST_MAP_READ);
|
||||
gst_byte_writer_put_data (&bw, map.data, map.size);
|
||||
gst_buffer_unmap (vidpad->vids_codec_data, &map);
|
||||
}
|
||||
gst_avi_mux_end_chunk (&bw, strf);
|
||||
}
|
||||
|
@ -1362,13 +1356,13 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
|
|||
buffer = gst_byte_writer_reset_and_get_buffer (&bw);
|
||||
|
||||
/* ... but RIFF includes more than just header */
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READWRITE);
|
||||
size = GST_READ_UINT32_LE (bdata + 4);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READWRITE);
|
||||
size = GST_READ_UINT32_LE (map.data + 4);
|
||||
size += 8 + avimux->data_size + avimux->idx_size;
|
||||
GST_WRITE_UINT32_LE (bdata + 4, size);
|
||||
GST_WRITE_UINT32_LE (map.data + 4, size);
|
||||
|
||||
GST_MEMDUMP_OBJECT (avimux, "avi header", bdata, bsize);
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
GST_MEMDUMP_OBJECT (avimux, "avi header", map.data, map.size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -1377,19 +1371,18 @@ static GstBuffer *
|
|||
gst_avi_mux_riff_get_avix_header (guint32 datax_size)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (24);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata + 0, "RIFF", 4);
|
||||
GST_WRITE_UINT32_LE (bdata + 4, datax_size + 3 * 4);
|
||||
memcpy (bdata + 8, "AVIX", 4);
|
||||
memcpy (bdata + 12, "LIST", 4);
|
||||
GST_WRITE_UINT32_LE (bdata + 16, datax_size);
|
||||
memcpy (bdata + 20, "movi", 4);
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data + 0, "RIFF", 4);
|
||||
GST_WRITE_UINT32_LE (map.data + 4, datax_size + 3 * 4);
|
||||
memcpy (map.data + 8, "AVIX", 4);
|
||||
memcpy (map.data + 12, "LIST", 4);
|
||||
GST_WRITE_UINT32_LE (map.data + 16, datax_size);
|
||||
memcpy (map.data + 20, "movi", 4);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -1398,15 +1391,14 @@ static inline GstBuffer *
|
|||
gst_avi_mux_riff_get_header (GstAviPad * avipad, guint32 video_frame_size)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (8);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata + 0, avipad->tag, 4);
|
||||
GST_WRITE_UINT32_LE (bdata + 4, video_frame_size);
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data + 0, avipad->tag, 4);
|
||||
GST_WRITE_UINT32_LE (map.data + 4, video_frame_size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -1425,8 +1417,7 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
|||
guint32 size, entry_count;
|
||||
gboolean is_pcm = FALSE;
|
||||
guint32 pcm_samples = 0;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
/* check if it is pcm */
|
||||
if (avipad && !avipad->is_video) {
|
||||
|
@ -1440,20 +1431,20 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
|||
/* allocate the maximum possible */
|
||||
buffer = gst_buffer_new_and_alloc (32 + 8 * avimux->idx_index);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
||||
data = bdata;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
|
||||
/* general index chunk info */
|
||||
memcpy (bdata + 0, chunk, 4); /* chunk id */
|
||||
GST_WRITE_UINT32_LE (bdata + 4, 0); /* chunk size; fill later */
|
||||
GST_WRITE_UINT16_LE (bdata + 8, 2); /* index entry is 2 words */
|
||||
bdata[10] = 0; /* index subtype */
|
||||
bdata[11] = GST_AVI_INDEX_OF_CHUNKS; /* index type: AVI_INDEX_OF_CHUNKS */
|
||||
GST_WRITE_UINT32_LE (bdata + 12, 0); /* entries in use; fill later */
|
||||
memcpy (bdata + 16, code, 4); /* stream to which index refers */
|
||||
GST_WRITE_UINT64_LE (bdata + 20, avimux->avix_start); /* base offset */
|
||||
GST_WRITE_UINT32_LE (bdata + 28, 0); /* reserved */
|
||||
bdata += 32;
|
||||
memcpy (map.data + 0, chunk, 4); /* chunk id */
|
||||
GST_WRITE_UINT32_LE (map.data + 4, 0); /* chunk size; fill later */
|
||||
GST_WRITE_UINT16_LE (map.data + 8, 2); /* index entry is 2 words */
|
||||
map.data[10] = 0; /* index subtype */
|
||||
map.data[11] = GST_AVI_INDEX_OF_CHUNKS; /* index type: AVI_INDEX_OF_CHUNKS */
|
||||
GST_WRITE_UINT32_LE (map.data + 12, 0); /* entries in use; fill later */
|
||||
memcpy (map.data + 16, code, 4); /* stream to which index refers */
|
||||
GST_WRITE_UINT64_LE (map.data + 20, avimux->avix_start); /* base offset */
|
||||
GST_WRITE_UINT32_LE (map.data + 28, 0); /* reserved */
|
||||
map.data += 32;
|
||||
|
||||
/* now the actual index entries */
|
||||
i = avimux->idx_index;
|
||||
|
@ -1461,23 +1452,24 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
|||
while (i > 0) {
|
||||
if (memcmp (&entry->id, code, 4) == 0) {
|
||||
/* enter relative offset to the data (!) */
|
||||
GST_WRITE_UINT32_LE (bdata, GUINT32_FROM_LE (entry->offset) + 8);
|
||||
GST_WRITE_UINT32_LE (map.data, GUINT32_FROM_LE (entry->offset) + 8);
|
||||
/* msb is set if not (!) keyframe */
|
||||
GST_WRITE_UINT32_LE (bdata + 4, GUINT32_FROM_LE (entry->size)
|
||||
GST_WRITE_UINT32_LE (map.data + 4, GUINT32_FROM_LE (entry->size)
|
||||
| (GUINT32_FROM_LE (entry->flags)
|
||||
& GST_RIFF_IF_KEYFRAME ? 0 : 1U << 31));
|
||||
bdata += 8;
|
||||
map.data += 8;
|
||||
}
|
||||
i--;
|
||||
entry++;
|
||||
}
|
||||
|
||||
/* ok, now we know the size and no of entries, fill in where needed */
|
||||
size = bdata - data;
|
||||
size = map.data - data;
|
||||
GST_WRITE_UINT32_LE (data + 4, size - 8);
|
||||
entry_count = (size - 32) / 8;
|
||||
GST_WRITE_UINT32_LE (data + 12, entry_count);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_resize (buffer, 0, size);
|
||||
|
||||
/* send */
|
||||
if ((res = gst_pad_push (avimux->srcpad, buffer)) != GST_FLOW_OK)
|
||||
|
@ -1543,16 +1535,17 @@ gst_avi_mux_write_index (GstAviMux * avimux)
|
|||
{
|
||||
GstFlowReturn res;
|
||||
GstBuffer *buffer;
|
||||
guint8 *buffdata;
|
||||
gsize buffsize;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (8);
|
||||
|
||||
buffdata = gst_buffer_map (buffer, &buffsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (buffdata + 0, "idx1", 4);
|
||||
GST_WRITE_UINT32_LE (buffdata + 4,
|
||||
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data + 0, "idx1", 4);
|
||||
GST_WRITE_UINT32_LE (map.data + 4,
|
||||
avimux->idx_index * sizeof (gst_riff_index_entry));
|
||||
gst_buffer_unmap (buffer, buffdata, buffsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
res = gst_pad_push (avimux->srcpad, buffer);
|
||||
if (res != GST_FLOW_OK)
|
||||
|
@ -1560,14 +1553,14 @@ gst_avi_mux_write_index (GstAviMux * avimux)
|
|||
|
||||
buffer = gst_buffer_new ();
|
||||
|
||||
buffsize = avimux->idx_index * sizeof (gst_riff_index_entry);
|
||||
buffdata = (guint8 *) avimux->idx;
|
||||
size = avimux->idx_index * sizeof (gst_riff_index_entry);
|
||||
data = (guint8 *) avimux->idx;
|
||||
avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
|
||||
|
||||
gst_buffer_take_memory (buffer, -1,
|
||||
gst_memory_new_wrapped (0, buffdata, g_free, buffsize, 0, buffsize));
|
||||
gst_memory_new_wrapped (0, data, g_free, size, 0, size));
|
||||
|
||||
avimux->total_data += buffsize + 8;
|
||||
avimux->total_data += size + 8;
|
||||
|
||||
res = gst_pad_push (avimux->srcpad, buffer);
|
||||
if (res != GST_FLOW_OK)
|
||||
|
@ -1882,14 +1875,9 @@ static GstFlowReturn
|
|||
gst_avi_mux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
|
||||
{
|
||||
GstBuffer *buffer;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (num_bytes);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
||||
memset (bdata, 0, num_bytes);
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_memset (buffer, 0, 0, num_bytes);
|
||||
|
||||
return gst_pad_push (avimux->srcpad, buffer);
|
||||
}
|
||||
|
|
|
@ -97,11 +97,11 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
|
|||
{
|
||||
const gchar *input_enc = NULL;
|
||||
GstBuffer *ret = NULL;
|
||||
gchar *data, *bdata;
|
||||
gsize bsize;
|
||||
gchar *data;
|
||||
GstMapInfo map;
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
data = bdata + offset;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = (gchar *) (map.data + offset);
|
||||
|
||||
if (len >= (3 + 1) && IS_BOM_UTF8 (data) &&
|
||||
g_utf8_validate (data + 3, len - 3, NULL)) {
|
||||
|
@ -160,7 +160,7 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
|
|||
}
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -183,25 +183,25 @@ gst_avi_subtitle_title_tag (GstAviSubtitle * sub, gchar * title)
|
|||
static GstFlowReturn
|
||||
gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
||||
{
|
||||
guint8 *data;
|
||||
gchar *name_utf8;
|
||||
guint name_length;
|
||||
guint file_length;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
/* check the magic word "GAB2\0", and the next word must be 2 */
|
||||
if (size < 12 || memcmp (data, "GAB2\0\2\0", 5 + 2) != 0)
|
||||
if (map.size < 12 || memcmp (map.data, "GAB2\0\2\0", 5 + 2) != 0)
|
||||
goto wrong_magic_word;
|
||||
|
||||
/* read 'name' of subtitle */
|
||||
name_length = GST_READ_UINT32_LE (data + 5 + 2);
|
||||
name_length = GST_READ_UINT32_LE (map.data + 5 + 2);
|
||||
GST_LOG_OBJECT (sub, "length of name: %u", name_length);
|
||||
if (size <= 17 + name_length)
|
||||
if (map.size <= 17 + name_length)
|
||||
goto wrong_name_length;
|
||||
|
||||
name_utf8 = g_convert ((gchar *) data + 11, name_length, "UTF-8", "UTF-16LE",
|
||||
name_utf8 =
|
||||
g_convert ((gchar *) map.data + 11, name_length, "UTF-8", "UTF-16LE",
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (name_utf8) {
|
||||
|
@ -211,13 +211,13 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
|||
}
|
||||
|
||||
/* next word must be 4 */
|
||||
if (GST_READ_UINT16_LE (data + 11 + name_length) != 0x4)
|
||||
if (GST_READ_UINT16_LE (map.data + 11 + name_length) != 0x4)
|
||||
goto wrong_fixed_word_2;
|
||||
|
||||
file_length = GST_READ_UINT32_LE (data + 13 + name_length);
|
||||
file_length = GST_READ_UINT32_LE (map.data + 13 + name_length);
|
||||
GST_LOG_OBJECT (sub, "length srt/ssa file: %u", file_length);
|
||||
|
||||
if (size < (17 + name_length + file_length))
|
||||
if (map.size < (17 + name_length + file_length))
|
||||
goto wrong_total_length;
|
||||
|
||||
/* store this, so we can send it again after a seek; note that we shouldn't
|
||||
|
@ -229,7 +229,7 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
|||
if (sub->subfile == NULL)
|
||||
goto extract_failed;
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
|
@ -237,38 +237,38 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
|||
wrong_magic_word:
|
||||
{
|
||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL), ("Wrong magic word"));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
wrong_name_length:
|
||||
{
|
||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||
("name doesn't fit in buffer (%" G_GSIZE_FORMAT " < %d)", size,
|
||||
("name doesn't fit in buffer (%" G_GSIZE_FORMAT " < %d)", map.size,
|
||||
17 + name_length));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
wrong_fixed_word_2:
|
||||
{
|
||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||
("wrong fixed word: expected %u, got %u", 4,
|
||||
GST_READ_UINT16_LE (data + 11 + name_length)));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
GST_READ_UINT16_LE (map.data + 11 + name_length)));
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
wrong_total_length:
|
||||
{
|
||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||
("buffer size is wrong: need %d bytes, have %" G_GSIZE_FORMAT " bytes",
|
||||
17 + name_length + file_length, size));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
17 + name_length + file_length, map.size));
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
extract_failed:
|
||||
{
|
||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||
("could not extract subtitles"));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,6 +266,7 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstCutter *filter;
|
||||
GstMapInfo map;
|
||||
gint16 *in_data;
|
||||
gint bpf, rate;
|
||||
gsize in_size;
|
||||
|
@ -284,7 +285,9 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
bpf = GST_AUDIO_INFO_BPF (&filter->info);
|
||||
rate = GST_AUDIO_INFO_RATE (&filter->info);
|
||||
|
||||
in_data = gst_buffer_map (buf, &in_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
in_data = (gint16 *) map.data;
|
||||
in_size = map.size;
|
||||
|
||||
GST_LOG_OBJECT (filter, "length of prerec buffer: %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (filter->pre_run_length));
|
||||
|
@ -307,7 +310,7 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
break;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, in_data, in_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
filter->silent_prev = filter->silent;
|
||||
|
||||
|
|
|
@ -221,8 +221,8 @@ static GstFlowReturn
|
|||
gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||
{
|
||||
GstBreakMyData *bmd = GST_BREAK_MY_DATA (trans);
|
||||
guint8 *data;
|
||||
gsize i, size;
|
||||
GstMapInfo map;
|
||||
gsize i;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_is_writable (buf), GST_FLOW_ERROR);
|
||||
|
||||
|
@ -234,14 +234,14 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
|||
i = 0;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||
|
||||
GST_LOG_OBJECT (bmd,
|
||||
"got buffer %p (size %" G_GSIZE_FORMAT ", timestamp %" G_GUINT64_FORMAT
|
||||
", offset %" G_GUINT64_FORMAT "", buf, size, GST_BUFFER_TIMESTAMP (buf),
|
||||
GST_BUFFER_OFFSET (buf));
|
||||
", offset %" G_GUINT64_FORMAT "", buf, map.size,
|
||||
GST_BUFFER_TIMESTAMP (buf), GST_BUFFER_OFFSET (buf));
|
||||
|
||||
for (; i < size; i++) {
|
||||
for (; i < map.size; i++) {
|
||||
if (g_rand_double_range (bmd->rand, 0, 1.0) <= bmd->probability) {
|
||||
guint8 new;
|
||||
|
||||
|
@ -252,14 +252,14 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
|||
}
|
||||
GST_INFO_OBJECT (bmd,
|
||||
"changing byte %" G_GSIZE_FORMAT " from 0x%02X to 0x%02X", i,
|
||||
(guint) GST_READ_UINT8 (data + i), (guint) ((guint8) new));
|
||||
data[i] = new;
|
||||
(guint) GST_READ_UINT8 (map.data + i), (guint) ((guint8) new));
|
||||
map.data[i] = new;
|
||||
}
|
||||
}
|
||||
/* don't overflow */
|
||||
bmd->skipped += MIN (G_MAXUINT - bmd->skipped, size);
|
||||
bmd->skipped += MIN (G_MAXUINT - bmd->skipped, map.size);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
GST_OBJECT_UNLOCK (bmd);
|
||||
|
||||
|
|
|
@ -214,12 +214,11 @@ md5_new (const GstTestInfo * info)
|
|||
static void
|
||||
md5_add (gpointer checksum, GstBuffer * buffer)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
g_checksum_update (checksum, data, size);
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
g_checksum_update (checksum, map.data, map.size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -820,8 +820,7 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
|||
GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
|
||||
GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans);
|
||||
GstClockTime timestamp;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
gint channels = GST_AUDIO_FILTER_CHANNELS (filter);
|
||||
|
||||
if (G_UNLIKELY (channels < 1 || equ->process == NULL))
|
||||
|
@ -852,9 +851,9 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
|||
}
|
||||
BANDS_UNLOCK (equ);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
equ->process (equ, data, size, channels);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
equ->process (equ, map.data, map.size, channels);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -527,13 +527,12 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstByteReader reader;
|
||||
guint8 type = 0;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 7, GST_FLOW_ERROR);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_byte_reader_init (&reader, data, size);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
gst_byte_reader_init (&reader, map.data, map.size);
|
||||
|
||||
gst_byte_reader_skip (&reader, 7);
|
||||
|
||||
|
@ -620,7 +619,7 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
}
|
||||
|
||||
cleanup:
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -662,30 +661,30 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
|||
break;
|
||||
case 10:
|
||||
{
|
||||
guint8 *data = NULL;
|
||||
gsize size;
|
||||
if (demux->audio_codec_data) {
|
||||
GstMapInfo map;
|
||||
|
||||
if (demux->audio_codec_data)
|
||||
data = gst_buffer_map (demux->audio_codec_data, &size, NULL,
|
||||
GST_MAP_READ);
|
||||
/* use codec-data to extract and verify samplerate */
|
||||
if (demux->audio_codec_data && size >= 2) {
|
||||
gint freq_index;
|
||||
gst_buffer_map (demux->audio_codec_data, &map, GST_MAP_READ);
|
||||
|
||||
freq_index = GST_READ_UINT16_BE (data);
|
||||
freq_index = (freq_index & 0x0780) >> 7;
|
||||
adjusted_rate =
|
||||
gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
|
||||
/* use codec-data to extract and verify samplerate */
|
||||
if (map.size >= 2) {
|
||||
gint freq_index;
|
||||
|
||||
if (adjusted_rate && (rate != adjusted_rate)) {
|
||||
GST_LOG_OBJECT (demux, "Ajusting AAC sample rate %d -> %d", rate,
|
||||
adjusted_rate);
|
||||
} else {
|
||||
adjusted_rate = rate;
|
||||
freq_index = GST_READ_UINT16_BE (map.data);
|
||||
freq_index = (freq_index & 0x0780) >> 7;
|
||||
adjusted_rate =
|
||||
gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
|
||||
|
||||
if (adjusted_rate && (rate != adjusted_rate)) {
|
||||
GST_LOG_OBJECT (demux, "Ajusting AAC sample rate %d -> %d", rate,
|
||||
adjusted_rate);
|
||||
} else {
|
||||
adjusted_rate = rate;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (demux->audio_codec_data, &map);
|
||||
}
|
||||
if (data)
|
||||
gst_buffer_unmap (demux->audio_codec_data, data, -1);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/mpeg",
|
||||
"mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE,
|
||||
"stream-format", G_TYPE_STRING, "raw", NULL);
|
||||
|
@ -811,9 +810,9 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
guint32 pts = 0, codec_tag = 0, rate = 5512, width = 8, channels = 1;
|
||||
guint32 codec_data = 0, pts_ext = 0;
|
||||
guint8 flags = 0;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
GstBuffer *outbuf;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
|
||||
GST_LOG_OBJECT (demux, "parsing an audio tag");
|
||||
|
||||
|
@ -833,7 +832,8 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
|
||||
/* Grab information about audio tag */
|
||||
pts = GST_READ_UINT24_BE (data);
|
||||
|
@ -849,7 +849,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
flags = GST_READ_UINT8 (data + 7);
|
||||
|
||||
/* Silently skip buffers with no data */
|
||||
if (size == 11)
|
||||
if (map.size == 11)
|
||||
goto beach;
|
||||
|
||||
/* Channels */
|
||||
|
@ -1094,7 +1094,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
demux->audio_linked = TRUE;
|
||||
|
||||
beach:
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1197,9 +1197,9 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
guint32 pts = 0, codec_data = 1, pts_ext = 0;
|
||||
gboolean keyframe = FALSE;
|
||||
guint8 flags = 0, codec_tag = 0;
|
||||
guint8 *data;
|
||||
GstBuffer *outbuf;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size,
|
||||
GST_FLOW_ERROR);
|
||||
|
@ -1217,7 +1217,8 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
|
||||
/* Grab information about video tag */
|
||||
pts = GST_READ_UINT24_BE (data);
|
||||
|
@ -1474,7 +1475,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
demux->video_linked = TRUE;
|
||||
|
||||
beach:
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1487,13 +1488,16 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
|
|||
guint8 type;
|
||||
gboolean keyframe = TRUE;
|
||||
GstClockTime ret = GST_CLOCK_TIME_NONE;
|
||||
guint8 *data, *bdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 12,
|
||||
GST_CLOCK_TIME_NONE);
|
||||
|
||||
data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
type = data[0];
|
||||
|
||||
|
@ -1550,7 +1554,7 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
|
|||
demux->duration = ret;
|
||||
|
||||
exit:
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1559,13 +1563,13 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 tag_type = 0;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 4, GST_FLOW_ERROR);
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
tag_type = data[0];
|
||||
tag_type = map.data[0];
|
||||
|
||||
switch (tag_type) {
|
||||
case 9:
|
||||
|
@ -1585,13 +1589,13 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
|
||||
/* Tag size is 1 byte of type + 3 bytes of size + 7 bytes + tag data size +
|
||||
* 4 bytes of previous tag size */
|
||||
demux->tag_data_size = GST_READ_UINT24_BE (data + 1);
|
||||
demux->tag_data_size = GST_READ_UINT24_BE (map.data + 1);
|
||||
demux->tag_size = demux->tag_data_size + 11;
|
||||
|
||||
GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT,
|
||||
demux->tag_data_size);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1600,14 +1604,14 @@ static GstFlowReturn
|
|||
gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 9, GST_FLOW_ERROR);
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
/* Check for the FLV tag */
|
||||
if (data[0] == 'F' && data[1] == 'L' && data[2] == 'V') {
|
||||
if (map.data[0] == 'F' && map.data[1] == 'L' && map.data[2] == 'V') {
|
||||
GST_DEBUG_OBJECT (demux, "FLV header detected");
|
||||
} else {
|
||||
if (G_UNLIKELY (demux->strict)) {
|
||||
|
@ -1619,7 +1623,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
|
||||
/* Now look at audio/video flags */
|
||||
{
|
||||
guint8 flags = data[4];
|
||||
guint8 flags = map.data[4];
|
||||
|
||||
demux->has_video = demux->has_audio = FALSE;
|
||||
|
||||
|
@ -1640,7 +1644,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
|||
demux->need_header = FALSE;
|
||||
|
||||
beach:
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2262,7 +2266,7 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
|||
gint64 ret = 0, offset;
|
||||
size_t tag_size, size;
|
||||
GstBuffer *buffer = NULL;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
if (!gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
|
||||
goto exit;
|
||||
|
@ -2277,9 +2281,9 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
|||
4, &buffer))
|
||||
goto exit;
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
tag_size = GST_READ_UINT32_BE (data);
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
tag_size = GST_READ_UINT32_BE (map.data);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
GST_DEBUG_OBJECT (demux, "last tag size: %" G_GSIZE_FORMAT, tag_size);
|
||||
gst_buffer_unref (buffer);
|
||||
buffer = NULL;
|
||||
|
@ -2290,10 +2294,10 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
|||
goto exit;
|
||||
|
||||
/* a consistency check */
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
size = GST_READ_UINT24_BE (data + 1);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
size = GST_READ_UINT24_BE (map.data + 1);
|
||||
if (size != tag_size - 11) {
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"tag size %" G_GSIZE_FORMAT ", expected %" G_GSIZE_FORMAT
|
||||
", corrupt or truncated file", size, tag_size - 11);
|
||||
|
@ -2304,8 +2308,8 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
|||
gst_flv_demux_parse_tag_timestamp (demux, FALSE, buffer, &size);
|
||||
|
||||
/* maybe get some more metadata */
|
||||
if (data[0] == 18) {
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
if (map.data[0] == 18) {
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
buffer = NULL;
|
||||
GST_DEBUG_OBJECT (demux, "script tag, pulling it to parse");
|
||||
|
@ -2314,7 +2318,7 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
|||
tag_size, &buffer))
|
||||
gst_flv_demux_parse_tag_script (demux, buffer);
|
||||
} else {
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
|
||||
exit:
|
||||
|
|
|
@ -678,6 +678,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux, gboolean full)
|
|||
{
|
||||
const GstTagList *tags;
|
||||
GstBuffer *script_tag, *tmp;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gint i, n_tags, tags_written = 0;
|
||||
|
||||
|
@ -800,13 +801,15 @@ tags:
|
|||
|
||||
if (!mux->streamable && mux->duration != GST_CLOCK_TIME_NONE) {
|
||||
gdouble d;
|
||||
GstMapInfo map;
|
||||
|
||||
d = gst_guint64_to_gdouble (mux->duration);
|
||||
d /= (gdouble) GST_SECOND;
|
||||
|
||||
GST_DEBUG_OBJECT (mux, "determined the duration to be %f", d);
|
||||
data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
|
||||
GST_WRITE_DOUBLE_BE (data + 29 + 2 + 8 + 1, d);
|
||||
gst_buffer_unmap (script_tag, data, -1);
|
||||
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
||||
GST_WRITE_DOUBLE_BE (map.data + 29 + 2 + 8 + 1, d);
|
||||
gst_buffer_unmap (script_tag, &map);
|
||||
}
|
||||
|
||||
if (mux->have_video) {
|
||||
|
@ -981,13 +984,13 @@ end:
|
|||
GST_WRITE_UINT32_BE (data, gst_buffer_get_size (script_tag));
|
||||
script_tag = gst_buffer_join (script_tag, tmp);
|
||||
|
||||
data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
|
||||
data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
|
||||
data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
|
||||
data[3] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 0) & 0xff;
|
||||
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
||||
map.data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
|
||||
map.data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
|
||||
map.data[3] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 0) & 0xff;
|
||||
|
||||
GST_WRITE_UINT32_BE (data + 11 + 13 + 1, tags_written);
|
||||
gst_buffer_unmap (script_tag, data, -1);
|
||||
GST_WRITE_UINT32_BE (map.data + 11 + 13 + 1, tags_written);
|
||||
gst_buffer_unmap (script_tag, &map);
|
||||
|
||||
exit:
|
||||
return script_tag;
|
||||
|
@ -998,15 +1001,17 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
|
|||
GstFlvPad * cpad, gboolean is_codec_data)
|
||||
{
|
||||
GstBuffer *tag;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
guint size;
|
||||
guint32 timestamp =
|
||||
(GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) ? GST_BUFFER_TIMESTAMP (buffer) /
|
||||
GST_MSECOND : cpad->last_timestamp / GST_MSECOND;
|
||||
guint8 *bdata;
|
||||
guint8 *data, *bdata;
|
||||
gsize bsize;
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
bdata = map.data;
|
||||
bsize = map.size;
|
||||
|
||||
size = 11;
|
||||
if (cpad->video) {
|
||||
|
@ -1076,7 +1081,7 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
|
|||
}
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
GST_WRITE_UINT32_BE (data + size - 4, size - 4);
|
||||
|
||||
|
|
|
@ -188,11 +188,11 @@ gst_id3demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
|
|||
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
|
||||
}
|
||||
} else {
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
||||
*tags = gst_tag_list_new_from_id3v1 (data);
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
*tags = gst_tag_list_new_from_id3v1 (map.data);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
if (G_UNLIKELY (*tags == NULL))
|
||||
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
|
||||
|
|
|
@ -108,15 +108,14 @@ atoms_recov_write_ftyp_info (FILE * f, AtomFTYP * ftyp, GstBuffer * prefix)
|
|||
guint64 size = 0;
|
||||
|
||||
if (prefix) {
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
bdata = gst_buffer_map (prefix, &bsize, NULL, GST_MAP_READ);
|
||||
if (fwrite (bdata, 1, bsize, f) != bsize) {
|
||||
gst_buffer_unmap (prefix, bdata, bsize);
|
||||
gst_buffer_map (prefix, &map, GST_MAP_READ);
|
||||
if (fwrite (map.data, 1, map.size, f) != map.size) {
|
||||
gst_buffer_unmap (prefix, &map);
|
||||
return FALSE;
|
||||
}
|
||||
gst_buffer_unmap (prefix, bdata, bsize);
|
||||
gst_buffer_unmap (prefix, &map);
|
||||
}
|
||||
if (!atom_ftyp_copy_data (ftyp, &data, &size, &offset)) {
|
||||
return FALSE;
|
||||
|
|
|
@ -524,7 +524,7 @@ gst_qt_mux_prepare_jpc_buffer (GstQTPad * qtpad, GstBuffer * buf,
|
|||
GstQTMux * qtmux)
|
||||
{
|
||||
GstBuffer *newbuf;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
|
||||
GST_LOG_OBJECT (qtmux, "Preparing jpc buffer");
|
||||
|
@ -536,11 +536,11 @@ gst_qt_mux_prepare_jpc_buffer (GstQTPad * qtpad, GstBuffer * buf,
|
|||
newbuf = gst_buffer_new_and_alloc (size + 8);
|
||||
gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_ALL, 8, size);
|
||||
|
||||
data = gst_buffer_map (newbuf, &size, NULL, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (data, size);
|
||||
GST_WRITE_UINT32_LE (data + 4, FOURCC_jp2c);
|
||||
gst_buffer_map (newbuf, &map, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (map.data, map.size);
|
||||
GST_WRITE_UINT32_LE (map.data + 4, FOURCC_jp2c);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
return newbuf;
|
||||
|
@ -651,8 +651,7 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
|
|||
GstCaps *caps;
|
||||
GstStructure *structure;
|
||||
gint flags = 0;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_BUFFER);
|
||||
|
||||
|
@ -685,11 +684,11 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
|
|||
goto done;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
|
||||
" -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), size);
|
||||
atom_moov_add_tag (qtmux->moov, fourcc, flags, data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
" -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), map.size);
|
||||
atom_moov_add_tag (qtmux->moov, fourcc, flags, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
done:
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
@ -1122,13 +1121,12 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
|
|||
if (buf && (caps = NULL /*gst_buffer_get_caps (buf) */ )) {
|
||||
GstStructure *s;
|
||||
const gchar *style = NULL;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
GST_DEBUG_OBJECT (qtmux,
|
||||
"Found private tag %d/%d; size %" G_GSIZE_FORMAT ", caps %"
|
||||
GST_PTR_FORMAT, i, num_tags, size, caps);
|
||||
GST_PTR_FORMAT, i, num_tags, map.size, caps);
|
||||
s = gst_caps_get_structure (caps, 0);
|
||||
if (s && (style = gst_structure_get_string (s, "style"))) {
|
||||
/* try to prevent some style tag ending up into another variant
|
||||
|
@ -1138,10 +1136,10 @@ gst_qt_mux_add_metadata_tags (GstQTMux * qtmux, const GstTagList * list)
|
|||
(strcmp (style, "iso") == 0 &&
|
||||
qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
|
||||
GST_DEBUG_OBJECT (qtmux, "Adding private tag");
|
||||
atom_moov_add_blob_tag (qtmux->moov, data, size);
|
||||
atom_moov_add_blob_tag (qtmux->moov, map.data, map.size);
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_caps_unref (caps);
|
||||
}
|
||||
}
|
||||
|
@ -1207,13 +1205,13 @@ gst_qt_mux_send_buffer (GstQTMux * qtmux, GstBuffer * buf, guint64 * offset,
|
|||
GST_LOG_OBJECT (qtmux, "sending buffer size %" G_GSIZE_FORMAT, size);
|
||||
|
||||
if (mind_fast && qtmux->fast_start_file) {
|
||||
GstMapInfo map;
|
||||
gint ret;
|
||||
guint8 *data;
|
||||
|
||||
GST_LOG_OBJECT (qtmux, "to temporary file");
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
ret = fwrite (data, sizeof (guint8), size, qtmux->fast_start_file);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
ret = fwrite (map.data, sizeof (guint8), map.size, qtmux->fast_start_file);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
if (ret != size)
|
||||
goto write_error;
|
||||
|
@ -1272,18 +1270,19 @@ gst_qt_mux_send_buffered_data (GstQTMux * qtmux, guint64 * offset)
|
|||
GST_DEBUG_OBJECT (qtmux, "Sending buffered data");
|
||||
while (ret == GST_FLOW_OK) {
|
||||
const int bufsize = 4096;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (bufsize);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
size = fread (data, sizeof (guint8), bufsize, qtmux->fast_start_file);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
size = fread (map.data, sizeof (guint8), bufsize, qtmux->fast_start_file);
|
||||
if (size == 0) {
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
break;
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d", (gint) size);
|
||||
GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d",
|
||||
(gint) map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
ret = gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
|
||||
buf = NULL;
|
||||
}
|
||||
|
@ -1383,8 +1382,7 @@ gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
|
|||
GstBuffer *buf;
|
||||
gboolean large_file;
|
||||
GstSegment segment;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
large_file = (mdat_size > MDAT_LARGE_FILE_LIMIT);
|
||||
|
||||
|
@ -1398,17 +1396,17 @@ gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
|
|||
|
||||
if (large_file) {
|
||||
buf = gst_buffer_new_and_alloc (sizeof (guint64));
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT64_BE (data, mdat_size + 16);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT64_BE (map.data, mdat_size + 16);
|
||||
} else {
|
||||
buf = gst_buffer_new_and_alloc (16);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (data, 8);
|
||||
GST_WRITE_UINT32_LE (data + 4, FOURCC_free);
|
||||
GST_WRITE_UINT32_BE (data + 8, mdat_size + 8);
|
||||
GST_WRITE_UINT32_LE (data + 12, FOURCC_mdat);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (map.data, 8);
|
||||
GST_WRITE_UINT32_LE (map.data + 4, FOURCC_free);
|
||||
GST_WRITE_UINT32_BE (map.data + 8, mdat_size + 8);
|
||||
GST_WRITE_UINT32_LE (map.data + 12, FOURCC_mdat);
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
|
||||
}
|
||||
|
@ -2822,25 +2820,24 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
|
|||
} else if (strcmp (mimetype, "audio/x-alac") == 0) {
|
||||
GstBuffer *codec_config;
|
||||
gint len;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
entry.fourcc = FOURCC_alac;
|
||||
data = gst_buffer_map ((GstBuffer *) codec_data, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map ((GstBuffer *) codec_data, &map, GST_MAP_READ);
|
||||
/* let's check if codec data already comes with 'alac' atom prefix */
|
||||
if (!codec_data || (len = size) < 28) {
|
||||
if (!codec_data || (len = map.size) < 28) {
|
||||
GST_DEBUG_OBJECT (qtmux, "broken caps, codec data missing");
|
||||
gst_buffer_unmap ((GstBuffer *) codec_data, data, size);
|
||||
gst_buffer_unmap ((GstBuffer *) codec_data, &map);
|
||||
goto refuse_caps;
|
||||
}
|
||||
if (GST_READ_UINT32_LE (data + 4) == FOURCC_alac) {
|
||||
if (GST_READ_UINT32_LE (map.data + 4) == FOURCC_alac) {
|
||||
len -= 8;
|
||||
codec_config =
|
||||
gst_buffer_copy_region ((GstBuffer *) codec_data, 0, 8, len);
|
||||
} else {
|
||||
codec_config = gst_buffer_ref ((GstBuffer *) codec_data);
|
||||
}
|
||||
gst_buffer_unmap ((GstBuffer *) codec_data, data, size);
|
||||
gst_buffer_unmap ((GstBuffer *) codec_data, &map);
|
||||
if (len != 28) {
|
||||
/* does not look good, but perhaps some trailing unneeded stuff */
|
||||
GST_WARNING_OBJECT (qtmux, "unexpected codec-data size, possibly broken");
|
||||
|
@ -2850,10 +2847,10 @@ gst_qt_mux_audio_sink_set_caps (GstPad * pad, GstCaps * caps)
|
|||
else
|
||||
ext_atom = build_codec_data_extension (FOURCC_alac, codec_config);
|
||||
/* set some more info */
|
||||
data = gst_buffer_map (codec_config, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (codec_config, &map, GST_MAP_READ);
|
||||
entry.bytes_per_sample = 2;
|
||||
entry.samples_per_packet = GST_READ_UINT32_BE (data + 4);
|
||||
gst_buffer_unmap (codec_config, data, size);
|
||||
entry.samples_per_packet = GST_READ_UINT32_BE (map.data + 4);
|
||||
gst_buffer_unmap (codec_config, &map);
|
||||
gst_buffer_unref (codec_config);
|
||||
}
|
||||
|
||||
|
|
|
@ -355,15 +355,11 @@ gst_qt_mux_map_format_to_header (GstQTMuxFormat format, GstBuffer ** _prefix,
|
|||
}
|
||||
case GST_QT_MUX_FORMAT_MJ2:
|
||||
{
|
||||
guint8 *bdata;
|
||||
|
||||
major = FOURCC_mjp2;
|
||||
comp = mjp2_brands;
|
||||
version = 0;
|
||||
prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
|
||||
bdata = gst_buffer_map (prefix, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, mjp2_prefix, sizeof (mjp2_prefix));
|
||||
gst_buffer_unmap (prefix, bdata, -1);
|
||||
gst_buffer_fill (prefix, 0, mjp2_prefix, sizeof (mjp2_prefix));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -195,7 +195,6 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
|
|||
GstBuffer *buf;
|
||||
gint size;
|
||||
GstCaps *caps;
|
||||
guint8 *bdata;
|
||||
|
||||
GST_DEBUG_OBJECT (rtpxqtdepay, "found avcC codec_data in sd, %u",
|
||||
chlen);
|
||||
|
@ -207,9 +206,7 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
|
|||
size = len - 8;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (size);
|
||||
bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, data + 8, size);
|
||||
gst_buffer_unmap (buf, bdata, -1);
|
||||
gst_buffer_fill (buf, 0, data + 8, size);
|
||||
caps = gst_caps_new_simple ("video/x-h264",
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -279,8 +276,6 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
guint8 *payload;
|
||||
guint8 ver, pck;
|
||||
gboolean s, q, l, d;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
|
@ -547,9 +542,7 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
{
|
||||
/* multiple samples per packet. */
|
||||
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, payload, payload_len);
|
||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
||||
gst_buffer_fill (outbuf, 0, payload, payload_len);
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
@ -591,9 +584,7 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
slen = payload_len;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (slen);
|
||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, payload, slen);
|
||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
||||
gst_buffer_fill (outbuf, 0, payload, slen);
|
||||
if (!s)
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||
|
||||
|
@ -611,9 +602,7 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
{
|
||||
/* one sample per packet, use adapter to combine based on marker bit. */
|
||||
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, payload, payload_len);
|
||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
||||
gst_buffer_fill (outbuf, 0, payload, payload_len);
|
||||
|
||||
gst_adapter_push (rtpxqtdepay->adapter, outbuf);
|
||||
|
||||
|
|
|
@ -527,10 +527,9 @@ gst_qtdemux_post_no_playable_stream_error (GstQTDemux * qtdemux)
|
|||
}
|
||||
|
||||
static void
|
||||
_gst_buffer_copy_into_mem (GstBuffer * dest, const guint8 * src,
|
||||
gsize offset, gsize size)
|
||||
_gst_buffer_copy_into_mem (GstBuffer * dest, gsize offset, const guint8 * src,
|
||||
gsize size)
|
||||
{
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
|
||||
g_return_if_fail (gst_buffer_is_writable (dest));
|
||||
|
@ -538,9 +537,7 @@ _gst_buffer_copy_into_mem (GstBuffer * dest, const guint8 * src,
|
|||
bsize = gst_buffer_get_size (dest);
|
||||
g_return_if_fail (bsize >= offset + size);
|
||||
|
||||
bdata = gst_buffer_map (dest, &bsize, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata + offset, src, size);
|
||||
gst_buffer_unmap (dest, bdata, bsize);
|
||||
gst_buffer_fill (dest, offset, src, size);
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
|
@ -561,7 +558,7 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
|
|||
GstBuffer ** buf)
|
||||
{
|
||||
GstFlowReturn flow;
|
||||
guint8 *bdata;
|
||||
GstMapInfo map;
|
||||
gsize bsize;
|
||||
|
||||
if (G_UNLIKELY (size == 0)) {
|
||||
|
@ -572,11 +569,11 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
|
|||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
bdata = gst_buffer_map (tmp, &bsize, NULL, GST_MAP_READ);
|
||||
size = QT_UINT32 (bdata);
|
||||
gst_buffer_map (tmp, &map, GST_MAP_READ);
|
||||
size = QT_UINT32 (map.data);
|
||||
GST_DEBUG_OBJECT (qtdemux, "size 0x%08" G_GINT64_MODIFIER "x", size);
|
||||
|
||||
gst_buffer_unmap (tmp, bdata, bsize);
|
||||
gst_buffer_unmap (tmp, &map);
|
||||
gst_buffer_unref (tmp);
|
||||
}
|
||||
|
||||
|
@ -1901,7 +1898,7 @@ qtdemux_parse_ftyp (GstQTDemux * qtdemux, const guint8 * buffer, gint length)
|
|||
GST_DEBUG_OBJECT (qtdemux, "major brand: %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (qtdemux->major_brand));
|
||||
buf = qtdemux->comp_brands = gst_buffer_new_and_alloc (length - 16);
|
||||
_gst_buffer_copy_into_mem (buf, buffer + 16, 0, length - 16);
|
||||
_gst_buffer_copy_into_mem (buf, 0, buffer + 16, length - 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2646,16 +2643,15 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
|||
GstBuffer *buf = NULL;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint64 cur_offset = qtdemux->offset;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, 16, &buf);
|
||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||
goto beach;
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
if (G_LIKELY (size >= 8))
|
||||
extract_initial_length_and_fourcc (data, size, &length, &fourcc);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (G_LIKELY (map.size >= 8))
|
||||
extract_initial_length_and_fourcc (map.data, map.size, &length, &fourcc);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
/* maybe we already got most we needed, so only consider this eof */
|
||||
|
@ -2700,49 +2696,50 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
|||
ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length, &moov);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto beach;
|
||||
data = gst_buffer_map (moov, &size, NULL, GST_MAP_READ);
|
||||
if (length != size) {
|
||||
gst_buffer_map (moov, &map, GST_MAP_READ);
|
||||
if (length != map.size) {
|
||||
/* Some files have a 'moov' atom at the end of the file which contains
|
||||
* a terminal 'free' atom where the body of the atom is missing.
|
||||
* Check for, and permit, this special case.
|
||||
*/
|
||||
if (size >= 8) {
|
||||
guint8 *final_data = data + (size - 8);
|
||||
if (map.size >= 8) {
|
||||
guint8 *final_data = map.data + (map.size - 8);
|
||||
guint32 final_length = QT_UINT32 (final_data);
|
||||
guint32 final_fourcc = QT_FOURCC (final_data + 4);
|
||||
gst_buffer_unmap (moov, data, size);
|
||||
if (final_fourcc == FOURCC_free && size + final_length - 8 == length) {
|
||||
gst_buffer_unmap (moov, &map);
|
||||
if (final_fourcc == FOURCC_free
|
||||
&& map.size + final_length - 8 == length) {
|
||||
/* Ok, we've found that special case. Allocate a new buffer with
|
||||
* that free atom actually present. */
|
||||
GstBuffer *newmoov = gst_buffer_new_and_alloc (length);
|
||||
gst_buffer_copy_into (newmoov, moov, 0, 0, size);
|
||||
data = gst_buffer_map (newmoov, &size, NULL, GST_MAP_WRITE);
|
||||
memset (data + length - final_length + 8, 0, final_length - 8);
|
||||
gst_buffer_copy_into (newmoov, moov, 0, 0, map.size);
|
||||
gst_buffer_map (newmoov, &map, GST_MAP_WRITE);
|
||||
memset (map.data + length - final_length + 8, 0, final_length - 8);
|
||||
gst_buffer_unref (moov);
|
||||
moov = newmoov;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (length != size) {
|
||||
if (length != map.size) {
|
||||
GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
|
||||
(_("This file is incomplete and cannot be played.")),
|
||||
("We got less than expected (received %" G_GSIZE_FORMAT
|
||||
", wanted %u, offset %" G_GUINT64_FORMAT ")", size,
|
||||
", wanted %u, offset %" G_GUINT64_FORMAT ")", map.size,
|
||||
(guint) length, cur_offset));
|
||||
gst_buffer_unmap (moov, data, size);
|
||||
gst_buffer_unmap (moov, &map);
|
||||
gst_buffer_unref (moov);
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto beach;
|
||||
}
|
||||
qtdemux->offset += length;
|
||||
|
||||
qtdemux_parse_moov (qtdemux, data, length);
|
||||
qtdemux_parse_moov (qtdemux, map.data, length);
|
||||
qtdemux_node_dump (qtdemux, qtdemux->moov_node);
|
||||
|
||||
qtdemux_parse_tree (qtdemux);
|
||||
g_node_destroy (qtdemux->moov_node);
|
||||
gst_buffer_unmap (moov, data, size);
|
||||
gst_buffer_unmap (moov, &map);
|
||||
gst_buffer_unref (moov);
|
||||
qtdemux->moov_node = NULL;
|
||||
qtdemux->got_moov = TRUE;
|
||||
|
@ -2758,9 +2755,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
|||
if (ret != GST_FLOW_OK)
|
||||
goto beach;
|
||||
qtdemux->offset += length;
|
||||
data = gst_buffer_map (ftyp, &size, NULL, GST_MAP_READ);
|
||||
qtdemux_parse_ftyp (qtdemux, data, size);
|
||||
gst_buffer_unmap (ftyp, data, size);
|
||||
gst_buffer_map (ftyp, &map, GST_MAP_READ);
|
||||
qtdemux_parse_ftyp (qtdemux, map.data, map.size);
|
||||
gst_buffer_unmap (ftyp, &map);
|
||||
gst_buffer_unref (ftyp);
|
||||
break;
|
||||
}
|
||||
|
@ -2773,9 +2770,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
|||
if (ret != GST_FLOW_OK)
|
||||
goto beach;
|
||||
qtdemux->offset += length;
|
||||
data = gst_buffer_map (uuid, &size, NULL, GST_MAP_READ);
|
||||
qtdemux_parse_uuid (qtdemux, data, size);
|
||||
gst_buffer_unmap (uuid, data, size);
|
||||
gst_buffer_map (uuid, &map, GST_MAP_READ);
|
||||
qtdemux_parse_uuid (qtdemux, map.data, map.size);
|
||||
gst_buffer_unmap (uuid, &map);
|
||||
gst_buffer_unref (uuid);
|
||||
break;
|
||||
}
|
||||
|
@ -2790,9 +2787,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
|||
ret = gst_qtdemux_pull_atom (qtdemux, cur_offset, length, &unknown);
|
||||
if (ret != GST_FLOW_OK)
|
||||
goto beach;
|
||||
data = gst_buffer_map (unknown, &size, NULL, GST_MAP_READ);
|
||||
GST_MEMDUMP ("Unknown tag", data, size);
|
||||
gst_buffer_unmap (unknown, data, size);
|
||||
gst_buffer_map (unknown, &map, GST_MAP_READ);
|
||||
GST_MEMDUMP ("Unknown tag", map.data, map.size);
|
||||
gst_buffer_unmap (unknown, &map);
|
||||
gst_buffer_unref (unknown);
|
||||
qtdemux->offset += length;
|
||||
break;
|
||||
|
@ -3521,9 +3518,8 @@ static GstBuffer *
|
|||
gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||
GstBuffer * buf)
|
||||
{
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
guint nsize = 0;
|
||||
gsize size;
|
||||
gchar *str;
|
||||
|
||||
/* not many cases for now */
|
||||
|
@ -3540,20 +3536,20 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
|||
return buf;
|
||||
}
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (G_LIKELY (size >= 2)) {
|
||||
nsize = GST_READ_UINT16_BE (data);
|
||||
nsize = MIN (nsize, size - 2);
|
||||
if (G_LIKELY (map.size >= 2)) {
|
||||
nsize = GST_READ_UINT16_BE (map.data);
|
||||
nsize = MIN (nsize, map.size - 2);
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%" G_GSIZE_FORMAT "",
|
||||
nsize, size);
|
||||
nsize, map.size);
|
||||
|
||||
/* takes care of UTF-8 validation or UTF-16 recognition,
|
||||
* no other encoding expected */
|
||||
str = gst_tag_freeform_string_to_utf8 ((gchar *) data + 2, nsize, NULL);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
str = gst_tag_freeform_string_to_utf8 ((gchar *) map.data + 2, nsize, NULL);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
if (str) {
|
||||
gst_buffer_unref (buf);
|
||||
buf = _gst_buffer_new_wrapped (str, strlen (str), g_free);
|
||||
|
@ -3581,12 +3577,11 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
|
|||
|
||||
if (G_UNLIKELY (stream->fourcc == FOURCC_rtsp)) {
|
||||
gchar *url;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
url = g_strndup ((gchar *) bdata, bsize);
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
url = g_strndup ((gchar *) map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
if (url != NULL && strlen (url) != 0) {
|
||||
/* we have RTSP redirect now */
|
||||
gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
|
||||
|
@ -4672,19 +4667,19 @@ qtdemux_parse_theora_extension (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
|||
switch (type) {
|
||||
case FOURCC_tCtH:
|
||||
buffer = gst_buffer_new_and_alloc (size);
|
||||
_gst_buffer_copy_into_mem (buffer, buf, 0, size);
|
||||
_gst_buffer_copy_into_mem (buffer, 0, buf, size);
|
||||
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||
GST_LOG_OBJECT (qtdemux, "parsing theora header");
|
||||
break;
|
||||
case FOURCC_tCt_:
|
||||
buffer = gst_buffer_new_and_alloc (size);
|
||||
_gst_buffer_copy_into_mem (buffer, buf, 0, size);
|
||||
_gst_buffer_copy_into_mem (buffer, 0, buf, size);
|
||||
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||
GST_LOG_OBJECT (qtdemux, "parsing theora comment");
|
||||
break;
|
||||
case FOURCC_tCtC:
|
||||
buffer = gst_buffer_new_and_alloc (size);
|
||||
_gst_buffer_copy_into_mem (buffer, buf, 0, size);
|
||||
_gst_buffer_copy_into_mem (buffer, 0, buf, size);
|
||||
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||
GST_LOG_OBJECT (qtdemux, "parsing theora codebook");
|
||||
break;
|
||||
|
@ -5175,8 +5170,7 @@ qtdemux_find_atom (GstQTDemux * qtdemux, guint64 * offset,
|
|||
G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), *offset);
|
||||
|
||||
while (TRUE) {
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
ret = gst_pad_pull_range (qtdemux->sinkpad, *offset, 16, &buf);
|
||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||
|
@ -5187,9 +5181,9 @@ qtdemux_find_atom (GstQTDemux * qtdemux, guint64 * offset,
|
|||
gst_buffer_unref (buf);
|
||||
goto locate_failed;
|
||||
}
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
extract_initial_length_and_fourcc (bdata, 16, length, &lfourcc);
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
extract_initial_length_and_fourcc (map.data, 16, length, &lfourcc);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
if (G_UNLIKELY (*length == 0)) {
|
||||
|
@ -5229,8 +5223,7 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
|
|||
GstBuffer *buf = NULL;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstFlowReturn res = GST_FLOW_OK;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
offset = qtdemux->moof_offset;
|
||||
GST_DEBUG_OBJECT (qtdemux, "next moof at offset %" G_GUINT64_FORMAT, offset);
|
||||
|
@ -5250,15 +5243,15 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
|
|||
ret = gst_qtdemux_pull_atom (qtdemux, offset, length, &buf);
|
||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||
goto flow_failed;
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
if (!qtdemux_parse_moof (qtdemux, bdata, bsize, offset, NULL)) {
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
if (!qtdemux_parse_moof (qtdemux, map.data, map.size, offset, NULL)) {
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
goto parse_failed;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
|
||||
|
@ -6102,7 +6095,7 @@ qtdemux_parse_svq3_stsd_data (GstQTDemux * qtdemux, GNode * stsd,
|
|||
seqh_size = QT_UINT32 (data + 4);
|
||||
if (seqh_size > 0) {
|
||||
_seqh = gst_buffer_new_and_alloc (seqh_size);
|
||||
_gst_buffer_copy_into_mem (_seqh, data + 8, 0, seqh_size);
|
||||
_gst_buffer_copy_into_mem (_seqh, 0, data + 8, seqh_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6259,24 +6252,24 @@ qtdemux_parse_amr_bitrate (GstBuffer * buf, gboolean wb)
|
|||
static const guint wb_bitrates[] = {
|
||||
6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850
|
||||
};
|
||||
guint8 *data;
|
||||
gsize size, max_mode;
|
||||
GstMapInfo map;
|
||||
gsize max_mode;
|
||||
guint16 mode_set;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (size != 0x11) {
|
||||
GST_DEBUG ("Atom should have size 0x11, not %" G_GSIZE_FORMAT, size);
|
||||
if (map.size != 0x11) {
|
||||
GST_DEBUG ("Atom should have size 0x11, not %" G_GSIZE_FORMAT, map.size);
|
||||
goto bad_data;
|
||||
}
|
||||
|
||||
if (QT_FOURCC (data + 4) != GST_MAKE_FOURCC ('d', 'a', 'm', 'r')) {
|
||||
if (QT_FOURCC (map.data + 4) != GST_MAKE_FOURCC ('d', 'a', 'm', 'r')) {
|
||||
GST_DEBUG ("Unknown atom in %" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (QT_UINT32 (data + 4)));
|
||||
GST_FOURCC_ARGS (QT_UINT32 (map.data + 4)));
|
||||
goto bad_data;
|
||||
}
|
||||
|
||||
mode_set = QT_UINT16 (data + 13);
|
||||
mode_set = QT_UINT16 (map.data + 13);
|
||||
|
||||
if (mode_set == (wb ? AMR_WB_ALL_MODES : AMR_NB_ALL_MODES))
|
||||
max_mode = 7 + (wb ? 1 : 0);
|
||||
|
@ -6290,11 +6283,11 @@ qtdemux_parse_amr_bitrate (GstBuffer * buf, gboolean wb)
|
|||
goto bad_data;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return wb ? wb_bitrates[max_mode] : nb_bitrates[max_mode];
|
||||
|
||||
bad_data:
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -6562,7 +6555,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
avc_data + 8 + 1, size - 1);
|
||||
|
||||
buf = gst_buffer_new_and_alloc (size);
|
||||
_gst_buffer_copy_into_mem (buf, avc_data + 0x8, 0, size);
|
||||
_gst_buffer_copy_into_mem (buf, 0, avc_data + 0x8, size);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -6641,7 +6634,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
if (len > 0x8) {
|
||||
len -= 0x8;
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
_gst_buffer_copy_into_mem (buf, data + 8, 0, len);
|
||||
_gst_buffer_copy_into_mem (buf, 0, data + 8, len);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -6825,7 +6818,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
if (len > 0x8) {
|
||||
len -= 0x8;
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
_gst_buffer_copy_into_mem (buf, data + 8, 0, len);
|
||||
_gst_buffer_copy_into_mem (buf, 0, data + 8, len);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -6855,7 +6848,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
|
||||
GST_DEBUG_OBJECT (qtdemux, "found codec_data in stsd");
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
_gst_buffer_copy_into_mem (buf, stsd_data, 0, len);
|
||||
_gst_buffer_copy_into_mem (buf, 0, stsd_data, len);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -6904,7 +6897,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
break;
|
||||
}
|
||||
buf = gst_buffer_new_and_alloc (ovc1_len - 198);
|
||||
_gst_buffer_copy_into_mem (buf, ovc1_data + 198, 0, ovc1_len - 198);
|
||||
_gst_buffer_copy_into_mem (buf, 0, ovc1_data + 198, ovc1_len - 198);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -7118,7 +7111,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
}
|
||||
wfex = (WAVEFORMATEX *) (owma_data + 36);
|
||||
buf = gst_buffer_new_and_alloc (owma_len - 54);
|
||||
_gst_buffer_copy_into_mem (buf, owma_data + 54, 0, owma_len - 54);
|
||||
_gst_buffer_copy_into_mem (buf, 0, owma_data + 54, owma_len - 54);
|
||||
if (wfex->wFormatTag == 0x0161) {
|
||||
codec_name = "Windows Media Audio";
|
||||
version = 2;
|
||||
|
@ -7217,7 +7210,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
headerlen -= 8;
|
||||
|
||||
headerbuf = gst_buffer_new_and_alloc (headerlen);
|
||||
_gst_buffer_copy_into_mem (headerbuf, waveheader, 0, headerlen);
|
||||
_gst_buffer_copy_into_mem (headerbuf, 0, waveheader, headerlen);
|
||||
|
||||
if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux),
|
||||
headerbuf, &header, &extra)) {
|
||||
|
@ -7256,7 +7249,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
if (len > 0x4C) {
|
||||
GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x4C);
|
||||
|
||||
_gst_buffer_copy_into_mem (buf, stsd_data + 0x4C, 0, len - 0x4C);
|
||||
_gst_buffer_copy_into_mem (buf, 0, stsd_data + 0x4C, len - 0x4C);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -7291,7 +7284,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
/* codec-data contains alac atom size and prefix,
|
||||
* ffmpeg likes it that way, not quite gst-ish though ...*/
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
_gst_buffer_copy_into_mem (buf, alac->data, 0, len);
|
||||
_gst_buffer_copy_into_mem (buf, 0, alac->data, len);
|
||||
gst_caps_set_simple (stream->caps,
|
||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -7312,7 +7305,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
|||
GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x34);
|
||||
guint bitrate;
|
||||
|
||||
_gst_buffer_copy_into_mem (buf, stsd_data + 0x34, 0, len - 0x34);
|
||||
_gst_buffer_copy_into_mem (buf, 0, stsd_data + 0x34, len - 0x34);
|
||||
|
||||
/* If we have enough data, let's try to get the 'damr' atom. See
|
||||
* the 3GPP container spec (26.244) for more details. */
|
||||
|
@ -7724,18 +7717,21 @@ qtdemux_is_brand_3gp (GstQTDemux * qtdemux, gboolean major)
|
|||
return ((qtdemux->major_brand & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
|
||||
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
||||
} else if (qtdemux->comp_brands != NULL) {
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
gboolean res = FALSE;
|
||||
|
||||
data = gst_buffer_map (qtdemux->comp_brands, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (qtdemux->comp_brands, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
while (size >= 4) {
|
||||
res = res || ((QT_FOURCC (data) & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
|
||||
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
||||
data += 4;
|
||||
size -= 4;
|
||||
}
|
||||
gst_buffer_unmap (qtdemux->comp_brands, data, size);
|
||||
gst_buffer_unmap (qtdemux->comp_brands, &map);
|
||||
return res;
|
||||
} else {
|
||||
return FALSE;
|
||||
|
@ -8514,7 +8510,7 @@ qtdemux_tag_add_blob (GNode * node, GstQTDemux * demux)
|
|||
data = node->data;
|
||||
len = QT_UINT32 (data);
|
||||
buf = gst_buffer_new_and_alloc (len);
|
||||
_gst_buffer_copy_into_mem (buf, data, 0, len);
|
||||
_gst_buffer_copy_into_mem (buf, 0, data, len);
|
||||
|
||||
/* heuristic to determine style of tag */
|
||||
if (QT_FOURCC (data + 4) == FOURCC_____ ||
|
||||
|
@ -9151,7 +9147,7 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
|||
GstBuffer *buffer;
|
||||
|
||||
buffer = gst_buffer_new_and_alloc (data_len);
|
||||
_gst_buffer_copy_into_mem (buffer, data_ptr, 0, data_len);
|
||||
_gst_buffer_copy_into_mem (buffer, 0, data_ptr, data_len);
|
||||
|
||||
GST_DEBUG_OBJECT (qtdemux, "setting codec_data from esds");
|
||||
GST_MEMDUMP_OBJECT (qtdemux, "codec_data from esds", data_ptr, data_len);
|
||||
|
|
|
@ -307,6 +307,7 @@ static GstFlowReturn
|
|||
gst_alaw_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstALawDec *alawdec;
|
||||
GstMapInfo inmap, outmap;
|
||||
gint16 *linear_data;
|
||||
guint8 *alaw_data;
|
||||
gsize alaw_size;
|
||||
|
@ -322,11 +323,14 @@ gst_alaw_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
GST_LOG_OBJECT (alawdec, "buffer with ts=%" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
||||
|
||||
alaw_data = gst_buffer_map (buffer, &alaw_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
alaw_data = inmap.data;
|
||||
alaw_size = inmap.size;
|
||||
|
||||
outbuf = gst_buffer_new_allocate (NULL, alaw_size, 0);
|
||||
|
||||
linear_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
linear_data = (gint16 *) outmap.data;
|
||||
|
||||
/* copy discont flag */
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
||||
|
@ -339,8 +343,8 @@ gst_alaw_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
linear_data[i] = alaw_to_s16 (alaw_data[i]);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (outbuf, linear_data, -1);
|
||||
gst_buffer_unmap (buffer, alaw_data, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (alawdec->srcpad, outbuf);
|
||||
|
|
|
@ -492,6 +492,7 @@ static GstFlowReturn
|
|||
gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstALawEnc *alawenc;
|
||||
GstMapInfo inmap, outmap;
|
||||
gint16 *linear_data;
|
||||
gsize linear_size;
|
||||
guint8 *alaw_data;
|
||||
|
@ -506,7 +507,9 @@ gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
if (G_UNLIKELY (alawenc->rate == 0 || alawenc->channels == 0))
|
||||
goto not_negotiated;
|
||||
|
||||
linear_data = gst_buffer_map (buffer, &linear_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
linear_data = (gint16 *) inmap.data;
|
||||
linear_size = inmap.size;
|
||||
|
||||
alaw_size = linear_size / 2;
|
||||
|
||||
|
@ -523,7 +526,9 @@ gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
GST_SECOND, alawenc->rate * alawenc->channels);
|
||||
}
|
||||
|
||||
alaw_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
alaw_data = outmap.data;
|
||||
alaw_size = outmap.size;
|
||||
|
||||
/* copy discont flag */
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
||||
|
@ -536,8 +541,8 @@ gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
alaw_data[i] = s16_to_alaw (linear_data[i]);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (outbuf, alaw_data, -1);
|
||||
gst_buffer_unmap (buffer, linear_data, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (alawenc->srcpad, outbuf);
|
||||
|
|
|
@ -240,6 +240,7 @@ static GstFlowReturn
|
|||
gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstMuLawDec *mulawdec;
|
||||
GstMapInfo inmap, outmap;
|
||||
gint16 *linear_data;
|
||||
guint8 *mulaw_data;
|
||||
gsize mulaw_size, linear_size;
|
||||
|
@ -251,12 +252,15 @@ gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
if (G_UNLIKELY (mulawdec->rate == 0))
|
||||
goto not_negotiated;
|
||||
|
||||
mulaw_data = gst_buffer_map (buffer, &mulaw_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
mulaw_data = inmap.data;
|
||||
mulaw_size = inmap.size;
|
||||
|
||||
linear_size = mulaw_size * 2;
|
||||
|
||||
outbuf = gst_buffer_new_allocate (NULL, linear_size, 0);
|
||||
linear_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
linear_data = (gint16 *) outmap.data;
|
||||
|
||||
/* copy discont flag */
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
||||
|
@ -271,8 +275,8 @@ gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
|
||||
mulaw_decode (mulaw_data, linear_data, mulaw_size);
|
||||
|
||||
gst_buffer_unmap (outbuf, linear_data, -1);
|
||||
gst_buffer_unmap (buffer, mulaw_data, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (mulawdec->srcpad, outbuf);
|
||||
|
|
|
@ -239,6 +239,7 @@ static GstFlowReturn
|
|||
gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstMuLawEnc *mulawenc;
|
||||
GstMapInfo inmap, outmap;
|
||||
gint16 *linear_data;
|
||||
gsize linear_size;
|
||||
guint8 *mulaw_data;
|
||||
|
@ -252,7 +253,9 @@ gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
if (!mulawenc->rate || !mulawenc->channels)
|
||||
goto not_negotiated;
|
||||
|
||||
linear_data = gst_buffer_map (buffer, &linear_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &inmap, GST_MAP_READ);
|
||||
linear_data = (gint16 *) inmap.data;
|
||||
linear_size = inmap.size;
|
||||
|
||||
mulaw_size = linear_size / 2;
|
||||
|
||||
|
@ -266,7 +269,8 @@ gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
GST_SECOND, mulawenc->rate * mulawenc->channels);
|
||||
}
|
||||
|
||||
mulaw_data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||
mulaw_data = outmap.data;
|
||||
|
||||
/* copy discont flag */
|
||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
||||
|
@ -277,8 +281,8 @@ gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
|
||||
mulaw_encode (linear_data, mulaw_data, mulaw_size);
|
||||
|
||||
gst_buffer_unmap (outbuf, mulaw_data, -1);
|
||||
gst_buffer_unmap (buffer, linear_data, -1);
|
||||
gst_buffer_unmap (outbuf, &outmap);
|
||||
gst_buffer_unmap (buffer, &inmap);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
ret = gst_pad_push (mulawenc->srcpad, outbuf);
|
||||
|
|
|
@ -534,7 +534,8 @@ static GstFlowReturn
|
|||
gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||
{
|
||||
GstLevel *filter;
|
||||
guint8 *in_data, *data;
|
||||
GstMapInfo map;
|
||||
guint8 *in_data;
|
||||
gsize in_size;
|
||||
gdouble CS;
|
||||
guint i;
|
||||
|
@ -550,7 +551,10 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
|||
bps = GST_AUDIO_INFO_BPS (&filter->info);
|
||||
rate = GST_AUDIO_INFO_RATE (&filter->info);
|
||||
|
||||
in_data = data = gst_buffer_map (in, &in_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (in, &map, GST_MAP_READ);
|
||||
in_data = map.data;
|
||||
in_size = map.size;
|
||||
|
||||
num_int_samples = in_size / bps;
|
||||
|
||||
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
||||
|
@ -678,7 +682,7 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
|||
filter->num_frames = 0;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (in, data, in_size);
|
||||
gst_buffer_unmap (in, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,6 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
|
|||
guint64 offset)
|
||||
{
|
||||
GstEbmlMaster m;
|
||||
gsize buf_size;
|
||||
|
||||
g_return_if_fail (el);
|
||||
g_return_if_fail (buf);
|
||||
|
@ -172,10 +171,10 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
|
|||
ebml->el = el;
|
||||
ebml->offset = offset;
|
||||
ebml->buf = buf;
|
||||
ebml->buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &ebml->map, GST_MAP_READ);
|
||||
ebml->readers = g_array_sized_new (FALSE, FALSE, sizeof (GstEbmlMaster), 10);
|
||||
m.offset = ebml->offset;
|
||||
gst_byte_reader_init (&m.br, ebml->buf_data, buf_size);
|
||||
gst_byte_reader_init (&m.br, ebml->map.data, ebml->map.size);
|
||||
g_array_append_val (ebml->readers, m);
|
||||
}
|
||||
|
||||
|
@ -186,7 +185,7 @@ gst_ebml_read_clear (GstEbmlRead * ebml)
|
|||
g_array_free (ebml->readers, TRUE);
|
||||
ebml->readers = NULL;
|
||||
if (ebml->buf) {
|
||||
gst_buffer_unmap (ebml->buf, ebml->buf_data, -1);
|
||||
gst_buffer_unmap (ebml->buf, &ebml->map);
|
||||
gst_buffer_unref (ebml->buf);
|
||||
}
|
||||
ebml->buf = NULL;
|
||||
|
|
|
@ -54,8 +54,8 @@ typedef struct _GstEbmlRead {
|
|||
GstElement *el;
|
||||
|
||||
GstBuffer *buf;
|
||||
gpointer buf_data;
|
||||
guint64 offset;
|
||||
GstMapInfo map;
|
||||
|
||||
GArray *readers;
|
||||
} GstEbmlRead;
|
||||
|
|
|
@ -285,6 +285,7 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint8 ** data_out, guint size)
|
|||
{
|
||||
/* Create new buffer of size + ID + length */
|
||||
GstBuffer *buf;
|
||||
GstMapInfo map;
|
||||
|
||||
/* length, ID */
|
||||
size += 12;
|
||||
|
@ -292,7 +293,9 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint8 ** data_out, guint size)
|
|||
buf = gst_buffer_new_and_alloc (size);
|
||||
GST_BUFFER_TIMESTAMP (buf) = ebml->timestamp;
|
||||
|
||||
*data_out = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
/* FIXME unmap not possible */
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
*data_out = map.data;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@ -408,6 +411,7 @@ static void
|
|||
gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
|
||||
guint8 * buf_data, guint8 * buf_data_end)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint data_size;
|
||||
|
||||
if (buf_data_end)
|
||||
|
@ -419,21 +423,25 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
|
|||
|
||||
/* if there's no cache, then don't push it! */
|
||||
if (ebml->writing_streamheader) {
|
||||
if (!buf_data)
|
||||
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
if (!buf_data) {
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
buf_data = map.data;
|
||||
}
|
||||
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
|
||||
}
|
||||
if (ebml->cache) {
|
||||
if (!buf_data)
|
||||
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
if (!buf_data) {
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
buf_data = map.data;
|
||||
}
|
||||
gst_byte_writer_put_data (ebml->cache, buf_data, data_size);
|
||||
gst_buffer_unmap (buf, buf_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if (buf_data)
|
||||
gst_buffer_unmap (buf, buf_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
if (ebml->last_write_result == GST_FLOW_OK) {
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
|
|
@ -470,8 +470,7 @@ gst_matroska_demux_reset (GstElement * element)
|
|||
|
||||
if (demux->common.cached_buffer) {
|
||||
if (demux->common.cached_data) {
|
||||
gst_buffer_unmap (demux->common.cached_buffer,
|
||||
demux->common.cached_data, -1);
|
||||
gst_buffer_unmap (demux->common.cached_buffer, &demux->common.cached_map);
|
||||
demux->common.cached_data = NULL;
|
||||
}
|
||||
gst_buffer_unref (demux->common.cached_buffer);
|
||||
|
@ -484,28 +483,28 @@ gst_matroska_demux_reset (GstElement * element)
|
|||
static GstBuffer *
|
||||
gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
|
||||
{
|
||||
gpointer data, buf_data;
|
||||
gsize size, buf_size;
|
||||
GstMapInfo map;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
|
||||
|
||||
GST_DEBUG ("decoding buffer %p", buf);
|
||||
|
||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
g_return_val_if_fail (buf_size > 0, buf);
|
||||
|
||||
data = buf_data;
|
||||
size = buf_size;
|
||||
g_return_val_if_fail (size > 0, buf);
|
||||
|
||||
if (gst_matroska_decode_data (context->encodings, &data, &size,
|
||||
GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME, FALSE)) {
|
||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return gst_buffer_new_wrapped (data, size);
|
||||
} else {
|
||||
GST_DEBUG ("decode data failed");
|
||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1587,6 +1586,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
const guint chunk = 64 * 1024;
|
||||
GstBuffer *buf = NULL;
|
||||
GstMapInfo map;
|
||||
gpointer data = NULL;
|
||||
gsize size;
|
||||
guint64 length;
|
||||
|
@ -1625,7 +1625,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
|||
gint cluster_pos;
|
||||
|
||||
if (buf != NULL) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
}
|
||||
|
@ -1635,7 +1635,9 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
|||
GST_DEBUG_OBJECT (demux,
|
||||
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
||||
gst_buffer_get_size (buf), newpos);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
gst_byte_reader_init (&reader, data, size);
|
||||
resume:
|
||||
cluster_pos = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
|
||||
|
@ -1690,7 +1692,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
|||
}
|
||||
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
}
|
||||
|
@ -2714,6 +2716,7 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
|||
GstMatroskaTrackAudioContext *audiocontext =
|
||||
(GstMatroskaTrackAudioContext *) stream;
|
||||
GstBuffer *newbuf = NULL;
|
||||
GstMapInfo map, outmap;
|
||||
guint8 *buf_data, *data;
|
||||
Wavpack4Header wvh;
|
||||
|
||||
|
@ -2744,7 +2747,8 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
|||
/* block_samples, flags and crc are already in the buffer */
|
||||
newbuf = gst_buffer_new_allocate (NULL, sizeof (Wavpack4Header) - 12, 0);
|
||||
|
||||
data = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
|
||||
data = outmap.data;
|
||||
data[0] = 'w';
|
||||
data[1] = 'v';
|
||||
data[2] = 'p';
|
||||
|
@ -2769,11 +2773,13 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
|||
gsize buf_size, size, out_size = 0;
|
||||
guint32 block_samples, flags, crc, blocksize;
|
||||
|
||||
buf_data = gst_buffer_map (*buf, &buf_size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (*buf, &map, GST_MAP_READ);
|
||||
buf_data = map.data;
|
||||
buf_size = map.size;
|
||||
|
||||
if (buf_size < 4) {
|
||||
GST_ERROR_OBJECT (element, "Too small wavpack buffer");
|
||||
gst_buffer_unmap (*buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (*buf, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
|
@ -2808,12 +2814,14 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
|||
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
|
||||
|
||||
outpos = 0;
|
||||
outdata = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
|
||||
outdata = outmap.data;
|
||||
} else {
|
||||
gst_buffer_unmap (newbuf, outdata, out_size);
|
||||
gst_buffer_unmap (newbuf, &outmap);
|
||||
out_size += sizeof (Wavpack4Header) + blocksize;
|
||||
gst_buffer_set_size (newbuf, out_size);
|
||||
outdata = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
|
||||
outdata = outmap.data;
|
||||
}
|
||||
|
||||
outdata[outpos] = 'w';
|
||||
|
@ -2839,11 +2847,11 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
|||
data += blocksize;
|
||||
size -= blocksize;
|
||||
}
|
||||
gst_buffer_unmap (*buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (*buf, &map);
|
||||
gst_buffer_unref (*buf);
|
||||
|
||||
if (newbuf)
|
||||
gst_buffer_unmap (newbuf, outdata, out_size);
|
||||
gst_buffer_unmap (newbuf, &outmap);
|
||||
|
||||
*buf = newbuf;
|
||||
audiocontext->wvpk_block_index += block_samples;
|
||||
|
@ -2893,20 +2901,15 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
|
|||
GError *err = NULL;
|
||||
GstBuffer *newbuf;
|
||||
gchar *utf8;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
sub_stream = (GstMatroskaTrackSubtitleContext *) stream;
|
||||
|
||||
data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
|
||||
|
||||
if (!data) {
|
||||
gst_buffer_unmap (*buf, data, -1);
|
||||
if (!gst_buffer_map (*buf, &map, GST_MAP_READ))
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
if (!sub_stream->invalid_utf8) {
|
||||
if (g_utf8_validate (data, size, NULL)) {
|
||||
if (g_utf8_validate ((gchar *) map.data, map.size, NULL)) {
|
||||
goto next;
|
||||
}
|
||||
GST_WARNING_OBJECT (element, "subtitle stream %d is not valid UTF-8, this "
|
||||
|
@ -2924,8 +2927,9 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
|
|||
}
|
||||
}
|
||||
|
||||
utf8 = g_convert_with_fallback (data, size, "UTF-8", encoding, (char *) "*",
|
||||
NULL, NULL, &err);
|
||||
utf8 =
|
||||
g_convert_with_fallback ((gchar *) map.data, map.size, "UTF-8", encoding,
|
||||
(char *) "*", NULL, NULL, &err);
|
||||
|
||||
if (err) {
|
||||
GST_LOG_OBJECT (element, "could not convert string from '%s' to UTF-8: %s",
|
||||
|
@ -2935,8 +2939,9 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
|
|||
|
||||
/* invalid input encoding, fall back to ISO-8859-15 (always succeeds) */
|
||||
encoding = "ISO-8859-15";
|
||||
utf8 = g_convert_with_fallback (data, size, "UTF-8", encoding, (char *) "*",
|
||||
NULL, NULL, NULL);
|
||||
utf8 =
|
||||
g_convert_with_fallback ((gchar *) map.data, map.size, "UTF-8",
|
||||
encoding, (char *) "*", NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (element, "converted subtitle text from %s to UTF-8 %s",
|
||||
|
@ -2949,28 +2954,27 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
|
|||
gst_buffer_copy_into (newbuf, *buf,
|
||||
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_META,
|
||||
0, -1);
|
||||
gst_buffer_unmap (*buf, data, size);
|
||||
|
||||
gst_buffer_unmap (*buf, &map);
|
||||
gst_buffer_unref (*buf);
|
||||
|
||||
*buf = newbuf;
|
||||
data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (*buf, &map, GST_MAP_READ);
|
||||
|
||||
next:
|
||||
if (sub_stream->check_markup) {
|
||||
/* caps claim markup text, so we need to escape text,
|
||||
* except if text is already markup and then needs no further escaping */
|
||||
sub_stream->seen_markup_tag = sub_stream->seen_markup_tag ||
|
||||
gst_matroska_demux_subtitle_chunk_has_tag (element, data);
|
||||
gst_matroska_demux_subtitle_chunk_has_tag (element, (gchar *) map.data);
|
||||
|
||||
if (!sub_stream->seen_markup_tag) {
|
||||
utf8 = g_markup_escape_text (data, size);
|
||||
utf8 = g_markup_escape_text ((gchar *) map.data, map.size);
|
||||
|
||||
newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
|
||||
gst_buffer_copy_into (newbuf, *buf,
|
||||
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS |
|
||||
GST_BUFFER_COPY_META, 0, -1);
|
||||
gst_buffer_unmap (*buf, data, size);
|
||||
gst_buffer_unmap (*buf, &map);
|
||||
gst_buffer_unref (*buf);
|
||||
|
||||
*buf = newbuf;
|
||||
|
@ -3017,38 +3021,36 @@ static GstBuffer *
|
|||
gst_matroska_demux_align_buffer (GstMatroskaDemux * demux,
|
||||
GstBuffer * buffer, gsize alignment)
|
||||
{
|
||||
gpointer data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
if (size < sizeof (guintptr)) {
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
if (map.size < sizeof (guintptr)) {
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
if (((guintptr) data) & (alignment - 1)) {
|
||||
if (((guintptr) map.data) & (alignment - 1)) {
|
||||
GstBuffer *new_buffer;
|
||||
gpointer new_data;
|
||||
|
||||
new_buffer = gst_buffer_new_allocate (NULL,
|
||||
gst_buffer_get_size (buffer), alignment);
|
||||
|
||||
/* Copy data "by hand", so ensure alignment is kept: */
|
||||
new_data = gst_buffer_map (new_buffer, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (new_data, data, size);
|
||||
gst_buffer_unmap (new_buffer, new_data, -1);
|
||||
gst_buffer_fill (new_buffer, 0, map.data, map.size);
|
||||
|
||||
gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
||||
GST_DEBUG_OBJECT (demux,
|
||||
"We want output aligned on %" G_GSIZE_FORMAT ", reallocated",
|
||||
alignment);
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return new_buffer;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -3063,8 +3065,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
|||
guint32 id;
|
||||
guint64 block_duration = -1;
|
||||
GstBuffer *buf = NULL;
|
||||
gpointer buf_data = NULL;
|
||||
gsize buf_size;
|
||||
GstMapInfo map;
|
||||
gint stream_num = -1, n, laces = 0;
|
||||
guint size = 0;
|
||||
gint *lace_size = NULL;
|
||||
|
@ -3095,16 +3096,16 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
|||
guint8 *data;
|
||||
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
}
|
||||
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
|
||||
break;
|
||||
|
||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
||||
data = buf_data;
|
||||
size = buf_size;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
/* first byte(s): blocknum */
|
||||
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
||||
|
@ -3637,7 +3638,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
|||
|
||||
done:
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
g_free (lace_size);
|
||||
|
@ -5305,8 +5306,11 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
|
|||
|
||||
/* make up decoder-specific data if it is not supplied */
|
||||
if (priv == NULL) {
|
||||
GstMapInfo map;
|
||||
|
||||
priv = gst_buffer_new_allocate (NULL, 5, 0);
|
||||
data = gst_buffer_map (priv, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (priv, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
rate_idx = aac_rate_idx (audiocontext->samplerate);
|
||||
profile = aac_profile_idx (codec_id);
|
||||
|
||||
|
@ -5316,7 +5320,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
|
|||
if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2,
|
||||
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2))) {
|
||||
mpegversion = 2;
|
||||
gst_buffer_unmap (priv, data, 5);
|
||||
gst_buffer_unmap (priv, &map);
|
||||
gst_buffer_set_size (priv, 2);
|
||||
} else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4,
|
||||
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4))) {
|
||||
|
@ -5329,13 +5333,13 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
|
|||
data[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
|
||||
data[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
|
||||
data[4] = (1 << 7) | (rate_idx << 3);
|
||||
gst_buffer_unmap (priv, data, 5);
|
||||
gst_buffer_unmap (priv, &map);
|
||||
} else {
|
||||
gst_buffer_unmap (priv, data, 5);
|
||||
gst_buffer_unmap (priv, &map);
|
||||
gst_buffer_set_size (priv, 2);
|
||||
}
|
||||
} else {
|
||||
gst_buffer_unmap (priv, data, 5);
|
||||
gst_buffer_unmap (priv, &map);
|
||||
gst_buffer_unref (priv);
|
||||
priv = NULL;
|
||||
GST_ERROR ("Unknown AAC profile and no codec private data");
|
||||
|
|
|
@ -1290,14 +1290,15 @@ vorbis_streamheader_to_codecdata (const GValue * streamheader,
|
|||
} else {
|
||||
if (gst_buffer_memcmp (buf0, 1, "vorbis", 6) == 0) {
|
||||
GstMatroskaTrackAudioContext *audiocontext;
|
||||
guint8 *data, *hdr;
|
||||
GstMapInfo map;
|
||||
guint8 *hdr;
|
||||
|
||||
data = gst_buffer_map (buf0, NULL, NULL, GST_MAP_READ);
|
||||
hdr = data + 1 + 6 + 4;
|
||||
gst_buffer_map (buf0, &map, GST_MAP_READ);
|
||||
hdr = map.data + 1 + 6 + 4;
|
||||
audiocontext = (GstMatroskaTrackAudioContext *) context;
|
||||
audiocontext->channels = GST_READ_UINT8 (hdr);
|
||||
audiocontext->samplerate = GST_READ_UINT32_LE (hdr + 1);
|
||||
gst_buffer_unmap (buf0, data, -1);
|
||||
gst_buffer_unmap (buf0, &map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1323,10 +1324,11 @@ theora_streamheader_to_codecdata (const GValue * streamheader,
|
|||
} else {
|
||||
GstMatroskaTrackVideoContext *videocontext;
|
||||
guint fps_num, fps_denom, par_num, par_denom;
|
||||
guint8 *data, *hdr;
|
||||
GstMapInfo map;
|
||||
guint8 *hdr;
|
||||
|
||||
data = gst_buffer_map (buf0, NULL, NULL, GST_MAP_READ);
|
||||
hdr = data + 1 + 6 + 3 + 2 + 2;
|
||||
gst_buffer_map (buf0, &map, GST_MAP_READ);
|
||||
hdr = map.data + 1 + 6 + 3 + 2 + 2;
|
||||
|
||||
videocontext = (GstMatroskaTrackVideoContext *) context;
|
||||
videocontext->pixel_width = GST_READ_UINT32_BE (hdr) >> 8;
|
||||
|
@ -1358,7 +1360,7 @@ theora_streamheader_to_codecdata (const GValue * streamheader,
|
|||
}
|
||||
hdr += 3 + 3;
|
||||
|
||||
gst_buffer_unmap (buf0, data, -1);
|
||||
gst_buffer_unmap (buf0, &map);
|
||||
}
|
||||
|
||||
if (buf0)
|
||||
|
@ -2008,26 +2010,26 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
|
|||
if (value)
|
||||
buf = gst_value_get_buffer (value);
|
||||
if (buf != NULL) {
|
||||
guint8 *priv_data = NULL, *priv_buffer_data;
|
||||
gsize priv_data_size = 0;
|
||||
GstMapInfo map;
|
||||
guint8 *priv_data = NULL;
|
||||
|
||||
priv_buffer_data =
|
||||
gst_buffer_map (buf, &priv_data_size, NULL, GST_MAP_READ);
|
||||
if (priv_data_size > SUBTITLE_MAX_CODEC_PRIVATE) {
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (map.size > SUBTITLE_MAX_CODEC_PRIVATE) {
|
||||
GST_WARNING_OBJECT (mux, "pad %" GST_PTR_FORMAT " subtitle private data"
|
||||
" exceeded maximum (%d); discarding", pad,
|
||||
SUBTITLE_MAX_CODEC_PRIVATE);
|
||||
gst_buffer_unmap (buf, priv_data, priv_data_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gst_matroska_mux_free_codec_priv (context);
|
||||
|
||||
priv_data = g_malloc0 (priv_data_size);
|
||||
memcpy (priv_data, priv_buffer_data, priv_data_size);
|
||||
priv_data = g_malloc0 (map.size);
|
||||
memcpy (priv_data, map.data, map.size);
|
||||
context->codec_priv = priv_data;
|
||||
context->codec_priv_size = priv_data_size;
|
||||
gst_buffer_unmap (buf, priv_buffer_data, priv_data_size);
|
||||
context->codec_priv_size = map.size;
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "codec_id %s, codec data size %" G_GSIZE_FORMAT,
|
||||
|
@ -2763,18 +2765,20 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
|
|||
{
|
||||
GstMatroskaTrackVideoContext *ctx =
|
||||
(GstMatroskaTrackVideoContext *) collect_pad->track;
|
||||
guint8 *buf_data, *data;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint8 parse_code;
|
||||
guint32 next_parse_offset;
|
||||
GstBuffer *ret = NULL;
|
||||
gboolean is_muxing_unit = FALSE;
|
||||
|
||||
buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
data = buf_data;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
if (size < 13) {
|
||||
gst_buffer_unmap (buf, buf_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return ret;
|
||||
}
|
||||
|
@ -2782,7 +2786,7 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
|
|||
/* Check if this buffer contains a picture or end-of-sequence packet */
|
||||
while (size >= 13) {
|
||||
if (GST_READ_UINT32_BE (data) != 0x42424344 /* 'BBCD' */ ) {
|
||||
gst_buffer_unmap (buf, buf_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return ret;
|
||||
}
|
||||
|
@ -2813,7 +2817,7 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
|
|||
else
|
||||
ctx->dirac_unit = gst_buffer_ref (buf);
|
||||
|
||||
gst_buffer_unmap (buf, buf_data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
if (is_muxing_unit) {
|
||||
ret = gst_buffer_make_writable (ctx->dirac_unit);
|
||||
|
|
|
@ -1230,6 +1230,7 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
const guint chunk = 64 * 1024;
|
||||
GstBuffer *buf = NULL;
|
||||
GstMapInfo map;
|
||||
gpointer data;
|
||||
gsize size;
|
||||
guint64 length;
|
||||
|
@ -1249,7 +1250,9 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
|
|||
GST_DEBUG_OBJECT (parse,
|
||||
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
||||
gst_buffer_get_size (buf), newpos);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
gst_byte_reader_init (&reader, data, size);
|
||||
cluster_pos = 0;
|
||||
resume:
|
||||
|
@ -1297,14 +1300,14 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
|
|||
} else {
|
||||
/* partial cluster id may have been in tail of buffer */
|
||||
newpos += MAX (size, 4) - 3;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
buf = NULL;
|
||||
}
|
||||
|
@ -1621,8 +1624,7 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
|
|||
guint32 id;
|
||||
guint64 block_duration = 0;
|
||||
GstBuffer *buf = NULL;
|
||||
gpointer buf_data = NULL;
|
||||
gsize buf_size = 0;
|
||||
GstMapInfo map;
|
||||
gint stream_num = -1, n, laces = 0;
|
||||
guint size = 0;
|
||||
gint *lace_size = NULL;
|
||||
|
@ -1656,10 +1658,9 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
|
|||
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
|
||||
break;
|
||||
|
||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
||||
|
||||
data = buf_data;
|
||||
size = buf_size;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
/* first byte(s): blocknum */
|
||||
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
||||
|
@ -2125,7 +2126,7 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
|
|||
|
||||
done:
|
||||
if (buf) {
|
||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
g_free (lace_size);
|
||||
|
|
|
@ -1615,16 +1615,18 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
|
|||
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||
GST_BUFFER_COPY_ALL, common->offset - cache_offset, size);
|
||||
if (bytes) {
|
||||
if (!common->cached_data)
|
||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
||||
NULL, NULL, GST_MAP_READ);
|
||||
if (!common->cached_data) {
|
||||
gst_buffer_map (common->cached_buffer, &common->cached_map,
|
||||
GST_MAP_READ);
|
||||
common->cached_data = common->cached_map.data;
|
||||
}
|
||||
*bytes = common->cached_data + common->offset - cache_offset;
|
||||
}
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
/* not enough data in the cache, free cache and get a new one */
|
||||
if (common->cached_data) {
|
||||
gst_buffer_unmap (common->cached_buffer, common->cached_data, -1);
|
||||
gst_buffer_unmap (common->cached_buffer, &common->cached_map);
|
||||
common->cached_data = NULL;
|
||||
}
|
||||
gst_buffer_unref (common->cached_buffer);
|
||||
|
@ -1644,8 +1646,8 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
|
|||
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||
GST_BUFFER_COPY_ALL, 0, size);
|
||||
if (bytes) {
|
||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
||||
NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (common->cached_buffer, &common->cached_map, GST_MAP_READ);
|
||||
common->cached_data = common->cached_map.data;
|
||||
*bytes = common->cached_data;
|
||||
}
|
||||
return GST_FLOW_OK;
|
||||
|
@ -1686,8 +1688,8 @@ gst_matroska_read_common_peek_bytes (GstMatroskaReadCommon * common, guint64
|
|||
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||
GST_BUFFER_COPY_ALL, 0, size);
|
||||
if (bytes) {
|
||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
||||
NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (common->cached_buffer, &common->cached_map, GST_MAP_READ);
|
||||
common->cached_data = common->cached_map.data;
|
||||
*bytes = common->cached_data;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ typedef struct _GstMatroskaReadCommon {
|
|||
/* pull mode caching */
|
||||
GstBuffer *cached_buffer;
|
||||
guint8 *cached_data;
|
||||
GstMapInfo cached_map;
|
||||
|
||||
/* push and pull mode */
|
||||
guint64 offset;
|
||||
|
|
|
@ -487,19 +487,18 @@ gst_multi_file_sink_write_stream_headers (GstMultiFileSink * sink)
|
|||
|
||||
for (i = 0; i < sink->n_streamheaders; i++) {
|
||||
GstBuffer *hdr;
|
||||
guint8 *sdata;
|
||||
gsize ssize;
|
||||
GstMapInfo map;
|
||||
int ret;
|
||||
|
||||
hdr = sink->streamheaders[i];
|
||||
sdata = gst_buffer_map (hdr, &ssize, NULL, GST_MAP_READ);
|
||||
ret = fwrite (sdata, ssize, 1, sink->file);
|
||||
gst_buffer_unmap (hdr, sdata, ssize);
|
||||
gst_buffer_map (hdr, &map, GST_MAP_READ);
|
||||
ret = fwrite (map.data, map.size, 1, sink->file);
|
||||
gst_buffer_unmap (hdr, &map);
|
||||
|
||||
if (ret != 1)
|
||||
return FALSE;
|
||||
|
||||
sink->cur_file_size += ssize;
|
||||
sink->cur_file_size += map.size;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -509,13 +508,12 @@ static GstFlowReturn
|
|||
gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||
{
|
||||
GstMultiFileSink *multifilesink;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gchar *filename;
|
||||
gboolean ret;
|
||||
GError *error = NULL;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
multifilesink = GST_MULTI_FILE_SINK (sink);
|
||||
|
||||
|
@ -525,7 +523,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
|
||||
filename = g_strdup_printf (multifilesink->filename,
|
||||
multifilesink->index);
|
||||
ret = g_file_set_contents (filename, (char *) data, size, &error);
|
||||
ret = g_file_set_contents (filename, (char *) map.data, map.size, &error);
|
||||
if (!ret)
|
||||
goto write_error;
|
||||
|
||||
|
@ -547,7 +545,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
goto stdio_write_error;
|
||||
}
|
||||
|
||||
ret = fwrite (data, size, 1, multifilesink->file);
|
||||
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||
if (ret != 1)
|
||||
goto stdio_write_error;
|
||||
|
||||
|
@ -576,7 +574,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
gst_multi_file_sink_write_stream_headers (multifilesink);
|
||||
}
|
||||
|
||||
ret = fwrite (data, size, 1, multifilesink->file);
|
||||
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||
if (ret != 1)
|
||||
goto stdio_write_error;
|
||||
|
||||
|
@ -590,7 +588,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
if (!gst_multi_file_sink_write_stream_headers (multifilesink))
|
||||
goto stdio_write_error;
|
||||
|
||||
ret = fwrite (data, size, 1, multifilesink->file);
|
||||
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||
|
||||
if (ret != 1)
|
||||
goto stdio_write_error;
|
||||
|
@ -599,7 +597,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
case GST_MULTI_FILE_SINK_NEXT_MAX_SIZE:{
|
||||
guint64 new_size;
|
||||
|
||||
new_size = multifilesink->cur_file_size + size;
|
||||
new_size = multifilesink->cur_file_size + map.size;
|
||||
if (new_size > multifilesink->max_file_size) {
|
||||
|
||||
GST_INFO_OBJECT (multifilesink, "current size: %" G_GUINT64_FORMAT
|
||||
|
@ -618,19 +616,19 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
|||
gst_multi_file_sink_write_stream_headers (multifilesink);
|
||||
}
|
||||
|
||||
ret = fwrite (data, size, 1, multifilesink->file);
|
||||
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||
|
||||
if (ret != 1)
|
||||
goto stdio_write_error;
|
||||
|
||||
multifilesink->cur_file_size += size;
|
||||
multifilesink->cur_file_size += map.size;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERRORS */
|
||||
|
@ -651,7 +649,7 @@ write_error:
|
|||
g_error_free (error);
|
||||
g_free (filename);
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
stdio_write_error:
|
||||
|
@ -664,7 +662,7 @@ stdio_write_error:
|
|||
GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
|
||||
("Error while writing to file."), ("%s", g_strerror (errno)));
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -472,6 +472,7 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
|
|||
GstBuffer *buf;
|
||||
GError *err = NULL;
|
||||
guint64 read_offset;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint to_read;
|
||||
|
||||
|
@ -490,7 +491,8 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
|
|||
|
||||
GST_BUFFER_OFFSET (buf) = offset;
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
|
||||
cancel = src->cancellable;
|
||||
|
||||
|
@ -553,7 +555,7 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
|
|||
|
||||
GST_BUFFER_OFFSET_END (buf) = offset;
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
*buffer = buf;
|
||||
GST_LOG_OBJECT (src, "read %" G_GSIZE_FORMAT " bytes into buf %p",
|
||||
|
|
|
@ -461,8 +461,7 @@ static GstFlowReturn
|
|||
gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||
{
|
||||
GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
|
||||
g_return_val_if_fail (filter->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
|
||||
|
@ -470,13 +469,14 @@ gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
if (filter->skip)
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT,
|
||||
map.size);
|
||||
|
||||
rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
|
||||
filter->analyze (filter->ctx, data, size, filter->depth);
|
||||
filter->analyze (filter->ctx, map.data, map.size, filter->depth);
|
||||
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
{
|
||||
GstRgLimiter *filter = GST_RG_LIMITER (base);
|
||||
gfloat *input;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
guint count;
|
||||
guint i;
|
||||
|
||||
|
@ -183,8 +183,8 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
|
||||
return GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
||||
input = (gfloat *) data;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
input = (gfloat *) map.data;
|
||||
count = gst_buffer_get_size (buf) / sizeof (gfloat);
|
||||
|
||||
for (i = count; i--;) {
|
||||
|
@ -195,7 +195,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
|||
input++;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
guint32 samples;
|
||||
guint16 asterisk_len;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||
|
||||
|
@ -162,14 +162,14 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
|||
samples = timestamp - asteriskh263->lastts;
|
||||
asteriskh263->lastts = timestamp;
|
||||
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
GST_ASTERISKH263_HEADER_TIMESTAMP (data) = g_htonl (samples);
|
||||
GST_ASTERISKH263_HEADER_LENGTH (data) = g_htons (asterisk_len);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
GST_ASTERISKH263_HEADER_TIMESTAMP (map.data) = g_htonl (samples);
|
||||
GST_ASTERISKH263_HEADER_LENGTH (map.data) = g_htons (asterisk_len);
|
||||
|
||||
/* copy the data into place */
|
||||
memcpy (data + GST_ASTERISKH263_HEADER_LEN, payload, payload_len);
|
||||
memcpy (map.data + GST_ASTERISKH263_HEADER_LEN, payload, payload_len);
|
||||
|
||||
gst_buffer_unmap (outbuf, data, -1);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||
if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
|
||||
|
|
|
@ -321,14 +321,15 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
{
|
||||
GstRtpAC3Pay *rtpac3pay;
|
||||
GstFlowReturn ret;
|
||||
gsize size, avail, left, NF;
|
||||
guint8 *data, *p;
|
||||
gsize avail, left, NF;
|
||||
GstMapInfo map;
|
||||
guint8 *p;
|
||||
guint packet_len;
|
||||
GstClockTime duration, timestamp;
|
||||
|
||||
rtpac3pay = GST_RTP_AC3_PAY (basepayload);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
|
@ -339,8 +340,8 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* count the amount of incomming packets */
|
||||
NF = 0;
|
||||
left = size;
|
||||
p = data;
|
||||
left = map.size;
|
||||
p = map.data;
|
||||
while (TRUE) {
|
||||
guint bsid, fscod, frmsizecod, frame_size;
|
||||
|
||||
|
@ -373,7 +374,7 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
p += frame_size;
|
||||
left -= frame_size;
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
if (NF == 0)
|
||||
goto no_frames;
|
||||
|
||||
|
@ -381,7 +382,7 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* get packet length of previous data and this new data,
|
||||
* payload length includes a 4 byte header */
|
||||
packet_len = gst_rtp_buffer_calc_packet_len (2 + avail + size, 0, 0);
|
||||
packet_len = gst_rtp_buffer_calc_packet_len (2 + avail + map.size, 0, 0);
|
||||
|
||||
/* if this buffer is going to overflow the packet, flush what we
|
||||
* have. */
|
||||
|
|
|
@ -273,8 +273,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf = NULL;
|
||||
gint payload_len;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
guint8 *odata;
|
||||
gsize osize;
|
||||
GstMapInfo map;
|
||||
|
||||
rtpamrdepay = GST_RTP_AMR_DEPAY (depayload);
|
||||
|
||||
|
@ -375,10 +374,10 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||
|
||||
/* point to destination */
|
||||
odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
|
||||
/* point to first data packet */
|
||||
p = odata;
|
||||
p = map.data;
|
||||
dp = payload + num_packets;
|
||||
if (rtpamrdepay->crc) {
|
||||
/* skip CRC if present */
|
||||
|
@ -400,7 +399,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
dp += fr_size;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (outbuf, odata, osize);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
/* we can set the duration because each packet is 20 milliseconds */
|
||||
GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;
|
||||
|
|
|
@ -228,9 +228,9 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
const gint *frame_size;
|
||||
GstFlowReturn ret;
|
||||
guint payload_len;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *payload, *data, *ptr, *payload_amr;
|
||||
guint8 *payload, *ptr, *payload_amr;
|
||||
GstClockTime timestamp, duration;
|
||||
guint packet_len, mtu;
|
||||
gint i, num_packets, num_nonempty_packets;
|
||||
|
@ -241,7 +241,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
rtpamrpay = GST_RTP_AMR_PAY (basepayload);
|
||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpamrpay);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
@ -252,7 +252,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
else
|
||||
frame_size = wb_frame_size;
|
||||
|
||||
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
|
||||
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", map.size);
|
||||
|
||||
/* FIXME, only
|
||||
* octet aligned, no interleaving, single channel, no CRC,
|
||||
|
@ -261,11 +261,11 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* first count number of packets and total amr frame size */
|
||||
amr_len = num_packets = num_nonempty_packets = 0;
|
||||
for (i = 0; i < size; i++) {
|
||||
for (i = 0; i < map.size; i++) {
|
||||
guint8 FT;
|
||||
gint fr_size;
|
||||
|
||||
FT = (data[i] & 0x78) >> 3;
|
||||
FT = (map.data[i] & 0x78) >> 3;
|
||||
|
||||
fr_size = frame_size[FT];
|
||||
GST_DEBUG_OBJECT (basepayload, "frame type %d, frame size %d", FT, fr_size);
|
||||
|
@ -281,12 +281,12 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
num_packets++;
|
||||
i += fr_size;
|
||||
}
|
||||
if (amr_len > size)
|
||||
if (amr_len > map.size)
|
||||
goto incomplete_frame;
|
||||
|
||||
/* we need one extra byte for the CMR, the ToC is in the input
|
||||
* data */
|
||||
payload_len = size + 1;
|
||||
payload_len = map.size + 1;
|
||||
|
||||
/* get packet len to check against MTU */
|
||||
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
|
||||
|
@ -343,7 +343,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* copy data in payload, first we copy all the FTs then all
|
||||
* the AMR data. The last FT has to have the F flag cleared. */
|
||||
ptr = data;
|
||||
ptr = map.data;
|
||||
for (i = 1; i <= num_packets; i++) {
|
||||
guint8 FT;
|
||||
gint fr_size;
|
||||
|
@ -371,7 +371,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
payload_amr += fr_size;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
@ -385,7 +385,7 @@ wrong_size:
|
|||
{
|
||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||
(NULL), ("received AMR frame with size <= 0"));
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return GST_FLOW_ERROR;
|
||||
|
@ -394,7 +394,7 @@ incomplete_frame:
|
|||
{
|
||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||
(NULL), ("received incomplete AMR frames"));
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return GST_FLOW_ERROR;
|
||||
|
@ -403,7 +403,7 @@ too_big:
|
|||
{
|
||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||
(NULL), ("received too many AMR frames for MTU"));
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return GST_FLOW_ERROR;
|
||||
|
|
|
@ -119,8 +119,8 @@ gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
GstRtpCELTDepay *rtpceltdepay;
|
||||
gint clock_rate, nb_channels = 0, frame_size = 0;
|
||||
GstBuffer *buf;
|
||||
guint8 *data, *ptr;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *ptr;
|
||||
const gchar *params;
|
||||
GstCaps *srccaps;
|
||||
gboolean res;
|
||||
|
@ -149,7 +149,8 @@ gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
|
||||
/* construct minimal header and comment packet for the decoder */
|
||||
buf = gst_buffer_new_and_alloc (60);
|
||||
ptr = data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
ptr = map.data;
|
||||
memcpy (ptr, "CELT ", 8);
|
||||
ptr += 8;
|
||||
memcpy (ptr, "1.1.12", 7);
|
||||
|
@ -169,7 +170,7 @@ gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
GST_WRITE_UINT32_LE (ptr, -1); /* bytes_per_packet */
|
||||
ptr += 4;
|
||||
GST_WRITE_UINT32_LE (ptr, 0); /* extra headers */
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
srccaps = gst_caps_new_empty_simple ("audio/x-celt");
|
||||
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
||||
|
|
|
@ -365,8 +365,8 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
{
|
||||
GstFlowReturn ret;
|
||||
GstRtpCELTPay *rtpceltpay;
|
||||
gsize size, payload_len;
|
||||
guint8 *data;
|
||||
gsize payload_len;
|
||||
GstMapInfo map;
|
||||
GstClockTime duration, packet_dur;
|
||||
guint i, ssize, packet_len;
|
||||
|
||||
|
@ -374,13 +374,13 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
ret = GST_FLOW_OK;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
switch (rtpceltpay->packet) {
|
||||
case 0:
|
||||
/* ident packet. We need to parse the headers to construct the RTP
|
||||
* properties. */
|
||||
if (!gst_rtp_celt_pay_parse_ident (rtpceltpay, data, size))
|
||||
if (!gst_rtp_celt_pay_parse_ident (rtpceltpay, map.data, map.size))
|
||||
goto parse_error;
|
||||
|
||||
goto cleanup;
|
||||
|
@ -391,23 +391,23 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
/* other packets go in the payload */
|
||||
break;
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
GST_LOG_OBJECT (rtpceltpay,
|
||||
"got buffer of duration %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT,
|
||||
GST_TIME_ARGS (duration), size);
|
||||
GST_TIME_ARGS (duration), map.size);
|
||||
|
||||
/* calculate the size of the size field and the payload */
|
||||
ssize = 1;
|
||||
for (i = size; i > 0xff; i -= 0xff)
|
||||
for (i = map.size; i > 0xff; i -= 0xff)
|
||||
ssize++;
|
||||
|
||||
GST_DEBUG_OBJECT (rtpceltpay, "bytes for size %u", ssize);
|
||||
|
||||
/* calculate what the new size and duration would be of the packet */
|
||||
payload_len = ssize + size + rtpceltpay->bytes + rtpceltpay->sbytes;
|
||||
payload_len = ssize + map.size + rtpceltpay->bytes + rtpceltpay->sbytes;
|
||||
if (rtpceltpay->qduration != -1 && duration != -1)
|
||||
packet_dur = rtpceltpay->qduration + duration;
|
||||
else
|
||||
|
@ -421,7 +421,7 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
}
|
||||
|
||||
/* queue the packet */
|
||||
gst_rtp_celt_pay_add_queued (rtpceltpay, buffer, ssize, size, duration);
|
||||
gst_rtp_celt_pay_add_queued (rtpceltpay, buffer, ssize, map.size, duration);
|
||||
|
||||
done:
|
||||
rtpceltpay->packet++;
|
||||
|
@ -431,14 +431,14 @@ done:
|
|||
/* ERRORS */
|
||||
cleanup:
|
||||
{
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
goto done;
|
||||
}
|
||||
parse_error:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
|
||||
("Error parsing first identification packet."));
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,8 +167,6 @@ gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
gint clock_rate;
|
||||
gboolean systemstream, ret;
|
||||
const gchar *encode, *media;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
|
||||
|
||||
|
@ -213,9 +211,7 @@ gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
/* Initialize the new accumulator frame.
|
||||
* If the previous frame exists, copy that into the accumulator frame.
|
||||
* This way, missing packets in the stream won't show up badly. */
|
||||
data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
|
||||
memset (data, 0, rtpdvdepay->frame_size);
|
||||
gst_buffer_unmap (rtpdvdepay->acc, data, size);
|
||||
gst_buffer_memset (rtpdvdepay->acc, 0, 0, rtpdvdepay->frame_size);
|
||||
|
||||
srccaps = gst_caps_new_simple ("video/x-dv",
|
||||
"systemstream", G_TYPE_BOOLEAN, systemstream,
|
||||
|
|
|
@ -282,8 +282,9 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstBuffer *outbuf;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
gint hdrlen;
|
||||
gsize size, osize;
|
||||
guint8 *data, *odata;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint8 *dest;
|
||||
guint filled;
|
||||
GstRTPBuffer rtp = { NULL, };
|
||||
|
@ -299,10 +300,9 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
max_payload_size = ((GST_RTP_BASE_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
|
||||
|
||||
/* The length of the buffer to transmit. */
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
|
||||
odata = data;
|
||||
osize = size;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
GST_DEBUG_OBJECT (rtpdvpay,
|
||||
"DV RTP payloader got buffer of %" G_GSIZE_FORMAT
|
||||
|
@ -368,7 +368,7 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
outbuf = NULL;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buffer, odata, osize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -195,8 +195,7 @@ static GstFlowReturn
|
|||
gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 HDR;
|
||||
GstRTPG723Pay *pay;
|
||||
GstClockTime packet_dur, timestamp;
|
||||
|
@ -204,7 +203,7 @@ gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
|||
|
||||
pay = GST_RTP_G723_PAY (payload);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
if (GST_BUFFER_IS_DISCONT (buf)) {
|
||||
|
@ -216,16 +215,16 @@ gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
|||
}
|
||||
|
||||
/* should be one of these sizes */
|
||||
if (size != 4 && size != 20 && size != 24)
|
||||
if (map.size != 4 && map.size != 20 && map.size != 24)
|
||||
goto invalid_size;
|
||||
|
||||
/* check size by looking at the header bits */
|
||||
HDR = data[0] & 0x3;
|
||||
if (size_tab[HDR] != size)
|
||||
HDR = map.data[0] & 0x3;
|
||||
if (size_tab[HDR] != map.size)
|
||||
goto wrong_size;
|
||||
|
||||
/* calculate packet size and duration */
|
||||
payload_len = gst_adapter_available (pay->adapter) + size;
|
||||
payload_len = gst_adapter_available (pay->adapter) + map.size;
|
||||
packet_dur = pay->duration + G723_FRAME_DURATION;
|
||||
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
|
||||
|
||||
|
@ -242,7 +241,7 @@ gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
|||
else
|
||||
pay->timestamp = 0;
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
/* add packet to the queue */
|
||||
gst_adapter_push (pay->adapter, buf);
|
||||
|
@ -260,8 +259,8 @@ invalid_size:
|
|||
{
|
||||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||
("Invalid input buffer size"),
|
||||
("Input size should be 4, 20 or 24, got %" G_GSIZE_FORMAT, size));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
("Input size should be 4, 20 or 24, got %" G_GSIZE_FORMAT, map.size));
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -270,8 +269,8 @@ wrong_size:
|
|||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||
("Wrong input buffer size"),
|
||||
("Expected input buffer size %u but got %" G_GSIZE_FORMAT,
|
||||
size_tab[HDR], size));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
size_tab[HDR], map.size));
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -225,9 +225,9 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
if (!outbuf)
|
||||
goto bad_len;
|
||||
} else {
|
||||
guint8 *in, *out, tmp, *odata;
|
||||
guint8 *in, *out, tmp;
|
||||
guint len;
|
||||
gsize osize;
|
||||
GstMapInfo map;
|
||||
|
||||
in = gst_rtp_buffer_get_payload (&rtp);
|
||||
len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
|
@ -237,8 +237,8 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
goto bad_len;
|
||||
outbuf = gst_buffer_make_writable (outbuf);
|
||||
|
||||
odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
|
||||
out = odata;
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
out = map.data;
|
||||
|
||||
/* we need to reshuffle the bytes, input is always of the form
|
||||
* A B C D ... with the number of bits depending on the bitrate. */
|
||||
|
@ -326,7 +326,7 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
break;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (outbuf, odata, osize);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
}
|
||||
|
||||
if (marker) {
|
||||
|
|
|
@ -267,16 +267,19 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
pay = GST_RTP_G726_PAY (payload);
|
||||
|
||||
if (!pay->aal2) {
|
||||
GstMapInfo map;
|
||||
guint8 *data, tmp;
|
||||
gsize len;
|
||||
gsize size;
|
||||
|
||||
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
|
||||
* when the buffer is writable. */
|
||||
buffer = gst_buffer_make_writable (buffer);
|
||||
|
||||
data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READWRITE);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READWRITE);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
GST_LOG_OBJECT (pay, "packing %" G_GSIZE_FORMAT " bytes of data", len);
|
||||
GST_LOG_OBJECT (pay, "packing %" G_GSIZE_FORMAT " bytes of data", map.size);
|
||||
|
||||
/* we need to reshuffle the bytes, output is of the form:
|
||||
* A B C D .. with the number of bits depending on the bitrate. */
|
||||
|
@ -290,11 +293,11 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
* |0 1|0 1|0 1|0 1|
|
||||
* +-+-+-+-+-+-+-+-+-
|
||||
*/
|
||||
while (len > 0) {
|
||||
while (size > 0) {
|
||||
tmp = *data;
|
||||
*data++ = ((tmp & 0xc0) >> 6) |
|
||||
((tmp & 0x30) >> 2) | ((tmp & 0x0c) << 2) | ((tmp & 0x03) << 6);
|
||||
len--;
|
||||
size--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -307,7 +310,7 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
* |1 2|0 1 2|0 1 2|2|0 1 2|0 1 2|0|0 1 2|0 1 2|0 1|
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||
*/
|
||||
while (len > 2) {
|
||||
while (size > 2) {
|
||||
tmp = *data;
|
||||
*data++ = ((tmp & 0xc0) >> 6) |
|
||||
((tmp & 0x38) >> 1) | ((tmp & 0x07) << 5);
|
||||
|
@ -317,7 +320,7 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
tmp = *data;
|
||||
*data++ = ((tmp & 0xe0) >> 5) |
|
||||
((tmp & 0x1c) >> 2) | ((tmp & 0x03) << 6);
|
||||
len -= 3;
|
||||
size -= 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -330,10 +333,10 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
* |0 1 2 3|0 1 2 3|0 1 2 3|0 1 2 3|
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||
*/
|
||||
while (len > 0) {
|
||||
while (size > 0) {
|
||||
tmp = *data;
|
||||
*data++ = ((tmp & 0xf0) >> 4) | ((tmp & 0x0f) << 4);
|
||||
len--;
|
||||
size--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -346,7 +349,7 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
* |2 3 4|0 1 2 3 4|4|0 1 2 3 4|0 1|1 2 3 4|0 1 2 3|3 4|0 1 2 3 4|0|0 1 2 3 4|0 1 2|
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||
*/
|
||||
while (len > 4) {
|
||||
while (size > 4) {
|
||||
tmp = *data;
|
||||
*data++ = ((tmp & 0xe0) >> 5) | ((tmp & 0x1f) << 3);
|
||||
tmp = *data;
|
||||
|
@ -359,12 +362,12 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
|||
((tmp & 0x3e) << 2) | ((tmp & 0x01) << 7);
|
||||
tmp = *data;
|
||||
*data++ = ((tmp & 0xf8) >> 3) | ((tmp & 0x07) << 5);
|
||||
len -= 5;
|
||||
size -= 5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, len);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
}
|
||||
|
||||
res =
|
||||
|
|
|
@ -330,11 +330,11 @@ gst_rtp_g729_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
|||
rtpg729pay->next_ts = timestamp;
|
||||
|
||||
if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
ret = gst_rtp_g729_pay_push (rtpg729pay, data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
ret = gst_rtp_g729_pay_push (rtpg729pay, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -127,21 +127,21 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstRTPGSMPay *rtpgsmpay;
|
||||
guint payload_len;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *payload, *data;
|
||||
GstMapInfo map;
|
||||
guint8 *payload;
|
||||
GstClockTime timestamp, duration;
|
||||
GstFlowReturn ret;
|
||||
gsize size;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpgsmpay = GST_RTP_GSM_PAY (basepayload);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
/* FIXME, only one GSM frame per RTP packet for now */
|
||||
payload_len = size;
|
||||
payload_len = map.size;
|
||||
|
||||
/* FIXME, just error out for now */
|
||||
if (payload_len > GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay))
|
||||
|
@ -158,11 +158,11 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* copy data in payload */
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
memcpy (payload, data, size);
|
||||
memcpy (payload, map.data, map.size);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
|
||||
|
@ -178,7 +178,7 @@ too_big:
|
|||
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
|
||||
("payload_len %u > mtu %u", payload_len,
|
||||
GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)));
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,32 +225,31 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
if (payload[0] & 0x80) {
|
||||
guint b, csize, left, offset;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
GstBuffer *subbuf;
|
||||
|
||||
/* C bit, we have inline caps */
|
||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_READ);
|
||||
|
||||
/* start reading the length, we need this to skip to the data later */
|
||||
csize = offset = 0;
|
||||
left = size;
|
||||
left = map.size;
|
||||
do {
|
||||
if (offset >= left) {
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
goto too_small;
|
||||
}
|
||||
b = data[offset++];
|
||||
b = map.data[offset++];
|
||||
csize = (csize << 7) | (b & 0x7f);
|
||||
} while (b & 0x80);
|
||||
|
||||
if (left < csize) {
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
goto too_small;
|
||||
}
|
||||
|
||||
/* parse and store in cache */
|
||||
outcaps = gst_caps_from_string ((gchar *) & data[offset]);
|
||||
outcaps = gst_caps_from_string ((gchar *) & map.data[offset]);
|
||||
store_cache (rtpgstdepay, CV, outcaps);
|
||||
|
||||
/* skip caps */
|
||||
|
@ -261,13 +260,13 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
"inline caps %u, length %u, %" GST_PTR_FORMAT, CV, csize, outcaps);
|
||||
|
||||
/* create real data buffer when needed */
|
||||
if (size)
|
||||
if (map.size)
|
||||
subbuf =
|
||||
gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, offset, left);
|
||||
else
|
||||
subbuf = NULL;
|
||||
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_buffer_unref (outbuf);
|
||||
outbuf = subbuf;
|
||||
}
|
||||
|
|
|
@ -126,8 +126,9 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstBuffer * buffer)
|
||||
{
|
||||
GstRtpGSTPay *rtpgstpay;
|
||||
guint8 *data, *ptr;
|
||||
gsize size, left;
|
||||
GstMapInfo map;
|
||||
guint8 *ptr;
|
||||
gsize left;
|
||||
GstBuffer *outbuf;
|
||||
GstFlowReturn ret;
|
||||
GstClockTime timestamp;
|
||||
|
@ -136,7 +137,7 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
rtpgstpay = GST_RTP_GST_PAY (basepayload);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
ret = GST_FLOW_OK;
|
||||
|
@ -156,8 +157,8 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*/
|
||||
frag_offset = 0;
|
||||
ptr = data;
|
||||
left = size;
|
||||
ptr = map.data;
|
||||
left = map.size;
|
||||
|
||||
while (left > 0) {
|
||||
guint towrite;
|
||||
|
@ -206,7 +207,7 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -307,7 +307,7 @@ gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
/* frame is completed: append to previous, push it out */
|
||||
guint len, padlen;
|
||||
guint avail;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
GST_LOG_OBJECT (depayload, "Frame complete");
|
||||
|
||||
|
@ -317,16 +317,16 @@ gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
outbuf = gst_buffer_new_and_alloc (len + padlen);
|
||||
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
memset (data + len, 0, padlen);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
memset (map.data + len, 0, padlen);
|
||||
|
||||
/* prepend previous data */
|
||||
if (avail > 0) {
|
||||
gst_adapter_copy (rtph263pdepay->adapter, data, 0, avail);
|
||||
gst_adapter_copy (rtph263pdepay->adapter, map.data, 0, avail);
|
||||
gst_adapter_flush (rtph263pdepay->adapter, avail);
|
||||
}
|
||||
memcpy (data + avail, payload, payload_len);
|
||||
gst_buffer_unmap (outbuf, data, len);
|
||||
memcpy (map.data + avail, payload, payload_len);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
return outbuf;
|
||||
|
|
|
@ -290,7 +290,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
GstRtpH264Depay *rtph264depay;
|
||||
const gchar *ps, *profile;
|
||||
GstBuffer *codec_data;
|
||||
guint8 *ptr, *data;
|
||||
GstMapInfo map;
|
||||
guint8 *ptr;
|
||||
gboolean res;
|
||||
|
||||
rtph264depay = GST_RTP_H264_DEPAY (depayload);
|
||||
|
@ -328,8 +329,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
/* we seriously overshoot the length, but it's fine. */
|
||||
codec_data = gst_buffer_new_and_alloc (len);
|
||||
|
||||
data = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
|
||||
ptr = data;
|
||||
gst_buffer_map (codec_data, &map, GST_MAP_WRITE);
|
||||
ptr = map.data;
|
||||
total = 0;
|
||||
for (i = 0; params[i]; i++) {
|
||||
guint save = 0;
|
||||
|
@ -345,7 +346,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
total += len + sizeof (sync_bytes);
|
||||
ptr += len;
|
||||
}
|
||||
gst_buffer_unmap (codec_data, data, total);
|
||||
gst_buffer_unmap (codec_data, &map);
|
||||
gst_buffer_resize (codec_data, 0, total);
|
||||
g_strfreev (params);
|
||||
|
||||
/* keep the codec_data, we need to send it as the first buffer. We cannot
|
||||
|
@ -408,7 +410,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
|
||||
codec_data = gst_buffer_new_and_alloc (len);
|
||||
|
||||
data = ptr = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (codec_data, &map, GST_MAP_WRITE);
|
||||
ptr = map.data;
|
||||
|
||||
/* 8 bits version == 1 */
|
||||
*ptr++ = 1;
|
||||
|
@ -451,7 +454,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
ptr += len;
|
||||
}
|
||||
g_free (pps);
|
||||
gst_buffer_unmap (codec_data, data, ptr - data);
|
||||
gst_buffer_resize (codec_data, 0, ptr - map.data);
|
||||
gst_buffer_unmap (codec_data, &map);
|
||||
|
||||
gst_caps_set_simple (srccaps,
|
||||
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
||||
|
@ -507,17 +511,16 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
|||
{
|
||||
GstRTPBaseDepayload *depayload = GST_RTP_BASE_DEPAYLOAD (rtph264depay);
|
||||
gint nal_type;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
GstBuffer *outbuf = NULL;
|
||||
GstClockTime out_timestamp;
|
||||
gboolean keyframe, out_keyframe;
|
||||
|
||||
data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
|
||||
if (G_UNLIKELY (size < 5))
|
||||
gst_buffer_map (nal, &map, GST_MAP_READ);
|
||||
if (G_UNLIKELY (map.size < 5))
|
||||
goto short_nal;
|
||||
|
||||
nal_type = data[4] & 0x1f;
|
||||
nal_type = map.data[4] & 0x1f;
|
||||
GST_DEBUG_OBJECT (rtph264depay, "handle NAL type %d", nal_type);
|
||||
|
||||
keyframe = NAL_TYPE_IS_KEY (nal_type);
|
||||
|
@ -537,7 +540,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
|||
if (nal_type == 1 || nal_type == 2 || nal_type == 5) {
|
||||
/* we have a picture start */
|
||||
start = TRUE;
|
||||
if (data[5] & 0x80) {
|
||||
if (map.data[5] & 0x80) {
|
||||
/* first_mb_in_slice == 0 completes a picture */
|
||||
complete = TRUE;
|
||||
}
|
||||
|
@ -566,7 +569,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
|||
GST_DEBUG_OBJECT (depayload, "using NAL as output");
|
||||
outbuf = nal;
|
||||
}
|
||||
gst_buffer_unmap (nal, data, size);
|
||||
gst_buffer_unmap (nal, &map);
|
||||
|
||||
if (outbuf) {
|
||||
/* prepend codec_data */
|
||||
|
@ -592,7 +595,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
|||
short_nal:
|
||||
{
|
||||
GST_WARNING_OBJECT (depayload, "dropping short NAL");
|
||||
gst_buffer_unmap (nal, data, size);
|
||||
gst_buffer_unmap (nal, &map);
|
||||
gst_buffer_unref (nal);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -603,25 +606,25 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay,
|
|||
gboolean send)
|
||||
{
|
||||
guint outsize;
|
||||
guint8 *outdata;
|
||||
GstMapInfo map;
|
||||
GstBuffer *outbuf;
|
||||
|
||||
outsize = gst_adapter_available (rtph264depay->adapter);
|
||||
outbuf = gst_adapter_take_buffer (rtph264depay->adapter, outsize);
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
GST_DEBUG_OBJECT (rtph264depay, "output %d bytes", outsize);
|
||||
|
||||
if (rtph264depay->byte_stream) {
|
||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
||||
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||
} else {
|
||||
outsize -= 4;
|
||||
outdata[0] = (outsize >> 24);
|
||||
outdata[1] = (outsize >> 16);
|
||||
outdata[2] = (outsize >> 8);
|
||||
outdata[3] = (outsize);
|
||||
map.data[0] = (outsize >> 24);
|
||||
map.data[1] = (outsize >> 16);
|
||||
map.data[2] = (outsize >> 8);
|
||||
map.data[3] = (outsize);
|
||||
}
|
||||
gst_buffer_unmap (outbuf, outdata, -1);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
rtph264depay->current_fu_type = 0;
|
||||
|
||||
|
@ -660,7 +663,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
guint8 *payload;
|
||||
guint header_len;
|
||||
guint8 nal_ref_idc;
|
||||
guint8 *outdata;
|
||||
GstMapInfo map;
|
||||
guint outsize, nalu_size;
|
||||
GstClockTime timestamp;
|
||||
gboolean marker;
|
||||
|
@ -738,21 +741,21 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
outsize = nalu_size + sizeof (sync_bytes);
|
||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
if (rtph264depay->byte_stream) {
|
||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
||||
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||
} else {
|
||||
outdata[0] = outdata[1] = 0;
|
||||
outdata[2] = payload[0];
|
||||
outdata[3] = payload[1];
|
||||
map.data[0] = map.data[1] = 0;
|
||||
map.data[2] = payload[0];
|
||||
map.data[3] = payload[1];
|
||||
}
|
||||
|
||||
/* strip NALU size */
|
||||
payload += 2;
|
||||
payload_len -= 2;
|
||||
|
||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
gst_adapter_push (rtph264depay->adapter, outbuf);
|
||||
|
||||
|
@ -826,10 +829,10 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
outsize = nalu_size + sizeof (sync_bytes);
|
||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
||||
outdata[sizeof (sync_bytes)] = nal_header;
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||
map.data[sizeof (sync_bytes)] = nal_header;
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
|
||||
|
||||
|
@ -842,10 +845,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
outsize = payload_len;
|
||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (outdata, payload, outsize);
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
gst_buffer_fill (outbuf, 0, payload, outsize);
|
||||
|
||||
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
|
||||
|
||||
|
@ -871,16 +871,16 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
outsize = nalu_size + sizeof (sync_bytes);
|
||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||
|
||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
if (rtph264depay->byte_stream) {
|
||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
||||
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||
} else {
|
||||
outdata[0] = outdata[1] = 0;
|
||||
outdata[2] = nalu_size >> 8;
|
||||
outdata[3] = nalu_size & 0xff;
|
||||
map.data[0] = map.data[1] = 0;
|
||||
map.data[2] = nalu_size >> 8;
|
||||
map.data[3] = nalu_size & 0xff;
|
||||
}
|
||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
||||
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
|
||||
marker);
|
||||
|
|
|
@ -373,8 +373,7 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
|
|||
GString *sprops;
|
||||
guint count;
|
||||
gboolean res;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
sprops = g_string_new ("");
|
||||
count = 0;
|
||||
|
@ -383,9 +382,9 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
|
|||
for (walk = payloader->sps; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
||||
|
||||
data = gst_buffer_map (sps_buf, &size, NULL, GST_MAP_READ);
|
||||
set = g_base64_encode (data, size);
|
||||
gst_buffer_unmap (sps_buf, data, size);
|
||||
gst_buffer_map (sps_buf, &map, GST_MAP_READ);
|
||||
set = g_base64_encode (map.data, map.size);
|
||||
gst_buffer_unmap (sps_buf, &map);
|
||||
|
||||
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
||||
g_free (set);
|
||||
|
@ -394,9 +393,9 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
|
|||
for (walk = payloader->pps; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *pps_buf = GST_BUFFER_CAST (walk->data);
|
||||
|
||||
data = gst_buffer_map (pps_buf, &size, NULL, GST_MAP_READ);
|
||||
set = g_base64_encode (data, size);
|
||||
gst_buffer_unmap (pps_buf, data, size);
|
||||
gst_buffer_map (pps_buf, &map, GST_MAP_READ);
|
||||
set = g_base64_encode (map.data, map.size);
|
||||
gst_buffer_unmap (pps_buf, &map);
|
||||
|
||||
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
||||
g_free (set);
|
||||
|
@ -420,8 +419,9 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
|||
GstRtpH264Pay *rtph264pay;
|
||||
GstStructure *str;
|
||||
const GValue *value;
|
||||
guint8 *data, *bdata;
|
||||
gsize size, bsize;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstBuffer *buffer;
|
||||
const gchar *alignment;
|
||||
|
||||
|
@ -449,9 +449,9 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
|||
|
||||
buffer = gst_value_get_buffer (value);
|
||||
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
data = bdata;
|
||||
size = bsize;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
||||
/* parse the avcC data */
|
||||
if (size < 7)
|
||||
|
@ -534,6 +534,7 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
|||
data += nal_size;
|
||||
size -= nal_size;
|
||||
}
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
/* and update the caps with the collected data */
|
||||
if (!gst_rtp_h264_pay_set_sps_pps (basepayload))
|
||||
goto set_sps_pps_failed;
|
||||
|
@ -566,7 +567,7 @@ set_sps_pps_failed:
|
|||
}
|
||||
error:
|
||||
{
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -595,6 +596,7 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
|
|||
|
||||
for (i = 0; params[i]; i++) {
|
||||
gsize nal_len;
|
||||
GstMapInfo map;
|
||||
guint8 *nalp;
|
||||
guint save = 0;
|
||||
gint state = 0;
|
||||
|
@ -603,10 +605,12 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
|
|||
nal_len = strlen (params[i]);
|
||||
buf = gst_buffer_new_and_alloc (nal_len);
|
||||
|
||||
nalp = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
nalp = map.data;
|
||||
nal_len = g_base64_decode_step (params[i], nal_len, nalp, &state, &save);
|
||||
nal_type = nalp[0];
|
||||
gst_buffer_unmap (buf, nalp, nal_len);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_resize (buf, 0, nal_len);
|
||||
|
||||
if (!nal_len) {
|
||||
gst_buffer_unref (buf);
|
||||
|
@ -792,18 +796,17 @@ gst_rtp_h264_pay_send_sps_pps (GstRTPBasePayload * basepayload,
|
|||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GList *walk;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
for (walk = rtph264pay->sps; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
||||
|
||||
GST_DEBUG_OBJECT (rtph264pay, "inserting SPS in the stream");
|
||||
/* resend SPS */
|
||||
data = gst_buffer_map (sps_buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (sps_buf, &map, GST_MAP_READ);
|
||||
ret = gst_rtp_h264_pay_payload_nal (basepayload,
|
||||
data, size, timestamp, sps_buf, FALSE);
|
||||
gst_buffer_unmap (sps_buf, data, size);
|
||||
map.data, map.size, timestamp, sps_buf, FALSE);
|
||||
gst_buffer_unmap (sps_buf, &map);
|
||||
/* Not critical here; but throw a warning */
|
||||
if (ret != GST_FLOW_OK)
|
||||
GST_WARNING ("Problem pushing SPS");
|
||||
|
@ -813,10 +816,10 @@ gst_rtp_h264_pay_send_sps_pps (GstRTPBasePayload * basepayload,
|
|||
|
||||
GST_DEBUG_OBJECT (rtph264pay, "inserting PPS in the stream");
|
||||
/* resend PPS */
|
||||
data = gst_buffer_map (pps_buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (pps_buf, &map, GST_MAP_READ);
|
||||
ret = gst_rtp_h264_pay_payload_nal (basepayload,
|
||||
data, size, timestamp, pps_buf, FALSE);
|
||||
gst_buffer_unmap (pps_buf, data, size);
|
||||
map.data, map.size, timestamp, pps_buf, FALSE);
|
||||
gst_buffer_unmap (pps_buf, &map);
|
||||
/* Not critical here; but throw a warning */
|
||||
if (ret != GST_FLOW_OK)
|
||||
GST_WARNING ("Problem pushing PPS");
|
||||
|
@ -1082,8 +1085,7 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstFlowReturn ret;
|
||||
gsize size;
|
||||
guint nal_len, i;
|
||||
guint8 *bdata = NULL;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
const guint8 *data, *nal_data;
|
||||
GstClockTime timestamp;
|
||||
GArray *nal_queue;
|
||||
|
@ -1108,9 +1110,9 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
if (!GST_CLOCK_TIME_IS_VALID (timestamp))
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
} else {
|
||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
data = bdata;
|
||||
size = bsize;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
|
||||
}
|
||||
|
@ -1307,7 +1309,7 @@ done:
|
|||
gst_adapter_unmap (rtph264pay->adapter);
|
||||
gst_adapter_flush (rtph264pay->adapter, pushed);
|
||||
} else {
|
||||
gst_buffer_unmap (buffer, bdata, bsize);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -267,8 +267,7 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
|||
GList *packets, *walk;
|
||||
guint8 end[2];
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
GstBuffer *buf;
|
||||
|
||||
rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
|
||||
|
@ -307,12 +306,12 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
|||
|
||||
if (walk == packets) {
|
||||
/* first buffer should contain the SOT */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (size < 12)
|
||||
if (map.size < 12)
|
||||
goto invalid_tile;
|
||||
|
||||
if (data[0] == 0xff && data[1] == J2K_MARKER_SOT) {
|
||||
if (map.data[0] == 0xff && map.data[1] == J2K_MARKER_SOT) {
|
||||
guint Psot, nPsot;
|
||||
|
||||
if (end[0] == 0xff && end[1] == J2K_MARKER_EOC)
|
||||
|
@ -320,19 +319,19 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
|||
else
|
||||
nPsot = avail;
|
||||
|
||||
Psot = GST_READ_UINT32_BE (&data[6]);
|
||||
Psot = GST_READ_UINT32_BE (&map.data[6]);
|
||||
if (Psot != nPsot && Psot != 0) {
|
||||
/* Psot must match the size of the tile */
|
||||
GST_DEBUG_OBJECT (rtpj2kdepay, "set Psot from %u to %u", Psot, nPsot);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
buf = gst_buffer_make_writable (buf);
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (&data[6], nPsot);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
GST_WRITE_UINT32_BE (&map.data[6], nPsot);
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %" G_GSIZE_FORMAT,
|
||||
|
@ -357,7 +356,7 @@ waiting_header:
|
|||
invalid_tile:
|
||||
{
|
||||
GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE, ("Invalid tile"), (NULL));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_adapter_clear (rtpj2kdepay->t_adapter);
|
||||
rtpj2kdepay->last_tile = -1;
|
||||
return ret;
|
||||
|
|
|
@ -335,8 +335,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
#if 0
|
||||
GstBufferList *list = NULL;
|
||||
#endif
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint mtu, max_size;
|
||||
guint offset;
|
||||
guint end, pos;
|
||||
|
@ -344,13 +343,13 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
pay = GST_RTP_J2K_PAY (basepayload);
|
||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
offset = pos = end = 0;
|
||||
|
||||
GST_LOG_OBJECT (pay,
|
||||
"got buffer size %" G_GSIZE_FORMAT ", timestamp %" GST_TIME_FORMAT, size,
|
||||
GST_TIME_ARGS (timestamp));
|
||||
"got buffer size %" G_GSIZE_FORMAT ", timestamp %" GST_TIME_FORMAT,
|
||||
map.size, GST_TIME_ARGS (timestamp));
|
||||
|
||||
/* do some header defaults first */
|
||||
state.header.tp = 0; /* only progressive scan */
|
||||
|
@ -413,11 +412,11 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
pos = end;
|
||||
|
||||
/* exit when finished */
|
||||
if (pos == size)
|
||||
if (pos == map.size)
|
||||
break;
|
||||
|
||||
/* scan next packetization unit and fill in the header */
|
||||
end = find_pu_end (pay, data, size, pos, &state);
|
||||
end = find_pu_end (pay, map.data, map.size, pos, &state);
|
||||
} while (TRUE);
|
||||
|
||||
while (pu_size > 0) {
|
||||
|
@ -468,7 +467,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
else
|
||||
state.header.MHF = 2;
|
||||
}
|
||||
if (end >= size)
|
||||
if (end >= map.size)
|
||||
gst_rtp_buffer_set_marker (&rtp, TRUE);
|
||||
}
|
||||
|
||||
|
@ -518,7 +517,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
#endif
|
||||
{
|
||||
/* copy payload */
|
||||
memcpy (header + HEADER_SIZE, &data[offset], data_size);
|
||||
memcpy (header + HEADER_SIZE, &map.data[offset], data_size);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||
|
@ -534,7 +533,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
offset += data_size;
|
||||
}
|
||||
offset = pos;
|
||||
} while (offset < size);
|
||||
} while (offset < map.size);
|
||||
|
||||
done:
|
||||
gst_buffer_unref (buffer);
|
||||
|
|
|
@ -602,8 +602,8 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
}
|
||||
|
||||
if (frag_offset == 0) {
|
||||
GstMapInfo map;
|
||||
guint size;
|
||||
guint8 *data;
|
||||
|
||||
if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
|
||||
GstCaps *outcaps;
|
||||
|
@ -645,9 +645,10 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
}
|
||||
/* max header length, should be big enough */
|
||||
outbuf = gst_buffer_new_and_alloc (1000);
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
size = MakeHeaders (data, type, width, height, qtable, precision, dri);
|
||||
gst_buffer_unmap (outbuf, data, size);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
size = MakeHeaders (map.data, type, width, height, qtable, precision, dri);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_buffer_resize (outbuf, 0, size);
|
||||
|
||||
GST_DEBUG_OBJECT (rtpjpegdepay, "pushing %u bytes of header", size);
|
||||
|
||||
|
@ -663,7 +664,7 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
if (gst_rtp_buffer_get_marker (&rtp)) {
|
||||
guint avail;
|
||||
guint8 end[2];
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
/* last buffer take all data out of the adapter */
|
||||
avail = gst_adapter_available (rtpjpegdepay->adapter);
|
||||
|
@ -678,10 +679,10 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
/* no EOI marker, add one */
|
||||
outbuf = gst_buffer_new_and_alloc (2);
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
data[0] = 0xff;
|
||||
data[1] = 0xd9;
|
||||
gst_buffer_unmap (outbuf, data, -1);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
map.data[0] = 0xff;
|
||||
map.data[1] = 0xd9;
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
|
||||
avail += 2;
|
||||
|
|
|
@ -607,7 +607,8 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
RtpQuantTable tables[15] = { {0, NULL}, };
|
||||
CompInfo info[3] = { {0,}, };
|
||||
guint quant_data_size;
|
||||
guint8 *data, *bdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint mtu;
|
||||
guint bytes_left;
|
||||
|
@ -621,7 +622,9 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
pay = GST_RTP_JPEG_PAY (basepayload);
|
||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
|
||||
|
||||
data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
offset = 0;
|
||||
|
||||
|
@ -835,7 +838,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
ret = gst_rtp_base_payload_push_list (basepayload, list);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
@ -844,28 +847,28 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
unsupported_jpeg:
|
||||
{
|
||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_NOT_SUPPORTED;
|
||||
}
|
||||
no_dimension:
|
||||
{
|
||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_NOT_NEGOTIATED;
|
||||
}
|
||||
invalid_format:
|
||||
{
|
||||
/* error was posted */
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
invalid_quant:
|
||||
{
|
||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
|
|
@ -161,6 +161,7 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
g_value_init (&v, GST_TYPE_BUFFER);
|
||||
if (gst_value_deserialize (&v, str)) {
|
||||
GstBuffer *buffer;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
gint i;
|
||||
|
@ -172,7 +173,9 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
gst_buffer_ref (buffer);
|
||||
g_value_unset (&v);
|
||||
|
||||
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 < 2) {
|
||||
GST_WARNING_OBJECT (depayload, "config too short (%d < 2)",
|
||||
|
@ -268,7 +271,8 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
}
|
||||
|
||||
/* ignore remaining bit, we're only interested in full bytes */
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_resize (buffer, 0, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
data = NULL;
|
||||
|
||||
gst_caps_set_simple (srccaps,
|
||||
|
@ -277,7 +281,7 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
"codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
||||
bad_config:
|
||||
if (data)
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
} else {
|
||||
g_warning ("cannot convert config to buffer");
|
||||
|
@ -295,7 +299,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
GstRtpMP4ADepay *rtpmp4adepay;
|
||||
GstBuffer *outbuf;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
guint8 *bdata;
|
||||
GstMapInfo map;
|
||||
|
||||
rtpmp4adepay = GST_RTP_MP4A_DEPAY (depayload);
|
||||
|
||||
|
@ -326,7 +330,8 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
GST_LOG_OBJECT (rtpmp4adepay, "have marker and %u available", avail);
|
||||
|
||||
outbuf = gst_adapter_take_buffer (rtpmp4adepay->adapter, avail);
|
||||
data = bdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
/* position in data we are at */
|
||||
pos = 0;
|
||||
|
||||
|
@ -387,7 +392,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
"possible wrongly encoded packet."));
|
||||
}
|
||||
|
||||
gst_buffer_unmap (outbuf, bdata, -1);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_buffer_unref (outbuf);
|
||||
}
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
@ -398,7 +403,7 @@ wrong_size:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtpmp4adepay, STREAM, DECODE,
|
||||
("Packet did not validate"), ("wrong packet size"));
|
||||
gst_buffer_unmap (outbuf, bdata, -1);
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
gst_buffer_unref (outbuf);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
return NULL;
|
||||
|
|
|
@ -132,13 +132,16 @@ static gboolean
|
|||
gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint8 objectType;
|
||||
guint8 samplingIdx;
|
||||
guint8 channelCfg;
|
||||
|
||||
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 < 2)
|
||||
goto too_short;
|
||||
|
@ -182,7 +185,7 @@ gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
|
|||
"objectType: %d, samplingIdx: %d (%d), channelCfg: %d", objectType,
|
||||
samplingIdx, rtpmp4apay->rate, channelCfg);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -193,28 +196,28 @@ too_short:
|
|||
(NULL),
|
||||
("config string too short, expected 2 bytes, got %" G_GSIZE_FORMAT,
|
||||
size));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
invalid_object:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
|
||||
(NULL), ("invalid object type 0"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
wrong_freq:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
||||
(NULL), ("unsupported frequency index %d", samplingIdx));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
wrong_channels:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
||||
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -272,10 +275,9 @@ gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
|||
GST_LOG_OBJECT (rtpmp4apay, "got codec_data");
|
||||
if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
|
||||
GstBuffer *buffer, *cbuffer;
|
||||
guint8 *config;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
GstMapInfo cmap;
|
||||
guint i;
|
||||
gsize size;
|
||||
|
||||
buffer = gst_value_get_buffer (codec_data);
|
||||
GST_LOG_OBJECT (rtpmp4apay, "configuring codec_data");
|
||||
|
@ -286,11 +288,11 @@ gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
|||
if (!res)
|
||||
goto config_failed;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
/* make the StreamMuxConfig, we need 15 bits for the header */
|
||||
cbuffer = gst_buffer_new_and_alloc (size + 2);
|
||||
config = gst_buffer_map (cbuffer, NULL, NULL, GST_MAP_WRITE);
|
||||
cbuffer = gst_buffer_new_and_alloc (map.size + 2);
|
||||
gst_buffer_map (cbuffer, &cmap, GST_MAP_WRITE);
|
||||
|
||||
/* Create StreamMuxConfig according to ISO/IEC 14496-3:
|
||||
*
|
||||
|
@ -300,17 +302,17 @@ gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
|||
* numProgram == 0 (4 bits)
|
||||
* numLayer == 0 (3 bits)
|
||||
*/
|
||||
config[0] = 0x40;
|
||||
config[1] = 0x00;
|
||||
cmap.data[0] = 0x40;
|
||||
cmap.data[1] = 0x00;
|
||||
|
||||
/* append the config bits, shifting them 1 bit left */
|
||||
for (i = 0; i < size; i++) {
|
||||
config[i + 1] |= ((data[i] & 0x80) >> 7);
|
||||
config[i + 2] |= ((data[i] & 0x7f) << 1);
|
||||
for (i = 0; i < map.size; i++) {
|
||||
cmap.data[i + 1] |= ((map.data[i] & 0x80) >> 7);
|
||||
cmap.data[i + 2] |= ((map.data[i] & 0x7f) << 1);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (cbuffer, config, -1);
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (cbuffer, &cmap);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
/* now we can configure the buffer */
|
||||
if (rtpmp4apay->config)
|
||||
|
@ -348,8 +350,9 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstFlowReturn ret;
|
||||
GstBuffer *outbuf;
|
||||
guint count, mtu;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
guint8 *data, *bdata;
|
||||
guint8 *data;
|
||||
gboolean fragmented;
|
||||
GstClockTime timestamp;
|
||||
|
||||
|
@ -357,7 +360,10 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
rtpmp4apay = GST_RTP_MP4A_PAY (basepayload);
|
||||
|
||||
data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
size = map.size;
|
||||
data = map.data;
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
fragmented = FALSE;
|
||||
|
@ -430,7 +436,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
fragmented = TRUE;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, bdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -181,16 +181,15 @@ static gboolean
|
|||
gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint8 objectType = 0;
|
||||
guint8 samplingIdx = 0;
|
||||
guint8 channelCfg = 0;
|
||||
GstBitReader br;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
gst_bit_reader_init (&br, data, size);
|
||||
gst_bit_reader_init (&br, map.data, map.size);
|
||||
|
||||
/* any object type is fine, we need to copy it to the profile-level-id field. */
|
||||
if (!gst_bit_reader_get_bits_uint8 (&br, &objectType, 5))
|
||||
|
@ -261,7 +260,7 @@ gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
|
|||
objectType, samplingIdx, rtpmp4gpay->rate, channelCfg,
|
||||
rtpmp4gpay->frame_len);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return TRUE;
|
||||
|
||||
/* ERROR */
|
||||
|
@ -269,28 +268,28 @@ too_short:
|
|||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||
(NULL), ("config string too short"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
invalid_object:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||
(NULL), ("invalid object type"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
wrong_freq:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
||||
(NULL), ("unsupported frequency index %d", samplingIdx));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
wrong_channels:
|
||||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
||||
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -301,21 +300,20 @@ static gboolean
|
|||
gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint32 code;
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
if (size < 5)
|
||||
if (map.size < 5)
|
||||
goto too_short;
|
||||
|
||||
code = GST_READ_UINT32_BE (data);
|
||||
code = GST_READ_UINT32_BE (map.data);
|
||||
|
||||
g_free (rtpmp4gpay->profile);
|
||||
if (code == VOS_STARTCODE) {
|
||||
/* get profile */
|
||||
rtpmp4gpay->profile = g_strdup_printf ("%d", (gint) data[4]);
|
||||
rtpmp4gpay->profile = g_strdup_printf ("%d", (gint) map.data[4]);
|
||||
} else {
|
||||
GST_ELEMENT_WARNING (rtpmp4gpay, STREAM, FORMAT,
|
||||
(NULL), ("profile not found in config string, assuming \'1\'"));
|
||||
|
@ -333,7 +331,7 @@ gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
|
|||
|
||||
GST_LOG_OBJECT (rtpmp4gpay, "profile %s", rtpmp4gpay->profile);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
return TRUE;
|
||||
|
||||
|
@ -342,7 +340,7 @@ too_short:
|
|||
{
|
||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||
(NULL), ("config string too short"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,14 +387,12 @@ gst_rtp_mp4v_pay_depay_data (GstRtpMP4VPay * enc, guint8 * data, guint size,
|
|||
}
|
||||
/* if config string changed or new profile, make new caps */
|
||||
if (!equal || newprofile) {
|
||||
guint8 *bdata;
|
||||
|
||||
if (enc->config)
|
||||
gst_buffer_unref (enc->config);
|
||||
enc->config = gst_buffer_new_and_alloc (i);
|
||||
bdata = gst_buffer_map (enc->config, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, data, i);
|
||||
gst_buffer_unmap (enc->config, bdata, -1);
|
||||
|
||||
gst_buffer_fill (enc->config, 0, data, i);
|
||||
|
||||
gst_rtp_mp4v_pay_new_caps (enc);
|
||||
}
|
||||
*strip = i;
|
||||
|
@ -444,9 +442,9 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstRtpMP4VPay *rtpmp4vpay;
|
||||
GstFlowReturn ret;
|
||||
guint avail;
|
||||
gsize size;
|
||||
guint packet_len;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
gboolean flush;
|
||||
gint strip;
|
||||
GstClockTime timestamp, duration;
|
||||
|
@ -458,7 +456,8 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
rtpmp4vpay = GST_RTP_MP4V_PAY (basepayload);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
size = map.size;
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
avail = gst_adapter_available (rtpmp4vpay->adapter);
|
||||
|
@ -474,9 +473,9 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
/* depay incomming data and see if we need to start a new RTP
|
||||
* packet */
|
||||
flush = gst_rtp_mp4v_pay_depay_data (rtpmp4vpay, data, size, &strip, &vopi);
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
data = NULL;
|
||||
flush =
|
||||
gst_rtp_mp4v_pay_depay_data (rtpmp4vpay, map.data, size, &strip, &vopi);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
if (strip) {
|
||||
/* strip off config if requested */
|
||||
|
|
|
@ -273,8 +273,7 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
|
|||
rtpmpadepay, GstADUFrame * frame)
|
||||
{
|
||||
GstADUFrame *dummy;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
dummy = g_slice_dup (GstADUFrame, frame);
|
||||
|
||||
|
@ -288,10 +287,10 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
|
|||
|
||||
dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4);
|
||||
|
||||
data = gst_buffer_map (dummy->buffer, &size, NULL, GST_MAP_WRITE);
|
||||
memset (data, 0, size);
|
||||
GST_WRITE_UINT32_BE (data, dummy->header);
|
||||
gst_buffer_unmap (dummy->buffer, data, size);
|
||||
gst_buffer_map (dummy->buffer, &map, GST_MAP_WRITE);
|
||||
memset (map.data, 0, map.size);
|
||||
GST_WRITE_UINT32_BE (map.data, dummy->header);
|
||||
gst_buffer_unmap (dummy->buffer, &map);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (dummy->buffer) = GST_BUFFER_TIMESTAMP (frame->buffer);
|
||||
|
||||
|
@ -308,18 +307,17 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
GstADUFrame *frame = NULL;
|
||||
guint version, layer, channels, size;
|
||||
guint crc;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
g_return_val_if_fail (buf != NULL, FALSE);
|
||||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
|
||||
if (bsize < 6)
|
||||
if (map.size < 6)
|
||||
goto corrupt_frame;
|
||||
|
||||
frame = g_slice_new0 (GstADUFrame);
|
||||
frame->header = GST_READ_UINT32_BE (bdata);
|
||||
frame->header = GST_READ_UINT32_BE (map.data);
|
||||
|
||||
size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay),
|
||||
frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
|
||||
|
@ -341,7 +339,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
|
||||
/* backpointer */
|
||||
if (layer == 3) {
|
||||
frame->backpointer = GST_READ_UINT16_BE (bdata + 4);
|
||||
frame->backpointer = GST_READ_UINT16_BE (map.data + 4);
|
||||
frame->backpointer >>= 7;
|
||||
GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer);
|
||||
}
|
||||
|
@ -353,15 +351,15 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
frame->data_size = frame->size - 4 - frame->side_info;
|
||||
|
||||
/* some size validation checks */
|
||||
if (4 + frame->side_info > bsize)
|
||||
if (4 + frame->side_info > map.size)
|
||||
goto corrupt_frame;
|
||||
|
||||
/* ADU data would then extend past MP3 frame,
|
||||
* even using past byte reservoir */
|
||||
if (-frame->backpointer + (gint) (bsize) > frame->size)
|
||||
if (-frame->backpointer + (gint) (map.size) > frame->size)
|
||||
goto corrupt_frame;
|
||||
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
/* ok, take buffer and queue */
|
||||
frame->buffer = buf;
|
||||
|
@ -373,7 +371,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
corrupt_frame:
|
||||
{
|
||||
GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
gst_buffer_unref (buf);
|
||||
if (frame)
|
||||
g_slice_free (GstADUFrame, frame);
|
||||
|
@ -413,13 +411,12 @@ gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
GstBuffer * buf)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
guint val, iindex, icc;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
val = GST_READ_UINT16_BE (data) >> 5;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
val = GST_READ_UINT16_BE (map.data) >> 5;
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
iindex = val >> 3;
|
||||
icc = val & 0x7;
|
||||
|
@ -476,8 +473,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
while (1) {
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
|
||||
if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
|
||||
rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head;
|
||||
|
@ -533,10 +529,10 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0);
|
||||
/* bytewriter corresponds to head frame,
|
||||
* i.e. the header and the side info must match */
|
||||
data = gst_buffer_map (head->buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (head->buffer, &map, GST_MAP_READ);
|
||||
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||
data, 4 + head->side_info);
|
||||
gst_buffer_unmap (head->buffer, data, size);
|
||||
map.data, 4 + head->side_info);
|
||||
gst_buffer_unmap (head->buffer, &map);
|
||||
}
|
||||
|
||||
buf = frame->buffer;
|
||||
|
@ -546,17 +542,17 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
rtpmpadepay->size);
|
||||
|
||||
if (rtpmpadepay->offset) {
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
/* no need to position, simply append */
|
||||
g_assert (size > rtpmpadepay->offset);
|
||||
av = MIN (av, size - rtpmpadepay->offset);
|
||||
g_assert (map.size > rtpmpadepay->offset);
|
||||
av = MIN (av, map.size - rtpmpadepay->offset);
|
||||
GST_LOG_OBJECT (rtpmpadepay,
|
||||
"appending %d bytes from ADU frame at offset %d", av,
|
||||
rtpmpadepay->offset);
|
||||
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||
data + rtpmpadepay->offset, av);
|
||||
map.data + rtpmpadepay->offset, av);
|
||||
rtpmpadepay->offset += av;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
} else {
|
||||
gint pos, tpos;
|
||||
|
||||
|
@ -594,14 +590,14 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av);
|
||||
} else {
|
||||
/* position and append */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame");
|
||||
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos);
|
||||
av = MIN (av, size - 4 - frame->side_info);
|
||||
av = MIN (av, map.size - 4 - frame->side_info);
|
||||
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||
data + 4 + frame->side_info, av);
|
||||
map.data + 4 + frame->side_info, av);
|
||||
rtpmpadepay->offset += av + 4 + frame->side_info;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,12 +241,12 @@ static GstBuffer *
|
|||
create_erasure_buffer (GstRtpQCELPDepay * depay)
|
||||
{
|
||||
GstBuffer *outbuf;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (1);
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
data[0] = 14;
|
||||
gst_buffer_unmap (outbuf, data, -1);
|
||||
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||
map.data[0] = 14;
|
||||
gst_buffer_unmap (outbuf, &map);
|
||||
|
||||
return outbuf;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
if (G_UNLIKELY (!rtpqdm2depay->configured)) {
|
||||
guint8 *ourdata;
|
||||
GstBuffer *codecdata;
|
||||
guint8 *cdata;
|
||||
GstMapInfo cmap;
|
||||
GstCaps *caps;
|
||||
|
||||
/* First bytes are unknown */
|
||||
|
@ -306,10 +306,10 @@ gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
/* Caps */
|
||||
codecdata = gst_buffer_new_and_alloc (48);
|
||||
cdata = gst_buffer_map (codecdata, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (cdata, headheader, 20);
|
||||
memcpy (cdata + 20, ourdata, 28);
|
||||
gst_buffer_unmap (codecdata, cdata, -1);
|
||||
gst_buffer_map (codecdata, &cmap, GST_MAP_WRITE);
|
||||
memcpy (cmap.data, headheader, 20);
|
||||
memcpy (cmap.data + 20, ourdata, 28);
|
||||
gst_buffer_unmap (codecdata, &cmap);
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-qdm2",
|
||||
"samplesize", G_TYPE_INT, 16,
|
||||
|
|
|
@ -118,7 +118,8 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
GstRtpSPEEXDepay *rtpspeexdepay;
|
||||
gint clock_rate, nb_channels;
|
||||
GstBuffer *buf;
|
||||
guint8 *data, *bdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
const gchar *params;
|
||||
GstCaps *srccaps;
|
||||
gboolean res;
|
||||
|
@ -139,7 +140,8 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
|
||||
/* construct minimal header and comment packet for the decoder */
|
||||
buf = gst_buffer_new_and_alloc (80);
|
||||
data = bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||
data = map.data;
|
||||
memcpy (data, "Speex ", 8);
|
||||
data += 8;
|
||||
memcpy (data, "1.1.12", 7);
|
||||
|
@ -169,7 +171,7 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
GST_WRITE_UINT32_LE (data, 0); /* reserved1 */
|
||||
data += 4;
|
||||
GST_WRITE_UINT32_LE (data, 0); /* reserved2 */
|
||||
gst_buffer_unmap (buf, bdata, -1);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
|
||||
srccaps = gst_caps_new_empty_simple ("audio/x-speex");
|
||||
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
||||
|
@ -178,9 +180,8 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
|||
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpspeexdepay), buf);
|
||||
|
||||
buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_speex_comment));
|
||||
bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (bdata, gst_rtp_speex_comment, sizeof (gst_rtp_speex_comment));
|
||||
gst_buffer_unmap (buf, bdata, -1);
|
||||
gst_buffer_fill (buf, 0, gst_rtp_speex_comment,
|
||||
sizeof (gst_rtp_speex_comment));
|
||||
|
||||
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpspeexdepay), buf);
|
||||
|
||||
|
|
|
@ -233,22 +233,22 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
{
|
||||
GstRtpSPEEXPay *rtpspeexpay;
|
||||
guint payload_len;
|
||||
gsize size;
|
||||
GstMapInfo map;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *payload, *data;
|
||||
guint8 *payload;
|
||||
GstClockTime timestamp, duration;
|
||||
GstFlowReturn ret;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpspeexpay = GST_RTP_SPEEX_PAY (basepayload);
|
||||
|
||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
switch (rtpspeexpay->packet) {
|
||||
case 0:
|
||||
/* ident packet. We need to parse the headers to construct the RTP
|
||||
* properties. */
|
||||
if (!gst_rtp_speex_pay_parse_ident (rtpspeexpay, data, size))
|
||||
if (!gst_rtp_speex_pay_parse_ident (rtpspeexpay, map.data, map.size))
|
||||
goto parse_error;
|
||||
|
||||
ret = GST_FLOW_OK;
|
||||
|
@ -271,7 +271,7 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
/* FIXME, only one SPEEX frame per RTP packet for now */
|
||||
payload_len = size;
|
||||
payload_len = map.size;
|
||||
|
||||
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
|
||||
/* FIXME, assert for now */
|
||||
|
@ -286,14 +286,14 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
|
||||
/* copy data in payload */
|
||||
memcpy (&payload[0], data, size);
|
||||
memcpy (&payload[0], map.data, map.size);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||
|
||||
done:
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
rtpspeexpay->packet++;
|
||||
|
@ -305,7 +305,7 @@ parse_error:
|
|||
{
|
||||
GST_ELEMENT_ERROR (rtpspeexpay, STREAM, DECODE, (NULL),
|
||||
("Error parsing first identification packet."));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
|
|
@ -200,8 +200,8 @@ gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
if (G_UNLIKELY (C)) {
|
||||
GstCaps *caps;
|
||||
GstBuffer *codec_data;
|
||||
GstMapInfo cmap;
|
||||
guint8 res;
|
||||
guint8 *cdata;
|
||||
|
||||
GST_DEBUG ("Configuration packet");
|
||||
|
||||
|
@ -229,14 +229,12 @@ gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
/* CodecData needs to be 'SEQH' + len (32bit) + data according to
|
||||
* ffmpeg's libavcodec/svq3.c:svq3_decode_init */
|
||||
codec_data = gst_buffer_new_and_alloc (payload_len + 6);
|
||||
cdata = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (cdata, "SEQH", 4);
|
||||
GST_WRITE_UINT32_LE (cdata + 4, payload_len - 2);
|
||||
memcpy (cdata + 8, payload + 2, payload_len - 2);
|
||||
|
||||
GST_MEMDUMP ("codec_data", cdata, gst_buffer_get_size (codec_data));
|
||||
|
||||
gst_buffer_unmap (codec_data, cdata, -1);
|
||||
gst_buffer_map (codec_data, &cmap, GST_MAP_WRITE);
|
||||
memcpy (cmap.data, "SEQH", 4);
|
||||
GST_WRITE_UINT32_LE (cmap.data + 4, payload_len - 2);
|
||||
memcpy (cmap.data + 8, payload + 2, payload_len - 2);
|
||||
GST_MEMDUMP ("codec_data", cmap.data, gst_buffer_get_size (codec_data));
|
||||
gst_buffer_unmap (codec_data, &cmap);
|
||||
|
||||
caps = gst_caps_new_simple ("video/x-svq",
|
||||
"svqversion", G_TYPE_INT, 3,
|
||||
|
|
|
@ -126,11 +126,14 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
|||
{
|
||||
GstBuffer *buf;
|
||||
guint32 num_headers;
|
||||
guint8 *data, *bdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
gint i, j;
|
||||
|
||||
data = bdata = 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 (rtptheoradepay, "config size %" G_GSIZE_FORMAT, size);
|
||||
|
||||
|
@ -236,7 +239,6 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
|||
|
||||
for (j = 0; j <= n_headers; j++) {
|
||||
guint h_size;
|
||||
guint8 *odata;
|
||||
|
||||
h_size = h_sizes[j];
|
||||
if (size < h_size) {
|
||||
|
@ -253,9 +255,7 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
|||
h_size);
|
||||
|
||||
buf = gst_buffer_new_and_alloc (h_size);
|
||||
odata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (odata, data, h_size);
|
||||
gst_buffer_unmap (buf, odata, -1);
|
||||
gst_buffer_fill (buf, 0, data, h_size);
|
||||
conf->headers = g_list_append (conf->headers, buf);
|
||||
data += h_size;
|
||||
size -= h_size;
|
||||
|
@ -263,14 +263,14 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
|||
rtptheoradepay->configs = g_list_append (rtptheoradepay->configs, conf);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (confbuf, bdata, -1);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
too_small:
|
||||
{
|
||||
GST_DEBUG_OBJECT (rtptheoradepay, "configuration too small");
|
||||
gst_buffer_unmap (confbuf, bdata, -1);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -281,23 +281,23 @@ gst_rtp_theora_depay_parse_inband_configuration (GstRtpTheoraDepay *
|
|||
guint length)
|
||||
{
|
||||
GstBuffer *confbuf;
|
||||
guint8 *conf;
|
||||
GstMapInfo map;
|
||||
|
||||
if (G_UNLIKELY (size < 4))
|
||||
return FALSE;
|
||||
|
||||
/* transform inline to out-of-band and parse that one */
|
||||
confbuf = gst_buffer_new_and_alloc (size + 9);
|
||||
conf = gst_buffer_map (confbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
gst_buffer_map (confbuf, &map, GST_MAP_WRITE);
|
||||
/* 1 header */
|
||||
GST_WRITE_UINT32_BE (conf, 1);
|
||||
GST_WRITE_UINT32_BE (map.data, 1);
|
||||
/* write Ident */
|
||||
GST_WRITE_UINT24_BE (conf + 4, ident);
|
||||
GST_WRITE_UINT24_BE (map.data + 4, ident);
|
||||
/* write sort-of-length */
|
||||
GST_WRITE_UINT16_BE (conf + 7, length);
|
||||
GST_WRITE_UINT16_BE (map.data + 7, length);
|
||||
/* copy remainder */
|
||||
memcpy (conf + 9, configuration, size);
|
||||
gst_buffer_unmap (confbuf, conf, -1);
|
||||
memcpy (map.data + 9, configuration, size);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
|
||||
return gst_rtp_theora_depay_parse_configuration (rtptheoradepay, confbuf);
|
||||
}
|
||||
|
@ -547,12 +547,8 @@ gst_rtp_theora_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
|||
(payload - to_free) + length, payload - to_free, length));
|
||||
to_free = NULL;
|
||||
} else {
|
||||
guint8 *odata;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (length);
|
||||
odata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (odata, payload, length);
|
||||
gst_buffer_unmap (outbuf, odata, -1);
|
||||
gst_buffer_fill (outbuf, 0, payload, length);
|
||||
}
|
||||
|
||||
if (payload_len > 0 && (payload[0] & 0xC0) == 0x0)
|
||||
|
|
|
@ -335,9 +335,8 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
|||
extralen = 1;
|
||||
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||
GstMapInfo map;
|
||||
guint bsize;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
bsize = gst_buffer_get_size (buf);
|
||||
length += bsize;
|
||||
|
@ -353,9 +352,9 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
|||
} while (bsize);
|
||||
}
|
||||
/* update hash */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
ident = fnv1_hash_32_update (ident, data, size);
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
ident = fnv1_hash_32_update (ident, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
/* packet length is header size + packet length */
|
||||
|
@ -421,13 +420,12 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
|||
/* copy header data */
|
||||
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
GstMapInfo map;
|
||||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
memcpy (data, bdata, bsize);
|
||||
gst_buffer_unmap (buf, bdata, -1);
|
||||
data += bsize;
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
memcpy (data, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
data += map.size;
|
||||
}
|
||||
|
||||
/* serialize to base64 */
|
||||
|
@ -643,6 +641,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
{
|
||||
GstRtpTheoraPay *rtptheorapay;
|
||||
GstFlowReturn ret;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
GstClockTime duration, timestamp;
|
||||
|
@ -651,7 +650,9 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
|
||||
rtptheorapay = GST_RTP_THEORA_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);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
|
@ -692,7 +693,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
if (TDT != 0) {
|
||||
GST_DEBUG_OBJECT (rtptheorapay, "collecting header, buffer %p", buffer);
|
||||
/* append header to the list of headers */
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer);
|
||||
ret = GST_FLOW_OK;
|
||||
goto done;
|
||||
|
@ -753,7 +754,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
ret = gst_rtp_theora_pay_payload_buffer (rtptheorapay, TDT, data, size,
|
||||
timestamp, duration, 0);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
done:
|
||||
|
@ -764,13 +765,13 @@ wrong_size:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||
("Invalid packet size (%" G_GSIZE_FORMAT " <= 0xffff)", size), (NULL));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
parse_id_failed:
|
||||
{
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
@ -778,7 +779,7 @@ unknown_header:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||
(NULL), ("Ignoring unknown header received"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -786,7 +787,7 @@ header_error:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||
(NULL), ("Error initializing header config"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -152,12 +152,15 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
|||
{
|
||||
GstBuffer *buf;
|
||||
guint32 num_headers;
|
||||
guint8 *data, *bdata;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
guint offset;
|
||||
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);
|
||||
|
||||
|
@ -295,7 +298,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
|||
rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
|
||||
}
|
||||
|
||||
gst_buffer_unmap (confbuf, bdata, -1);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
gst_buffer_unref (confbuf);
|
||||
|
||||
return TRUE;
|
||||
|
@ -304,7 +307,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
|||
too_small:
|
||||
{
|
||||
GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
|
||||
gst_buffer_unmap (confbuf, bdata, -1);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
gst_buffer_unref (confbuf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -316,23 +319,23 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
|
|||
guint length)
|
||||
{
|
||||
GstBuffer *confbuf;
|
||||
guint8 *conf;
|
||||
GstMapInfo map;
|
||||
|
||||
if (G_UNLIKELY (size < 4))
|
||||
return FALSE;
|
||||
|
||||
/* transform inline to out-of-band and parse that one */
|
||||
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 */
|
||||
GST_WRITE_UINT32_BE (conf, 1);
|
||||
GST_WRITE_UINT32_BE (map.data, 1);
|
||||
/* write Ident */
|
||||
GST_WRITE_UINT24_BE (conf + 4, ident);
|
||||
GST_WRITE_UINT24_BE (map.data + 4, ident);
|
||||
/* write sort-of-length */
|
||||
GST_WRITE_UINT16_BE (conf + 7, length);
|
||||
GST_WRITE_UINT16_BE (map.data + 7, length);
|
||||
/* copy remainder */
|
||||
memcpy (conf + 9, configuration, size);
|
||||
gst_buffer_unmap (confbuf, conf, -1);
|
||||
memcpy (map.data + 9, configuration, size);
|
||||
gst_buffer_unmap (confbuf, &map);
|
||||
|
||||
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));
|
||||
to_free = NULL;
|
||||
} else {
|
||||
guint8 *data;
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (length);
|
||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
||||
memcpy (data, payload, length);
|
||||
gst_buffer_unmap (outbuf, data, -1);
|
||||
gst_buffer_fill (outbuf, 0, payload, length);
|
||||
}
|
||||
|
||||
payload += length;
|
||||
|
|
|
@ -291,10 +291,10 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
|
|||
ident = fnv1_hash_32_new ();
|
||||
for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
|
||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||
guint bsize, osize;
|
||||
guint8 *data;
|
||||
GstMapInfo map;
|
||||
guint bsize;
|
||||
|
||||
bsize = osize = gst_buffer_get_size (buf);
|
||||
bsize = gst_buffer_get_size (buf);
|
||||
length += bsize;
|
||||
n_headers++;
|
||||
|
||||
|
@ -307,9 +307,9 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
|
|||
} while (bsize);
|
||||
}
|
||||
/* update hash */
|
||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
||||
ident = fnv1_hash_32_update (ident, data, osize);
|
||||
gst_buffer_unmap (buf, data, -1);
|
||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||
ident = fnv1_hash_32_update (ident, map.data, map.size);
|
||||
gst_buffer_unmap (buf, &map);
|
||||
}
|
||||
|
||||
/* packet length is header size + packet length */
|
||||
|
@ -475,6 +475,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstRtpVorbisPay *rtpvorbispay;
|
||||
GstFlowReturn ret;
|
||||
guint newsize;
|
||||
GstMapInfo map;
|
||||
gsize size;
|
||||
guint8 *data;
|
||||
guint packet_len;
|
||||
|
@ -488,7 +489,9 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * 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);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||
|
||||
|
@ -523,7 +526,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
if (VDT != 0) {
|
||||
GST_DEBUG_OBJECT (rtpvorbispay, "collecting header");
|
||||
/* 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);
|
||||
ret = GST_FLOW_OK;
|
||||
goto done;
|
||||
|
@ -623,7 +626,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
if (rtp.buffer)
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
done:
|
||||
|
@ -635,13 +638,13 @@ wrong_size:
|
|||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||
("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 0xffff)", size),
|
||||
(NULL));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
parse_id_failed:
|
||||
{
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
@ -649,7 +652,7 @@ unknown_header:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||
(NULL), ("Ignoring unknown header received"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -657,7 +660,7 @@ header_error:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||
(NULL), ("Error initializing header config"));
|
||||
gst_buffer_unmap (buffer, data, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -2240,7 +2240,8 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
|
|||
|
||||
if (fci_length > 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -2091,9 +2091,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
GstRTSPSrc *src;
|
||||
GstRTSPStream *stream;
|
||||
GstFlowReturn res = GST_FLOW_OK;
|
||||
GstMapInfo map;
|
||||
guint8 *data;
|
||||
guint size;
|
||||
gsize bsize;
|
||||
GstRTSPResult ret;
|
||||
GstRTSPMessage message = { 0 };
|
||||
GstRTSPConnection *conn;
|
||||
|
@ -2101,8 +2101,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
|
||||
src = stream->parent;
|
||||
|
||||
data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
||||
size = bsize;
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
size = map.size;
|
||||
data = map.data;
|
||||
|
||||
gst_rtsp_message_init_data (&message, stream->channel[1]);
|
||||
|
||||
|
@ -2123,7 +2124,7 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|||
gst_rtsp_message_steal_body (&message, &data, &size);
|
||||
gst_rtsp_message_unset (&message);
|
||||
|
||||
gst_buffer_unmap (buffer, data, size);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return res;
|
||||
|
|
|
@ -857,14 +857,17 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
guint nfft = 2 * bands - 2;
|
||||
guint input_pos;
|
||||
gfloat *input;
|
||||
const guint8 *data, *mdata;
|
||||
GstMapInfo map;
|
||||
const guint8 *data;
|
||||
gsize size;
|
||||
guint fft_todo, msg_todo, block_size;
|
||||
gboolean have_full_interval;
|
||||
GstSpectrumChannel *cd;
|
||||
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);
|
||||
|
||||
|
@ -993,7 +996,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
|
||||
spectrum->input_pos = input_pos;
|
||||
|
||||
gst_buffer_unmap (buffer, (guint8 *) mdata, -1);
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
|
||||
g_assert (size == 0);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue