mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01: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);
|
GstCmmlDec *dec = GST_CMML_DEC (parent);
|
||||||
GstCmmlPacketType packet;
|
GstCmmlPacketType packet;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
/* the EOS page could be empty */
|
/* the EOS page could be empty */
|
||||||
|
@ -400,7 +403,7 @@ gst_cmml_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return dec->flow_return;
|
return dec->flow_return;
|
||||||
|
|
|
@ -598,23 +598,23 @@ gst_cmml_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GstCmmlEnc *enc = GST_CMML_ENC (parent);
|
GstCmmlEnc *enc = GST_CMML_ENC (parent);
|
||||||
gchar *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* the CMML handlers registered with enc->parser will override this when
|
/* the CMML handlers registered with enc->parser will override this when
|
||||||
* encoding/pushing the buffers downstream
|
* encoding/pushing the buffers downstream
|
||||||
*/
|
*/
|
||||||
enc->flow_return = GST_FLOW_OK;
|
enc->flow_return = GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
if (!gst_cmml_parser_parse_chunk (enc->parser, data, size, &err)) {
|
if (!gst_cmml_parser_parse_chunk (enc->parser, (gchar *) map.data, map.size,
|
||||||
|
&err)) {
|
||||||
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
|
GST_ELEMENT_ERROR (enc, STREAM, ENCODE, (NULL), ("%s", err->message));
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
enc->flow_return = GST_FLOW_ERROR;
|
enc->flow_return = GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return enc->flow_return;
|
return enc->flow_return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,8 +536,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
||||||
guint channels = frame->header.channels;
|
guint channels = frame->header.channels;
|
||||||
guint samples = frame->header.blocksize;
|
guint samples = frame->header.blocksize;
|
||||||
guint j, i;
|
guint j, i;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
gboolean caps_changed;
|
gboolean caps_changed;
|
||||||
|
|
||||||
GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
|
GST_LOG_OBJECT (flacdec, "samples in frame header: %d", samples);
|
||||||
|
@ -618,9 +617,9 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
||||||
GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
|
GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps");
|
||||||
outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0);
|
outbuf = gst_buffer_new_allocate (NULL, samples * channels * (width / 8), 0);
|
||||||
|
|
||||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
if (width == 8) {
|
if (width == 8) {
|
||||||
gint8 *outbuffer = (gint8 *) data;
|
gint8 *outbuffer = (gint8 *) map.data;
|
||||||
gint *reorder_map = flacdec->channel_reorder_map;
|
gint *reorder_map = flacdec->channel_reorder_map;
|
||||||
|
|
||||||
if (width != depth) {
|
if (width != depth) {
|
||||||
|
@ -637,7 +636,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (width == 16) {
|
} else if (width == 16) {
|
||||||
gint16 *outbuffer = (gint16 *) data;
|
gint16 *outbuffer = (gint16 *) map.data;
|
||||||
gint *reorder_map = flacdec->channel_reorder_map;
|
gint *reorder_map = flacdec->channel_reorder_map;
|
||||||
|
|
||||||
if (width != depth) {
|
if (width != depth) {
|
||||||
|
@ -655,7 +654,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (width == 32) {
|
} else if (width == 32) {
|
||||||
gint32 *outbuffer = (gint32 *) data;
|
gint32 *outbuffer = (gint32 *) map.data;
|
||||||
gint *reorder_map = flacdec->channel_reorder_map;
|
gint *reorder_map = flacdec->channel_reorder_map;
|
||||||
|
|
||||||
if (width != depth) {
|
if (width != depth) {
|
||||||
|
@ -675,7 +674,7 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame,
|
||||||
} else {
|
} else {
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples);
|
GST_DEBUG_OBJECT (flacdec, "pushing %d samples", samples);
|
||||||
|
|
||||||
|
@ -743,17 +742,17 @@ gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec, GstBuffer * buf)
|
||||||
if (G_UNLIKELY (!dec->got_headers)) {
|
if (G_UNLIKELY (!dec->got_headers)) {
|
||||||
gboolean got_audio_frame;
|
gboolean got_audio_frame;
|
||||||
gint64 unused;
|
gint64 unused;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* check if this is a flac audio frame (rather than a header or junk) */
|
/* check if this is a flac audio frame (rather than a header or junk) */
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
got_audio_frame = gst_flac_dec_scan_got_frame (dec, data, size, &unused);
|
got_audio_frame =
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_flac_dec_scan_got_frame (dec, map.data, map.size, &unused);
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
if (!got_audio_frame) {
|
if (!got_audio_frame) {
|
||||||
GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " "
|
GST_INFO_OBJECT (dec, "dropping in-stream header, %" G_GSIZE_FORMAT " "
|
||||||
"bytes", size);
|
"bytes", map.size);
|
||||||
gst_audio_decoder_finish_frame (audio_dec, NULL, 1);
|
gst_audio_decoder_finish_frame (audio_dec, NULL, 1);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,8 +516,7 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
|
||||||
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
|
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
|
||||||
#endif
|
#endif
|
||||||
gint i;
|
gint i;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
for (i = 0; i < n_images + n_preview_images; i++) {
|
for (i = 0; i < n_images + n_preview_images; i++) {
|
||||||
if (i < n_images) {
|
if (i < n_images) {
|
||||||
|
@ -545,10 +544,10 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc, guint64 total_samples)
|
||||||
image_type = image_type + 2;
|
image_type = image_type + 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
|
FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
|
||||||
data, size, TRUE);
|
map.data, map.size, TRUE);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* FIXME: There's no way to set the picture type in libFLAC */
|
/* FIXME: There's no way to set the picture type in libFLAC */
|
||||||
|
@ -915,6 +914,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
|
|
||||||
for (l = enc->headers; l != NULL; l = l->next) {
|
for (l = enc->headers; l != NULL; l = l->next) {
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
|
@ -925,7 +925,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
buf = GST_BUFFER_CAST (l->data);
|
buf = GST_BUFFER_CAST (l->data);
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_IN_CAPS);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
/* find initial 4-byte marker which we need to skip later on */
|
/* find initial 4-byte marker which we need to skip later on */
|
||||||
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
|
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
|
||||||
|
@ -936,7 +938,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
vorbiscomment = buf;
|
vorbiscomment = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
||||||
|
@ -951,8 +953,9 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint16 num;
|
guint16 num;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *bdata;
|
guint8 *bdata;
|
||||||
gsize bsize, slen;
|
gsize slen;
|
||||||
|
|
||||||
/* minus one for the marker that is merged with streaminfo here */
|
/* minus one for the marker that is merged with streaminfo here */
|
||||||
num = g_list_length (enc->headers) - 1;
|
num = g_list_length (enc->headers) - 1;
|
||||||
|
@ -960,7 +963,8 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
slen = gst_buffer_get_size (streaminfo);
|
slen = gst_buffer_get_size (streaminfo);
|
||||||
buf = gst_buffer_new_and_alloc (13 + slen);
|
buf = gst_buffer_new_and_alloc (13 + slen);
|
||||||
|
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
|
bdata = map.data;
|
||||||
bdata[0] = 0x7f;
|
bdata[0] = 0x7f;
|
||||||
memcpy (bdata + 1, "FLAC", 4);
|
memcpy (bdata + 1, "FLAC", 4);
|
||||||
bdata[5] = 0x01; /* mapping version major */
|
bdata[5] = 0x01; /* mapping version major */
|
||||||
|
@ -969,7 +973,7 @@ gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
||||||
bdata[8] = (num & 0x00FF) >> 0;
|
bdata[8] = (num & 0x00FF) >> 0;
|
||||||
memcpy (bdata + 9, "fLaC", 4);
|
memcpy (bdata + 9, "fLaC", 4);
|
||||||
gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
|
gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
notgst_value_array_append_buffer (&array, buf);
|
notgst_value_array_append_buffer (&array, buf);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -1169,12 +1173,11 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstFlacEnc *flacenc;
|
GstFlacEnc *flacenc;
|
||||||
FLAC__int32 *data;
|
FLAC__int32 *data;
|
||||||
gsize bsize;
|
|
||||||
gint samples, width, channels;
|
gint samples, width, channels;
|
||||||
gulong i;
|
gulong i;
|
||||||
gint j;
|
gint j;
|
||||||
FLAC__bool res;
|
FLAC__bool res;
|
||||||
gpointer bdata;
|
GstMapInfo map;
|
||||||
GstAudioInfo *info =
|
GstAudioInfo *info =
|
||||||
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
|
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
|
||||||
gint *reorder_map;
|
gint *reorder_map;
|
||||||
|
@ -1202,28 +1205,28 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
||||||
return flacenc->last_flow;
|
return flacenc->last_flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
samples = bsize / (width >> 3);
|
samples = map.size / (width >> 3);
|
||||||
|
|
||||||
data = g_malloc (samples * sizeof (FLAC__int32));
|
data = g_malloc (samples * sizeof (FLAC__int32));
|
||||||
|
|
||||||
samples /= channels;
|
samples /= channels;
|
||||||
if (width == 8) {
|
if (width == 8) {
|
||||||
gint8 *indata = (gint8 *) bdata;
|
gint8 *indata = (gint8 *) map.data;
|
||||||
|
|
||||||
for (i = 0; i < samples; i++)
|
for (i = 0; i < samples; i++)
|
||||||
for (j = 0; j < channels; j++)
|
for (j = 0; j < channels; j++)
|
||||||
data[i * channels + reorder_map[j]] =
|
data[i * channels + reorder_map[j]] =
|
||||||
(FLAC__int32) indata[i * channels + j];
|
(FLAC__int32) indata[i * channels + j];
|
||||||
} else if (width == 16) {
|
} else if (width == 16) {
|
||||||
gint16 *indata = (gint16 *) bdata;
|
gint16 *indata = (gint16 *) map.data;
|
||||||
|
|
||||||
for (i = 0; i < samples; i++)
|
for (i = 0; i < samples; i++)
|
||||||
for (j = 0; j < channels; j++)
|
for (j = 0; j < channels; j++)
|
||||||
data[i * channels + reorder_map[j]] =
|
data[i * channels + reorder_map[j]] =
|
||||||
(FLAC__int32) indata[i * channels + j];
|
(FLAC__int32) indata[i * channels + j];
|
||||||
} else if (width == 24) {
|
} else if (width == 24) {
|
||||||
guint8 *indata = (guint8 *) bdata;
|
guint8 *indata = (guint8 *) map.data;
|
||||||
guint32 val;
|
guint32 val;
|
||||||
|
|
||||||
for (i = 0; i < samples; i++)
|
for (i = 0; i < samples; i++)
|
||||||
|
@ -1234,7 +1237,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
||||||
data[i * channels + reorder_map[j]] = (FLAC__int32) val;
|
data[i * channels + reorder_map[j]] = (FLAC__int32) val;
|
||||||
}
|
}
|
||||||
} else if (width == 32) {
|
} else if (width == 32) {
|
||||||
gint32 *indata = (gint32 *) bdata;
|
gint32 *indata = (gint32 *) map.data;
|
||||||
|
|
||||||
for (i = 0; i < samples; i++)
|
for (i = 0; i < samples; i++)
|
||||||
for (j = 0; j < channels; j++)
|
for (j = 0; j < channels; j++)
|
||||||
|
@ -1243,7 +1246,7 @@ gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
||||||
} else {
|
} else {
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
|
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
|
||||||
(const FLAC__int32 *) data, samples / channels);
|
(const FLAC__int32 *) data, samples / channels);
|
||||||
|
|
|
@ -191,7 +191,7 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstFlacTag *tag;
|
GstFlacTag *tag;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
|
@ -284,9 +284,9 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
/* clear the is-last flag, as the last metadata block will
|
/* clear the is-last flag, as the last metadata block will
|
||||||
* be the vorbis comment block which we will build ourselves.
|
* be the vorbis comment block which we will build ourselves.
|
||||||
*/
|
*/
|
||||||
data = gst_buffer_map (metadata_buffer, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (metadata_buffer, &map, GST_MAP_READWRITE);
|
||||||
data[0] &= (~0x80);
|
map.data[0] &= (~0x80);
|
||||||
gst_buffer_unmap (metadata_buffer, data, size);
|
gst_buffer_unmap (metadata_buffer, &map);
|
||||||
|
|
||||||
if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
|
if (tag->state == GST_FLAC_TAG_STATE_WRITING_METADATA_BLOCK) {
|
||||||
GST_DEBUG_OBJECT (tag, "pushing metadata block buffer");
|
GST_DEBUG_OBJECT (tag, "pushing metadata block buffer");
|
||||||
|
@ -362,11 +362,11 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
goto no_buffer;
|
goto no_buffer;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
memset (data, 0, size);
|
memset (map.data, 0, map.size);
|
||||||
data[0] = 0x81; /* 0x80 = Last metadata block,
|
map.data[0] = 0x81; /* 0x80 = Last metadata block,
|
||||||
* 0x01 = padding block */
|
* 0x01 = padding block */
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
} else {
|
} else {
|
||||||
guchar header[4];
|
guchar header[4];
|
||||||
guint8 fbit[1];
|
guint8 fbit[1];
|
||||||
|
@ -399,14 +399,14 @@ gst_flac_tag_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
/* The 4 byte metadata block header isn't accounted for in the total
|
/* The 4 byte metadata block header isn't accounted for in the total
|
||||||
* size of the metadata block
|
* size of the metadata block
|
||||||
*/
|
*/
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
data[1] = (((size - 4) & 0xFF0000) >> 16);
|
map.data[1] = (((map.size - 4) & 0xFF0000) >> 16);
|
||||||
data[2] = (((size - 4) & 0x00FF00) >> 8);
|
map.data[2] = (((map.size - 4) & 0x00FF00) >> 8);
|
||||||
data[3] = ((size - 4) & 0x0000FF);
|
map.data[3] = ((map.size - 4) & 0x0000FF);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment "
|
GST_DEBUG_OBJECT (tag, "pushing %" G_GSIZE_FORMAT " byte vorbiscomment "
|
||||||
"buffer", size);
|
"buffer", map.size);
|
||||||
|
|
||||||
ret = gst_pad_push (tag->srcpad, buffer);
|
ret = gst_pad_push (tag->srcpad, buffer);
|
||||||
if (ret != GST_FLOW_OK) {
|
if (ret != GST_FLOW_OK) {
|
||||||
|
|
|
@ -159,10 +159,11 @@ static void
|
||||||
ensure_memory (GstJpegEnc * jpegenc)
|
ensure_memory (GstJpegEnc * jpegenc)
|
||||||
{
|
{
|
||||||
GstMemory *new_memory;
|
GstMemory *new_memory;
|
||||||
|
GstMapInfo map;
|
||||||
gsize old_size, desired_size, new_size;
|
gsize old_size, desired_size, new_size;
|
||||||
guint8 *new_data;
|
guint8 *new_data;
|
||||||
|
|
||||||
old_size = jpegenc->output_size;
|
old_size = jpegenc->output_map.size;
|
||||||
if (old_size == 0)
|
if (old_size == 0)
|
||||||
desired_size = jpegenc->bufsize;
|
desired_size = jpegenc->bufsize;
|
||||||
else
|
else
|
||||||
|
@ -171,19 +172,20 @@ ensure_memory (GstJpegEnc * jpegenc)
|
||||||
/* Our output memory wasn't big enough.
|
/* Our output memory wasn't big enough.
|
||||||
* Make a new memory that's twice the size, */
|
* Make a new memory that's twice the size, */
|
||||||
new_memory = gst_allocator_alloc (NULL, desired_size, 3);
|
new_memory = gst_allocator_alloc (NULL, desired_size, 3);
|
||||||
new_data = gst_memory_map (new_memory, &new_size, NULL, GST_MAP_READWRITE);
|
gst_memory_map (new_memory, &map, GST_MAP_READWRITE);
|
||||||
|
new_data = map.data;
|
||||||
|
new_size = map.size;
|
||||||
|
|
||||||
/* copy previous data if any */
|
/* copy previous data if any */
|
||||||
if (jpegenc->output_mem) {
|
if (jpegenc->output_mem) {
|
||||||
memcpy (new_data, jpegenc->output_data, old_size);
|
memcpy (new_data, jpegenc->output_map.data, old_size);
|
||||||
gst_memory_unmap (jpegenc->output_mem);
|
gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
|
||||||
gst_memory_unref (jpegenc->output_mem);
|
gst_memory_unref (jpegenc->output_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* drop it into place, */
|
/* drop it into place, */
|
||||||
jpegenc->output_mem = new_memory;
|
jpegenc->output_mem = new_memory;
|
||||||
jpegenc->output_data = new_data;
|
jpegenc->output_map = map;
|
||||||
jpegenc->output_size = new_size;
|
|
||||||
|
|
||||||
/* and last, update libjpeg on where to work. */
|
/* and last, update libjpeg on where to work. */
|
||||||
jpegenc->jdest.next_output_byte = new_data + old_size;
|
jpegenc->jdest.next_output_byte = new_data + old_size;
|
||||||
|
@ -215,12 +217,12 @@ gst_jpegenc_term_destination (j_compress_ptr cinfo)
|
||||||
GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
|
GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);
|
||||||
GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
|
GST_DEBUG_OBJECT (jpegenc, "gst_jpegenc_chain: term_source");
|
||||||
|
|
||||||
gst_memory_unmap (jpegenc->output_mem);
|
gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);
|
||||||
/* Trim the buffer size. we will push it in the chain function */
|
/* Trim the buffer size. we will push it in the chain function */
|
||||||
gst_memory_resize (jpegenc->output_mem, 0,
|
gst_memory_resize (jpegenc->output_mem, 0,
|
||||||
jpegenc->output_size - jpegenc->jdest.free_in_buffer);
|
jpegenc->output_map.size - jpegenc->jdest.free_in_buffer);
|
||||||
jpegenc->output_data = NULL;
|
jpegenc->output_map.data = NULL;
|
||||||
jpegenc->output_size = 0;
|
jpegenc->output_map.size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -566,12 +568,10 @@ gst_jpegenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3);
|
jpegenc->output_mem = gst_allocator_alloc (NULL, jpegenc->bufsize, 3);
|
||||||
jpegenc->output_data =
|
gst_memory_map (jpegenc->output_mem, &jpegenc->output_map, GST_MAP_READWRITE);
|
||||||
gst_memory_map (jpegenc->output_mem, &jpegenc->output_size, NULL,
|
|
||||||
GST_MAP_READWRITE);
|
|
||||||
|
|
||||||
jpegenc->jdest.next_output_byte = jpegenc->output_data;
|
jpegenc->jdest.next_output_byte = jpegenc->output_map.data;
|
||||||
jpegenc->jdest.free_in_buffer = jpegenc->output_size;
|
jpegenc->jdest.free_in_buffer = jpegenc->output_map.size;
|
||||||
|
|
||||||
/* prepare for raw input */
|
/* prepare for raw input */
|
||||||
#if JPEG_LIB_VERSION >= 70
|
#if JPEG_LIB_VERSION >= 70
|
||||||
|
|
|
@ -86,8 +86,7 @@ struct _GstJpegEnc
|
||||||
GstFlowReturn last_ret;
|
GstFlowReturn last_ret;
|
||||||
|
|
||||||
GstMemory *output_mem;
|
GstMemory *output_mem;
|
||||||
gpointer output_data;
|
GstMapInfo output_map;
|
||||||
gsize output_size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstJpegEncClass
|
struct _GstJpegEncClass
|
||||||
|
|
|
@ -615,8 +615,7 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstPngDec *pngdec;
|
GstPngDec *pngdec;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 *bdata = NULL;
|
GstMapInfo map = GST_MAP_INFO_INIT;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
pngdec = GST_PNGDEC (parent);
|
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_timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
pngdec->in_duration = GST_BUFFER_DURATION (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 */
|
/* 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->image_ready) {
|
||||||
if (pngdec->framed) {
|
if (pngdec->framed) {
|
||||||
|
@ -666,8 +665,8 @@ gst_pngdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
ret = pngdec->ret;
|
ret = pngdec->ret;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
if (G_LIKELY (bdata))
|
if (G_LIKELY (map.data))
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
/* And release the buffer */
|
/* And release the buffer */
|
||||||
gst_buffer_unref (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)
|
user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length)
|
||||||
{
|
{
|
||||||
GstPngEnc *pngenc;
|
GstPngEnc *pngenc;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *bdata;
|
|
||||||
|
|
||||||
pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr);
|
pngenc = (GstPngEnc *) png_get_io_ptr (png_ptr);
|
||||||
|
|
||||||
bdata = gst_buffer_map (pngenc->buffer_out, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (pngenc->buffer_out, &map, GST_MAP_WRITE);
|
||||||
if (pngenc->written + length >= size) {
|
if (pngenc->written + length >= map.size) {
|
||||||
gst_buffer_unmap (pngenc->buffer_out, data, -1);
|
gst_buffer_unmap (pngenc->buffer_out, &map);
|
||||||
GST_ERROR_OBJECT (pngenc, "output buffer bigger than the input buffer!?");
|
GST_ERROR_OBJECT (pngenc, "output buffer bigger than the input buffer!?");
|
||||||
png_error (png_ptr, "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);
|
GST_DEBUG_OBJECT (pngenc, "writing %u bytes", (guint) length);
|
||||||
|
|
||||||
memcpy (bdata + pngenc->written, data, length);
|
memcpy (map.data + pngenc->written, data, length);
|
||||||
gst_buffer_unmap (pngenc->buffer_out, data, -1);
|
gst_buffer_unmap (pngenc->buffer_out, &map);
|
||||||
pngenc->written += length;
|
pngenc->written += length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1737,8 +1737,7 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
|
||||||
/* FIXME: alloc memory from PA if possible */
|
/* FIXME: alloc memory from PA if possible */
|
||||||
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
|
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
|
||||||
GstBuffer *out;
|
GstBuffer *out;
|
||||||
guint8 *indata, *outdata;
|
GstMapInfo inmap, outmap;
|
||||||
gsize insize, outsize;
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
if (framesize <= 0)
|
if (framesize <= 0)
|
||||||
|
@ -1746,14 +1745,14 @@ gst_pulsesink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
|
||||||
|
|
||||||
out = gst_buffer_new_and_alloc (framesize);
|
out = gst_buffer_new_and_alloc (framesize);
|
||||||
|
|
||||||
indata = gst_buffer_map (buf, &insize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &inmap, GST_MAP_READ);
|
||||||
outdata = gst_buffer_map (out, &outsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (out, &outmap, GST_MAP_WRITE);
|
||||||
|
|
||||||
res = gst_audio_iec61937_payload (indata, insize,
|
res = gst_audio_iec61937_payload (inmap.data, inmap.size,
|
||||||
outdata, outsize, &sink->ringbuffer->spec);
|
outmap.data, outmap.size, &sink->ringbuffer->spec);
|
||||||
|
|
||||||
gst_buffer_unmap (buf, indata, insize);
|
gst_buffer_unmap (buf, &inmap);
|
||||||
gst_buffer_unmap (out, outdata, outsize);
|
gst_buffer_unmap (out, &outmap);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
gst_buffer_unref (out);
|
gst_buffer_unref (out);
|
||||||
|
|
|
@ -623,30 +623,28 @@ send_message_locked (GstSoupHttpClientSink * souphttpsink)
|
||||||
if (souphttpsink->offset == 0) {
|
if (souphttpsink->offset == 0) {
|
||||||
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
|
for (g = souphttpsink->streamheader_buffers; g; g = g_list_next (g)) {
|
||||||
GstBuffer *buffer = g->data;
|
GstBuffer *buffer = g->data;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* FIXME, lifetime of the buffer? */
|
/* FIXME, lifetime of the buffer? */
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
soup_message_body_append (souphttpsink->message->request_body,
|
soup_message_body_append (souphttpsink->message->request_body,
|
||||||
SOUP_MEMORY_STATIC, data, size);
|
SOUP_MEMORY_STATIC, map.data, map.size);
|
||||||
n += size;
|
n += map.size;
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
|
for (g = souphttpsink->queued_buffers; g; g = g_list_next (g)) {
|
||||||
GstBuffer *buffer = g->data;
|
GstBuffer *buffer = g->data;
|
||||||
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
|
if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* FIXME, lifetime of the buffer? */
|
/* FIXME, lifetime of the buffer? */
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
soup_message_body_append (souphttpsink->message->request_body,
|
soup_message_body_append (souphttpsink->message->request_body,
|
||||||
SOUP_MEMORY_STATIC, data, size);
|
SOUP_MEMORY_STATIC, map.data, map.size);
|
||||||
n += size;
|
n += map.size;
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -876,7 +876,7 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
} SoupGstChunk;
|
} SoupGstChunk;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -884,7 +884,7 @@ gst_soup_http_src_chunk_free (gpointer user_data)
|
||||||
{
|
{
|
||||||
SoupGstChunk *chunk = (SoupGstChunk *) user_data;
|
SoupGstChunk *chunk = (SoupGstChunk *) user_data;
|
||||||
|
|
||||||
gst_buffer_unmap (chunk->buffer, chunk->data, -1);
|
gst_buffer_unmap (chunk->buffer, &chunk->map);
|
||||||
gst_buffer_unref (chunk->buffer);
|
gst_buffer_unref (chunk->buffer);
|
||||||
g_slice_free (SoupGstChunk, chunk);
|
g_slice_free (SoupGstChunk, chunk);
|
||||||
}
|
}
|
||||||
|
@ -919,9 +919,9 @@ gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
|
||||||
|
|
||||||
chunk = g_slice_new0 (SoupGstChunk);
|
chunk = g_slice_new0 (SoupGstChunk);
|
||||||
chunk->buffer = gstbuf;
|
chunk->buffer = gstbuf;
|
||||||
chunk->data = gst_buffer_map (gstbuf, &length, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
|
||||||
|
|
||||||
soupbuf = soup_buffer_new_with_owner (chunk->data, length,
|
soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
|
||||||
chunk, gst_soup_http_src_chunk_free);
|
chunk, gst_soup_http_src_chunk_free);
|
||||||
|
|
||||||
return soupbuf;
|
return soupbuf;
|
||||||
|
|
|
@ -190,13 +190,12 @@ static GstFlowReturn
|
||||||
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
|
gst_speex_dec_parse_header (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
char *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
/* get the header */
|
/* get the header */
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
dec->header = speex_packet_to_header (data, size);
|
dec->header = speex_packet_to_header ((gchar *) map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
if (!dec->header)
|
if (!dec->header)
|
||||||
goto no_header;
|
goto no_header;
|
||||||
|
@ -368,23 +367,22 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
gint i, fpp;
|
gint i, fpp;
|
||||||
SpeexBits *bits;
|
SpeexBits *bits;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
char *data;
|
|
||||||
|
|
||||||
if (!dec->frame_duration)
|
if (!dec->frame_duration)
|
||||||
goto not_negotiated;
|
goto not_negotiated;
|
||||||
|
|
||||||
if (G_LIKELY (gst_buffer_get_size (buf))) {
|
if (G_LIKELY (gst_buffer_get_size (buf))) {
|
||||||
/* send data to the bitstream */
|
/* send data to the bitstream */
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
speex_bits_read_from (&dec->bits, data, size);
|
speex_bits_read_from (&dec->bits, (gchar *) map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
fpp = dec->header->frames_per_packet;
|
fpp = dec->header->frames_per_packet;
|
||||||
bits = &dec->bits;
|
bits = &dec->bits;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT
|
GST_DEBUG_OBJECT (dec, "received buffer of size %" G_GSIZE_FORMAT
|
||||||
", fpp %d, %d bits", size, fpp, speex_bits_remaining (bits));
|
", fpp %d, %d bits", map.size, fpp, speex_bits_remaining (bits));
|
||||||
} else {
|
} else {
|
||||||
/* FIXME ? actually consider how much concealment is needed */
|
/* FIXME ? actually consider how much concealment is needed */
|
||||||
/* concealment data, pass NULL as the bits parameters */
|
/* concealment data, pass NULL as the bits parameters */
|
||||||
|
@ -396,7 +394,6 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
/* now decode each frame, catering for unknown number of them (e.g. rtp) */
|
/* now decode each frame, catering for unknown number of them (e.g. rtp) */
|
||||||
for (i = 0; i < fpp; i++) {
|
for (i = 0; i < fpp; i++) {
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gint16 *out_data;
|
|
||||||
gint ret;
|
gint ret;
|
||||||
|
|
||||||
GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp,
|
GST_LOG_OBJECT (dec, "decoding frame %d/%d, %d bits remaining", i, fpp,
|
||||||
|
@ -418,9 +415,8 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
gst_buffer_new_allocate (NULL,
|
gst_buffer_new_allocate (NULL,
|
||||||
dec->frame_size * dec->header->nb_channels * 2, 0);
|
dec->frame_size * dec->header->nb_channels * 2, 0);
|
||||||
|
|
||||||
out_data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
ret = speex_decode_int (dec->state, bits, out_data);
|
ret = speex_decode_int (dec->state, bits, (spx_int16_t *) map.data);
|
||||||
gst_buffer_unmap (outbuf, out_data, size);
|
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
/* uh? end of stream */
|
/* uh? end of stream */
|
||||||
|
@ -445,7 +441,10 @@ gst_speex_dec_parse_data (GstSpeexDec * dec, GstBuffer * buf)
|
||||||
gst_buffer_unref (outbuf);
|
gst_buffer_unref (outbuf);
|
||||||
}
|
}
|
||||||
if (dec->header->nb_channels == 2)
|
if (dec->header->nb_channels == 2)
|
||||||
speex_decode_stereo_int (out_data, dec->frame_size, dec->stereo);
|
speex_decode_stereo_int ((spx_int16_t *) map.data, dec->frame_size,
|
||||||
|
dec->stereo);
|
||||||
|
|
||||||
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
|
res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
|
||||||
|
|
||||||
|
@ -469,8 +468,8 @@ not_negotiated:
|
||||||
static gboolean
|
static gboolean
|
||||||
memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
|
memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
|
||||||
{
|
{
|
||||||
|
GstMapInfo map;
|
||||||
gsize size1, size2;
|
gsize size1, size2;
|
||||||
gpointer data1;
|
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
size1 = gst_buffer_get_size (buf1);
|
size1 = gst_buffer_get_size (buf1);
|
||||||
|
@ -479,9 +478,9 @@ memcmp_buffers (GstBuffer * buf1, GstBuffer * buf2)
|
||||||
if (size1 != size2)
|
if (size1 != size2)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
data1 = gst_buffer_map (buf1, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buf1, &map, GST_MAP_READ);
|
||||||
res = gst_buffer_memcmp (buf2, 0, data1, size1) == 0;
|
res = gst_buffer_memcmp (buf2, 0, map.data, map.size) == 0;
|
||||||
gst_buffer_unmap (buf1, data1, size1);
|
gst_buffer_unmap (buf1, &map);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -539,13 +539,16 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
||||||
gint frame_size = enc->frame_size;
|
gint frame_size = enc->frame_size;
|
||||||
gint bytes = frame_size * 2 * enc->channels, samples;
|
gint bytes = frame_size * 2 * enc->channels, samples;
|
||||||
gint outsize, written, dtx_ret = 0;
|
gint outsize, written, dtx_ret = 0;
|
||||||
guint8 *data, *data0 = NULL, *bdata, *outdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data, *data0 = NULL, *bdata;
|
||||||
gsize bsize, size;
|
gsize bsize, size;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
if (G_LIKELY (buf)) {
|
if (G_LIKELY (buf)) {
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
bdata = map.data;
|
||||||
|
bsize = map.size;
|
||||||
|
|
||||||
if (G_UNLIKELY (bsize % bytes)) {
|
if (G_UNLIKELY (bsize % bytes)) {
|
||||||
GST_DEBUG_OBJECT (enc, "draining; adding silence samples");
|
GST_DEBUG_OBJECT (enc, "draining; adding silence samples");
|
||||||
|
@ -553,7 +556,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
||||||
size = ((bsize / bytes) + 1) * bytes;
|
size = ((bsize / bytes) + 1) * bytes;
|
||||||
data0 = data = g_malloc0 (size);
|
data0 = data = g_malloc0 (size);
|
||||||
memcpy (data, bdata, bsize);
|
memcpy (data, bdata, bsize);
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
bdata = NULL;
|
bdata = NULL;
|
||||||
} else {
|
} else {
|
||||||
data = bdata;
|
data = bdata;
|
||||||
|
@ -585,7 +588,7 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
||||||
outsize = speex_bits_nbytes (&enc->bits);
|
outsize = speex_bits_nbytes (&enc->bits);
|
||||||
|
|
||||||
if (bdata)
|
if (bdata)
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc),
|
ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc),
|
||||||
|
@ -596,9 +599,9 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
||||||
goto done;
|
goto done;
|
||||||
#endif
|
#endif
|
||||||
outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
|
outbuf = gst_buffer_new_allocate (NULL, outsize, 0);
|
||||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
|
|
||||||
written = speex_bits_write (&enc->bits, (gchar *) outdata, outsize);
|
written = speex_bits_write (&enc->bits, (gchar *) map.data, outsize);
|
||||||
|
|
||||||
if (G_UNLIKELY (written < outsize)) {
|
if (G_UNLIKELY (written < outsize)) {
|
||||||
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
|
GST_ERROR_OBJECT (enc, "short write: %d < %d bytes", written, outsize);
|
||||||
|
@ -606,7 +609,8 @@ gst_speex_enc_encode (GstSpeexEnc * enc, GstBuffer * buf)
|
||||||
GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize);
|
GST_ERROR_OBJECT (enc, "overrun: %d > %d bytes", written, outsize);
|
||||||
written = outsize;
|
written = outsize;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (outbuf, outdata, written);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
gst_buffer_resize (outbuf, 0, written);
|
||||||
|
|
||||||
if (!dtx_ret)
|
if (!dtx_ret)
|
||||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||||
|
|
|
@ -328,24 +328,23 @@ static gboolean
|
||||||
gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
|
gst_ape_demux_identify_tag (GstTagDemux * demux, GstBuffer * buffer,
|
||||||
gboolean start_tag, guint * tag_size)
|
gboolean start_tag, guint * tag_size)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
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",
|
GST_DEBUG_OBJECT (demux, "No APETAGEX marker at %s - not an APE file",
|
||||||
(start_tag) ? "start" : "end");
|
(start_tag) ? "start" : "end");
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
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 */
|
/* size is without header, so add 32 to account for that */
|
||||||
*tag_size += 32;
|
*tag_size += 32;
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -354,15 +353,18 @@ static GstTagDemuxResult
|
||||||
gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
|
gst_ape_demux_parse_tag (GstTagDemux * demux, GstBuffer * buffer,
|
||||||
gboolean start_tag, guint * tag_size, GstTagList ** tags)
|
gboolean start_tag, guint * tag_size, GstTagList ** tags)
|
||||||
{
|
{
|
||||||
guint8 *data_start, *data;
|
guint8 *data;
|
||||||
guint8 *footer;
|
guint8 *footer;
|
||||||
gboolean have_header;
|
gboolean have_header;
|
||||||
gboolean end_tag = !start_tag;
|
gboolean end_tag = !start_tag;
|
||||||
GstCaps *sink_caps;
|
GstCaps *sink_caps;
|
||||||
guint version, footer_size;
|
guint version, footer_size;
|
||||||
|
GstMapInfo map;
|
||||||
gsize size;
|
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);
|
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_TAG_CONTAINER_FORMAT, sink_caps);
|
||||||
gst_caps_unref (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;
|
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);
|
GstAudioAmplify *filter = GST_AUDIO_AMPLIFY (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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)))
|
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -691,8 +691,7 @@ gst_audio_dynamic_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
|
GstAudioDynamic *filter = GST_AUDIO_DYNAMIC (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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)))
|
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,8 +359,7 @@ gst_audio_echo_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
GstAudioEcho *self = GST_AUDIO_ECHO (base);
|
GstAudioEcho *self = GST_AUDIO_ECHO (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (self);
|
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;
|
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 channels = GST_AUDIO_FILTER_CHANNELS (self);
|
||||||
gint bps = GST_AUDIO_FILTER_BPS (self);
|
gint bps = GST_AUDIO_FILTER_BPS (self);
|
||||||
gint outsize, outsamples;
|
gint outsize, outsamples;
|
||||||
guint8 *in, *out, *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
guint8 *in, *out;
|
||||||
|
|
||||||
if (channels == 0 || rate == 0 || self->nsamples_in == 0) {
|
if (channels == 0 || rate == 0 || self->nsamples_in == 0) {
|
||||||
self->buffer_fill = 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 */
|
/* Convolve the residue with zeros to get the actual remaining data */
|
||||||
in = g_new0 (guint8, outsize);
|
in = g_new0 (guint8, outsize);
|
||||||
data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_READWRITE);
|
||||||
self->nsamples_out += self->process (self, in, data, outsamples);
|
self->nsamples_out += self->process (self, in, map.data, outsamples);
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
g_free (in);
|
g_free (in);
|
||||||
} else {
|
} else {
|
||||||
guint gensamples = 0;
|
guint gensamples = 0;
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
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) {
|
while (gensamples < outsamples) {
|
||||||
guint step_insamples = self->block_length - self->buffer_fill;
|
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);
|
step_gensamples = self->process (self, zeroes, out, step_insamples);
|
||||||
g_free (zeroes);
|
g_free (zeroes);
|
||||||
|
|
||||||
memcpy (data + gensamples * bps, out, MIN (step_gensamples,
|
memcpy (map.data + gensamples * bps, out, MIN (step_gensamples,
|
||||||
outsamples - gensamples) * bps);
|
outsamples - gensamples) * bps);
|
||||||
gensamples += MIN (step_gensamples, outsamples - gensamples);
|
gensamples += MIN (step_gensamples, outsamples - gensamples);
|
||||||
|
|
||||||
|
@ -696,7 +696,7 @@ gst_audio_fx_base_fir_filter_push_residue (GstAudioFXBaseFIRFilter * self)
|
||||||
}
|
}
|
||||||
self->nsamples_out += gensamples;
|
self->nsamples_out += gensamples;
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set timestamp, offset, etc from the values we
|
/* 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 channels = GST_AUDIO_FILTER_CHANNELS (self);
|
||||||
gint rate = GST_AUDIO_FILTER_RATE (self);
|
gint rate = GST_AUDIO_FILTER_RATE (self);
|
||||||
gint bps = GST_AUDIO_FILTER_BPS (self);
|
gint bps = GST_AUDIO_FILTER_BPS (self);
|
||||||
guint8 *indata, *outdata;
|
GstMapInfo inmap, outmap;
|
||||||
gsize insize, outsize;
|
|
||||||
guint input_samples;
|
guint input_samples;
|
||||||
guint output_samples;
|
guint output_samples;
|
||||||
guint generated_samples;
|
guint generated_samples;
|
||||||
|
@ -858,18 +857,19 @@ gst_audio_fx_base_fir_filter_transform (GstBaseTransform * base,
|
||||||
self->start_off = GST_BUFFER_OFFSET (inbuf);
|
self->start_off = GST_BUFFER_OFFSET (inbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
|
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
|
||||||
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||||
|
|
||||||
input_samples = (insize / bps) / channels;
|
input_samples = (inmap.size / bps) / channels;
|
||||||
output_samples = (outsize / bps) / channels;
|
output_samples = (outmap.size / bps) / channels;
|
||||||
|
|
||||||
self->nsamples_in += input_samples;
|
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 (inbuf, &inmap);
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
|
|
||||||
g_assert (generated_samples <= output_samples);
|
g_assert (generated_samples <= output_samples);
|
||||||
self->nsamples_out += generated_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);
|
GstAudioFXBaseIIRFilter *filter = GST_AUDIO_FX_BASE_IIR_FILTER (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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);
|
g_return_val_if_fail (filter->a != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,8 +228,7 @@ gst_audio_invert_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
|
GstAudioInvert *filter = GST_AUDIO_INVERT (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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)))
|
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,8 +331,7 @@ gst_audio_karaoke_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
|
GstAudioKaraoke *filter = GST_AUDIO_KARAOKE (base);
|
||||||
guint num_samples;
|
guint num_samples;
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
stream_time =
|
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)))
|
G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
num_samples = size / GST_AUDIO_FILTER_BPS (filter);
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,8 +626,7 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
{
|
{
|
||||||
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
|
GstAudioPanorama *filter = GST_AUDIO_PANORAMA (base);
|
||||||
GstClockTime timestamp, stream_time;
|
GstClockTime timestamp, stream_time;
|
||||||
guint8 *indata, *outdata;
|
GstMapInfo inmap, outmap;
|
||||||
gsize insize, outsize;
|
|
||||||
|
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
|
||||||
stream_time =
|
stream_time =
|
||||||
|
@ -639,20 +638,20 @@ gst_audio_panorama_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
||||||
if (GST_CLOCK_TIME_IS_VALID (stream_time))
|
if (GST_CLOCK_TIME_IS_VALID (stream_time))
|
||||||
gst_object_sync_values (GST_OBJECT (filter), stream_time);
|
gst_object_sync_values (GST_OBJECT (filter), stream_time);
|
||||||
|
|
||||||
indata = gst_buffer_map (inbuf, &insize, NULL, GST_MAP_READ);
|
gst_buffer_map (inbuf, &inmap, GST_MAP_READ);
|
||||||
outdata = gst_buffer_map (outbuf, &outsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &outmap, GST_MAP_WRITE);
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
|
if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP))) {
|
||||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
|
||||||
memset (outdata, 0, outsize);
|
memset (outmap.data, 0, outmap.size);
|
||||||
} else {
|
} 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 (inbuf, &inmap);
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,20 +257,19 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
|
||||||
GstBuffer *buf = gst_value_get_buffer (value);
|
GstBuffer *buf = gst_value_get_buffer (value);
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint sr_idx;
|
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);
|
sr_idx = ((map.data[0] & 0x07) << 1) | ((map.data[1] & 0x80) >> 7);
|
||||||
aacparse->object_type = (data[0] & 0xf8) >> 3;
|
aacparse->object_type = (map.data[0] & 0xf8) >> 3;
|
||||||
aacparse->sample_rate = gst_aac_parse_get_sample_rate_from_index (sr_idx);
|
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->header_type = DSPAAC_HEADER_NONE;
|
||||||
aacparse->mpegversion = 4;
|
aacparse->mpegversion = 4;
|
||||||
aacparse->frame_samples = (data[1] & 4) ? 960 : 1024;
|
aacparse->frame_samples = (map.data[1] & 4) ? 960 : 1024;
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
|
GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
|
||||||
"samples=%d", aacparse->object_type, aacparse->sample_rate,
|
"samples=%d", aacparse->object_type, aacparse->sample_rate,
|
||||||
|
@ -913,8 +912,7 @@ static gboolean
|
||||||
gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
GstAacParse *aacparse;
|
GstAacParse *aacparse;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
gboolean lost_sync;
|
gboolean lost_sync;
|
||||||
|
@ -923,25 +921,25 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
aacparse = GST_AAC_PARSE (parse);
|
aacparse = GST_AAC_PARSE (parse);
|
||||||
buffer = frame->buffer;
|
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);
|
lost_sync = GST_BASE_PARSE_LOST_SYNC (parse);
|
||||||
|
|
||||||
if (aacparse->header_type == DSPAAC_HEADER_ADIF ||
|
if (aacparse->header_type == DSPAAC_HEADER_ADIF ||
|
||||||
aacparse->header_type == DSPAAC_HEADER_NONE) {
|
aacparse->header_type == DSPAAC_HEADER_NONE) {
|
||||||
/* There is nothing to parse */
|
/* There is nothing to parse */
|
||||||
*framesize = size;
|
*framesize = map.size;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
} else if (aacparse->header_type == DSPAAC_HEADER_NOT_PARSED || lost_sync) {
|
} 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);
|
GST_BASE_PARSE_DRAINING (parse), framesize, skipsize);
|
||||||
|
|
||||||
} else if (aacparse->header_type == DSPAAC_HEADER_ADTS) {
|
} else if (aacparse->header_type == DSPAAC_HEADER_ADTS) {
|
||||||
guint needed_data = 1024;
|
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);
|
GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
@ -953,8 +951,8 @@ gst_aac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
} else if (aacparse->header_type == DSPAAC_HEADER_LOAS) {
|
} else if (aacparse->header_type == DSPAAC_HEADER_LOAS) {
|
||||||
guint needed_data = 1024;
|
guint needed_data = 1024;
|
||||||
|
|
||||||
ret = gst_aac_parse_check_loas_frame (aacparse, data,
|
ret = gst_aac_parse_check_loas_frame (aacparse, map.data,
|
||||||
size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
map.size, GST_BASE_PARSE_DRAINING (parse), framesize, &needed_data);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
GST_DEBUG ("buffer didn't contain valid frame");
|
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),
|
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
|
||||||
ADTS_MAX_SIZE);
|
ADTS_MAX_SIZE);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1003,8 +1001,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
gint rate, channels;
|
gint rate, channels;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
aacparse = GST_AAC_PARSE (parse);
|
aacparse = GST_AAC_PARSE (parse);
|
||||||
buffer = frame->buffer;
|
buffer = frame->buffer;
|
||||||
|
@ -1013,10 +1010,10 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
/* see above */
|
/* see above */
|
||||||
frame->overhead = 7;
|
frame->overhead = 7;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
gst_aac_parse_parse_adts_header (aacparse, data,
|
gst_aac_parse_parse_adts_header (aacparse, map.data,
|
||||||
&rate, &channels, NULL, NULL);
|
&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);
|
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 */
|
/* see above */
|
||||||
frame->overhead = 3;
|
frame->overhead = 3;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
if (!gst_aac_parse_read_loas_config (aacparse, data, size, &rate, &channels,
|
if (!gst_aac_parse_read_loas_config (aacparse, map.data, map.size, &rate,
|
||||||
NULL)) {
|
&channels, NULL)) {
|
||||||
GST_WARNING_OBJECT (aacparse, "Error reading LOAS config");
|
GST_WARNING_OBJECT (aacparse, "Error reading LOAS config");
|
||||||
} else if (G_UNLIKELY (rate != aacparse->sample_rate
|
} else if (G_UNLIKELY (rate != aacparse->sample_rate
|
||||||
|| channels != aacparse->channels)) {
|
|| 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,
|
GST_INFO_OBJECT (aacparse, "New LOAS config: %d Hz, %d channels", rate,
|
||||||
channels);
|
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.
|
/* 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
|
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)
|
guint * sid)
|
||||||
{
|
{
|
||||||
GstBitReader bits;
|
GstBitReader bits;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint8 fscod, frmsizcod, bsid, acmod, lfe_on, rate_scale;
|
guint8 fscod, frmsizcod, bsid, acmod, lfe_on, rate_scale;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ac3parse, "parsing ac3");
|
GST_LOG_OBJECT (ac3parse, "parsing ac3");
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
gst_bit_reader_init (&bits, data, size);
|
gst_bit_reader_init (&bits, map.data, map.size);
|
||||||
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
||||||
|
|
||||||
gst_bit_reader_skip_unchecked (&bits, 16 + 16);
|
gst_bit_reader_skip_unchecked (&bits, 16 + 16);
|
||||||
|
@ -360,7 +359,7 @@ gst_ac3_parse_frame_header_ac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -371,16 +370,15 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
||||||
guint * sid)
|
guint * sid)
|
||||||
{
|
{
|
||||||
GstBitReader bits;
|
GstBitReader bits;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint16 frmsiz, sample_rate, blocks;
|
guint16 frmsiz, sample_rate, blocks;
|
||||||
guint8 strmtyp, fscod, fscod2, acmod, lfe_on, strmid, numblkscod;
|
guint8 strmtyp, fscod, fscod2, acmod, lfe_on, strmid, numblkscod;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
GST_LOG_OBJECT (ac3parse, "parsing e-ac3");
|
GST_LOG_OBJECT (ac3parse, "parsing e-ac3");
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
gst_bit_reader_init (&bits, data, size);
|
gst_bit_reader_init (&bits, map.data, map.size);
|
||||||
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
gst_bit_reader_skip_unchecked (&bits, skip * 8);
|
||||||
|
|
||||||
gst_bit_reader_skip_unchecked (&bits, 16);
|
gst_bit_reader_skip_unchecked (&bits, 16);
|
||||||
|
@ -426,7 +424,7 @@ gst_ac3_parse_frame_header_eac3 (GstAc3Parse * ac3parse, GstBuffer * buf,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -439,14 +437,13 @@ gst_ac3_parse_frame_header (GstAc3Parse * parse, GstBuffer * buf, gint skip,
|
||||||
GstBitReader bits;
|
GstBitReader bits;
|
||||||
guint16 sync;
|
guint16 sync;
|
||||||
guint8 bsid;
|
guint8 bsid;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
gst_bit_reader_init (&bits, data, size);
|
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);
|
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);
|
GST_DEBUG_OBJECT (parse, "unexpected bsid %d", bsid);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -495,24 +492,23 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
gboolean lost_sync, draining, eac, more = FALSE;
|
gboolean lost_sync, draining, eac, more = FALSE;
|
||||||
guint frmsiz, blocks, sid;
|
guint frmsiz, blocks, sid;
|
||||||
gint have_blocks = 0;
|
gint have_blocks = 0;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
gboolean ret = FALSE;
|
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;
|
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,
|
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);
|
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
||||||
|
|
||||||
/* didn't find anything that looks like a sync word, skip */
|
/* didn't find anything that looks like a sync word, skip */
|
||||||
if (off < 0) {
|
if (off < 0) {
|
||||||
*skipsize = size - 3;
|
*skipsize = map.size - 3;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +558,8 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
do {
|
do {
|
||||||
*framesize += frmsiz;
|
*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;
|
more = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -605,7 +602,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,8 +259,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
GstBaseParseFrame * frame, guint * framesize, gint * skipsize)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
gint fsize, mode, dsize;
|
gint fsize, mode, dsize;
|
||||||
GstAmrParse *amrparse;
|
GstAmrParse *amrparse;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
@ -268,14 +267,14 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
amrparse = GST_AMR_PARSE (parse);
|
amrparse = GST_AMR_PARSE (parse);
|
||||||
buffer = frame->buffer;
|
buffer = frame->buffer;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
dsize = size;
|
dsize = map.size;
|
||||||
|
|
||||||
GST_LOG ("buffer: %d bytes", dsize);
|
GST_LOG ("buffer: %d bytes", dsize);
|
||||||
|
|
||||||
if (amrparse->need_header) {
|
if (amrparse->need_header) {
|
||||||
if (dsize >= AMR_MIME_HEADER_SIZE &&
|
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;
|
amrparse->need_header = FALSE;
|
||||||
gst_base_parse_set_frame_rate (GST_BASE_PARSE (amrparse), 50, 1, 2, 2);
|
gst_base_parse_set_frame_rate (GST_BASE_PARSE (amrparse), 50, 1, 2, 2);
|
||||||
} else {
|
} else {
|
||||||
|
@ -287,9 +286,9 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does this look like a possible frame header candidate? */
|
/* 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 */
|
/* 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 */
|
fsize = amrparse->block_size[mode] + 1; /* +1 for the header byte */
|
||||||
|
|
||||||
/* We recognize this data as a valid frame when:
|
/* We recognize this data as a valid frame when:
|
||||||
|
@ -307,7 +306,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
} else if (dsize > fsize) {
|
} else if (dsize > fsize) {
|
||||||
/* enough data, check for next sync */
|
/* enough data, check for next sync */
|
||||||
if ((data[fsize] & 0x83) == 0)
|
if ((map.data[fsize] & 0x83) == 0)
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
} else if (GST_BASE_PARSE_DRAINING (parse)) {
|
} else if (GST_BASE_PARSE_DRAINING (parse)) {
|
||||||
/* not enough, but draining, so ok */
|
/* not enough, but draining, so ok */
|
||||||
|
@ -326,7 +325,7 @@ gst_amr_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
GST_LOG ("sync lost");
|
GST_LOG ("sync lost");
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,31 +318,30 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
guint32 sync = 0;
|
guint32 sync = 0;
|
||||||
guint size, rate, chans, num_blocks, samples_per_block;
|
guint size, rate, chans, num_blocks, samples_per_block;
|
||||||
gint off = -1;
|
gint off = -1;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
gboolean ret = FALSE;
|
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;
|
goto cleanup;
|
||||||
|
|
||||||
parser_in_sync = !GST_BASE_PARSE_LOST_SYNC (parse);
|
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)) {
|
if (G_LIKELY (parser_in_sync && dcaparse->last_sync != 0)) {
|
||||||
off = gst_byte_reader_masked_scan_uint32 (&r, 0xffffffff,
|
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)) {
|
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 */
|
/* didn't find anything that looks like a sync word, skip */
|
||||||
if (off < 0) {
|
if (off < 0) {
|
||||||
*skipsize = bufsize - 3;
|
*skipsize = map.size - 3;
|
||||||
GST_DEBUG_OBJECT (dcaparse, "no sync, skipping %d bytes", *skipsize);
|
GST_DEBUG_OBJECT (dcaparse, "no sync, skipping %d bytes", *skipsize);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -374,12 +373,12 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
if (!parser_in_sync && !parser_draining) {
|
if (!parser_in_sync && !parser_draining) {
|
||||||
/* check for second frame to be sure */
|
/* check for second frame to be sure */
|
||||||
GST_DEBUG_OBJECT (dcaparse, "resyncing; checking next frame syncword");
|
GST_DEBUG_OBJECT (dcaparse, "resyncing; checking next frame syncword");
|
||||||
if (bufsize >= (size + 16)) {
|
if (map.size >= (size + 16)) {
|
||||||
guint s2, r2, c2, n2, s3;
|
guint s2, r2, c2, n2, s3;
|
||||||
gboolean t;
|
gboolean t;
|
||||||
|
|
||||||
GST_MEMDUMP ("buf", data, size + 16);
|
GST_MEMDUMP ("buf", map.data, size + 16);
|
||||||
gst_byte_reader_init (&r, data, bufsize);
|
gst_byte_reader_init (&r, map.data, map.size);
|
||||||
gst_byte_reader_skip_unchecked (&r, size);
|
gst_byte_reader_skip_unchecked (&r, size);
|
||||||
|
|
||||||
if (!gst_dca_parse_parse_header (dcaparse, &r, &s2, &r2, &c2, NULL, NULL,
|
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
|
/* FIXME: baseparse always seems to hand us buffers of min_frame_size
|
||||||
* bytes, which is unhelpful here */
|
* bytes, which is unhelpful here */
|
||||||
GST_LOG_OBJECT (dcaparse,
|
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);
|
size + 16);
|
||||||
/* *skipsize = 0; */
|
/* *skipsize = 0; */
|
||||||
/* return FALSE; */
|
/* return FALSE; */
|
||||||
|
@ -405,7 +404,7 @@ gst_dca_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
return ret;
|
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;
|
guint size, rate, chans, depth, block_size, num_blocks, samples_per_block;
|
||||||
gint endianness;
|
gint endianness;
|
||||||
gboolean terminator;
|
gboolean terminator;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
gst_byte_reader_init (&r, data, bufsize);
|
gst_byte_reader_init (&r, map.data, map.size);
|
||||||
|
|
||||||
if (!gst_dca_parse_parse_header (dcaparse, &r, &size, &rate, &chans, &depth,
|
if (!gst_dca_parse_parse_header (dcaparse, &r, &size, &rate, &chans, &depth,
|
||||||
&endianness, &num_blocks, &samples_per_block, &terminator))
|
&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_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;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -463,7 +461,7 @@ broken_header:
|
||||||
{
|
{
|
||||||
/* this really shouldn't ever happen */
|
/* this really shouldn't ever happen */
|
||||||
GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
|
GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
|
||||||
gst_buffer_unmap (buf, data, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,8 +616,7 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
||||||
GstBaseParseFrame * frame, guint * ret)
|
GstBaseParseFrame * frame, guint * ret)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint max, remaining;
|
guint max, remaining;
|
||||||
guint i, search_start, search_end;
|
guint i, search_start, search_end;
|
||||||
FrameHeaderCheckReturn header_ret;
|
FrameHeaderCheckReturn header_ret;
|
||||||
|
@ -625,13 +624,13 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
buffer = frame->buffer;
|
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;
|
goto need_more;
|
||||||
|
|
||||||
header_ret =
|
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);
|
&block_size);
|
||||||
if (header_ret == FRAME_HEADER_INVALID) {
|
if (header_ret == FRAME_HEADER_INVALID) {
|
||||||
*ret = 0;
|
*ret = 0;
|
||||||
|
@ -643,22 +642,22 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
||||||
/* mind unknown framesize */
|
/* mind unknown framesize */
|
||||||
search_start = MAX (2, flacparse->min_framesize);
|
search_start = MAX (2, flacparse->min_framesize);
|
||||||
if (flacparse->max_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
|
else
|
||||||
search_end = size;
|
search_end = map.size;
|
||||||
search_end -= 2;
|
search_end -= 2;
|
||||||
|
|
||||||
remaining = size;
|
remaining = map.size;
|
||||||
|
|
||||||
for (i = search_start; i < search_end; i++, remaining--) {
|
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 =
|
header_ret =
|
||||||
gst_flac_parse_frame_header_is_valid (flacparse, data + i, remaining,
|
gst_flac_parse_frame_header_is_valid (flacparse, map.data + i,
|
||||||
FALSE, NULL);
|
remaining, FALSE, NULL);
|
||||||
if (header_ret == FRAME_HEADER_VALID) {
|
if (header_ret == FRAME_HEADER_VALID) {
|
||||||
if (flacparse->check_frame_checksums) {
|
if (flacparse->check_frame_checksums) {
|
||||||
guint16 actual_crc = gst_flac_calculate_crc16 (data, i - 2);
|
guint16 actual_crc = gst_flac_calculate_crc16 (map.data, i - 2);
|
||||||
guint16 expected_crc = GST_READ_UINT16_BE (data + i - 2);
|
guint16 expected_crc = GST_READ_UINT16_BE (map.data + i - 2);
|
||||||
|
|
||||||
if (actual_crc != expected_crc)
|
if (actual_crc != expected_crc)
|
||||||
continue;
|
continue;
|
||||||
|
@ -676,17 +675,17 @@ gst_flac_parse_frame_is_valid (GstFlacParse * flacparse,
|
||||||
/* For the last frame output everything to the end */
|
/* For the last frame output everything to the end */
|
||||||
if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
|
if (G_UNLIKELY (GST_BASE_PARSE_DRAINING (flacparse))) {
|
||||||
if (flacparse->check_frame_checksums) {
|
if (flacparse->check_frame_checksums) {
|
||||||
guint16 actual_crc = gst_flac_calculate_crc16 (data, size - 2);
|
guint16 actual_crc = gst_flac_calculate_crc16 (map.data, map.size - 2);
|
||||||
guint16 expected_crc = GST_READ_UINT16_BE (data + size - 2);
|
guint16 expected_crc = GST_READ_UINT16_BE (map.data + map.size - 2);
|
||||||
|
|
||||||
if (actual_crc == expected_crc) {
|
if (actual_crc == expected_crc) {
|
||||||
*ret = size;
|
*ret = map.size;
|
||||||
flacparse->block_size = block_size;
|
flacparse->block_size = block_size;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*ret = size;
|
*ret = map.size;
|
||||||
flacparse->block_size = block_size;
|
flacparse->block_size = block_size;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -697,11 +696,11 @@ need_more:
|
||||||
max = flacparse->max_framesize + 16;
|
max = flacparse->max_framesize + 16;
|
||||||
if (max == 16)
|
if (max == 16)
|
||||||
max = 1 << 24;
|
max = 1 << 24;
|
||||||
*ret = MIN (size + 4096, max);
|
*ret = MIN (map.size + 4096, max);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,24 +710,23 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
{
|
{
|
||||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||||
GstBuffer *buffer = frame->buffer;
|
GstBuffer *buffer = frame->buffer;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
gboolean result = TRUE;
|
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;
|
result = FALSE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
|
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");
|
GST_DEBUG_OBJECT (flacparse, "fLaC marker found");
|
||||||
*framesize = 4;
|
*framesize = 4;
|
||||||
goto cleanup;
|
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");
|
GST_DEBUG_OBJECT (flacparse, "Found headerless FLAC");
|
||||||
/* Minimal size of a frame header */
|
/* Minimal size of a frame header */
|
||||||
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (flacparse), 9);
|
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) {
|
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);
|
GST_DEBUG_OBJECT (flacparse, "Found metadata block of size %u", size);
|
||||||
*framesize = size;
|
*framesize = size;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((GST_READ_UINT16_BE (data) & 0xfffe) == 0xfff8) {
|
if ((GST_READ_UINT16_BE (map.data) & 0xfffe) == 0xfff8) {
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
guint next;
|
guint next;
|
||||||
|
|
||||||
|
@ -772,7 +770,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next == 0) {
|
if (next == 0) {
|
||||||
} else if (next > bufsize) {
|
} else if (next > map.size) {
|
||||||
GST_DEBUG_OBJECT (flacparse, "Requesting %u bytes", next);
|
GST_DEBUG_OBJECT (flacparse, "Requesting %u bytes", next);
|
||||||
*skipsize = 0;
|
*skipsize = 0;
|
||||||
gst_base_parse_set_min_frame_size (parse, next);
|
gst_base_parse_set_min_frame_size (parse, next);
|
||||||
|
@ -780,7 +778,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
GST_ERROR_OBJECT (flacparse,
|
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;
|
result = FALSE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -789,10 +787,10 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
GstByteReader reader;
|
GstByteReader reader;
|
||||||
gint off;
|
gint off;
|
||||||
|
|
||||||
gst_byte_reader_init (&reader, data, bufsize);
|
gst_byte_reader_init (&reader, map.data, map.size);
|
||||||
off =
|
off =
|
||||||
gst_byte_reader_masked_scan_uint32 (&reader, 0xfffc0000, 0xfff80000,
|
gst_byte_reader_masked_scan_uint32 (&reader, 0xfffc0000, 0xfff80000,
|
||||||
0, bufsize);
|
0, map.size);
|
||||||
|
|
||||||
if (off > 0) {
|
if (off > 0) {
|
||||||
GST_DEBUG_OBJECT (parse, "Possible sync at buffer offset %d", off);
|
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;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (flacparse, "Sync code not found");
|
GST_DEBUG_OBJECT (flacparse, "Sync code not found");
|
||||||
*skipsize = bufsize - 3;
|
*skipsize = map.size - 3;
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -810,7 +808,7 @@ gst_flac_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buffer, data, bufsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,15 +816,14 @@ static gboolean
|
||||||
gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBitReader reader;
|
GstBitReader reader;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
gst_bit_reader_init (&reader, data, size);
|
gst_bit_reader_init (&reader, map.data, map.size);
|
||||||
|
|
||||||
if (size != 4 + 34) {
|
if (map.size != 4 + 34) {
|
||||||
GST_ERROR_OBJECT (flacparse,
|
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;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +876,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||||
GST_FORMAT_DEFAULT, flacparse->total_samples, 0);
|
GST_FORMAT_DEFAULT, flacparse->total_samples, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (flacparse, "STREAMINFO:\n"
|
GST_DEBUG_OBJECT (flacparse, "STREAMINFO:\n"
|
||||||
"\tmin/max blocksize: %u/%u,\n"
|
"\tmin/max blocksize: %u/%u,\n"
|
||||||
|
@ -898,7 +895,7 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||||
error:
|
error:
|
||||||
GST_ERROR_OBJECT (flacparse, "Failed to read data");
|
GST_ERROR_OBJECT (flacparse, "Failed to read data");
|
||||||
failure:
|
failure:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,13 +903,13 @@ static gboolean
|
||||||
gst_flac_parse_handle_vorbiscomment (GstFlacParse * flacparse,
|
gst_flac_parse_handle_vorbiscomment (GstFlacParse * flacparse,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
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);
|
flacparse->tags =
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_tag_list_from_vorbiscomment (map.data, map.size, map.data, 4, NULL);
|
||||||
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
if (flacparse->tags == NULL) {
|
if (flacparse->tags == NULL) {
|
||||||
GST_ERROR_OBJECT (flacparse, "Invalid vorbiscomment block");
|
GST_ERROR_OBJECT (flacparse, "Invalid vorbiscomment block");
|
||||||
|
@ -928,13 +925,12 @@ static gboolean
|
||||||
gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
|
gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstByteReader reader;
|
GstByteReader reader;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
guint32 img_len = 0, img_type = 0;
|
guint32 img_len = 0, img_type = 0;
|
||||||
guint32 img_mimetype_len = 0, img_description_len = 0;
|
guint32 img_mimetype_len = 0, img_description_len = 0;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
gst_byte_reader_init (&reader, data, bufsize);
|
gst_byte_reader_init (&reader, map.data, map.size);
|
||||||
|
|
||||||
if (!gst_byte_reader_skip (&reader, 4))
|
if (!gst_byte_reader_skip (&reader, 4))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -962,19 +958,19 @@ gst_flac_parse_handle_picture (GstFlacParse * flacparse, GstBuffer * buffer)
|
||||||
flacparse->tags = gst_tag_list_new_empty ();
|
flacparse->tags = gst_tag_list_new_empty ();
|
||||||
|
|
||||||
gst_tag_list_add_id3_image (flacparse->tags,
|
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)) {
|
if (gst_tag_list_is_empty (flacparse->tags)) {
|
||||||
gst_tag_list_free (flacparse->tags);
|
gst_tag_list_free (flacparse->tags);
|
||||||
flacparse->tags = NULL;
|
flacparse->tags = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, bufsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
GST_ERROR_OBJECT (flacparse, "Error reading data");
|
GST_ERROR_OBJECT (flacparse, "Error reading data");
|
||||||
gst_buffer_unmap (buffer, data, bufsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -995,8 +991,7 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
||||||
{
|
{
|
||||||
GstByteReader br;
|
GstByteReader br;
|
||||||
gint64 offset = 0, samples = 0;
|
gint64 offset = 0, samples = 0;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (flacparse,
|
GST_DEBUG_OBJECT (flacparse,
|
||||||
"parsing seektable; base offset %" G_GINT64_FORMAT, boffset);
|
"parsing seektable; base offset %" G_GINT64_FORMAT, boffset);
|
||||||
|
@ -1004,8 +999,8 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
||||||
if (boffset <= 0)
|
if (boffset <= 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
data = gst_buffer_map (flacparse->seektable, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (flacparse->seektable, &map, GST_MAP_READ);
|
||||||
gst_byte_reader_init (&br, data, bufsize);
|
gst_byte_reader_init (&br, map.data, map.size);
|
||||||
|
|
||||||
/* skip header */
|
/* skip header */
|
||||||
if (!gst_byte_reader_skip (&br, 4))
|
if (!gst_byte_reader_skip (&br, 4))
|
||||||
|
@ -1032,7 +1027,7 @@ gst_flac_parse_process_seektable (GstFlacParse * flacparse, gint64 boffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (flacparse->seektable, data, bufsize);
|
gst_buffer_unmap (flacparse->seektable, &map);
|
||||||
exit:
|
exit:
|
||||||
gst_buffer_unref (flacparse->seektable);
|
gst_buffer_unref (flacparse->seektable);
|
||||||
flacparse->seektable = NULL;
|
flacparse->seektable = NULL;
|
||||||
|
@ -1075,22 +1070,21 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
|
||||||
|
|
||||||
for (l = flacparse->headers; l; l = l->next) {
|
for (l = flacparse->headers; l; l = l->next) {
|
||||||
GstBuffer *header = l->data;
|
GstBuffer *header = l->data;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
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);
|
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;
|
marker = header;
|
||||||
} else if (size > 1 && (data[0] & 0x7f) == 0) {
|
} else if (map.size > 1 && (map.data[0] & 0x7f) == 0) {
|
||||||
streaminfo = header;
|
streaminfo = header;
|
||||||
} else if (size > 1 && (data[0] & 0x7f) == 4) {
|
} else if (map.size > 1 && (map.data[0] & 0x7f) == 4) {
|
||||||
vorbiscomment = header;
|
vorbiscomment = header;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (header, data, size);
|
gst_buffer_unmap (header, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
||||||
|
@ -1106,29 +1100,28 @@ gst_flac_parse_handle_headers (GstFlacParse * flacparse)
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint16 num;
|
guint16 num;
|
||||||
guint8 *sinfodata, *writedata;
|
GstMapInfo sinfomap, writemap;
|
||||||
gsize sinfosize, writesize;
|
|
||||||
|
|
||||||
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 */
|
/* minus one for the marker that is merged with streaminfo here */
|
||||||
num = g_list_length (flacparse->headers) - 1;
|
num = g_list_length (flacparse->headers) - 1;
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (13 + sinfosize);
|
buf = gst_buffer_new_and_alloc (13 + sinfomap.size);
|
||||||
writedata = gst_buffer_map (buf, &writesize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &writemap, GST_MAP_WRITE);
|
||||||
|
|
||||||
writedata[0] = 0x7f;
|
writemap.data[0] = 0x7f;
|
||||||
memcpy (writedata + 1, "FLAC", 4);
|
memcpy (writemap.data + 1, "FLAC", 4);
|
||||||
writedata[5] = 0x01; /* mapping version major */
|
writemap.data[5] = 0x01; /* mapping version major */
|
||||||
writedata[6] = 0x00; /* mapping version minor */
|
writemap.data[6] = 0x00; /* mapping version minor */
|
||||||
writedata[7] = (num & 0xFF00) >> 8;
|
writemap.data[7] = (num & 0xFF00) >> 8;
|
||||||
writedata[8] = (num & 0x00FF) >> 0;
|
writemap.data[8] = (num & 0x00FF) >> 0;
|
||||||
memcpy (writedata + 9, "fLaC", 4);
|
memcpy (writemap.data + 9, "fLaC", 4);
|
||||||
memcpy (writedata + 13, sinfodata, sinfosize);
|
memcpy (writemap.data + 13, sinfomap.data, sinfomap.size);
|
||||||
_value_array_append_buffer (&array, buf);
|
_value_array_append_buffer (&array, buf);
|
||||||
|
|
||||||
gst_buffer_unmap (streaminfo, sinfodata, sinfosize);
|
gst_buffer_unmap (streaminfo, &sinfomap);
|
||||||
gst_buffer_unmap (buf, writedata, writesize);
|
gst_buffer_unmap (buf, &writemap);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1185,13 +1178,12 @@ static gboolean
|
||||||
gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
||||||
{
|
{
|
||||||
GstBuffer *marker, *streaminfo, *vorbiscomment;
|
GstBuffer *marker, *streaminfo, *vorbiscomment;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
|
|
||||||
marker = gst_buffer_new_and_alloc (4);
|
marker = gst_buffer_new_and_alloc (4);
|
||||||
data = gst_buffer_map (marker, &bufsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (marker, &map, GST_MAP_WRITE);
|
||||||
memcpy (data, "fLaC", 4);
|
memcpy (map.data, "fLaC", 4);
|
||||||
gst_buffer_unmap (marker, data, bufsize);
|
gst_buffer_unmap (marker, &map);
|
||||||
GST_BUFFER_TIMESTAMP (marker) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_TIMESTAMP (marker) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_DURATION (marker) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_DURATION (marker) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_OFFSET (marker) = 0;
|
GST_BUFFER_OFFSET (marker) = 0;
|
||||||
|
@ -1199,37 +1191,37 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
||||||
flacparse->headers = g_list_append (flacparse->headers, marker);
|
flacparse->headers = g_list_append (flacparse->headers, marker);
|
||||||
|
|
||||||
streaminfo = gst_buffer_new_and_alloc (4 + 34);
|
streaminfo = gst_buffer_new_and_alloc (4 + 34);
|
||||||
data = gst_buffer_map (streaminfo, &bufsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (streaminfo, &map, GST_MAP_WRITE);
|
||||||
memset (data, 0, 4 + 34);
|
memset (map.data, 0, 4 + 34);
|
||||||
|
|
||||||
/* metadata block header */
|
/* metadata block header */
|
||||||
data[0] = 0x00; /* is_last = 0; type = 0; */
|
map.data[0] = 0x00; /* is_last = 0; type = 0; */
|
||||||
data[1] = 0x00; /* length = 34; */
|
map.data[1] = 0x00; /* length = 34; */
|
||||||
data[2] = 0x00;
|
map.data[2] = 0x00;
|
||||||
data[3] = 0x22;
|
map.data[3] = 0x22;
|
||||||
|
|
||||||
/* streaminfo */
|
/* streaminfo */
|
||||||
|
|
||||||
data[4] = (flacparse->block_size >> 8) & 0xff; /* min blocksize = blocksize; */
|
map.data[4] = (flacparse->block_size >> 8) & 0xff; /* min blocksize = blocksize; */
|
||||||
data[5] = (flacparse->block_size) & 0xff;
|
map.data[5] = (flacparse->block_size) & 0xff;
|
||||||
data[6] = (flacparse->block_size >> 8) & 0xff; /* max blocksize = blocksize; */
|
map.data[6] = (flacparse->block_size >> 8) & 0xff; /* max blocksize = blocksize; */
|
||||||
data[7] = (flacparse->block_size) & 0xff;
|
map.data[7] = (flacparse->block_size) & 0xff;
|
||||||
|
|
||||||
data[8] = 0x00; /* min framesize = 0; */
|
map.data[8] = 0x00; /* min framesize = 0; */
|
||||||
data[9] = 0x00;
|
map.data[9] = 0x00;
|
||||||
data[10] = 0x00;
|
map.data[10] = 0x00;
|
||||||
data[11] = 0x00; /* max framesize = 0; */
|
map.data[11] = 0x00; /* max framesize = 0; */
|
||||||
data[12] = 0x00;
|
map.data[12] = 0x00;
|
||||||
data[13] = 0x00;
|
map.data[13] = 0x00;
|
||||||
|
|
||||||
data[14] = (flacparse->samplerate >> 12) & 0xff;
|
map.data[14] = (flacparse->samplerate >> 12) & 0xff;
|
||||||
data[15] = (flacparse->samplerate >> 4) & 0xff;
|
map.data[15] = (flacparse->samplerate >> 4) & 0xff;
|
||||||
data[16] = (flacparse->samplerate >> 0) & 0xf0;
|
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;
|
map.data[16] |= ((flacparse->bps - 1) >> 4) & 0x01;
|
||||||
data[17] = (((flacparse->bps - 1)) & 0x0f) << 4;
|
map.data[17] = (((flacparse->bps - 1)) & 0x0f) << 4;
|
||||||
|
|
||||||
{
|
{
|
||||||
gint64 duration;
|
gint64 duration;
|
||||||
|
@ -1238,16 +1230,16 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
||||||
GST_FORMAT_TIME, &duration)) {
|
GST_FORMAT_TIME, &duration)) {
|
||||||
duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacparse->samplerate);
|
duration = GST_CLOCK_TIME_TO_FRAMES (duration, flacparse->samplerate);
|
||||||
|
|
||||||
data[17] |= (duration >> 32) & 0xff;
|
map.data[17] |= (duration >> 32) & 0xff;
|
||||||
data[18] |= (duration >> 24) & 0xff;
|
map.data[18] |= (duration >> 24) & 0xff;
|
||||||
data[19] |= (duration >> 16) & 0xff;
|
map.data[19] |= (duration >> 16) & 0xff;
|
||||||
data[20] |= (duration >> 8) & 0xff;
|
map.data[20] |= (duration >> 8) & 0xff;
|
||||||
data[21] |= (duration >> 0) & 0xff;
|
map.data[21] |= (duration >> 0) & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* MD5 = 0; */
|
/* MD5 = 0; */
|
||||||
|
|
||||||
gst_buffer_unmap (streaminfo, data, bufsize);
|
gst_buffer_unmap (streaminfo, &map);
|
||||||
GST_BUFFER_TIMESTAMP (streaminfo) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_TIMESTAMP (streaminfo) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_DURATION (streaminfo) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_DURATION (streaminfo) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_OFFSET (streaminfo) = 0;
|
GST_BUFFER_OFFSET (streaminfo) = 0;
|
||||||
|
@ -1267,27 +1259,27 @@ gst_flac_parse_generate_headers (GstFlacParse * flacparse)
|
||||||
sizeof (header), NULL);
|
sizeof (header), NULL);
|
||||||
gst_tag_list_free (taglist);
|
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 */
|
/* Get rid of framing bit */
|
||||||
if (data[bufsize - 1] == 1) {
|
if (map.data[map.size - 1] == 1) {
|
||||||
GstBuffer *sub;
|
GstBuffer *sub;
|
||||||
|
|
||||||
sub =
|
sub =
|
||||||
gst_buffer_copy_region (vorbiscomment, GST_BUFFER_COPY_ALL, 0,
|
gst_buffer_copy_region (vorbiscomment, GST_BUFFER_COPY_ALL, 0,
|
||||||
bufsize - 1);
|
map.size - 1);
|
||||||
gst_buffer_unmap (vorbiscomment, data, bufsize);
|
gst_buffer_unmap (vorbiscomment, &map);
|
||||||
gst_buffer_unref (vorbiscomment);
|
gst_buffer_unref (vorbiscomment);
|
||||||
vorbiscomment = sub;
|
vorbiscomment = sub;
|
||||||
data = gst_buffer_map (vorbiscomment, &bufsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (vorbiscomment, &map, GST_MAP_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
size = bufsize - 4;
|
size = map.size - 4;
|
||||||
data[1] = ((size & 0xFF0000) >> 16);
|
map.data[1] = ((size & 0xFF0000) >> 16);
|
||||||
data[2] = ((size & 0x00FF00) >> 8);
|
map.data[2] = ((size & 0x00FF00) >> 8);
|
||||||
data[3] = (size & 0x0000FF);
|
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_TIMESTAMP (vorbiscomment) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_DURATION (vorbiscomment) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_DURATION (vorbiscomment) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_OFFSET (vorbiscomment) = 0;
|
GST_BUFFER_OFFSET (vorbiscomment) = 0;
|
||||||
|
@ -1303,11 +1295,10 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
{
|
{
|
||||||
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
|
||||||
GstBuffer *buffer = frame->buffer;
|
GstBuffer *buffer = frame->buffer;
|
||||||
guint8 *data = NULL;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
GstFlowReturn res = GST_FLOW_ERROR;
|
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) {
|
if (flacparse->state == GST_FLAC_PARSE_STATE_INIT) {
|
||||||
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
|
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;
|
res = GST_BASE_PARSE_FLOW_DROPPED;
|
||||||
} else if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
|
} else if (flacparse->state == GST_FLAC_PARSE_STATE_HEADERS) {
|
||||||
gboolean is_last = ((data[0] & 0x80) == 0x80);
|
gboolean is_last = ((map.data[0] & 0x80) == 0x80);
|
||||||
guint type = (data[0] & 0x7F);
|
guint type = (map.data[0] & 0x7F);
|
||||||
|
|
||||||
if (type == 127) {
|
if (type == 127) {
|
||||||
GST_WARNING_OBJECT (flacparse, "Invalid metadata block type");
|
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);
|
flacparse->offset = GST_BUFFER_OFFSET (buffer);
|
||||||
ret =
|
ret =
|
||||||
gst_flac_parse_frame_header_is_valid (flacparse,
|
gst_flac_parse_frame_header_is_valid (flacparse,
|
||||||
data, bufsize, TRUE, NULL);
|
map.data, map.size, TRUE, NULL);
|
||||||
if (ret != FRAME_HEADER_VALID) {
|
if (ret != FRAME_HEADER_VALID) {
|
||||||
GST_ERROR_OBJECT (flacparse,
|
GST_ERROR_OBJECT (flacparse,
|
||||||
"Baseclass didn't provide a complete frame");
|
"Baseclass didn't provide a complete frame");
|
||||||
|
@ -1458,8 +1449,7 @@ gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (data)
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unmap (buffer, data, bufsize);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,18 +375,17 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
|
||||||
guint32 header, int bpf, gboolean at_eos, gint * valid)
|
guint32 header, int bpf, gboolean at_eos, gint * valid)
|
||||||
{
|
{
|
||||||
guint32 next_header;
|
guint32 next_header;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize available;
|
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
int frames_found = 1;
|
int frames_found = 1;
|
||||||
int offset = bpf;
|
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) {
|
while (frames_found < MIN_RESYNC_FRAMES) {
|
||||||
/* Check if we have enough data for all these frames, plus the next
|
/* Check if we have enough data for all these frames, plus the next
|
||||||
frame header. */
|
frame header. */
|
||||||
if (available < offset + 4) {
|
if (map.size < offset + 4) {
|
||||||
if (at_eos) {
|
if (at_eos) {
|
||||||
/* Running out of data at EOS is fine; just accept it */
|
/* Running out of data at EOS is fine; just accept it */
|
||||||
*valid = TRUE;
|
*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",
|
GST_DEBUG_OBJECT (mp3parse, "At %d: header=%08X, header2=%08X, bpf=%d",
|
||||||
offset, (unsigned int) header, (unsigned int) next_header, bpf);
|
offset, (unsigned int) header, (unsigned int) next_header, bpf);
|
||||||
|
|
||||||
|
@ -435,7 +434,7 @@ gst_mp3parse_validate_extended (GstMpegAudioParse * mp3parse, GstBuffer * buf,
|
||||||
*valid = TRUE;
|
*valid = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, available);
|
gst_buffer_unmap (buf, &map);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,24 +496,23 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
gboolean lost_sync, draining, valid, caps_change;
|
gboolean lost_sync, draining, valid, caps_change;
|
||||||
guint32 header;
|
guint32 header;
|
||||||
guint bitrate, layer, rate, channels, version, mode, crc;
|
guint bitrate, layer, rate, channels, version, mode, crc;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (G_UNLIKELY (bufsize < 6))
|
if (G_UNLIKELY (map.size < 6))
|
||||||
goto cleanup;
|
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,
|
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);
|
GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off);
|
||||||
|
|
||||||
/* didn't find anything that looks like a sync word, skip */
|
/* didn't find anything that looks like a sync word, skip */
|
||||||
if (off < 0) {
|
if (off < 0) {
|
||||||
*skipsize = bufsize - 3;
|
*skipsize = map.size - 3;
|
||||||
goto cleanup;
|
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 */
|
/* 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)) {
|
if (!gst_mpeg_audio_parse_head_check (mp3parse, header)) {
|
||||||
*skipsize = 1;
|
*skipsize = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -572,7 +570,7 @@ gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, data, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,8 +586,8 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
||||||
guint64 avail;
|
guint64 avail;
|
||||||
gint64 upstream_total_bytes = 0;
|
gint64 upstream_total_bytes = 0;
|
||||||
guint32 read_id_xing = 0, read_id_vbri = 0;
|
guint32 read_id_xing = 0, read_id_vbri = 0;
|
||||||
guint8 *data, *origdata;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
guint8 *data;
|
||||||
guint bitrate;
|
guint bitrate;
|
||||||
|
|
||||||
if (mp3parse->sent_codec_tag)
|
if (mp3parse->sent_codec_tag)
|
||||||
|
@ -616,8 +614,9 @@ gst_mpeg_audio_parse_handle_first_frame (GstMpegAudioParse * mp3parse,
|
||||||
offset_vbri += 4;
|
offset_vbri += 4;
|
||||||
|
|
||||||
/* Check if we have enough data to read the Xing header */
|
/* Check if we have enough data to read the Xing header */
|
||||||
origdata = data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
avail = bufsize;
|
data = map.data;
|
||||||
|
avail = map.size;
|
||||||
|
|
||||||
if (avail >= offset_xing + 4) {
|
if (avail >= offset_xing + 4) {
|
||||||
read_id_xing = GST_READ_UINT32_BE (data + offset_xing);
|
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;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = origdata;
|
data = map.data;
|
||||||
data += offset_vbri + 26;
|
data += offset_vbri + 26;
|
||||||
|
|
||||||
/* VBRI seek table: frame/seek_frames -> byte */
|
/* 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);
|
gst_base_parse_set_average_bitrate (GST_BASE_PARSE (mp3parse), bitrate);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buf, origdata, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -984,16 +983,15 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
|
||||||
{
|
{
|
||||||
GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);
|
GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);
|
||||||
GstBuffer *buf = frame->buffer;
|
GstBuffer *buf = frame->buffer;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize bufsize;
|
|
||||||
guint bitrate, layer, rate, channels, version, mode, crc;
|
guint bitrate, layer, rate, channels, version, mode, crc;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (G_UNLIKELY (bufsize < 4))
|
if (G_UNLIKELY (map.size < 4))
|
||||||
goto short_buffer;
|
goto short_buffer;
|
||||||
|
|
||||||
if (!mp3_type_frame_length_from_header (mp3parse,
|
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))
|
&version, &layer, &channels, &bitrate, &rate, &mode, &crc))
|
||||||
goto broken_header;
|
goto broken_header;
|
||||||
|
|
||||||
|
@ -1048,21 +1046,21 @@ gst_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
|
||||||
mp3parse->last_crc = crc;
|
mp3parse->last_crc = crc;
|
||||||
mp3parse->last_mode = mode;
|
mp3parse->last_mode = mode;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
broken_header:
|
broken_header:
|
||||||
{
|
{
|
||||||
/* this really shouldn't ever happen */
|
/* 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));
|
GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
short_buffer:
|
short_buffer:
|
||||||
{
|
{
|
||||||
gst_buffer_unmap (buf, data, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1198,6 +1198,7 @@ static gboolean
|
||||||
gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
||||||
GstBuffer * buf, guint64 ** _indexes)
|
GstBuffer * buf, guint64 ** _indexes)
|
||||||
{
|
{
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint16 bpe = 16;
|
guint16 bpe = 16;
|
||||||
guint32 num, i;
|
guint32 num, i;
|
||||||
|
@ -1207,7 +1208,9 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
||||||
*_indexes = NULL;
|
*_indexes = NULL;
|
||||||
|
|
||||||
if (buf) {
|
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 {
|
} else {
|
||||||
data = NULL;
|
data = NULL;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
@ -1246,7 +1249,7 @@ gst_avi_demux_parse_superindex (GstAviDemux * avi,
|
||||||
indexes[i] = GST_BUFFER_OFFSET_NONE;
|
indexes[i] = GST_BUFFER_OFFSET_NONE;
|
||||||
*_indexes = indexes;
|
*_indexes = indexes;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1258,7 +1261,7 @@ too_small:
|
||||||
"Not enough data to parse superindex (%" G_GSIZE_FORMAT
|
"Not enough data to parse superindex (%" G_GSIZE_FORMAT
|
||||||
" available, 24 needed)", size);
|
" available, 24 needed)", size);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1267,7 +1270,7 @@ invalid_params:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (avi, "invalid index parameters (num = %d, bpe = %d)",
|
GST_ERROR_OBJECT (avi, "invalid index parameters (num = %d, bpe = %d)",
|
||||||
num, bpe);
|
num, bpe);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1469,18 +1472,20 @@ static gboolean
|
||||||
gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
|
gst_avi_demux_parse_subindex (GstAviDemux * avi, GstAviStream * stream,
|
||||||
GstBuffer * buf)
|
GstBuffer * buf)
|
||||||
{
|
{
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint16 bpe;
|
guint16 bpe;
|
||||||
guint32 num, i;
|
guint32 num, i;
|
||||||
guint64 baseoff;
|
guint64 baseoff;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return TRUE;
|
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 */
|
/* check size */
|
||||||
if (size < 24)
|
if (map.size < 24)
|
||||||
goto too_small;
|
goto too_small;
|
||||||
|
|
||||||
/* We don't support index-data yet */
|
/* 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++) {
|
for (i = 0; i < num; i++) {
|
||||||
GstAviIndexEntry entry;
|
GstAviIndexEntry entry;
|
||||||
|
|
||||||
if (size < 24 + bpe * (i + 1))
|
if (map.size < 24 + bpe * (i + 1))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* fill in offset and size. offset contains the keyframe flag in the
|
/* 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;
|
goto out_of_mem;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1543,14 +1548,14 @@ too_small:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (avi,
|
GST_ERROR_OBJECT (avi,
|
||||||
"Not enough data to parse subindex (%" G_GSIZE_FORMAT
|
"Not enough data to parse subindex (%" G_GSIZE_FORMAT
|
||||||
" available, 24 needed)", size);
|
" available, 24 needed)", map.size);
|
||||||
goto done; /* continue */
|
goto done; /* continue */
|
||||||
}
|
}
|
||||||
not_implemented:
|
not_implemented:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (avi, STREAM, NOT_IMPLEMENTED, (NULL),
|
GST_ELEMENT_ERROR (avi, STREAM, NOT_IMPLEMENTED, (NULL),
|
||||||
("Subindex-is-data is not implemented"));
|
("Subindex-is-data is not implemented"));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1565,7 +1570,7 @@ out_of_mem:
|
||||||
("Cannot allocate memory for %u*%u=%u bytes",
|
("Cannot allocate memory for %u*%u=%u bytes",
|
||||||
(guint) sizeof (GstAviIndexEntry), num,
|
(guint) sizeof (GstAviIndexEntry), num,
|
||||||
(guint) sizeof (GstAviIndexEntry) * num));
|
(guint) sizeof (GstAviIndexEntry) * num));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1868,17 +1873,17 @@ gst_avi_demux_roundup_list (GstAviDemux * avi, GstBuffer ** buf)
|
||||||
|
|
||||||
if (G_UNLIKELY (size & 1)) {
|
if (G_UNLIKELY (size & 1)) {
|
||||||
GstBuffer *obuf;
|
GstBuffer *obuf;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (avi, "rounding up dubious list size %" G_GSIZE_FORMAT,
|
GST_DEBUG_OBJECT (avi, "rounding up dubious list size %" G_GSIZE_FORMAT,
|
||||||
size);
|
size);
|
||||||
obuf = gst_buffer_new_and_alloc (size + 1);
|
obuf = gst_buffer_new_and_alloc (size + 1);
|
||||||
|
|
||||||
data = gst_buffer_map (obuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (obuf, &map, GST_MAP_WRITE);
|
||||||
gst_buffer_extract (*buf, 0, data, size);
|
gst_buffer_extract (*buf, 0, map.data, size);
|
||||||
/* assume 0 padding, at least makes outcome deterministic */
|
/* assume 0 padding, at least makes outcome deterministic */
|
||||||
data[size] = 0;
|
map.data[size] = 0;
|
||||||
gst_buffer_unmap (obuf, data, size + 1);
|
gst_buffer_unmap (obuf, &map);
|
||||||
gst_buffer_replace (buf, obuf);
|
gst_buffer_replace (buf, obuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2103,12 +2108,11 @@ gst_avi_demux_parse_stream (GstAviDemux * avi, GstBuffer * buf)
|
||||||
case GST_RIFF_TAG_strn:
|
case GST_RIFF_TAG_strn:
|
||||||
g_free (stream->name);
|
g_free (stream->name);
|
||||||
if (sub != NULL) {
|
if (sub != NULL) {
|
||||||
gchar *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
bdata = gst_buffer_map (sub, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||||
stream->name = g_strndup (bdata, bsize);
|
stream->name = g_strndup ((gchar *) map.data, map.size);
|
||||||
gst_buffer_unmap (sub, bdata, bsize);
|
gst_buffer_unmap (sub, &map);
|
||||||
gst_buffer_unref (sub);
|
gst_buffer_unref (sub);
|
||||||
sub = NULL;
|
sub = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2343,26 +2347,25 @@ gst_avi_demux_parse_odml (GstAviDemux * avi, GstBuffer * buf)
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case GST_RIFF_TAG_dmlh:{
|
case GST_RIFF_TAG_dmlh:{
|
||||||
gst_riff_dmlh dmlh, *_dmlh;
|
gst_riff_dmlh dmlh, *_dmlh;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
/* sub == NULL is possible and means an empty buffer */
|
/* sub == NULL is possible and means an empty buffer */
|
||||||
if (sub == NULL)
|
if (sub == NULL)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||||
|
|
||||||
/* check size */
|
/* check size */
|
||||||
if (size < sizeof (gst_riff_dmlh)) {
|
if (map.size < sizeof (gst_riff_dmlh)) {
|
||||||
GST_ERROR_OBJECT (avi,
|
GST_ERROR_OBJECT (avi,
|
||||||
"DMLH entry is too small (%" G_GSIZE_FORMAT " bytes, %d needed)",
|
"DMLH entry is too small (%" G_GSIZE_FORMAT " bytes, %d needed)",
|
||||||
size, (int) sizeof (gst_riff_dmlh));
|
map.size, (int) sizeof (gst_riff_dmlh));
|
||||||
gst_buffer_unmap (sub, data, size);
|
gst_buffer_unmap (sub, &map);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
_dmlh = (gst_riff_dmlh *) data;
|
_dmlh = (gst_riff_dmlh *) map.data;
|
||||||
dmlh.totalframes = GST_READ_UINT32_LE (&_dmlh->totalframes);
|
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",
|
GST_INFO_OBJECT (avi, "dmlh tag found: totalframes: %u",
|
||||||
dmlh.totalframes);
|
dmlh.totalframes);
|
||||||
|
@ -2539,8 +2542,7 @@ gst_avi_demux_stream_for_id (GstAviDemux * avi, guint32 id)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint i, num, n;
|
guint i, num, n;
|
||||||
gst_riff_index_entry *index;
|
gst_riff_index_entry *index;
|
||||||
GstClockTime stamp;
|
GstClockTime stamp;
|
||||||
|
@ -2551,18 +2553,18 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return FALSE;
|
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 ();
|
stamp = gst_util_get_timestamp ();
|
||||||
|
|
||||||
/* see how many items in the index */
|
/* 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)
|
if (num == 0)
|
||||||
goto empty_list;
|
goto empty_list;
|
||||||
|
|
||||||
GST_INFO_OBJECT (avi, "Parsing index, nr_entries = %6d", num);
|
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 */
|
/* figure out if the index is 0 based or relative to the MOVI start */
|
||||||
entry.offset = GST_READ_UINT32_LE (&index[0].offset);
|
entry.offset = GST_READ_UINT32_LE (&index[0].offset);
|
||||||
|
@ -2613,7 +2615,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
||||||
|
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
/* get stream stats now */
|
/* get stream stats now */
|
||||||
|
@ -2629,7 +2631,7 @@ gst_avi_demux_parse_index (GstAviDemux * avi, GstBuffer * buf)
|
||||||
empty_list:
|
empty_list:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (avi, "empty index");
|
GST_DEBUG_OBJECT (avi, "empty index");
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2639,7 +2641,7 @@ out_of_mem:
|
||||||
("Cannot allocate memory for %u*%u=%u bytes",
|
("Cannot allocate memory for %u*%u=%u bytes",
|
||||||
(guint) sizeof (GstAviIndexEntry), num,
|
(guint) sizeof (GstAviIndexEntry), num,
|
||||||
(guint) sizeof (GstAviIndexEntry) * num));
|
(guint) sizeof (GstAviIndexEntry) * num));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2659,8 +2661,7 @@ gst_avi_demux_stream_index (GstAviDemux * avi)
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint32 tag;
|
guint32 tag;
|
||||||
guint32 size;
|
guint32 size;
|
||||||
gsize bsize;
|
GstMapInfo map;
|
||||||
guint8 *bdata;
|
|
||||||
|
|
||||||
GST_DEBUG ("demux stream index at offset %" G_GUINT64_FORMAT, offset);
|
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)
|
if (res != GST_FLOW_OK)
|
||||||
goto pull_failed;
|
goto pull_failed;
|
||||||
|
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (bsize < 8)
|
if (map.size < 8)
|
||||||
goto too_small;
|
goto too_small;
|
||||||
|
|
||||||
/* check tag first before blindy trying to read 'size' bytes */
|
/* check tag first before blindy trying to read 'size' bytes */
|
||||||
tag = GST_READ_UINT32_LE (bdata);
|
tag = GST_READ_UINT32_LE (map.data);
|
||||||
size = GST_READ_UINT32_LE (bdata + 4);
|
size = GST_READ_UINT32_LE (map.data + 4);
|
||||||
if (tag == GST_RIFF_TAG_LIST) {
|
if (tag == GST_RIFF_TAG_LIST) {
|
||||||
/* this is the movi tag */
|
/* this is the movi tag */
|
||||||
GST_DEBUG_OBJECT (avi, "skip LIST chunk, size %" G_GUINT32_FORMAT,
|
GST_DEBUG_OBJECT (avi, "skip LIST chunk, size %" G_GUINT32_FORMAT,
|
||||||
(8 + GST_ROUND_UP_2 (size)));
|
(8 + GST_ROUND_UP_2 (size)));
|
||||||
offset += 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);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto pull_failed;
|
goto pull_failed;
|
||||||
|
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (bsize < 8)
|
if (map.size < 8)
|
||||||
goto too_small;
|
goto too_small;
|
||||||
|
|
||||||
tag = GST_READ_UINT32_LE (bdata);
|
tag = GST_READ_UINT32_LE (map.data);
|
||||||
size = GST_READ_UINT32_LE (bdata + 4);
|
size = GST_READ_UINT32_LE (map.data + 4);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
if (tag != GST_RIFF_TAG_idx1)
|
if (tag != GST_RIFF_TAG_idx1)
|
||||||
|
@ -2740,7 +2741,7 @@ pull_failed:
|
||||||
too_small:
|
too_small:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (avi, "Buffer is 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);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2852,26 +2853,25 @@ gst_avi_demux_peek_tag (GstAviDemux * avi, guint64 offset, guint32 * tag,
|
||||||
{
|
{
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
gsize bufsize;
|
GstMapInfo map;
|
||||||
guint8 *bufdata;
|
|
||||||
|
|
||||||
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
res = gst_pad_pull_range (avi->sinkpad, offset, 8, &buf);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
goto pull_failed;
|
goto pull_failed;
|
||||||
|
|
||||||
bufdata = gst_buffer_map (buf, &bufsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (bufsize != 8)
|
if (map.size != 8)
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
*tag = GST_READ_UINT32_LE (bufdata);
|
*tag = GST_READ_UINT32_LE (map.data);
|
||||||
*size = GST_READ_UINT32_LE (bufdata + 4);
|
*size = GST_READ_UINT32_LE (map.data + 4);
|
||||||
|
|
||||||
GST_LOG_OBJECT (avi, "Tag[%" GST_FOURCC_FORMAT "] (size:%d) %"
|
GST_LOG_OBJECT (avi, "Tag[%" GST_FOURCC_FORMAT "] (size:%d) %"
|
||||||
G_GINT64_FORMAT " -- %" G_GINT64_FORMAT, GST_FOURCC_ARGS (*tag),
|
G_GINT64_FORMAT " -- %" G_GINT64_FORMAT, GST_FOURCC_ARGS (*tag),
|
||||||
*size, offset + 8, offset + 8 + (gint64) * size);
|
*size, offset + 8, offset + 8 + (gint64) * size);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buf, bufdata, bufsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -2885,7 +2885,7 @@ pull_failed:
|
||||||
wrong_size:
|
wrong_size:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (avi, "got %" G_GSIZE_FORMAT " bytes which is <> 8 bytes",
|
GST_DEBUG_OBJECT (avi, "got %" G_GSIZE_FORMAT " bytes which is <> 8 bytes",
|
||||||
bufsize);
|
map.size);
|
||||||
res = GST_FLOW_ERROR;
|
res = GST_FLOW_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -3512,11 +3512,12 @@ gst_avi_demux_parse_idit_text (GstAviDemux * avi, gchar * data)
|
||||||
static void
|
static void
|
||||||
gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
gchar *data, *ptr;
|
GstMapInfo map;
|
||||||
gsize size, left;
|
gchar *ptr;
|
||||||
|
gsize left;
|
||||||
gchar *safedata = NULL;
|
gchar *safedata = NULL;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
/*
|
/*
|
||||||
* According to:
|
* According to:
|
||||||
* http://www.eden-foundation.org/products/code/film_date_stamp/index.html
|
* 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 */
|
/* skip eventual initial whitespace */
|
||||||
ptr = data;
|
ptr = (gchar *) map.data;
|
||||||
left = size;
|
left = map.size;
|
||||||
|
|
||||||
while (left > 0 && g_ascii_isspace (ptr[0])) {
|
while (left > 0 && g_ascii_isspace (ptr[0])) {
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -3560,7 +3561,7 @@ gst_avi_demux_parse_idit (GstAviDemux * avi, GstBuffer * buf)
|
||||||
|
|
||||||
non_parsable:
|
non_parsable:
|
||||||
GST_WARNING_OBJECT (avi, "IDIT tag has no parsable info");
|
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 */
|
/* now, read the elements from the header until the end */
|
||||||
while (gst_riff_parse_chunk (element, buf, &offset, &tag, &sub)) {
|
while (gst_riff_parse_chunk (element, buf, &offset, &tag, &sub)) {
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
/* sub can be NULL on empty tags */
|
/* sub can be NULL on empty tags */
|
||||||
if (!sub)
|
if (!sub)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
data = gst_buffer_map (sub, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (sub, &map, GST_MAP_READ);
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case GST_RIFF_TAG_LIST:
|
case GST_RIFF_TAG_LIST:
|
||||||
if (size < 4)
|
if (map.size < 4)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
switch (GST_READ_UINT32_LE (data)) {
|
switch (GST_READ_UINT32_LE (map.data)) {
|
||||||
case GST_RIFF_LIST_strl:
|
case GST_RIFF_LIST_strl:
|
||||||
if (!(gst_avi_demux_parse_stream (avi, sub))) {
|
if (!(gst_avi_demux_parse_stream (avi, sub))) {
|
||||||
GST_ELEMENT_WARNING (avi, STREAM, DEMUX, (NULL),
|
GST_ELEMENT_WARNING (avi, STREAM, DEMUX, (NULL),
|
||||||
|
@ -3670,8 +3670,8 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
||||||
default:
|
default:
|
||||||
GST_WARNING_OBJECT (avi,
|
GST_WARNING_OBJECT (avi,
|
||||||
"Unknown list %" GST_FOURCC_FORMAT " in AVI header",
|
"Unknown list %" GST_FOURCC_FORMAT " in AVI header",
|
||||||
GST_FOURCC_ARGS (GST_READ_UINT32_LE (data)));
|
GST_FOURCC_ARGS (GST_READ_UINT32_LE (map.data)));
|
||||||
GST_MEMDUMP_OBJECT (avi, "Unknown list", data, size);
|
GST_MEMDUMP_OBJECT (avi, "Unknown list", map.data, map.size);
|
||||||
/* fall-through */
|
/* fall-through */
|
||||||
case GST_RIFF_TAG_JUNQ:
|
case GST_RIFF_TAG_JUNQ:
|
||||||
case GST_RIFF_TAG_JUNK:
|
case GST_RIFF_TAG_JUNK:
|
||||||
|
@ -3685,13 +3685,13 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
||||||
GST_WARNING_OBJECT (avi,
|
GST_WARNING_OBJECT (avi,
|
||||||
"Unknown tag %" GST_FOURCC_FORMAT " in AVI header at off %d",
|
"Unknown tag %" GST_FOURCC_FORMAT " in AVI header at off %d",
|
||||||
GST_FOURCC_ARGS (tag), offset);
|
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 */
|
/* fall-through */
|
||||||
case GST_RIFF_TAG_JUNQ:
|
case GST_RIFF_TAG_JUNQ:
|
||||||
case GST_RIFF_TAG_JUNK:
|
case GST_RIFF_TAG_JUNK:
|
||||||
next:
|
next:
|
||||||
if (sub) {
|
if (sub) {
|
||||||
gst_buffer_unmap (sub, data, size);
|
gst_buffer_unmap (sub, &map);
|
||||||
gst_buffer_unref (sub);
|
gst_buffer_unref (sub);
|
||||||
}
|
}
|
||||||
sub = NULL;
|
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) */
|
/* Now, find the data (i.e. skip all junk between header and data) */
|
||||||
do {
|
do {
|
||||||
|
GstMapInfo map;
|
||||||
guint size;
|
guint size;
|
||||||
gsize bsize;
|
|
||||||
guint8 *data;
|
|
||||||
guint32 tag, ltag;
|
guint32 tag, ltag;
|
||||||
|
|
||||||
res = gst_pad_pull_range (avi->sinkpad, avi->offset, 12, &buf);
|
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;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
tag = GST_READ_UINT32_LE (data);
|
tag = GST_READ_UINT32_LE (map.data);
|
||||||
size = GST_READ_UINT32_LE (data + 4);
|
size = GST_READ_UINT32_LE (map.data + 4);
|
||||||
ltag = GST_READ_UINT32_LE (data + 8);
|
ltag = GST_READ_UINT32_LE (map.data + 8);
|
||||||
|
|
||||||
GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
|
GST_DEBUG ("tag %" GST_FOURCC_FORMAT ", size %u",
|
||||||
GST_FOURCC_ARGS (tag), size);
|
GST_FOURCC_ARGS (tag), size);
|
||||||
GST_MEMDUMP ("Tag content", data, bsize);
|
GST_MEMDUMP ("Tag content", map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
|
@ -3806,9 +3805,9 @@ gst_avi_demux_stream_header_pull (GstAviDemux * avi)
|
||||||
GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
|
GST_DEBUG_OBJECT (avi, "couldn't read INFO chunk");
|
||||||
goto pull_range_failed;
|
goto pull_range_failed;
|
||||||
}
|
}
|
||||||
data = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
GST_MEMDUMP ("Junk", data, bsize);
|
GST_MEMDUMP ("Junk", map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
avi->offset += 8 + GST_ROUND_UP_2 (size);
|
avi->offset += 8 + GST_ROUND_UP_2 (size);
|
||||||
|
@ -4410,8 +4409,8 @@ gst_avi_demux_invert (GstAviStream * stream, GstBuffer * buf)
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
gint y, w, h;
|
gint y, w, h;
|
||||||
gint bpp, stride;
|
gint bpp, stride;
|
||||||
guint8 *tmp = NULL, *data;
|
guint8 *tmp = NULL;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
if (stream->strh->type != GST_RIFF_FCC_vids)
|
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);
|
buf = gst_buffer_make_writable (buf);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
if (size < (stride * h)) {
|
if (map.size < (stride * h)) {
|
||||||
GST_WARNING ("Buffer is smaller than reported Width x Height x Depth");
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = g_malloc (stride);
|
tmp = g_malloc (stride);
|
||||||
|
|
||||||
for (y = 0; y < h / 2; y++) {
|
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);
|
g_free (tmp);
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -629,19 +629,18 @@ static GstFlowReturn
|
||||||
gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
|
gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint spf;
|
guint spf;
|
||||||
guint32 header;
|
guint32 header;
|
||||||
gulong layer;
|
gulong layer;
|
||||||
gulong version;
|
gulong version;
|
||||||
gint lsf, mpg25;
|
gint lsf, mpg25;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
if (size < 4)
|
if (map.size < 4)
|
||||||
goto not_parsed;
|
goto not_parsed;
|
||||||
|
|
||||||
header = GST_READ_UINT32_BE (data);
|
header = GST_READ_UINT32_BE (map.data);
|
||||||
|
|
||||||
if ((header & 0xffe00000) != 0xffe00000)
|
if ((header & 0xffe00000) != 0xffe00000)
|
||||||
goto not_parsed;
|
goto not_parsed;
|
||||||
|
@ -677,7 +676,7 @@ gst_avi_mux_audsink_scan_mpeg_audio (GstAviMux * avimux, GstAviPad * avipad,
|
||||||
goto cbr_fallback;
|
goto cbr_fallback;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -1136,8 +1135,7 @@ gst_avi_mux_riff_get_avi_header (GstAviMux * avimux)
|
||||||
GstByteWriter bw;
|
GstByteWriter bw;
|
||||||
GSList *node;
|
GSList *node;
|
||||||
guint avih, riff, hdrl;
|
guint avih, riff, hdrl;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (avimux, "creating avi header, data_size %u, idx_size %u",
|
GST_DEBUG_OBJECT (avimux, "creating avi header, data_size %u, idx_size %u",
|
||||||
avimux->data_size, avimux->idx_size);
|
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.num_colors);
|
||||||
gst_byte_writer_put_uint32_le (&bw, vidpad->vids.imp_colors);
|
gst_byte_writer_put_uint32_le (&bw, vidpad->vids.imp_colors);
|
||||||
if (vidpad->vids_codec_data) {
|
if (vidpad->vids_codec_data) {
|
||||||
bdata =
|
gst_buffer_map (vidpad->vids_codec_data, &map, GST_MAP_READ);
|
||||||
gst_buffer_map (vidpad->vids_codec_data, &bsize, NULL,
|
gst_byte_writer_put_data (&bw, map.data, map.size);
|
||||||
GST_MAP_READ);
|
gst_buffer_unmap (vidpad->vids_codec_data, &map);
|
||||||
gst_byte_writer_put_data (&bw, bdata, bsize);
|
|
||||||
gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
|
|
||||||
}
|
}
|
||||||
gst_avi_mux_end_chunk (&bw, strf);
|
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, audpad->auds.size);
|
||||||
gst_byte_writer_put_uint16_le (&bw, codec_size);
|
gst_byte_writer_put_uint16_le (&bw, codec_size);
|
||||||
if (audpad->auds_codec_data) {
|
if (audpad->auds_codec_data) {
|
||||||
bdata =
|
gst_buffer_map (audpad->auds_codec_data, &map, GST_MAP_READ);
|
||||||
gst_buffer_map (audpad->auds_codec_data, &bsize, NULL,
|
gst_byte_writer_put_data (&bw, map.data, map.size);
|
||||||
GST_MAP_READ);
|
gst_buffer_unmap (vidpad->vids_codec_data, &map);
|
||||||
gst_byte_writer_put_data (&bw, bdata, bsize);
|
|
||||||
gst_buffer_unmap (vidpad->vids_codec_data, bdata, bsize);
|
|
||||||
}
|
}
|
||||||
gst_avi_mux_end_chunk (&bw, strf);
|
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);
|
buffer = gst_byte_writer_reset_and_get_buffer (&bw);
|
||||||
|
|
||||||
/* ... but RIFF includes more than just header */
|
/* ... but RIFF includes more than just header */
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_READWRITE);
|
||||||
size = GST_READ_UINT32_LE (bdata + 4);
|
size = GST_READ_UINT32_LE (map.data + 4);
|
||||||
size += 8 + avimux->data_size + avimux->idx_size;
|
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_MEMDUMP_OBJECT (avimux, "avi header", map.data, map.size);
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -1377,19 +1371,18 @@ static GstBuffer *
|
||||||
gst_avi_mux_riff_get_avix_header (guint32 datax_size)
|
gst_avi_mux_riff_get_avix_header (guint32 datax_size)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (24);
|
buffer = gst_buffer_new_and_alloc (24);
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
memcpy (bdata + 0, "RIFF", 4);
|
memcpy (map.data + 0, "RIFF", 4);
|
||||||
GST_WRITE_UINT32_LE (bdata + 4, datax_size + 3 * 4);
|
GST_WRITE_UINT32_LE (map.data + 4, datax_size + 3 * 4);
|
||||||
memcpy (bdata + 8, "AVIX", 4);
|
memcpy (map.data + 8, "AVIX", 4);
|
||||||
memcpy (bdata + 12, "LIST", 4);
|
memcpy (map.data + 12, "LIST", 4);
|
||||||
GST_WRITE_UINT32_LE (bdata + 16, datax_size);
|
GST_WRITE_UINT32_LE (map.data + 16, datax_size);
|
||||||
memcpy (bdata + 20, "movi", 4);
|
memcpy (map.data + 20, "movi", 4);
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -1398,15 +1391,14 @@ static inline GstBuffer *
|
||||||
gst_avi_mux_riff_get_header (GstAviPad * avipad, guint32 video_frame_size)
|
gst_avi_mux_riff_get_header (GstAviPad * avipad, guint32 video_frame_size)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (8);
|
buffer = gst_buffer_new_and_alloc (8);
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
memcpy (bdata + 0, avipad->tag, 4);
|
memcpy (map.data + 0, avipad->tag, 4);
|
||||||
GST_WRITE_UINT32_LE (bdata + 4, video_frame_size);
|
GST_WRITE_UINT32_LE (map.data + 4, video_frame_size);
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -1425,8 +1417,7 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
||||||
guint32 size, entry_count;
|
guint32 size, entry_count;
|
||||||
gboolean is_pcm = FALSE;
|
gboolean is_pcm = FALSE;
|
||||||
guint32 pcm_samples = 0;
|
guint32 pcm_samples = 0;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
/* check if it is pcm */
|
/* check if it is pcm */
|
||||||
if (avipad && !avipad->is_video) {
|
if (avipad && !avipad->is_video) {
|
||||||
|
@ -1440,20 +1431,20 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
||||||
/* allocate the maximum possible */
|
/* allocate the maximum possible */
|
||||||
buffer = gst_buffer_new_and_alloc (32 + 8 * avimux->idx_index);
|
buffer = gst_buffer_new_and_alloc (32 + 8 * avimux->idx_index);
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
data = bdata;
|
data = map.data;
|
||||||
|
|
||||||
/* general index chunk info */
|
/* general index chunk info */
|
||||||
memcpy (bdata + 0, chunk, 4); /* chunk id */
|
memcpy (map.data + 0, chunk, 4); /* chunk id */
|
||||||
GST_WRITE_UINT32_LE (bdata + 4, 0); /* chunk size; fill later */
|
GST_WRITE_UINT32_LE (map.data + 4, 0); /* chunk size; fill later */
|
||||||
GST_WRITE_UINT16_LE (bdata + 8, 2); /* index entry is 2 words */
|
GST_WRITE_UINT16_LE (map.data + 8, 2); /* index entry is 2 words */
|
||||||
bdata[10] = 0; /* index subtype */
|
map.data[10] = 0; /* index subtype */
|
||||||
bdata[11] = GST_AVI_INDEX_OF_CHUNKS; /* index type: AVI_INDEX_OF_CHUNKS */
|
map.data[11] = GST_AVI_INDEX_OF_CHUNKS; /* index type: AVI_INDEX_OF_CHUNKS */
|
||||||
GST_WRITE_UINT32_LE (bdata + 12, 0); /* entries in use; fill later */
|
GST_WRITE_UINT32_LE (map.data + 12, 0); /* entries in use; fill later */
|
||||||
memcpy (bdata + 16, code, 4); /* stream to which index refers */
|
memcpy (map.data + 16, code, 4); /* stream to which index refers */
|
||||||
GST_WRITE_UINT64_LE (bdata + 20, avimux->avix_start); /* base offset */
|
GST_WRITE_UINT64_LE (map.data + 20, avimux->avix_start); /* base offset */
|
||||||
GST_WRITE_UINT32_LE (bdata + 28, 0); /* reserved */
|
GST_WRITE_UINT32_LE (map.data + 28, 0); /* reserved */
|
||||||
bdata += 32;
|
map.data += 32;
|
||||||
|
|
||||||
/* now the actual index entries */
|
/* now the actual index entries */
|
||||||
i = avimux->idx_index;
|
i = avimux->idx_index;
|
||||||
|
@ -1461,23 +1452,24 @@ gst_avi_mux_write_avix_index (GstAviMux * avimux, GstAviPad * avipad,
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
if (memcmp (&entry->id, code, 4) == 0) {
|
if (memcmp (&entry->id, code, 4) == 0) {
|
||||||
/* enter relative offset to the data (!) */
|
/* 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 */
|
/* 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)
|
| (GUINT32_FROM_LE (entry->flags)
|
||||||
& GST_RIFF_IF_KEYFRAME ? 0 : 1U << 31));
|
& GST_RIFF_IF_KEYFRAME ? 0 : 1U << 31));
|
||||||
bdata += 8;
|
map.data += 8;
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
entry++;
|
entry++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ok, now we know the size and no of entries, fill in where needed */
|
/* 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);
|
GST_WRITE_UINT32_LE (data + 4, size - 8);
|
||||||
entry_count = (size - 32) / 8;
|
entry_count = (size - 32) / 8;
|
||||||
GST_WRITE_UINT32_LE (data + 12, entry_count);
|
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 */
|
/* send */
|
||||||
if ((res = gst_pad_push (avimux->srcpad, buffer)) != GST_FLOW_OK)
|
if ((res = gst_pad_push (avimux->srcpad, buffer)) != GST_FLOW_OK)
|
||||||
|
@ -1543,16 +1535,17 @@ gst_avi_mux_write_index (GstAviMux * avimux)
|
||||||
{
|
{
|
||||||
GstFlowReturn res;
|
GstFlowReturn res;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *buffdata;
|
GstMapInfo map;
|
||||||
gsize buffsize;
|
guint8 *data;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (8);
|
buffer = gst_buffer_new_and_alloc (8);
|
||||||
|
|
||||||
buffdata = gst_buffer_map (buffer, &buffsize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buffer, &map, GST_MAP_WRITE);
|
||||||
memcpy (buffdata + 0, "idx1", 4);
|
memcpy (map.data + 0, "idx1", 4);
|
||||||
GST_WRITE_UINT32_LE (buffdata + 4,
|
GST_WRITE_UINT32_LE (map.data + 4,
|
||||||
avimux->idx_index * sizeof (gst_riff_index_entry));
|
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);
|
res = gst_pad_push (avimux->srcpad, buffer);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
|
@ -1560,14 +1553,14 @@ gst_avi_mux_write_index (GstAviMux * avimux)
|
||||||
|
|
||||||
buffer = gst_buffer_new ();
|
buffer = gst_buffer_new ();
|
||||||
|
|
||||||
buffsize = avimux->idx_index * sizeof (gst_riff_index_entry);
|
size = avimux->idx_index * sizeof (gst_riff_index_entry);
|
||||||
buffdata = (guint8 *) avimux->idx;
|
data = (guint8 *) avimux->idx;
|
||||||
avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
|
avimux->idx = NULL; /* will be free()'ed by gst_buffer_unref() */
|
||||||
|
|
||||||
gst_buffer_take_memory (buffer, -1,
|
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);
|
res = gst_pad_push (avimux->srcpad, buffer);
|
||||||
if (res != GST_FLOW_OK)
|
if (res != GST_FLOW_OK)
|
||||||
|
@ -1882,14 +1875,9 @@ static GstFlowReturn
|
||||||
gst_avi_mux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
|
gst_avi_mux_send_pad_data (GstAviMux * avimux, gulong num_bytes)
|
||||||
{
|
{
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
guint8 *bdata;
|
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (num_bytes);
|
buffer = gst_buffer_new_and_alloc (num_bytes);
|
||||||
|
gst_buffer_memset (buffer, 0, 0, num_bytes);
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_WRITE);
|
|
||||||
memset (bdata, 0, num_bytes);
|
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
|
||||||
|
|
||||||
return gst_pad_push (avimux->srcpad, buffer);
|
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;
|
const gchar *input_enc = NULL;
|
||||||
GstBuffer *ret = NULL;
|
GstBuffer *ret = NULL;
|
||||||
gchar *data, *bdata;
|
gchar *data;
|
||||||
gsize bsize;
|
GstMapInfo map;
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
data = bdata + offset;
|
data = (gchar *) (map.data + offset);
|
||||||
|
|
||||||
if (len >= (3 + 1) && IS_BOM_UTF8 (data) &&
|
if (len >= (3 + 1) && IS_BOM_UTF8 (data) &&
|
||||||
g_utf8_validate (data + 3, len - 3, NULL)) {
|
g_utf8_validate (data + 3, len - 3, NULL)) {
|
||||||
|
@ -160,7 +160,7 @@ gst_avi_subtitle_extract_file (GstAviSubtitle * sub, GstBuffer * buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -183,25 +183,25 @@ gst_avi_subtitle_title_tag (GstAviSubtitle * sub, gchar * title)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
|
||||||
gchar *name_utf8;
|
gchar *name_utf8;
|
||||||
guint name_length;
|
guint name_length;
|
||||||
guint file_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 */
|
/* 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;
|
goto wrong_magic_word;
|
||||||
|
|
||||||
/* read 'name' of subtitle */
|
/* 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);
|
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;
|
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);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
if (name_utf8) {
|
if (name_utf8) {
|
||||||
|
@ -211,13 +211,13 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* next word must be 4 */
|
/* 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;
|
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);
|
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;
|
goto wrong_total_length;
|
||||||
|
|
||||||
/* store this, so we can send it again after a seek; note that we shouldn't
|
/* 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)
|
if (sub->subfile == NULL)
|
||||||
goto extract_failed;
|
goto extract_failed;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -237,38 +237,38 @@ gst_avi_subtitle_parse_gab2_chunk (GstAviSubtitle * sub, GstBuffer * buf)
|
||||||
wrong_magic_word:
|
wrong_magic_word:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL), ("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;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
wrong_name_length:
|
wrong_name_length:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
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));
|
17 + name_length));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
wrong_fixed_word_2:
|
wrong_fixed_word_2:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||||
("wrong fixed word: expected %u, got %u", 4,
|
("wrong fixed word: expected %u, got %u", 4,
|
||||||
GST_READ_UINT16_LE (data + 11 + name_length)));
|
GST_READ_UINT16_LE (map.data + 11 + name_length)));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
wrong_total_length:
|
wrong_total_length:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||||
("buffer size is wrong: need %d bytes, have %" G_GSIZE_FORMAT " bytes",
|
("buffer size is wrong: need %d bytes, have %" G_GSIZE_FORMAT " bytes",
|
||||||
17 + name_length + file_length, size));
|
17 + name_length + file_length, map.size));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
extract_failed:
|
extract_failed:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
GST_ELEMENT_ERROR (sub, STREAM, DECODE, (NULL),
|
||||||
("could not extract subtitles"));
|
("could not extract subtitles"));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,7 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstCutter *filter;
|
GstCutter *filter;
|
||||||
|
GstMapInfo map;
|
||||||
gint16 *in_data;
|
gint16 *in_data;
|
||||||
gint bpf, rate;
|
gint bpf, rate;
|
||||||
gsize in_size;
|
gsize in_size;
|
||||||
|
@ -284,7 +285,9 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
bpf = GST_AUDIO_INFO_BPF (&filter->info);
|
bpf = GST_AUDIO_INFO_BPF (&filter->info);
|
||||||
rate = GST_AUDIO_INFO_RATE (&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_LOG_OBJECT (filter, "length of prerec buffer: %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (filter->pre_run_length));
|
GST_TIME_ARGS (filter->pre_run_length));
|
||||||
|
@ -307,7 +310,7 @@ gst_cutter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, in_data, in_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
filter->silent_prev = filter->silent;
|
filter->silent_prev = filter->silent;
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,8 @@ static GstFlowReturn
|
||||||
gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstBreakMyData *bmd = GST_BREAK_MY_DATA (trans);
|
GstBreakMyData *bmd = GST_BREAK_MY_DATA (trans);
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize i, size;
|
gsize i;
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_is_writable (buf), GST_FLOW_ERROR);
|
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;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
|
|
||||||
GST_LOG_OBJECT (bmd,
|
GST_LOG_OBJECT (bmd,
|
||||||
"got buffer %p (size %" G_GSIZE_FORMAT ", timestamp %" G_GUINT64_FORMAT
|
"got buffer %p (size %" G_GSIZE_FORMAT ", timestamp %" G_GUINT64_FORMAT
|
||||||
", offset %" G_GUINT64_FORMAT "", buf, size, GST_BUFFER_TIMESTAMP (buf),
|
", offset %" G_GUINT64_FORMAT "", buf, map.size,
|
||||||
GST_BUFFER_OFFSET (buf));
|
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) {
|
if (g_rand_double_range (bmd->rand, 0, 1.0) <= bmd->probability) {
|
||||||
guint8 new;
|
guint8 new;
|
||||||
|
|
||||||
|
@ -252,14 +252,14 @@ gst_break_my_data_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
GST_INFO_OBJECT (bmd,
|
GST_INFO_OBJECT (bmd,
|
||||||
"changing byte %" G_GSIZE_FORMAT " from 0x%02X to 0x%02X", i,
|
"changing byte %" G_GSIZE_FORMAT " from 0x%02X to 0x%02X", i,
|
||||||
(guint) GST_READ_UINT8 (data + i), (guint) ((guint8) new));
|
(guint) GST_READ_UINT8 (map.data + i), (guint) ((guint8) new));
|
||||||
data[i] = new;
|
map.data[i] = new;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* don't overflow */
|
/* 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);
|
GST_OBJECT_UNLOCK (bmd);
|
||||||
|
|
||||||
|
|
|
@ -214,12 +214,11 @@ md5_new (const GstTestInfo * info)
|
||||||
static void
|
static void
|
||||||
md5_add (gpointer checksum, GstBuffer * buffer)
|
md5_add (gpointer checksum, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
g_checksum_update (checksum, data, size);
|
g_checksum_update (checksum, map.data, map.size);
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -820,8 +820,7 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
|
GstAudioFilter *filter = GST_AUDIO_FILTER (btrans);
|
||||||
GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans);
|
GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans);
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
gint channels = GST_AUDIO_FILTER_CHANNELS (filter);
|
gint channels = GST_AUDIO_FILTER_CHANNELS (filter);
|
||||||
|
|
||||||
if (G_UNLIKELY (channels < 1 || equ->process == NULL))
|
if (G_UNLIKELY (channels < 1 || equ->process == NULL))
|
||||||
|
@ -852,9 +851,9 @@ gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
BANDS_UNLOCK (equ);
|
BANDS_UNLOCK (equ);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
equ->process (equ, data, size, channels);
|
equ->process (equ, map.data, map.size, channels);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,13 +527,12 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstByteReader reader;
|
GstByteReader reader;
|
||||||
guint8 type = 0;
|
guint8 type = 0;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 7, GST_FLOW_ERROR);
|
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_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
gst_byte_reader_init (&reader, data, size);
|
gst_byte_reader_init (&reader, map.data, map.size);
|
||||||
|
|
||||||
gst_byte_reader_skip (&reader, 7);
|
gst_byte_reader_skip (&reader, 7);
|
||||||
|
|
||||||
|
@ -620,7 +619,7 @@ gst_flv_demux_parse_tag_script (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -662,30 +661,30 @@ gst_flv_demux_audio_negotiate (GstFlvDemux * demux, guint32 codec_tag,
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
{
|
{
|
||||||
guint8 *data = NULL;
|
if (demux->audio_codec_data) {
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
|
|
||||||
if (demux->audio_codec_data)
|
gst_buffer_map (demux->audio_codec_data, &map, GST_MAP_READ);
|
||||||
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;
|
|
||||||
|
|
||||||
freq_index = GST_READ_UINT16_BE (data);
|
/* use codec-data to extract and verify samplerate */
|
||||||
freq_index = (freq_index & 0x0780) >> 7;
|
if (map.size >= 2) {
|
||||||
adjusted_rate =
|
gint freq_index;
|
||||||
gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
|
|
||||||
|
|
||||||
if (adjusted_rate && (rate != adjusted_rate)) {
|
freq_index = GST_READ_UINT16_BE (map.data);
|
||||||
GST_LOG_OBJECT (demux, "Ajusting AAC sample rate %d -> %d", rate,
|
freq_index = (freq_index & 0x0780) >> 7;
|
||||||
adjusted_rate);
|
adjusted_rate =
|
||||||
} else {
|
gst_codec_utils_aac_get_sample_rate_from_index (freq_index);
|
||||||
adjusted_rate = rate;
|
|
||||||
|
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",
|
caps = gst_caps_new_simple ("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE,
|
"mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE,
|
||||||
"stream-format", G_TYPE_STRING, "raw", NULL);
|
"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 pts = 0, codec_tag = 0, rate = 5512, width = 8, channels = 1;
|
||||||
guint32 codec_data = 0, pts_ext = 0;
|
guint32 codec_data = 0, pts_ext = 0;
|
||||||
guint8 flags = 0;
|
guint8 flags = 0;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gsize size;
|
guint8 *data;
|
||||||
|
|
||||||
GST_LOG_OBJECT (demux, "parsing an audio tag");
|
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;
|
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 */
|
/* Grab information about audio tag */
|
||||||
pts = GST_READ_UINT24_BE (data);
|
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);
|
flags = GST_READ_UINT8 (data + 7);
|
||||||
|
|
||||||
/* Silently skip buffers with no data */
|
/* Silently skip buffers with no data */
|
||||||
if (size == 11)
|
if (map.size == 11)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
/* Channels */
|
/* Channels */
|
||||||
|
@ -1094,7 +1094,7 @@ gst_flv_demux_parse_tag_audio (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
demux->audio_linked = TRUE;
|
demux->audio_linked = TRUE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
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;
|
guint32 pts = 0, codec_data = 1, pts_ext = 0;
|
||||||
gboolean keyframe = FALSE;
|
gboolean keyframe = FALSE;
|
||||||
guint8 flags = 0, codec_tag = 0;
|
guint8 flags = 0, codec_tag = 0;
|
||||||
guint8 *data;
|
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size,
|
g_return_val_if_fail (gst_buffer_get_size (buffer) == demux->tag_size,
|
||||||
GST_FLOW_ERROR);
|
GST_FLOW_ERROR);
|
||||||
|
@ -1217,7 +1217,8 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
return GST_FLOW_ERROR;
|
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 */
|
/* Grab information about video tag */
|
||||||
pts = GST_READ_UINT24_BE (data);
|
pts = GST_READ_UINT24_BE (data);
|
||||||
|
@ -1474,7 +1475,7 @@ gst_flv_demux_parse_tag_video (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
demux->video_linked = TRUE;
|
demux->video_linked = TRUE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1487,13 +1488,16 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
|
||||||
guint8 type;
|
guint8 type;
|
||||||
gboolean keyframe = TRUE;
|
gboolean keyframe = TRUE;
|
||||||
GstClockTime ret = GST_CLOCK_TIME_NONE;
|
GstClockTime ret = GST_CLOCK_TIME_NONE;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 12,
|
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 12,
|
||||||
GST_CLOCK_TIME_NONE);
|
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];
|
type = data[0];
|
||||||
|
|
||||||
|
@ -1550,7 +1554,7 @@ gst_flv_demux_parse_tag_timestamp (GstFlvDemux * demux, gboolean index,
|
||||||
demux->duration = ret;
|
demux->duration = ret;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,13 +1563,13 @@ gst_flv_demux_parse_tag_type (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 tag_type = 0;
|
guint8 tag_type = 0;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 4, GST_FLOW_ERROR);
|
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) {
|
switch (tag_type) {
|
||||||
case 9:
|
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 +
|
/* Tag size is 1 byte of type + 3 bytes of size + 7 bytes + tag data size +
|
||||||
* 4 bytes of previous tag 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;
|
demux->tag_size = demux->tag_data_size + 11;
|
||||||
|
|
||||||
GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT,
|
GST_LOG_OBJECT (demux, "tag data size is %" G_GUINT64_FORMAT,
|
||||||
demux->tag_data_size);
|
demux->tag_data_size);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1600,14 +1604,14 @@ static GstFlowReturn
|
||||||
gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
g_return_val_if_fail (gst_buffer_get_size (buffer) >= 9, GST_FLOW_ERROR);
|
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 */
|
/* 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");
|
GST_DEBUG_OBJECT (demux, "FLV header detected");
|
||||||
} else {
|
} else {
|
||||||
if (G_UNLIKELY (demux->strict)) {
|
if (G_UNLIKELY (demux->strict)) {
|
||||||
|
@ -1619,7 +1623,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
|
|
||||||
/* Now look at audio/video flags */
|
/* Now look at audio/video flags */
|
||||||
{
|
{
|
||||||
guint8 flags = data[4];
|
guint8 flags = map.data[4];
|
||||||
|
|
||||||
demux->has_video = demux->has_audio = FALSE;
|
demux->has_video = demux->has_audio = FALSE;
|
||||||
|
|
||||||
|
@ -1640,7 +1644,7 @@ gst_flv_demux_parse_header (GstFlvDemux * demux, GstBuffer * buffer)
|
||||||
demux->need_header = FALSE;
|
demux->need_header = FALSE;
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2262,7 +2266,7 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
||||||
gint64 ret = 0, offset;
|
gint64 ret = 0, offset;
|
||||||
size_t tag_size, size;
|
size_t tag_size, size;
|
||||||
GstBuffer *buffer = NULL;
|
GstBuffer *buffer = NULL;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
if (!gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
|
if (!gst_pad_peer_query_duration (demux->sinkpad, GST_FORMAT_BYTES, &offset))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -2277,9 +2281,9 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
||||||
4, &buffer))
|
4, &buffer))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
tag_size = GST_READ_UINT32_BE (data);
|
tag_size = GST_READ_UINT32_BE (map.data);
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
GST_DEBUG_OBJECT (demux, "last tag size: %" G_GSIZE_FORMAT, tag_size);
|
GST_DEBUG_OBJECT (demux, "last tag size: %" G_GSIZE_FORMAT, tag_size);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
|
@ -2290,10 +2294,10 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/* a consistency check */
|
/* a consistency check */
|
||||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
size = GST_READ_UINT24_BE (data + 1);
|
size = GST_READ_UINT24_BE (map.data + 1);
|
||||||
if (size != tag_size - 11) {
|
if (size != tag_size - 11) {
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"tag size %" G_GSIZE_FORMAT ", expected %" G_GSIZE_FORMAT
|
"tag size %" G_GSIZE_FORMAT ", expected %" G_GSIZE_FORMAT
|
||||||
", corrupt or truncated file", size, tag_size - 11);
|
", 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);
|
gst_flv_demux_parse_tag_timestamp (demux, FALSE, buffer, &size);
|
||||||
|
|
||||||
/* maybe get some more metadata */
|
/* maybe get some more metadata */
|
||||||
if (data[0] == 18) {
|
if (map.data[0] == 18) {
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
GST_DEBUG_OBJECT (demux, "script tag, pulling it to parse");
|
GST_DEBUG_OBJECT (demux, "script tag, pulling it to parse");
|
||||||
|
@ -2314,7 +2318,7 @@ gst_flv_demux_get_metadata (GstFlvDemux * demux)
|
||||||
tag_size, &buffer))
|
tag_size, &buffer))
|
||||||
gst_flv_demux_parse_tag_script (demux, buffer);
|
gst_flv_demux_parse_tag_script (demux, buffer);
|
||||||
} else {
|
} else {
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
|
@ -678,6 +678,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux, gboolean full)
|
||||||
{
|
{
|
||||||
const GstTagList *tags;
|
const GstTagList *tags;
|
||||||
GstBuffer *script_tag, *tmp;
|
GstBuffer *script_tag, *tmp;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gint i, n_tags, tags_written = 0;
|
gint i, n_tags, tags_written = 0;
|
||||||
|
|
||||||
|
@ -800,13 +801,15 @@ tags:
|
||||||
|
|
||||||
if (!mux->streamable && mux->duration != GST_CLOCK_TIME_NONE) {
|
if (!mux->streamable && mux->duration != GST_CLOCK_TIME_NONE) {
|
||||||
gdouble d;
|
gdouble d;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
d = gst_guint64_to_gdouble (mux->duration);
|
d = gst_guint64_to_gdouble (mux->duration);
|
||||||
d /= (gdouble) GST_SECOND;
|
d /= (gdouble) GST_SECOND;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mux, "determined the duration to be %f", d);
|
GST_DEBUG_OBJECT (mux, "determined the duration to be %f", d);
|
||||||
data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
||||||
GST_WRITE_DOUBLE_BE (data + 29 + 2 + 8 + 1, d);
|
GST_WRITE_DOUBLE_BE (map.data + 29 + 2 + 8 + 1, d);
|
||||||
gst_buffer_unmap (script_tag, data, -1);
|
gst_buffer_unmap (script_tag, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->have_video) {
|
if (mux->have_video) {
|
||||||
|
@ -981,13 +984,13 @@ end:
|
||||||
GST_WRITE_UINT32_BE (data, gst_buffer_get_size (script_tag));
|
GST_WRITE_UINT32_BE (data, gst_buffer_get_size (script_tag));
|
||||||
script_tag = gst_buffer_join (script_tag, tmp);
|
script_tag = gst_buffer_join (script_tag, tmp);
|
||||||
|
|
||||||
data = gst_buffer_map (script_tag, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (script_tag, &map, GST_MAP_WRITE);
|
||||||
data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
|
map.data[1] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 16) & 0xff;
|
||||||
data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
|
map.data[2] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 8) & 0xff;
|
||||||
data[3] = ((gst_buffer_get_size (script_tag) - 11 - 4) >> 0) & 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_WRITE_UINT32_BE (map.data + 11 + 13 + 1, tags_written);
|
||||||
gst_buffer_unmap (script_tag, data, -1);
|
gst_buffer_unmap (script_tag, &map);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return script_tag;
|
return script_tag;
|
||||||
|
@ -998,15 +1001,17 @@ gst_flv_mux_buffer_to_tag_internal (GstFlvMux * mux, GstBuffer * buffer,
|
||||||
GstFlvPad * cpad, gboolean is_codec_data)
|
GstFlvPad * cpad, gboolean is_codec_data)
|
||||||
{
|
{
|
||||||
GstBuffer *tag;
|
GstBuffer *tag;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
guint size;
|
guint size;
|
||||||
guint32 timestamp =
|
guint32 timestamp =
|
||||||
(GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) ? GST_BUFFER_TIMESTAMP (buffer) /
|
(GST_BUFFER_TIMESTAMP_IS_VALID (buffer)) ? GST_BUFFER_TIMESTAMP (buffer) /
|
||||||
GST_MSECOND : cpad->last_timestamp / GST_MSECOND;
|
GST_MSECOND : cpad->last_timestamp / GST_MSECOND;
|
||||||
guint8 *bdata;
|
guint8 *data, *bdata;
|
||||||
gsize bsize;
|
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;
|
size = 11;
|
||||||
if (cpad->video) {
|
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);
|
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;
|
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
*tags = gst_tag_list_new_from_id3v1 (data);
|
*tags = gst_tag_list_new_from_id3v1 (map.data);
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
if (G_UNLIKELY (*tags == NULL))
|
if (G_UNLIKELY (*tags == NULL))
|
||||||
return GST_TAG_DEMUX_RESULT_BROKEN_TAG;
|
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;
|
guint64 size = 0;
|
||||||
|
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
bdata = gst_buffer_map (prefix, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (prefix, &map, GST_MAP_READ);
|
||||||
if (fwrite (bdata, 1, bsize, f) != bsize) {
|
if (fwrite (map.data, 1, map.size, f) != map.size) {
|
||||||
gst_buffer_unmap (prefix, bdata, bsize);
|
gst_buffer_unmap (prefix, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (prefix, bdata, bsize);
|
gst_buffer_unmap (prefix, &map);
|
||||||
}
|
}
|
||||||
if (!atom_ftyp_copy_data (ftyp, &data, &size, &offset)) {
|
if (!atom_ftyp_copy_data (ftyp, &data, &size, &offset)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -524,7 +524,7 @@ gst_qt_mux_prepare_jpc_buffer (GstQTPad * qtpad, GstBuffer * buf,
|
||||||
GstQTMux * qtmux)
|
GstQTMux * qtmux)
|
||||||
{
|
{
|
||||||
GstBuffer *newbuf;
|
GstBuffer *newbuf;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
GST_LOG_OBJECT (qtmux, "Preparing jpc buffer");
|
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);
|
newbuf = gst_buffer_new_and_alloc (size + 8);
|
||||||
gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_ALL, 8, size);
|
gst_buffer_copy_into (newbuf, buf, GST_BUFFER_COPY_ALL, 8, size);
|
||||||
|
|
||||||
data = gst_buffer_map (newbuf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (newbuf, &map, GST_MAP_WRITE);
|
||||||
GST_WRITE_UINT32_BE (data, size);
|
GST_WRITE_UINT32_BE (map.data, map.size);
|
||||||
GST_WRITE_UINT32_LE (data + 4, FOURCC_jp2c);
|
GST_WRITE_UINT32_LE (map.data + 4, FOURCC_jp2c);
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
return newbuf;
|
return newbuf;
|
||||||
|
@ -651,8 +651,7 @@ gst_qt_mux_add_mp4_cover (GstQTMux * qtmux, const GstTagList * list,
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gint flags = 0;
|
gint flags = 0;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
g_return_if_fail (gst_tag_get_type (tag) == GST_TYPE_BUFFER);
|
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;
|
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
|
GST_DEBUG_OBJECT (qtmux, "Adding tag %" GST_FOURCC_FORMAT
|
||||||
" -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), size);
|
" -> image size %" G_GSIZE_FORMAT "", GST_FOURCC_ARGS (fourcc), map.size);
|
||||||
atom_moov_add_tag (qtmux->moov, fourcc, flags, data, size);
|
atom_moov_add_tag (qtmux->moov, fourcc, flags, map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
done:
|
done:
|
||||||
g_value_unset (&value);
|
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) */ )) {
|
if (buf && (caps = NULL /*gst_buffer_get_caps (buf) */ )) {
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const gchar *style = NULL;
|
const gchar *style = NULL;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
GST_DEBUG_OBJECT (qtmux,
|
GST_DEBUG_OBJECT (qtmux,
|
||||||
"Found private tag %d/%d; size %" G_GSIZE_FORMAT ", caps %"
|
"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);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
if (s && (style = gst_structure_get_string (s, "style"))) {
|
if (s && (style = gst_structure_get_string (s, "style"))) {
|
||||||
/* try to prevent some style tag ending up into another variant
|
/* 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 &&
|
(strcmp (style, "iso") == 0 &&
|
||||||
qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
|
qtmux_klass->format == GST_QT_MUX_FORMAT_3GP)) {
|
||||||
GST_DEBUG_OBJECT (qtmux, "Adding private tag");
|
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);
|
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);
|
GST_LOG_OBJECT (qtmux, "sending buffer size %" G_GSIZE_FORMAT, size);
|
||||||
|
|
||||||
if (mind_fast && qtmux->fast_start_file) {
|
if (mind_fast && qtmux->fast_start_file) {
|
||||||
|
GstMapInfo map;
|
||||||
gint ret;
|
gint ret;
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (qtmux, "to temporary file");
|
GST_LOG_OBJECT (qtmux, "to temporary file");
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
ret = fwrite (data, sizeof (guint8), size, qtmux->fast_start_file);
|
ret = fwrite (map.data, sizeof (guint8), map.size, qtmux->fast_start_file);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
if (ret != size)
|
if (ret != size)
|
||||||
goto write_error;
|
goto write_error;
|
||||||
|
@ -1272,18 +1270,19 @@ gst_qt_mux_send_buffered_data (GstQTMux * qtmux, guint64 * offset)
|
||||||
GST_DEBUG_OBJECT (qtmux, "Sending buffered data");
|
GST_DEBUG_OBJECT (qtmux, "Sending buffered data");
|
||||||
while (ret == GST_FLOW_OK) {
|
while (ret == GST_FLOW_OK) {
|
||||||
const int bufsize = 4096;
|
const int bufsize = 4096;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (bufsize);
|
buf = gst_buffer_new_and_alloc (bufsize);
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
size = fread (data, sizeof (guint8), bufsize, qtmux->fast_start_file);
|
size = fread (map.data, sizeof (guint8), bufsize, qtmux->fast_start_file);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
gst_buffer_unmap (buf, data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, data, size);
|
GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d",
|
||||||
GST_LOG_OBJECT (qtmux, "Pushing buffered buffer of size %d", (gint) size);
|
(gint) map.size);
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
ret = gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
|
ret = gst_qt_mux_send_buffer (qtmux, buf, offset, FALSE);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1383,8 +1382,7 @@ gst_qt_mux_update_mdat_size (GstQTMux * qtmux, guint64 mdat_pos,
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
gboolean large_file;
|
gboolean large_file;
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
large_file = (mdat_size > MDAT_LARGE_FILE_LIMIT);
|
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) {
|
if (large_file) {
|
||||||
buf = gst_buffer_new_and_alloc (sizeof (guint64));
|
buf = gst_buffer_new_and_alloc (sizeof (guint64));
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
GST_WRITE_UINT64_BE (data, mdat_size + 16);
|
GST_WRITE_UINT64_BE (map.data, mdat_size + 16);
|
||||||
} else {
|
} else {
|
||||||
buf = gst_buffer_new_and_alloc (16);
|
buf = gst_buffer_new_and_alloc (16);
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
GST_WRITE_UINT32_BE (data, 8);
|
GST_WRITE_UINT32_BE (map.data, 8);
|
||||||
GST_WRITE_UINT32_LE (data + 4, FOURCC_free);
|
GST_WRITE_UINT32_LE (map.data + 4, FOURCC_free);
|
||||||
GST_WRITE_UINT32_BE (data + 8, mdat_size + 8);
|
GST_WRITE_UINT32_BE (map.data + 8, mdat_size + 8);
|
||||||
GST_WRITE_UINT32_LE (data + 12, FOURCC_mdat);
|
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);
|
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) {
|
} else if (strcmp (mimetype, "audio/x-alac") == 0) {
|
||||||
GstBuffer *codec_config;
|
GstBuffer *codec_config;
|
||||||
gint len;
|
gint len;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
entry.fourcc = FOURCC_alac;
|
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 */
|
/* 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_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;
|
goto refuse_caps;
|
||||||
}
|
}
|
||||||
if (GST_READ_UINT32_LE (data + 4) == FOURCC_alac) {
|
if (GST_READ_UINT32_LE (map.data + 4) == FOURCC_alac) {
|
||||||
len -= 8;
|
len -= 8;
|
||||||
codec_config =
|
codec_config =
|
||||||
gst_buffer_copy_region ((GstBuffer *) codec_data, 0, 8, len);
|
gst_buffer_copy_region ((GstBuffer *) codec_data, 0, 8, len);
|
||||||
} else {
|
} else {
|
||||||
codec_config = gst_buffer_ref ((GstBuffer *) codec_data);
|
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) {
|
if (len != 28) {
|
||||||
/* does not look good, but perhaps some trailing unneeded stuff */
|
/* does not look good, but perhaps some trailing unneeded stuff */
|
||||||
GST_WARNING_OBJECT (qtmux, "unexpected codec-data size, possibly broken");
|
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
|
else
|
||||||
ext_atom = build_codec_data_extension (FOURCC_alac, codec_config);
|
ext_atom = build_codec_data_extension (FOURCC_alac, codec_config);
|
||||||
/* set some more info */
|
/* 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.bytes_per_sample = 2;
|
||||||
entry.samples_per_packet = GST_READ_UINT32_BE (data + 4);
|
entry.samples_per_packet = GST_READ_UINT32_BE (map.data + 4);
|
||||||
gst_buffer_unmap (codec_config, data, size);
|
gst_buffer_unmap (codec_config, &map);
|
||||||
gst_buffer_unref (codec_config);
|
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:
|
case GST_QT_MUX_FORMAT_MJ2:
|
||||||
{
|
{
|
||||||
guint8 *bdata;
|
|
||||||
|
|
||||||
major = FOURCC_mjp2;
|
major = FOURCC_mjp2;
|
||||||
comp = mjp2_brands;
|
comp = mjp2_brands;
|
||||||
version = 0;
|
version = 0;
|
||||||
prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
|
prefix = gst_buffer_new_and_alloc (sizeof (mjp2_prefix));
|
||||||
bdata = gst_buffer_map (prefix, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (prefix, 0, mjp2_prefix, sizeof (mjp2_prefix));
|
||||||
memcpy (bdata, mjp2_prefix, sizeof (mjp2_prefix));
|
|
||||||
gst_buffer_unmap (prefix, bdata, -1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -195,7 +195,6 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
gint size;
|
gint size;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guint8 *bdata;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpxqtdepay, "found avcC codec_data in sd, %u",
|
GST_DEBUG_OBJECT (rtpxqtdepay, "found avcC codec_data in sd, %u",
|
||||||
chlen);
|
chlen);
|
||||||
|
@ -207,9 +206,7 @@ gst_rtp_quicktime_parse_sd (GstRtpXQTDepay * rtpxqtdepay, guint8 * data,
|
||||||
size = len - 8;
|
size = len - 8;
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (size);
|
buf = gst_buffer_new_and_alloc (size);
|
||||||
bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (buf, 0, data + 8, size);
|
||||||
memcpy (bdata, data + 8, size);
|
|
||||||
gst_buffer_unmap (buf, bdata, -1);
|
|
||||||
caps = gst_caps_new_simple ("video/x-h264",
|
caps = gst_caps_new_simple ("video/x-h264",
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -279,8 +276,6 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
guint8 *payload;
|
guint8 *payload;
|
||||||
guint8 ver, pck;
|
guint8 ver, pck;
|
||||||
gboolean s, q, l, d;
|
gboolean s, q, l, d;
|
||||||
guint8 *bdata;
|
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||||
payload = gst_rtp_buffer_get_payload (&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. */
|
/* multiple samples per packet. */
|
||||||
outbuf = gst_buffer_new_and_alloc (payload_len);
|
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (outbuf, 0, payload, payload_len);
|
||||||
memcpy (bdata, payload, payload_len);
|
|
||||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
|
||||||
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -591,9 +584,7 @@ gst_rtp_xqt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
slen = payload_len;
|
slen = payload_len;
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (slen);
|
outbuf = gst_buffer_new_and_alloc (slen);
|
||||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (outbuf, 0, payload, slen);
|
||||||
memcpy (bdata, payload, slen);
|
|
||||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
|
||||||
if (!s)
|
if (!s)
|
||||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
|
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. */
|
/* one sample per packet, use adapter to combine based on marker bit. */
|
||||||
outbuf = gst_buffer_new_and_alloc (payload_len);
|
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||||
bdata = gst_buffer_map (outbuf, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (outbuf, 0, payload, payload_len);
|
||||||
memcpy (bdata, payload, payload_len);
|
|
||||||
gst_buffer_unmap (outbuf, bdata, bsize);
|
|
||||||
|
|
||||||
gst_adapter_push (rtpxqtdepay->adapter, outbuf);
|
gst_adapter_push (rtpxqtdepay->adapter, outbuf);
|
||||||
|
|
||||||
|
|
|
@ -527,10 +527,9 @@ gst_qtdemux_post_no_playable_stream_error (GstQTDemux * qtdemux)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gst_buffer_copy_into_mem (GstBuffer * dest, const guint8 * src,
|
_gst_buffer_copy_into_mem (GstBuffer * dest, gsize offset, const guint8 * src,
|
||||||
gsize offset, gsize size)
|
gsize size)
|
||||||
{
|
{
|
||||||
guint8 *bdata;
|
|
||||||
gsize bsize;
|
gsize bsize;
|
||||||
|
|
||||||
g_return_if_fail (gst_buffer_is_writable (dest));
|
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);
|
bsize = gst_buffer_get_size (dest);
|
||||||
g_return_if_fail (bsize >= offset + size);
|
g_return_if_fail (bsize >= offset + size);
|
||||||
|
|
||||||
bdata = gst_buffer_map (dest, &bsize, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (dest, offset, src, size);
|
||||||
memcpy (bdata + offset, src, size);
|
|
||||||
gst_buffer_unmap (dest, bdata, bsize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
|
@ -561,7 +558,7 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
|
||||||
GstBuffer ** buf)
|
GstBuffer ** buf)
|
||||||
{
|
{
|
||||||
GstFlowReturn flow;
|
GstFlowReturn flow;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
gsize bsize;
|
||||||
|
|
||||||
if (G_UNLIKELY (size == 0)) {
|
if (G_UNLIKELY (size == 0)) {
|
||||||
|
@ -572,11 +569,11 @@ gst_qtdemux_pull_atom (GstQTDemux * qtdemux, guint64 offset, guint64 size,
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
bdata = gst_buffer_map (tmp, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (tmp, &map, GST_MAP_READ);
|
||||||
size = QT_UINT32 (bdata);
|
size = QT_UINT32 (map.data);
|
||||||
GST_DEBUG_OBJECT (qtdemux, "size 0x%08" G_GINT64_MODIFIER "x", size);
|
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);
|
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_DEBUG_OBJECT (qtdemux, "major brand: %" GST_FOURCC_FORMAT,
|
||||||
GST_FOURCC_ARGS (qtdemux->major_brand));
|
GST_FOURCC_ARGS (qtdemux->major_brand));
|
||||||
buf = qtdemux->comp_brands = gst_buffer_new_and_alloc (length - 16);
|
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;
|
GstBuffer *buf = NULL;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint64 cur_offset = qtdemux->offset;
|
guint64 cur_offset = qtdemux->offset;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, 16, &buf);
|
ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, 16, &buf);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
goto beach;
|
goto beach;
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (G_LIKELY (size >= 8))
|
if (G_LIKELY (map.size >= 8))
|
||||||
extract_initial_length_and_fourcc (data, size, &length, &fourcc);
|
extract_initial_length_and_fourcc (map.data, map.size, &length, &fourcc);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
/* maybe we already got most we needed, so only consider this eof */
|
/* 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);
|
ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length, &moov);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto beach;
|
goto beach;
|
||||||
data = gst_buffer_map (moov, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (moov, &map, GST_MAP_READ);
|
||||||
if (length != size) {
|
if (length != map.size) {
|
||||||
/* Some files have a 'moov' atom at the end of the file which contains
|
/* 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.
|
* a terminal 'free' atom where the body of the atom is missing.
|
||||||
* Check for, and permit, this special case.
|
* Check for, and permit, this special case.
|
||||||
*/
|
*/
|
||||||
if (size >= 8) {
|
if (map.size >= 8) {
|
||||||
guint8 *final_data = data + (size - 8);
|
guint8 *final_data = map.data + (map.size - 8);
|
||||||
guint32 final_length = QT_UINT32 (final_data);
|
guint32 final_length = QT_UINT32 (final_data);
|
||||||
guint32 final_fourcc = QT_FOURCC (final_data + 4);
|
guint32 final_fourcc = QT_FOURCC (final_data + 4);
|
||||||
gst_buffer_unmap (moov, data, size);
|
gst_buffer_unmap (moov, &map);
|
||||||
if (final_fourcc == FOURCC_free && size + final_length - 8 == length) {
|
if (final_fourcc == FOURCC_free
|
||||||
|
&& map.size + final_length - 8 == length) {
|
||||||
/* Ok, we've found that special case. Allocate a new buffer with
|
/* Ok, we've found that special case. Allocate a new buffer with
|
||||||
* that free atom actually present. */
|
* that free atom actually present. */
|
||||||
GstBuffer *newmoov = gst_buffer_new_and_alloc (length);
|
GstBuffer *newmoov = gst_buffer_new_and_alloc (length);
|
||||||
gst_buffer_copy_into (newmoov, moov, 0, 0, size);
|
gst_buffer_copy_into (newmoov, moov, 0, 0, map.size);
|
||||||
data = gst_buffer_map (newmoov, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (newmoov, &map, GST_MAP_WRITE);
|
||||||
memset (data + length - final_length + 8, 0, final_length - 8);
|
memset (map.data + length - final_length + 8, 0, final_length - 8);
|
||||||
gst_buffer_unref (moov);
|
gst_buffer_unref (moov);
|
||||||
moov = newmoov;
|
moov = newmoov;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length != size) {
|
if (length != map.size) {
|
||||||
GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
|
GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
|
||||||
(_("This file is incomplete and cannot be played.")),
|
(_("This file is incomplete and cannot be played.")),
|
||||||
("We got less than expected (received %" G_GSIZE_FORMAT
|
("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));
|
(guint) length, cur_offset));
|
||||||
gst_buffer_unmap (moov, data, size);
|
gst_buffer_unmap (moov, &map);
|
||||||
gst_buffer_unref (moov);
|
gst_buffer_unref (moov);
|
||||||
ret = GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
qtdemux->offset += length;
|
qtdemux->offset += length;
|
||||||
|
|
||||||
qtdemux_parse_moov (qtdemux, data, length);
|
qtdemux_parse_moov (qtdemux, map.data, length);
|
||||||
qtdemux_node_dump (qtdemux, qtdemux->moov_node);
|
qtdemux_node_dump (qtdemux, qtdemux->moov_node);
|
||||||
|
|
||||||
qtdemux_parse_tree (qtdemux);
|
qtdemux_parse_tree (qtdemux);
|
||||||
g_node_destroy (qtdemux->moov_node);
|
g_node_destroy (qtdemux->moov_node);
|
||||||
gst_buffer_unmap (moov, data, size);
|
gst_buffer_unmap (moov, &map);
|
||||||
gst_buffer_unref (moov);
|
gst_buffer_unref (moov);
|
||||||
qtdemux->moov_node = NULL;
|
qtdemux->moov_node = NULL;
|
||||||
qtdemux->got_moov = TRUE;
|
qtdemux->got_moov = TRUE;
|
||||||
|
@ -2758,9 +2755,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto beach;
|
goto beach;
|
||||||
qtdemux->offset += length;
|
qtdemux->offset += length;
|
||||||
data = gst_buffer_map (ftyp, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (ftyp, &map, GST_MAP_READ);
|
||||||
qtdemux_parse_ftyp (qtdemux, data, size);
|
qtdemux_parse_ftyp (qtdemux, map.data, map.size);
|
||||||
gst_buffer_unmap (ftyp, data, size);
|
gst_buffer_unmap (ftyp, &map);
|
||||||
gst_buffer_unref (ftyp);
|
gst_buffer_unref (ftyp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2773,9 +2770,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto beach;
|
goto beach;
|
||||||
qtdemux->offset += length;
|
qtdemux->offset += length;
|
||||||
data = gst_buffer_map (uuid, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (uuid, &map, GST_MAP_READ);
|
||||||
qtdemux_parse_uuid (qtdemux, data, size);
|
qtdemux_parse_uuid (qtdemux, map.data, map.size);
|
||||||
gst_buffer_unmap (uuid, data, size);
|
gst_buffer_unmap (uuid, &map);
|
||||||
gst_buffer_unref (uuid);
|
gst_buffer_unref (uuid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2790,9 +2787,9 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
|
||||||
ret = gst_qtdemux_pull_atom (qtdemux, cur_offset, length, &unknown);
|
ret = gst_qtdemux_pull_atom (qtdemux, cur_offset, length, &unknown);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto beach;
|
goto beach;
|
||||||
data = gst_buffer_map (unknown, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (unknown, &map, GST_MAP_READ);
|
||||||
GST_MEMDUMP ("Unknown tag", data, size);
|
GST_MEMDUMP ("Unknown tag", map.data, map.size);
|
||||||
gst_buffer_unmap (unknown, data, size);
|
gst_buffer_unmap (unknown, &map);
|
||||||
gst_buffer_unref (unknown);
|
gst_buffer_unref (unknown);
|
||||||
qtdemux->offset += length;
|
qtdemux->offset += length;
|
||||||
break;
|
break;
|
||||||
|
@ -3521,9 +3518,8 @@ static GstBuffer *
|
||||||
gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
GstBuffer * buf)
|
GstBuffer * buf)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
guint nsize = 0;
|
guint nsize = 0;
|
||||||
gsize size;
|
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
|
||||||
/* not many cases for now */
|
/* not many cases for now */
|
||||||
|
@ -3540,20 +3536,20 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
return buf;
|
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)) {
|
if (G_LIKELY (map.size >= 2)) {
|
||||||
nsize = GST_READ_UINT16_BE (data);
|
nsize = GST_READ_UINT16_BE (map.data);
|
||||||
nsize = MIN (nsize, size - 2);
|
nsize = MIN (nsize, map.size - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%" G_GSIZE_FORMAT "",
|
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,
|
/* takes care of UTF-8 validation or UTF-16 recognition,
|
||||||
* no other encoding expected */
|
* no other encoding expected */
|
||||||
str = gst_tag_freeform_string_to_utf8 ((gchar *) data + 2, nsize, NULL);
|
str = gst_tag_freeform_string_to_utf8 ((gchar *) map.data + 2, nsize, NULL);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
if (str) {
|
if (str) {
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = _gst_buffer_new_wrapped (str, strlen (str), g_free);
|
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)) {
|
if (G_UNLIKELY (stream->fourcc == FOURCC_rtsp)) {
|
||||||
gchar *url;
|
gchar *url;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
url = g_strndup ((gchar *) bdata, bsize);
|
url = g_strndup ((gchar *) map.data, map.size);
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
if (url != NULL && strlen (url) != 0) {
|
if (url != NULL && strlen (url) != 0) {
|
||||||
/* we have RTSP redirect now */
|
/* we have RTSP redirect now */
|
||||||
gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
|
gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
|
||||||
|
@ -4672,19 +4667,19 @@ qtdemux_parse_theora_extension (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case FOURCC_tCtH:
|
case FOURCC_tCtH:
|
||||||
buffer = gst_buffer_new_and_alloc (size);
|
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);
|
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||||
GST_LOG_OBJECT (qtdemux, "parsing theora header");
|
GST_LOG_OBJECT (qtdemux, "parsing theora header");
|
||||||
break;
|
break;
|
||||||
case FOURCC_tCt_:
|
case FOURCC_tCt_:
|
||||||
buffer = gst_buffer_new_and_alloc (size);
|
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);
|
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||||
GST_LOG_OBJECT (qtdemux, "parsing theora comment");
|
GST_LOG_OBJECT (qtdemux, "parsing theora comment");
|
||||||
break;
|
break;
|
||||||
case FOURCC_tCtC:
|
case FOURCC_tCtC:
|
||||||
buffer = gst_buffer_new_and_alloc (size);
|
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);
|
stream->buffers = g_slist_append (stream->buffers, buffer);
|
||||||
GST_LOG_OBJECT (qtdemux, "parsing theora codebook");
|
GST_LOG_OBJECT (qtdemux, "parsing theora codebook");
|
||||||
break;
|
break;
|
||||||
|
@ -5175,8 +5170,7 @@ qtdemux_find_atom (GstQTDemux * qtdemux, guint64 * offset,
|
||||||
G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), *offset);
|
G_GUINT64_FORMAT, GST_FOURCC_ARGS (fourcc), *offset);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
ret = gst_pad_pull_range (qtdemux->sinkpad, *offset, 16, &buf);
|
ret = gst_pad_pull_range (qtdemux->sinkpad, *offset, 16, &buf);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
|
@ -5187,9 +5181,9 @@ qtdemux_find_atom (GstQTDemux * qtdemux, guint64 * offset,
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
goto locate_failed;
|
goto locate_failed;
|
||||||
}
|
}
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
extract_initial_length_and_fourcc (bdata, 16, length, &lfourcc);
|
extract_initial_length_and_fourcc (map.data, 16, length, &lfourcc);
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
if (G_UNLIKELY (*length == 0)) {
|
if (G_UNLIKELY (*length == 0)) {
|
||||||
|
@ -5229,8 +5223,7 @@ qtdemux_add_fragmented_samples (GstQTDemux * qtdemux)
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
offset = qtdemux->moof_offset;
|
offset = qtdemux->moof_offset;
|
||||||
GST_DEBUG_OBJECT (qtdemux, "next moof at offset %" G_GUINT64_FORMAT, 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);
|
ret = gst_qtdemux_pull_atom (qtdemux, offset, length, &buf);
|
||||||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
goto flow_failed;
|
goto flow_failed;
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
if (!qtdemux_parse_moof (qtdemux, bdata, bsize, offset, NULL)) {
|
if (!qtdemux_parse_moof (qtdemux, map.data, map.size, offset, NULL)) {
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
goto parse_failed;
|
goto parse_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
|
|
||||||
|
@ -6102,7 +6095,7 @@ qtdemux_parse_svq3_stsd_data (GstQTDemux * qtdemux, GNode * stsd,
|
||||||
seqh_size = QT_UINT32 (data + 4);
|
seqh_size = QT_UINT32 (data + 4);
|
||||||
if (seqh_size > 0) {
|
if (seqh_size > 0) {
|
||||||
_seqh = gst_buffer_new_and_alloc (seqh_size);
|
_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[] = {
|
static const guint wb_bitrates[] = {
|
||||||
6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850
|
6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850
|
||||||
};
|
};
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size, max_mode;
|
gsize max_mode;
|
||||||
guint16 mode_set;
|
guint16 mode_set;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
|
||||||
if (size != 0x11) {
|
if (map.size != 0x11) {
|
||||||
GST_DEBUG ("Atom should have size 0x11, not %" G_GSIZE_FORMAT, size);
|
GST_DEBUG ("Atom should have size 0x11, not %" G_GSIZE_FORMAT, map.size);
|
||||||
goto bad_data;
|
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_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;
|
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))
|
if (mode_set == (wb ? AMR_WB_ALL_MODES : AMR_NB_ALL_MODES))
|
||||||
max_mode = 7 + (wb ? 1 : 0);
|
max_mode = 7 + (wb ? 1 : 0);
|
||||||
|
@ -6290,11 +6283,11 @@ qtdemux_parse_amr_bitrate (GstBuffer * buf, gboolean wb)
|
||||||
goto bad_data;
|
goto bad_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return wb ? wb_bitrates[max_mode] : nb_bitrates[max_mode];
|
return wb ? wb_bitrates[max_mode] : nb_bitrates[max_mode];
|
||||||
|
|
||||||
bad_data:
|
bad_data:
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6562,7 +6555,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
avc_data + 8 + 1, size - 1);
|
avc_data + 8 + 1, size - 1);
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (size);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -6641,7 +6634,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
if (len > 0x8) {
|
if (len > 0x8) {
|
||||||
len -= 0x8;
|
len -= 0x8;
|
||||||
buf = gst_buffer_new_and_alloc (len);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -6825,7 +6818,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
if (len > 0x8) {
|
if (len > 0x8) {
|
||||||
len -= 0x8;
|
len -= 0x8;
|
||||||
buf = gst_buffer_new_and_alloc (len);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -6855,7 +6848,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (qtdemux, "found codec_data in stsd");
|
GST_DEBUG_OBJECT (qtdemux, "found codec_data in stsd");
|
||||||
buf = gst_buffer_new_and_alloc (len);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -6904,7 +6897,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buf = gst_buffer_new_and_alloc (ovc1_len - 198);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -7118,7 +7111,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
}
|
}
|
||||||
wfex = (WAVEFORMATEX *) (owma_data + 36);
|
wfex = (WAVEFORMATEX *) (owma_data + 36);
|
||||||
buf = gst_buffer_new_and_alloc (owma_len - 54);
|
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) {
|
if (wfex->wFormatTag == 0x0161) {
|
||||||
codec_name = "Windows Media Audio";
|
codec_name = "Windows Media Audio";
|
||||||
version = 2;
|
version = 2;
|
||||||
|
@ -7217,7 +7210,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
headerlen -= 8;
|
headerlen -= 8;
|
||||||
|
|
||||||
headerbuf = gst_buffer_new_and_alloc (headerlen);
|
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),
|
if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux),
|
||||||
headerbuf, &header, &extra)) {
|
headerbuf, &header, &extra)) {
|
||||||
|
@ -7256,7 +7249,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
if (len > 0x4C) {
|
if (len > 0x4C) {
|
||||||
GstBuffer *buf = gst_buffer_new_and_alloc (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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -7291,7 +7284,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
/* codec-data contains alac atom size and prefix,
|
/* codec-data contains alac atom size and prefix,
|
||||||
* ffmpeg likes it that way, not quite gst-ish though ...*/
|
* ffmpeg likes it that way, not quite gst-ish though ...*/
|
||||||
buf = gst_buffer_new_and_alloc (len);
|
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,
|
gst_caps_set_simple (stream->caps,
|
||||||
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
"codec_data", GST_TYPE_BUFFER, buf, NULL);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -7312,7 +7305,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
|
||||||
GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x34);
|
GstBuffer *buf = gst_buffer_new_and_alloc (len - 0x34);
|
||||||
guint bitrate;
|
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
|
/* If we have enough data, let's try to get the 'damr' atom. See
|
||||||
* the 3GPP container spec (26.244) for more details. */
|
* 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)) ==
|
return ((qtdemux->major_brand & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
|
||||||
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
||||||
} else if (qtdemux->comp_brands != NULL) {
|
} else if (qtdemux->comp_brands != NULL) {
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
gboolean res = FALSE;
|
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) {
|
while (size >= 4) {
|
||||||
res = res || ((QT_FOURCC (data) & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
|
res = res || ((QT_FOURCC (data) & GST_MAKE_FOURCC (255, 255, 0, 0)) ==
|
||||||
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
GST_MAKE_FOURCC ('3', 'g', 0, 0));
|
||||||
data += 4;
|
data += 4;
|
||||||
size -= 4;
|
size -= 4;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (qtdemux->comp_brands, data, size);
|
gst_buffer_unmap (qtdemux->comp_brands, &map);
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -8514,7 +8510,7 @@ qtdemux_tag_add_blob (GNode * node, GstQTDemux * demux)
|
||||||
data = node->data;
|
data = node->data;
|
||||||
len = QT_UINT32 (data);
|
len = QT_UINT32 (data);
|
||||||
buf = gst_buffer_new_and_alloc (len);
|
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 */
|
/* heuristic to determine style of tag */
|
||||||
if (QT_FOURCC (data + 4) == FOURCC_____ ||
|
if (QT_FOURCC (data + 4) == FOURCC_____ ||
|
||||||
|
@ -9151,7 +9147,7 @@ gst_qtdemux_handle_esds (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
|
||||||
buffer = gst_buffer_new_and_alloc (data_len);
|
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_DEBUG_OBJECT (qtdemux, "setting codec_data from esds");
|
||||||
GST_MEMDUMP_OBJECT (qtdemux, "codec_data from esds", data_ptr, data_len);
|
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)
|
gst_alaw_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstALawDec *alawdec;
|
GstALawDec *alawdec;
|
||||||
|
GstMapInfo inmap, outmap;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
guint8 *alaw_data;
|
guint8 *alaw_data;
|
||||||
gsize alaw_size;
|
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_LOG_OBJECT (alawdec, "buffer with ts=%" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
|
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);
|
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 */
|
/* copy discont flag */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
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]);
|
linear_data[i] = alaw_to_s16 (alaw_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, linear_data, -1);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
gst_buffer_unmap (buffer, alaw_data, -1);
|
gst_buffer_unmap (buffer, &inmap);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
ret = gst_pad_push (alawdec->srcpad, outbuf);
|
ret = gst_pad_push (alawdec->srcpad, outbuf);
|
||||||
|
|
|
@ -492,6 +492,7 @@ static GstFlowReturn
|
||||||
gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
gst_alaw_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstALawEnc *alawenc;
|
GstALawEnc *alawenc;
|
||||||
|
GstMapInfo inmap, outmap;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
gsize linear_size;
|
gsize linear_size;
|
||||||
guint8 *alaw_data;
|
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))
|
if (G_UNLIKELY (alawenc->rate == 0 || alawenc->channels == 0))
|
||||||
goto not_negotiated;
|
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;
|
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);
|
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 */
|
/* copy discont flag */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
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]);
|
alaw_data[i] = s16_to_alaw (linear_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, alaw_data, -1);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
gst_buffer_unmap (buffer, linear_data, -1);
|
gst_buffer_unmap (buffer, &inmap);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
ret = gst_pad_push (alawenc->srcpad, outbuf);
|
ret = gst_pad_push (alawenc->srcpad, outbuf);
|
||||||
|
|
|
@ -240,6 +240,7 @@ static GstFlowReturn
|
||||||
gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstMuLawDec *mulawdec;
|
GstMuLawDec *mulawdec;
|
||||||
|
GstMapInfo inmap, outmap;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
guint8 *mulaw_data;
|
guint8 *mulaw_data;
|
||||||
gsize mulaw_size, linear_size;
|
gsize mulaw_size, linear_size;
|
||||||
|
@ -251,12 +252,15 @@ gst_mulawdec_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
if (G_UNLIKELY (mulawdec->rate == 0))
|
if (G_UNLIKELY (mulawdec->rate == 0))
|
||||||
goto not_negotiated;
|
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;
|
linear_size = mulaw_size * 2;
|
||||||
|
|
||||||
outbuf = gst_buffer_new_allocate (NULL, linear_size, 0);
|
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 */
|
/* copy discont flag */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
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);
|
mulaw_decode (mulaw_data, linear_data, mulaw_size);
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, linear_data, -1);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
gst_buffer_unmap (buffer, mulaw_data, -1);
|
gst_buffer_unmap (buffer, &inmap);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
ret = gst_pad_push (mulawdec->srcpad, outbuf);
|
ret = gst_pad_push (mulawdec->srcpad, outbuf);
|
||||||
|
|
|
@ -239,6 +239,7 @@ static GstFlowReturn
|
||||||
gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstMuLawEnc *mulawenc;
|
GstMuLawEnc *mulawenc;
|
||||||
|
GstMapInfo inmap, outmap;
|
||||||
gint16 *linear_data;
|
gint16 *linear_data;
|
||||||
gsize linear_size;
|
gsize linear_size;
|
||||||
guint8 *mulaw_data;
|
guint8 *mulaw_data;
|
||||||
|
@ -252,7 +253,9 @@ gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
if (!mulawenc->rate || !mulawenc->channels)
|
if (!mulawenc->rate || !mulawenc->channels)
|
||||||
goto not_negotiated;
|
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;
|
mulaw_size = linear_size / 2;
|
||||||
|
|
||||||
|
@ -266,7 +269,8 @@ gst_mulawenc_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GST_SECOND, mulawenc->rate * mulawenc->channels);
|
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 */
|
/* copy discont flag */
|
||||||
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))
|
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);
|
mulaw_encode (linear_data, mulaw_data, mulaw_size);
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, mulaw_data, -1);
|
gst_buffer_unmap (outbuf, &outmap);
|
||||||
gst_buffer_unmap (buffer, linear_data, -1);
|
gst_buffer_unmap (buffer, &inmap);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
ret = gst_pad_push (mulawenc->srcpad, outbuf);
|
ret = gst_pad_push (mulawenc->srcpad, outbuf);
|
||||||
|
|
|
@ -534,7 +534,8 @@ static GstFlowReturn
|
||||||
gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
{
|
{
|
||||||
GstLevel *filter;
|
GstLevel *filter;
|
||||||
guint8 *in_data, *data;
|
GstMapInfo map;
|
||||||
|
guint8 *in_data;
|
||||||
gsize in_size;
|
gsize in_size;
|
||||||
gdouble CS;
|
gdouble CS;
|
||||||
guint i;
|
guint i;
|
||||||
|
@ -550,7 +551,10 @@ gst_level_transform_ip (GstBaseTransform * trans, GstBuffer * in)
|
||||||
bps = GST_AUDIO_INFO_BPS (&filter->info);
|
bps = GST_AUDIO_INFO_BPS (&filter->info);
|
||||||
rate = GST_AUDIO_INFO_RATE (&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;
|
num_int_samples = in_size / bps;
|
||||||
|
|
||||||
GST_LOG_OBJECT (filter, "analyzing %u sample frames at ts %" GST_TIME_FORMAT,
|
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;
|
filter->num_frames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (in, data, in_size);
|
gst_buffer_unmap (in, &map);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,6 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
|
||||||
guint64 offset)
|
guint64 offset)
|
||||||
{
|
{
|
||||||
GstEbmlMaster m;
|
GstEbmlMaster m;
|
||||||
gsize buf_size;
|
|
||||||
|
|
||||||
g_return_if_fail (el);
|
g_return_if_fail (el);
|
||||||
g_return_if_fail (buf);
|
g_return_if_fail (buf);
|
||||||
|
@ -172,10 +171,10 @@ gst_ebml_read_init (GstEbmlRead * ebml, GstElement * el, GstBuffer * buf,
|
||||||
ebml->el = el;
|
ebml->el = el;
|
||||||
ebml->offset = offset;
|
ebml->offset = offset;
|
||||||
ebml->buf = buf;
|
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);
|
ebml->readers = g_array_sized_new (FALSE, FALSE, sizeof (GstEbmlMaster), 10);
|
||||||
m.offset = ebml->offset;
|
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);
|
g_array_append_val (ebml->readers, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +185,7 @@ gst_ebml_read_clear (GstEbmlRead * ebml)
|
||||||
g_array_free (ebml->readers, TRUE);
|
g_array_free (ebml->readers, TRUE);
|
||||||
ebml->readers = NULL;
|
ebml->readers = NULL;
|
||||||
if (ebml->buf) {
|
if (ebml->buf) {
|
||||||
gst_buffer_unmap (ebml->buf, ebml->buf_data, -1);
|
gst_buffer_unmap (ebml->buf, &ebml->map);
|
||||||
gst_buffer_unref (ebml->buf);
|
gst_buffer_unref (ebml->buf);
|
||||||
}
|
}
|
||||||
ebml->buf = NULL;
|
ebml->buf = NULL;
|
||||||
|
|
|
@ -54,8 +54,8 @@ typedef struct _GstEbmlRead {
|
||||||
GstElement *el;
|
GstElement *el;
|
||||||
|
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
gpointer buf_data;
|
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
GArray *readers;
|
GArray *readers;
|
||||||
} GstEbmlRead;
|
} GstEbmlRead;
|
||||||
|
|
|
@ -285,6 +285,7 @@ gst_ebml_write_element_new (GstEbmlWrite * ebml, guint8 ** data_out, guint size)
|
||||||
{
|
{
|
||||||
/* Create new buffer of size + ID + length */
|
/* Create new buffer of size + ID + length */
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
/* length, ID */
|
/* length, ID */
|
||||||
size += 12;
|
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);
|
buf = gst_buffer_new_and_alloc (size);
|
||||||
GST_BUFFER_TIMESTAMP (buf) = ebml->timestamp;
|
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;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@ -408,6 +411,7 @@ static void
|
||||||
gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
|
gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf,
|
||||||
guint8 * buf_data, guint8 * buf_data_end)
|
guint8 * buf_data, guint8 * buf_data_end)
|
||||||
{
|
{
|
||||||
|
GstMapInfo map;
|
||||||
guint data_size;
|
guint data_size;
|
||||||
|
|
||||||
if (buf_data_end)
|
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 there's no cache, then don't push it! */
|
||||||
if (ebml->writing_streamheader) {
|
if (ebml->writing_streamheader) {
|
||||||
if (!buf_data)
|
if (!buf_data) {
|
||||||
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
|
buf_data = map.data;
|
||||||
|
}
|
||||||
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
|
gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size);
|
||||||
}
|
}
|
||||||
if (ebml->cache) {
|
if (ebml->cache) {
|
||||||
if (!buf_data)
|
if (!buf_data) {
|
||||||
buf_data = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
|
buf_data = map.data;
|
||||||
|
}
|
||||||
gst_byte_writer_put_data (ebml->cache, buf_data, data_size);
|
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);
|
gst_buffer_unref (buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf_data)
|
if (buf_data)
|
||||||
gst_buffer_unmap (buf, buf_data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
if (ebml->last_write_result == GST_FLOW_OK) {
|
if (ebml->last_write_result == GST_FLOW_OK) {
|
||||||
buf = gst_buffer_make_writable (buf);
|
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_buffer) {
|
||||||
if (demux->common.cached_data) {
|
if (demux->common.cached_data) {
|
||||||
gst_buffer_unmap (demux->common.cached_buffer,
|
gst_buffer_unmap (demux->common.cached_buffer, &demux->common.cached_map);
|
||||||
demux->common.cached_data, -1);
|
|
||||||
demux->common.cached_data = NULL;
|
demux->common.cached_data = NULL;
|
||||||
}
|
}
|
||||||
gst_buffer_unref (demux->common.cached_buffer);
|
gst_buffer_unref (demux->common.cached_buffer);
|
||||||
|
@ -484,28 +483,28 @@ gst_matroska_demux_reset (GstElement * element)
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
|
gst_matroska_decode_buffer (GstMatroskaTrackContext * context, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
gpointer data, buf_data;
|
GstMapInfo map;
|
||||||
gsize size, buf_size;
|
gpointer data;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
|
g_return_val_if_fail (GST_IS_BUFFER (buf), NULL);
|
||||||
|
|
||||||
GST_DEBUG ("decoding buffer %p", buf);
|
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);
|
g_return_val_if_fail (size > 0, buf);
|
||||||
|
|
||||||
data = buf_data;
|
|
||||||
size = buf_size;
|
|
||||||
|
|
||||||
if (gst_matroska_decode_data (context->encodings, &data, &size,
|
if (gst_matroska_decode_data (context->encodings, &data, &size,
|
||||||
GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME, FALSE)) {
|
GST_MATROSKA_TRACK_ENCODING_SCOPE_FRAME, FALSE)) {
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return gst_buffer_new_wrapped (data, size);
|
return gst_buffer_new_wrapped (data, size);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG ("decode data failed");
|
GST_DEBUG ("decode data failed");
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1587,6 +1586,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
const guint chunk = 64 * 1024;
|
const guint chunk = 64 * 1024;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
|
GstMapInfo map;
|
||||||
gpointer data = NULL;
|
gpointer data = NULL;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint64 length;
|
guint64 length;
|
||||||
|
@ -1625,7 +1625,7 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
||||||
gint cluster_pos;
|
gint cluster_pos;
|
||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1635,9 @@ gst_matroska_demux_search_cluster (GstMatroskaDemux * demux, gint64 * pos)
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
||||||
gst_buffer_get_size (buf), newpos);
|
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);
|
gst_byte_reader_init (&reader, data, size);
|
||||||
resume:
|
resume:
|
||||||
cluster_pos = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff,
|
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) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -2714,6 +2716,7 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
||||||
GstMatroskaTrackAudioContext *audiocontext =
|
GstMatroskaTrackAudioContext *audiocontext =
|
||||||
(GstMatroskaTrackAudioContext *) stream;
|
(GstMatroskaTrackAudioContext *) stream;
|
||||||
GstBuffer *newbuf = NULL;
|
GstBuffer *newbuf = NULL;
|
||||||
|
GstMapInfo map, outmap;
|
||||||
guint8 *buf_data, *data;
|
guint8 *buf_data, *data;
|
||||||
Wavpack4Header wvh;
|
Wavpack4Header wvh;
|
||||||
|
|
||||||
|
@ -2744,7 +2747,8 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
||||||
/* block_samples, flags and crc are already in the buffer */
|
/* block_samples, flags and crc are already in the buffer */
|
||||||
newbuf = gst_buffer_new_allocate (NULL, sizeof (Wavpack4Header) - 12, 0);
|
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[0] = 'w';
|
||||||
data[1] = 'v';
|
data[1] = 'v';
|
||||||
data[2] = 'p';
|
data[2] = 'p';
|
||||||
|
@ -2769,11 +2773,13 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
||||||
gsize buf_size, size, out_size = 0;
|
gsize buf_size, size, out_size = 0;
|
||||||
guint32 block_samples, flags, crc, blocksize;
|
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) {
|
if (buf_size < 4) {
|
||||||
GST_ERROR_OBJECT (element, "Too small wavpack buffer");
|
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;
|
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);
|
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS, 0, -1);
|
||||||
|
|
||||||
outpos = 0;
|
outpos = 0;
|
||||||
outdata = gst_buffer_map (newbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (newbuf, &outmap, GST_MAP_WRITE);
|
||||||
|
outdata = outmap.data;
|
||||||
} else {
|
} else {
|
||||||
gst_buffer_unmap (newbuf, outdata, out_size);
|
gst_buffer_unmap (newbuf, &outmap);
|
||||||
out_size += sizeof (Wavpack4Header) + blocksize;
|
out_size += sizeof (Wavpack4Header) + blocksize;
|
||||||
gst_buffer_set_size (newbuf, out_size);
|
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';
|
outdata[outpos] = 'w';
|
||||||
|
@ -2839,11 +2847,11 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
|
||||||
data += blocksize;
|
data += blocksize;
|
||||||
size -= blocksize;
|
size -= blocksize;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (*buf, buf_data, buf_size);
|
gst_buffer_unmap (*buf, &map);
|
||||||
gst_buffer_unref (*buf);
|
gst_buffer_unref (*buf);
|
||||||
|
|
||||||
if (newbuf)
|
if (newbuf)
|
||||||
gst_buffer_unmap (newbuf, outdata, out_size);
|
gst_buffer_unmap (newbuf, &outmap);
|
||||||
|
|
||||||
*buf = newbuf;
|
*buf = newbuf;
|
||||||
audiocontext->wvpk_block_index += block_samples;
|
audiocontext->wvpk_block_index += block_samples;
|
||||||
|
@ -2893,20 +2901,15 @@ gst_matroska_demux_check_subtitle_buffer (GstElement * element,
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GstBuffer *newbuf;
|
GstBuffer *newbuf;
|
||||||
gchar *utf8;
|
gchar *utf8;
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
sub_stream = (GstMatroskaTrackSubtitleContext *) stream;
|
sub_stream = (GstMatroskaTrackSubtitleContext *) stream;
|
||||||
|
|
||||||
data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
|
if (!gst_buffer_map (*buf, &map, GST_MAP_READ))
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
gst_buffer_unmap (*buf, data, -1);
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
|
||||||
|
|
||||||
if (!sub_stream->invalid_utf8) {
|
if (!sub_stream->invalid_utf8) {
|
||||||
if (g_utf8_validate (data, size, NULL)) {
|
if (g_utf8_validate ((gchar *) map.data, map.size, NULL)) {
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
GST_WARNING_OBJECT (element, "subtitle stream %d is not valid UTF-8, this "
|
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 *) "*",
|
utf8 =
|
||||||
NULL, NULL, &err);
|
g_convert_with_fallback ((gchar *) map.data, map.size, "UTF-8", encoding,
|
||||||
|
(char *) "*", NULL, NULL, &err);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
GST_LOG_OBJECT (element, "could not convert string from '%s' to UTF-8: %s",
|
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) */
|
/* invalid input encoding, fall back to ISO-8859-15 (always succeeds) */
|
||||||
encoding = "ISO-8859-15";
|
encoding = "ISO-8859-15";
|
||||||
utf8 = g_convert_with_fallback (data, size, "UTF-8", encoding, (char *) "*",
|
utf8 =
|
||||||
NULL, NULL, NULL);
|
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",
|
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_into (newbuf, *buf,
|
||||||
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_META,
|
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_META,
|
||||||
0, -1);
|
0, -1);
|
||||||
gst_buffer_unmap (*buf, data, size);
|
gst_buffer_unmap (*buf, &map);
|
||||||
|
|
||||||
gst_buffer_unref (*buf);
|
gst_buffer_unref (*buf);
|
||||||
|
|
||||||
*buf = newbuf;
|
*buf = newbuf;
|
||||||
data = gst_buffer_map (*buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (*buf, &map, GST_MAP_READ);
|
||||||
|
|
||||||
next:
|
next:
|
||||||
if (sub_stream->check_markup) {
|
if (sub_stream->check_markup) {
|
||||||
/* caps claim markup text, so we need to escape text,
|
/* caps claim markup text, so we need to escape text,
|
||||||
* except if text is already markup and then needs no further escaping */
|
* except if text is already markup and then needs no further escaping */
|
||||||
sub_stream->seen_markup_tag = sub_stream->seen_markup_tag ||
|
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) {
|
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));
|
newbuf = gst_buffer_new_wrapped (utf8, strlen (utf8));
|
||||||
gst_buffer_copy_into (newbuf, *buf,
|
gst_buffer_copy_into (newbuf, *buf,
|
||||||
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS |
|
GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_FLAGS |
|
||||||
GST_BUFFER_COPY_META, 0, -1);
|
GST_BUFFER_COPY_META, 0, -1);
|
||||||
gst_buffer_unmap (*buf, data, size);
|
gst_buffer_unmap (*buf, &map);
|
||||||
gst_buffer_unref (*buf);
|
gst_buffer_unref (*buf);
|
||||||
|
|
||||||
*buf = newbuf;
|
*buf = newbuf;
|
||||||
|
@ -3017,38 +3021,36 @@ static GstBuffer *
|
||||||
gst_matroska_demux_align_buffer (GstMatroskaDemux * demux,
|
gst_matroska_demux_align_buffer (GstMatroskaDemux * demux,
|
||||||
GstBuffer * buffer, gsize alignment)
|
GstBuffer * buffer, gsize alignment)
|
||||||
{
|
{
|
||||||
gpointer data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
|
||||||
if (size < sizeof (guintptr)) {
|
if (map.size < sizeof (guintptr)) {
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((guintptr) data) & (alignment - 1)) {
|
if (((guintptr) map.data) & (alignment - 1)) {
|
||||||
GstBuffer *new_buffer;
|
GstBuffer *new_buffer;
|
||||||
gpointer new_data;
|
|
||||||
|
|
||||||
new_buffer = gst_buffer_new_allocate (NULL,
|
new_buffer = gst_buffer_new_allocate (NULL,
|
||||||
gst_buffer_get_size (buffer), alignment);
|
gst_buffer_get_size (buffer), alignment);
|
||||||
|
|
||||||
/* Copy data "by hand", so ensure alignment is kept: */
|
/* Copy data "by hand", so ensure alignment is kept: */
|
||||||
new_data = gst_buffer_map (new_buffer, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (new_buffer, 0, map.data, map.size);
|
||||||
memcpy (new_data, data, size);
|
|
||||||
gst_buffer_unmap (new_buffer, new_data, -1);
|
|
||||||
gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
||||||
GST_DEBUG_OBJECT (demux,
|
GST_DEBUG_OBJECT (demux,
|
||||||
"We want output aligned on %" G_GSIZE_FORMAT ", reallocated",
|
"We want output aligned on %" G_GSIZE_FORMAT ", reallocated",
|
||||||
alignment);
|
alignment);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return new_buffer;
|
return new_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3063,8 +3065,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
guint32 id;
|
guint32 id;
|
||||||
guint64 block_duration = -1;
|
guint64 block_duration = -1;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
gpointer buf_data = NULL;
|
GstMapInfo map;
|
||||||
gsize buf_size;
|
|
||||||
gint stream_num = -1, n, laces = 0;
|
gint stream_num = -1, n, laces = 0;
|
||||||
guint size = 0;
|
guint size = 0;
|
||||||
gint *lace_size = NULL;
|
gint *lace_size = NULL;
|
||||||
|
@ -3095,16 +3096,16 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
|
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
data = buf_data;
|
data = map.data;
|
||||||
size = buf_size;
|
size = map.size;
|
||||||
|
|
||||||
/* first byte(s): blocknum */
|
/* first byte(s): blocknum */
|
||||||
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
||||||
|
@ -3637,7 +3638,7 @@ gst_matroska_demux_parse_blockgroup_or_simpleblock (GstMatroskaDemux * demux,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buf) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
g_free (lace_size);
|
g_free (lace_size);
|
||||||
|
@ -5305,8 +5306,11 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
|
||||||
|
|
||||||
/* make up decoder-specific data if it is not supplied */
|
/* make up decoder-specific data if it is not supplied */
|
||||||
if (priv == NULL) {
|
if (priv == NULL) {
|
||||||
|
GstMapInfo map;
|
||||||
|
|
||||||
priv = gst_buffer_new_allocate (NULL, 5, 0);
|
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);
|
rate_idx = aac_rate_idx (audiocontext->samplerate);
|
||||||
profile = aac_profile_idx (codec_id);
|
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,
|
if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2,
|
||||||
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2))) {
|
strlen (GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG2))) {
|
||||||
mpegversion = 2;
|
mpegversion = 2;
|
||||||
gst_buffer_unmap (priv, data, 5);
|
gst_buffer_unmap (priv, &map);
|
||||||
gst_buffer_set_size (priv, 2);
|
gst_buffer_set_size (priv, 2);
|
||||||
} else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4,
|
} else if (!strncmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_AAC_MPEG4,
|
||||||
strlen (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[2] = AAC_SYNC_EXTENSION_TYPE >> 3;
|
||||||
data[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
|
data[3] = ((AAC_SYNC_EXTENSION_TYPE & 0x07) << 5) | 5;
|
||||||
data[4] = (1 << 7) | (rate_idx << 3);
|
data[4] = (1 << 7) | (rate_idx << 3);
|
||||||
gst_buffer_unmap (priv, data, 5);
|
gst_buffer_unmap (priv, &map);
|
||||||
} else {
|
} else {
|
||||||
gst_buffer_unmap (priv, data, 5);
|
gst_buffer_unmap (priv, &map);
|
||||||
gst_buffer_set_size (priv, 2);
|
gst_buffer_set_size (priv, 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gst_buffer_unmap (priv, data, 5);
|
gst_buffer_unmap (priv, &map);
|
||||||
gst_buffer_unref (priv);
|
gst_buffer_unref (priv);
|
||||||
priv = NULL;
|
priv = NULL;
|
||||||
GST_ERROR ("Unknown AAC profile and no codec private data");
|
GST_ERROR ("Unknown AAC profile and no codec private data");
|
||||||
|
|
|
@ -1290,14 +1290,15 @@ vorbis_streamheader_to_codecdata (const GValue * streamheader,
|
||||||
} else {
|
} else {
|
||||||
if (gst_buffer_memcmp (buf0, 1, "vorbis", 6) == 0) {
|
if (gst_buffer_memcmp (buf0, 1, "vorbis", 6) == 0) {
|
||||||
GstMatroskaTrackAudioContext *audiocontext;
|
GstMatroskaTrackAudioContext *audiocontext;
|
||||||
guint8 *data, *hdr;
|
GstMapInfo map;
|
||||||
|
guint8 *hdr;
|
||||||
|
|
||||||
data = gst_buffer_map (buf0, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buf0, &map, GST_MAP_READ);
|
||||||
hdr = data + 1 + 6 + 4;
|
hdr = map.data + 1 + 6 + 4;
|
||||||
audiocontext = (GstMatroskaTrackAudioContext *) context;
|
audiocontext = (GstMatroskaTrackAudioContext *) context;
|
||||||
audiocontext->channels = GST_READ_UINT8 (hdr);
|
audiocontext->channels = GST_READ_UINT8 (hdr);
|
||||||
audiocontext->samplerate = GST_READ_UINT32_LE (hdr + 1);
|
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 {
|
} else {
|
||||||
GstMatroskaTrackVideoContext *videocontext;
|
GstMatroskaTrackVideoContext *videocontext;
|
||||||
guint fps_num, fps_denom, par_num, par_denom;
|
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);
|
gst_buffer_map (buf0, &map, GST_MAP_READ);
|
||||||
hdr = data + 1 + 6 + 3 + 2 + 2;
|
hdr = map.data + 1 + 6 + 3 + 2 + 2;
|
||||||
|
|
||||||
videocontext = (GstMatroskaTrackVideoContext *) context;
|
videocontext = (GstMatroskaTrackVideoContext *) context;
|
||||||
videocontext->pixel_width = GST_READ_UINT32_BE (hdr) >> 8;
|
videocontext->pixel_width = GST_READ_UINT32_BE (hdr) >> 8;
|
||||||
|
@ -1358,7 +1360,7 @@ theora_streamheader_to_codecdata (const GValue * streamheader,
|
||||||
}
|
}
|
||||||
hdr += 3 + 3;
|
hdr += 3 + 3;
|
||||||
|
|
||||||
gst_buffer_unmap (buf0, data, -1);
|
gst_buffer_unmap (buf0, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf0)
|
if (buf0)
|
||||||
|
@ -2008,26 +2010,26 @@ gst_matroska_mux_subtitle_pad_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
if (value)
|
if (value)
|
||||||
buf = gst_value_get_buffer (value);
|
buf = gst_value_get_buffer (value);
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
guint8 *priv_data = NULL, *priv_buffer_data;
|
GstMapInfo map;
|
||||||
gsize priv_data_size = 0;
|
guint8 *priv_data = NULL;
|
||||||
|
|
||||||
priv_buffer_data =
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
gst_buffer_map (buf, &priv_data_size, NULL, GST_MAP_READ);
|
|
||||||
if (priv_data_size > SUBTITLE_MAX_CODEC_PRIVATE) {
|
if (map.size > SUBTITLE_MAX_CODEC_PRIVATE) {
|
||||||
GST_WARNING_OBJECT (mux, "pad %" GST_PTR_FORMAT " subtitle private data"
|
GST_WARNING_OBJECT (mux, "pad %" GST_PTR_FORMAT " subtitle private data"
|
||||||
" exceeded maximum (%d); discarding", pad,
|
" exceeded maximum (%d); discarding", pad,
|
||||||
SUBTITLE_MAX_CODEC_PRIVATE);
|
SUBTITLE_MAX_CODEC_PRIVATE);
|
||||||
gst_buffer_unmap (buf, priv_data, priv_data_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_matroska_mux_free_codec_priv (context);
|
gst_matroska_mux_free_codec_priv (context);
|
||||||
|
|
||||||
priv_data = g_malloc0 (priv_data_size);
|
priv_data = g_malloc0 (map.size);
|
||||||
memcpy (priv_data, priv_buffer_data, priv_data_size);
|
memcpy (priv_data, map.data, map.size);
|
||||||
context->codec_priv = priv_data;
|
context->codec_priv = priv_data;
|
||||||
context->codec_priv_size = priv_data_size;
|
context->codec_priv_size = map.size;
|
||||||
gst_buffer_unmap (buf, priv_buffer_data, priv_data_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (pad, "codec_id %s, codec data size %" G_GSIZE_FORMAT,
|
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 *ctx =
|
||||||
(GstMatroskaTrackVideoContext *) collect_pad->track;
|
(GstMatroskaTrackVideoContext *) collect_pad->track;
|
||||||
guint8 *buf_data, *data;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint8 parse_code;
|
guint8 parse_code;
|
||||||
guint32 next_parse_offset;
|
guint32 next_parse_offset;
|
||||||
GstBuffer *ret = NULL;
|
GstBuffer *ret = NULL;
|
||||||
gboolean is_muxing_unit = FALSE;
|
gboolean is_muxing_unit = FALSE;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
data = buf_data;
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
if (size < 13) {
|
if (size < 13) {
|
||||||
gst_buffer_unmap (buf, buf_data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return ret;
|
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 */
|
/* Check if this buffer contains a picture or end-of-sequence packet */
|
||||||
while (size >= 13) {
|
while (size >= 13) {
|
||||||
if (GST_READ_UINT32_BE (data) != 0x42424344 /* 'BBCD' */ ) {
|
if (GST_READ_UINT32_BE (data) != 0x42424344 /* 'BBCD' */ ) {
|
||||||
gst_buffer_unmap (buf, buf_data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -2813,7 +2817,7 @@ gst_matroska_mux_handle_dirac_packet (GstMatroskaMux * mux,
|
||||||
else
|
else
|
||||||
ctx->dirac_unit = gst_buffer_ref (buf);
|
ctx->dirac_unit = gst_buffer_ref (buf);
|
||||||
|
|
||||||
gst_buffer_unmap (buf, buf_data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
if (is_muxing_unit) {
|
if (is_muxing_unit) {
|
||||||
ret = gst_buffer_make_writable (ctx->dirac_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;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
const guint chunk = 64 * 1024;
|
const guint chunk = 64 * 1024;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
|
GstMapInfo map;
|
||||||
gpointer data;
|
gpointer data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint64 length;
|
guint64 length;
|
||||||
|
@ -1249,7 +1250,9 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
|
||||||
GST_DEBUG_OBJECT (parse,
|
GST_DEBUG_OBJECT (parse,
|
||||||
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
"read buffer size %" G_GSIZE_FORMAT " at offset %" G_GINT64_FORMAT,
|
||||||
gst_buffer_get_size (buf), newpos);
|
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);
|
gst_byte_reader_init (&reader, data, size);
|
||||||
cluster_pos = 0;
|
cluster_pos = 0;
|
||||||
resume:
|
resume:
|
||||||
|
@ -1297,14 +1300,14 @@ gst_matroska_parse_search_cluster (GstMatroskaParse * parse, gint64 * pos)
|
||||||
} else {
|
} else {
|
||||||
/* partial cluster id may have been in tail of buffer */
|
/* partial cluster id may have been in tail of buffer */
|
||||||
newpos += MAX (size, 4) - 3;
|
newpos += MAX (size, 4) - 3;
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1621,8 +1624,7 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
|
||||||
guint32 id;
|
guint32 id;
|
||||||
guint64 block_duration = 0;
|
guint64 block_duration = 0;
|
||||||
GstBuffer *buf = NULL;
|
GstBuffer *buf = NULL;
|
||||||
gpointer buf_data = NULL;
|
GstMapInfo map;
|
||||||
gsize buf_size = 0;
|
|
||||||
gint stream_num = -1, n, laces = 0;
|
gint stream_num = -1, n, laces = 0;
|
||||||
guint size = 0;
|
guint size = 0;
|
||||||
gint *lace_size = NULL;
|
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)
|
if ((ret = gst_ebml_read_buffer (ebml, &id, &buf)) != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
buf_data = gst_buffer_map (buf, &buf_size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
data = buf_data;
|
size = map.size;
|
||||||
size = buf_size;
|
|
||||||
|
|
||||||
/* first byte(s): blocknum */
|
/* first byte(s): blocknum */
|
||||||
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
if ((n = gst_matroska_ebmlnum_uint (data, size, &num)) < 0)
|
||||||
|
@ -2125,7 +2126,7 @@ gst_matroska_parse_parse_blockgroup_or_simpleblock (GstMatroskaParse * parse,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (buf) {
|
if (buf) {
|
||||||
gst_buffer_unmap (buf, buf_data, buf_size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
g_free (lace_size);
|
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,
|
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||||
GST_BUFFER_COPY_ALL, common->offset - cache_offset, size);
|
GST_BUFFER_COPY_ALL, common->offset - cache_offset, size);
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
if (!common->cached_data)
|
if (!common->cached_data) {
|
||||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
gst_buffer_map (common->cached_buffer, &common->cached_map,
|
||||||
NULL, NULL, GST_MAP_READ);
|
GST_MAP_READ);
|
||||||
|
common->cached_data = common->cached_map.data;
|
||||||
|
}
|
||||||
*bytes = common->cached_data + common->offset - cache_offset;
|
*bytes = common->cached_data + common->offset - cache_offset;
|
||||||
}
|
}
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
/* not enough data in the cache, free cache and get a new one */
|
/* not enough data in the cache, free cache and get a new one */
|
||||||
if (common->cached_data) {
|
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;
|
common->cached_data = NULL;
|
||||||
}
|
}
|
||||||
gst_buffer_unref (common->cached_buffer);
|
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,
|
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||||
GST_BUFFER_COPY_ALL, 0, size);
|
GST_BUFFER_COPY_ALL, 0, size);
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
gst_buffer_map (common->cached_buffer, &common->cached_map, GST_MAP_READ);
|
||||||
NULL, NULL, GST_MAP_READ);
|
common->cached_data = common->cached_map.data;
|
||||||
*bytes = common->cached_data;
|
*bytes = common->cached_data;
|
||||||
}
|
}
|
||||||
return GST_FLOW_OK;
|
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,
|
*p_buf = gst_buffer_copy_region (common->cached_buffer,
|
||||||
GST_BUFFER_COPY_ALL, 0, size);
|
GST_BUFFER_COPY_ALL, 0, size);
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
common->cached_data = gst_buffer_map (common->cached_buffer,
|
gst_buffer_map (common->cached_buffer, &common->cached_map, GST_MAP_READ);
|
||||||
NULL, NULL, GST_MAP_READ);
|
common->cached_data = common->cached_map.data;
|
||||||
*bytes = common->cached_data;
|
*bytes = common->cached_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ typedef struct _GstMatroskaReadCommon {
|
||||||
/* pull mode caching */
|
/* pull mode caching */
|
||||||
GstBuffer *cached_buffer;
|
GstBuffer *cached_buffer;
|
||||||
guint8 *cached_data;
|
guint8 *cached_data;
|
||||||
|
GstMapInfo cached_map;
|
||||||
|
|
||||||
/* push and pull mode */
|
/* push and pull mode */
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
|
|
|
@ -487,19 +487,18 @@ gst_multi_file_sink_write_stream_headers (GstMultiFileSink * sink)
|
||||||
|
|
||||||
for (i = 0; i < sink->n_streamheaders; i++) {
|
for (i = 0; i < sink->n_streamheaders; i++) {
|
||||||
GstBuffer *hdr;
|
GstBuffer *hdr;
|
||||||
guint8 *sdata;
|
GstMapInfo map;
|
||||||
gsize ssize;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
hdr = sink->streamheaders[i];
|
hdr = sink->streamheaders[i];
|
||||||
sdata = gst_buffer_map (hdr, &ssize, NULL, GST_MAP_READ);
|
gst_buffer_map (hdr, &map, GST_MAP_READ);
|
||||||
ret = fwrite (sdata, ssize, 1, sink->file);
|
ret = fwrite (map.data, map.size, 1, sink->file);
|
||||||
gst_buffer_unmap (hdr, sdata, ssize);
|
gst_buffer_unmap (hdr, &map);
|
||||||
|
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
sink->cur_file_size += ssize;
|
sink->cur_file_size += map.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -509,13 +508,12 @@ static GstFlowReturn
|
||||||
gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstMultiFileSink *multifilesink;
|
GstMultiFileSink *multifilesink;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
GError *error = NULL;
|
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);
|
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,
|
filename = g_strdup_printf (multifilesink->filename,
|
||||||
multifilesink->index);
|
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)
|
if (!ret)
|
||||||
goto write_error;
|
goto write_error;
|
||||||
|
|
||||||
|
@ -547,7 +545,7 @@ gst_multi_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
goto stdio_write_error;
|
goto stdio_write_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fwrite (data, size, 1, multifilesink->file);
|
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
goto stdio_write_error;
|
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);
|
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)
|
if (ret != 1)
|
||||||
goto stdio_write_error;
|
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))
|
if (!gst_multi_file_sink_write_stream_headers (multifilesink))
|
||||||
goto stdio_write_error;
|
goto stdio_write_error;
|
||||||
|
|
||||||
ret = fwrite (data, size, 1, multifilesink->file);
|
ret = fwrite (map.data, map.size, 1, multifilesink->file);
|
||||||
|
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
goto stdio_write_error;
|
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:{
|
case GST_MULTI_FILE_SINK_NEXT_MAX_SIZE:{
|
||||||
guint64 new_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) {
|
if (new_size > multifilesink->max_file_size) {
|
||||||
|
|
||||||
GST_INFO_OBJECT (multifilesink, "current size: %" G_GUINT64_FORMAT
|
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);
|
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)
|
if (ret != 1)
|
||||||
goto stdio_write_error;
|
goto stdio_write_error;
|
||||||
|
|
||||||
multifilesink->cur_file_size += size;
|
multifilesink->cur_file_size += map.size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -651,7 +649,7 @@ write_error:
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
stdio_write_error:
|
stdio_write_error:
|
||||||
|
@ -664,7 +662,7 @@ stdio_write_error:
|
||||||
GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
|
GST_ELEMENT_ERROR (multifilesink, RESOURCE, WRITE,
|
||||||
("Error while writing to file."), ("%s", g_strerror (errno)));
|
("Error while writing to file."), ("%s", g_strerror (errno)));
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -472,6 +472,7 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
guint64 read_offset;
|
guint64 read_offset;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint to_read;
|
guint to_read;
|
||||||
|
|
||||||
|
@ -490,7 +491,8 @@ gst_split_file_src_create (GstBaseSrc * basesrc, guint64 offset, guint size,
|
||||||
|
|
||||||
GST_BUFFER_OFFSET (buf) = offset;
|
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;
|
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_OFFSET_END (buf) = offset;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
*buffer = buf;
|
*buffer = buf;
|
||||||
GST_LOG_OBJECT (src, "read %" G_GSIZE_FORMAT " bytes into buf %p",
|
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)
|
gst_rg_analysis_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
|
GstRgAnalysis *filter = GST_RG_ANALYSIS (base);
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
|
g_return_val_if_fail (filter->ctx != NULL, GST_FLOW_WRONG_STATE);
|
||||||
g_return_val_if_fail (filter->analyze != NULL, GST_FLOW_NOT_NEGOTIATED);
|
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)
|
if (filter->skip)
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT, size);
|
GST_LOG_OBJECT (filter, "processing buffer of size %" G_GSIZE_FORMAT,
|
||||||
|
map.size);
|
||||||
|
|
||||||
rg_analysis_start_buffer (filter->ctx, GST_BUFFER_TIMESTAMP (buf));
|
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;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstRgLimiter *filter = GST_RG_LIMITER (base);
|
GstRgLimiter *filter = GST_RG_LIMITER (base);
|
||||||
gfloat *input;
|
gfloat *input;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
guint count;
|
guint count;
|
||||||
guint i;
|
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))
|
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
input = (gfloat *) data;
|
input = (gfloat *) map.data;
|
||||||
count = gst_buffer_get_size (buf) / sizeof (gfloat);
|
count = gst_buffer_get_size (buf) / sizeof (gfloat);
|
||||||
|
|
||||||
for (i = count; i--;) {
|
for (i = count; i--;) {
|
||||||
|
@ -195,7 +195,7 @@ gst_rg_limiter_transform_ip (GstBaseTransform * base, GstBuffer * buf)
|
||||||
input++;
|
input++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ gst_asteriskh263_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
|
||||||
guint32 samples;
|
guint32 samples;
|
||||||
guint16 asterisk_len;
|
guint16 asterisk_len;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
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;
|
samples = timestamp - asteriskh263->lastts;
|
||||||
asteriskh263->lastts = timestamp;
|
asteriskh263->lastts = timestamp;
|
||||||
|
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
GST_ASTERISKH263_HEADER_TIMESTAMP (data) = g_htonl (samples);
|
GST_ASTERISKH263_HEADER_TIMESTAMP (map.data) = g_htonl (samples);
|
||||||
GST_ASTERISKH263_HEADER_LENGTH (data) = g_htons (asterisk_len);
|
GST_ASTERISKH263_HEADER_LENGTH (map.data) = g_htons (asterisk_len);
|
||||||
|
|
||||||
/* copy the data into place */
|
/* 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;
|
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
|
||||||
if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
|
if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
|
||||||
|
|
|
@ -321,14 +321,15 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
{
|
{
|
||||||
GstRtpAC3Pay *rtpac3pay;
|
GstRtpAC3Pay *rtpac3pay;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
gsize size, avail, left, NF;
|
gsize avail, left, NF;
|
||||||
guint8 *data, *p;
|
GstMapInfo map;
|
||||||
|
guint8 *p;
|
||||||
guint packet_len;
|
guint packet_len;
|
||||||
GstClockTime duration, timestamp;
|
GstClockTime duration, timestamp;
|
||||||
|
|
||||||
rtpac3pay = GST_RTP_AC3_PAY (basepayload);
|
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);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
|
@ -339,8 +340,8 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
/* count the amount of incomming packets */
|
/* count the amount of incomming packets */
|
||||||
NF = 0;
|
NF = 0;
|
||||||
left = size;
|
left = map.size;
|
||||||
p = data;
|
p = map.data;
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
guint bsid, fscod, frmsizecod, frame_size;
|
guint bsid, fscod, frmsizecod, frame_size;
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ gst_rtp_ac3_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
p += frame_size;
|
p += frame_size;
|
||||||
left -= frame_size;
|
left -= frame_size;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
if (NF == 0)
|
if (NF == 0)
|
||||||
goto no_frames;
|
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,
|
/* get packet length of previous data and this new data,
|
||||||
* payload length includes a 4 byte header */
|
* 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
|
/* if this buffer is going to overflow the packet, flush what we
|
||||||
* have. */
|
* have. */
|
||||||
|
|
|
@ -273,8 +273,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
GstBuffer *outbuf = NULL;
|
GstBuffer *outbuf = NULL;
|
||||||
gint payload_len;
|
gint payload_len;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
guint8 *odata;
|
GstMapInfo map;
|
||||||
gsize osize;
|
|
||||||
|
|
||||||
rtpamrdepay = GST_RTP_AMR_DEPAY (depayload);
|
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);
|
outbuf = gst_buffer_new_and_alloc (payload_len);
|
||||||
|
|
||||||
/* point to destination */
|
/* 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 */
|
/* point to first data packet */
|
||||||
p = odata;
|
p = map.data;
|
||||||
dp = payload + num_packets;
|
dp = payload + num_packets;
|
||||||
if (rtpamrdepay->crc) {
|
if (rtpamrdepay->crc) {
|
||||||
/* skip CRC if present */
|
/* skip CRC if present */
|
||||||
|
@ -400,7 +399,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
dp += fr_size;
|
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 */
|
/* we can set the duration because each packet is 20 milliseconds */
|
||||||
GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;
|
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;
|
const gint *frame_size;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
guint payload_len;
|
guint payload_len;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint8 *payload, *data, *ptr, *payload_amr;
|
guint8 *payload, *ptr, *payload_amr;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
guint packet_len, mtu;
|
guint packet_len, mtu;
|
||||||
gint i, num_packets, num_nonempty_packets;
|
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);
|
rtpamrpay = GST_RTP_AMR_PAY (basepayload);
|
||||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (rtpamrpay);
|
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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
@ -252,7 +252,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
else
|
else
|
||||||
frame_size = wb_frame_size;
|
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
|
/* FIXME, only
|
||||||
* octet aligned, no interleaving, single channel, no CRC,
|
* 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 */
|
/* first count number of packets and total amr frame size */
|
||||||
amr_len = num_packets = num_nonempty_packets = 0;
|
amr_len = num_packets = num_nonempty_packets = 0;
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < map.size; i++) {
|
||||||
guint8 FT;
|
guint8 FT;
|
||||||
gint fr_size;
|
gint fr_size;
|
||||||
|
|
||||||
FT = (data[i] & 0x78) >> 3;
|
FT = (map.data[i] & 0x78) >> 3;
|
||||||
|
|
||||||
fr_size = frame_size[FT];
|
fr_size = frame_size[FT];
|
||||||
GST_DEBUG_OBJECT (basepayload, "frame type %d, frame size %d", FT, fr_size);
|
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++;
|
num_packets++;
|
||||||
i += fr_size;
|
i += fr_size;
|
||||||
}
|
}
|
||||||
if (amr_len > size)
|
if (amr_len > map.size)
|
||||||
goto incomplete_frame;
|
goto incomplete_frame;
|
||||||
|
|
||||||
/* we need one extra byte for the CMR, the ToC is in the input
|
/* we need one extra byte for the CMR, the ToC is in the input
|
||||||
* data */
|
* data */
|
||||||
payload_len = size + 1;
|
payload_len = map.size + 1;
|
||||||
|
|
||||||
/* get packet len to check against MTU */
|
/* get packet len to check against MTU */
|
||||||
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
|
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
|
/* 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. */
|
* 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++) {
|
for (i = 1; i <= num_packets; i++) {
|
||||||
guint8 FT;
|
guint8 FT;
|
||||||
gint fr_size;
|
gint fr_size;
|
||||||
|
@ -371,7 +371,7 @@ gst_rtp_amr_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
payload_amr += fr_size;
|
payload_amr += fr_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
@ -385,7 +385,7 @@ wrong_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||||
(NULL), ("received AMR frame with size <= 0"));
|
(NULL), ("received AMR frame with size <= 0"));
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
@ -394,7 +394,7 @@ incomplete_frame:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||||
(NULL), ("received incomplete AMR frames"));
|
(NULL), ("received incomplete AMR frames"));
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
@ -403,7 +403,7 @@ too_big:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (basepayload, STREAM, FORMAT,
|
||||||
(NULL), ("received too many AMR frames for MTU"));
|
(NULL), ("received too many AMR frames for MTU"));
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
|
|
@ -119,8 +119,8 @@ gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
GstRtpCELTDepay *rtpceltdepay;
|
GstRtpCELTDepay *rtpceltdepay;
|
||||||
gint clock_rate, nb_channels = 0, frame_size = 0;
|
gint clock_rate, nb_channels = 0, frame_size = 0;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint8 *data, *ptr;
|
GstMapInfo map;
|
||||||
gsize size;
|
guint8 *ptr;
|
||||||
const gchar *params;
|
const gchar *params;
|
||||||
GstCaps *srccaps;
|
GstCaps *srccaps;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
@ -149,7 +149,8 @@ gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
|
|
||||||
/* construct minimal header and comment packet for the decoder */
|
/* construct minimal header and comment packet for the decoder */
|
||||||
buf = gst_buffer_new_and_alloc (60);
|
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);
|
memcpy (ptr, "CELT ", 8);
|
||||||
ptr += 8;
|
ptr += 8;
|
||||||
memcpy (ptr, "1.1.12", 7);
|
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 */
|
GST_WRITE_UINT32_LE (ptr, -1); /* bytes_per_packet */
|
||||||
ptr += 4;
|
ptr += 4;
|
||||||
GST_WRITE_UINT32_LE (ptr, 0); /* extra headers */
|
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");
|
srccaps = gst_caps_new_empty_simple ("audio/x-celt");
|
||||||
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
||||||
|
|
|
@ -365,8 +365,8 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
{
|
{
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstRtpCELTPay *rtpceltpay;
|
GstRtpCELTPay *rtpceltpay;
|
||||||
gsize size, payload_len;
|
gsize payload_len;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
GstClockTime duration, packet_dur;
|
GstClockTime duration, packet_dur;
|
||||||
guint i, ssize, packet_len;
|
guint i, ssize, packet_len;
|
||||||
|
|
||||||
|
@ -374,13 +374,13 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
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) {
|
switch (rtpceltpay->packet) {
|
||||||
case 0:
|
case 0:
|
||||||
/* ident packet. We need to parse the headers to construct the RTP
|
/* ident packet. We need to parse the headers to construct the RTP
|
||||||
* properties. */
|
* 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 parse_error;
|
||||||
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -391,23 +391,23 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
/* other packets go in the payload */
|
/* other packets go in the payload */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
GST_LOG_OBJECT (rtpceltpay,
|
GST_LOG_OBJECT (rtpceltpay,
|
||||||
"got buffer of duration %" GST_TIME_FORMAT ", size %" G_GSIZE_FORMAT,
|
"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 */
|
/* calculate the size of the size field and the payload */
|
||||||
ssize = 1;
|
ssize = 1;
|
||||||
for (i = size; i > 0xff; i -= 0xff)
|
for (i = map.size; i > 0xff; i -= 0xff)
|
||||||
ssize++;
|
ssize++;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpceltpay, "bytes for size %u", ssize);
|
GST_DEBUG_OBJECT (rtpceltpay, "bytes for size %u", ssize);
|
||||||
|
|
||||||
/* calculate what the new size and duration would be of the packet */
|
/* 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)
|
if (rtpceltpay->qduration != -1 && duration != -1)
|
||||||
packet_dur = rtpceltpay->qduration + duration;
|
packet_dur = rtpceltpay->qduration + duration;
|
||||||
else
|
else
|
||||||
|
@ -421,7 +421,7 @@ gst_rtp_celt_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* queue the packet */
|
/* 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:
|
done:
|
||||||
rtpceltpay->packet++;
|
rtpceltpay->packet++;
|
||||||
|
@ -431,14 +431,14 @@ done:
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
cleanup:
|
cleanup:
|
||||||
{
|
{
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
parse_error:
|
parse_error:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
|
GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
|
||||||
("Error parsing first identification packet."));
|
("Error parsing first identification packet."));
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,6 @@ gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
gint clock_rate;
|
gint clock_rate;
|
||||||
gboolean systemstream, ret;
|
gboolean systemstream, ret;
|
||||||
const gchar *encode, *media;
|
const gchar *encode, *media;
|
||||||
guint8 *data;
|
|
||||||
gsize size;
|
|
||||||
|
|
||||||
rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
|
rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
|
||||||
|
|
||||||
|
@ -213,9 +211,7 @@ gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
/* Initialize the new accumulator frame.
|
/* Initialize the new accumulator frame.
|
||||||
* If the previous frame exists, copy that into the 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. */
|
* This way, missing packets in the stream won't show up badly. */
|
||||||
data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_memset (rtpdvdepay->acc, 0, 0, rtpdvdepay->frame_size);
|
||||||
memset (data, 0, rtpdvdepay->frame_size);
|
|
||||||
gst_buffer_unmap (rtpdvdepay->acc, data, size);
|
|
||||||
|
|
||||||
srccaps = gst_caps_new_simple ("video/x-dv",
|
srccaps = gst_caps_new_simple ("video/x-dv",
|
||||||
"systemstream", G_TYPE_BOOLEAN, systemstream,
|
"systemstream", G_TYPE_BOOLEAN, systemstream,
|
||||||
|
|
|
@ -282,8 +282,9 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
gint hdrlen;
|
gint hdrlen;
|
||||||
gsize size, osize;
|
gsize size;
|
||||||
guint8 *data, *odata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
guint8 *dest;
|
guint8 *dest;
|
||||||
guint filled;
|
guint filled;
|
||||||
GstRTPBuffer rtp = { NULL, };
|
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;
|
max_payload_size = ((GST_RTP_BASE_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
|
||||||
|
|
||||||
/* The length of the buffer to transmit. */
|
/* The length of the buffer to transmit. */
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
odata = data;
|
size = map.size;
|
||||||
osize = size;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpdvpay,
|
GST_DEBUG_OBJECT (rtpdvpay,
|
||||||
"DV RTP payloader got buffer of %" G_GSIZE_FORMAT
|
"DV RTP payloader got buffer of %" G_GSIZE_FORMAT
|
||||||
|
@ -368,7 +368,7 @@ gst_rtp_dv_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
outbuf = NULL;
|
outbuf = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, odata, osize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -195,8 +195,7 @@ static GstFlowReturn
|
||||||
gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint8 HDR;
|
guint8 HDR;
|
||||||
GstRTPG723Pay *pay;
|
GstRTPG723Pay *pay;
|
||||||
GstClockTime packet_dur, timestamp;
|
GstClockTime packet_dur, timestamp;
|
||||||
|
@ -204,7 +203,7 @@ gst_rtp_g723_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
||||||
|
|
||||||
pay = GST_RTP_G723_PAY (payload);
|
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);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
if (GST_BUFFER_IS_DISCONT (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 */
|
/* 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;
|
goto invalid_size;
|
||||||
|
|
||||||
/* check size by looking at the header bits */
|
/* check size by looking at the header bits */
|
||||||
HDR = data[0] & 0x3;
|
HDR = map.data[0] & 0x3;
|
||||||
if (size_tab[HDR] != size)
|
if (size_tab[HDR] != map.size)
|
||||||
goto wrong_size;
|
goto wrong_size;
|
||||||
|
|
||||||
/* calculate packet size and duration */
|
/* 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_dur = pay->duration + G723_FRAME_DURATION;
|
||||||
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
|
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
|
else
|
||||||
pay->timestamp = 0;
|
pay->timestamp = 0;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
/* add packet to the queue */
|
/* add packet to the queue */
|
||||||
gst_adapter_push (pay->adapter, buf);
|
gst_adapter_push (pay->adapter, buf);
|
||||||
|
@ -260,8 +259,8 @@ invalid_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||||
("Invalid input buffer size"),
|
("Invalid input buffer size"),
|
||||||
("Input size should be 4, 20 or 24, got %" G_GSIZE_FORMAT, size));
|
("Input size should be 4, 20 or 24, got %" G_GSIZE_FORMAT, map.size));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
@ -270,8 +269,8 @@ wrong_size:
|
||||||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||||
("Wrong input buffer size"),
|
("Wrong input buffer size"),
|
||||||
("Expected input buffer size %u but got %" G_GSIZE_FORMAT,
|
("Expected input buffer size %u but got %" G_GSIZE_FORMAT,
|
||||||
size_tab[HDR], size));
|
size_tab[HDR], map.size));
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,9 +225,9 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
if (!outbuf)
|
if (!outbuf)
|
||||||
goto bad_len;
|
goto bad_len;
|
||||||
} else {
|
} else {
|
||||||
guint8 *in, *out, tmp, *odata;
|
guint8 *in, *out, tmp;
|
||||||
guint len;
|
guint len;
|
||||||
gsize osize;
|
GstMapInfo map;
|
||||||
|
|
||||||
in = gst_rtp_buffer_get_payload (&rtp);
|
in = gst_rtp_buffer_get_payload (&rtp);
|
||||||
len = gst_rtp_buffer_get_payload_len (&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;
|
goto bad_len;
|
||||||
outbuf = gst_buffer_make_writable (outbuf);
|
outbuf = gst_buffer_make_writable (outbuf);
|
||||||
|
|
||||||
odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
out = odata;
|
out = map.data;
|
||||||
|
|
||||||
/* we need to reshuffle the bytes, input is always of the form
|
/* 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. */
|
* 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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (outbuf, odata, osize);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marker) {
|
if (marker) {
|
||||||
|
|
|
@ -267,16 +267,19 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
||||||
pay = GST_RTP_G726_PAY (payload);
|
pay = GST_RTP_G726_PAY (payload);
|
||||||
|
|
||||||
if (!pay->aal2) {
|
if (!pay->aal2) {
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data, tmp;
|
guint8 *data, tmp;
|
||||||
gsize len;
|
gsize size;
|
||||||
|
|
||||||
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
|
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
|
||||||
* when the buffer is writable. */
|
* when the buffer is writable. */
|
||||||
buffer = gst_buffer_make_writable (buffer);
|
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:
|
/* we need to reshuffle the bytes, output is of the form:
|
||||||
* A B C D .. with the number of bits depending on the bitrate. */
|
* 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|
|
* |0 1|0 1|0 1|0 1|
|
||||||
* +-+-+-+-+-+-+-+-+-
|
* +-+-+-+-+-+-+-+-+-
|
||||||
*/
|
*/
|
||||||
while (len > 0) {
|
while (size > 0) {
|
||||||
tmp = *data;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xc0) >> 6) |
|
*data++ = ((tmp & 0xc0) >> 6) |
|
||||||
((tmp & 0x30) >> 2) | ((tmp & 0x0c) << 2) | ((tmp & 0x03) << 6);
|
((tmp & 0x30) >> 2) | ((tmp & 0x0c) << 2) | ((tmp & 0x03) << 6);
|
||||||
len--;
|
size--;
|
||||||
}
|
}
|
||||||
break;
|
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|
|
* |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;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xc0) >> 6) |
|
*data++ = ((tmp & 0xc0) >> 6) |
|
||||||
((tmp & 0x38) >> 1) | ((tmp & 0x07) << 5);
|
((tmp & 0x38) >> 1) | ((tmp & 0x07) << 5);
|
||||||
|
@ -317,7 +320,7 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
||||||
tmp = *data;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xe0) >> 5) |
|
*data++ = ((tmp & 0xe0) >> 5) |
|
||||||
((tmp & 0x1c) >> 2) | ((tmp & 0x03) << 6);
|
((tmp & 0x1c) >> 2) | ((tmp & 0x03) << 6);
|
||||||
len -= 3;
|
size -= 3;
|
||||||
}
|
}
|
||||||
break;
|
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|
|
* |0 1 2 3|0 1 2 3|0 1 2 3|0 1 2 3|
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||||
*/
|
*/
|
||||||
while (len > 0) {
|
while (size > 0) {
|
||||||
tmp = *data;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xf0) >> 4) | ((tmp & 0x0f) << 4);
|
*data++ = ((tmp & 0xf0) >> 4) | ((tmp & 0x0f) << 4);
|
||||||
len--;
|
size--;
|
||||||
}
|
}
|
||||||
break;
|
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|
|
* |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;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xe0) >> 5) | ((tmp & 0x1f) << 3);
|
*data++ = ((tmp & 0xe0) >> 5) | ((tmp & 0x1f) << 3);
|
||||||
tmp = *data;
|
tmp = *data;
|
||||||
|
@ -359,12 +362,12 @@ gst_rtp_g726_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
|
||||||
((tmp & 0x3e) << 2) | ((tmp & 0x01) << 7);
|
((tmp & 0x3e) << 2) | ((tmp & 0x01) << 7);
|
||||||
tmp = *data;
|
tmp = *data;
|
||||||
*data++ = ((tmp & 0xf8) >> 3) | ((tmp & 0x07) << 5);
|
*data++ = ((tmp & 0xf8) >> 3) | ((tmp & 0x07) << 5);
|
||||||
len -= 5;
|
size -= 5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, len);
|
gst_buffer_unmap (buffer, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
res =
|
res =
|
||||||
|
|
|
@ -330,11 +330,11 @@ gst_rtp_g729_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buf)
|
||||||
rtpg729pay->next_ts = timestamp;
|
rtpg729pay->next_ts = timestamp;
|
||||||
|
|
||||||
if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
|
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);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
ret = gst_rtp_g729_pay_push (rtpg729pay, data, size);
|
ret = gst_rtp_g729_pay_push (rtpg729pay, map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,21 +127,21 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstRTPGSMPay *rtpgsmpay;
|
GstRTPGSMPay *rtpgsmpay;
|
||||||
guint payload_len;
|
guint payload_len;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint8 *payload, *data;
|
GstMapInfo map;
|
||||||
|
guint8 *payload;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
gsize size;
|
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
|
|
||||||
rtpgsmpay = GST_RTP_GSM_PAY (basepayload);
|
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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
/* FIXME, only one GSM frame per RTP packet for now */
|
/* FIXME, only one GSM frame per RTP packet for now */
|
||||||
payload_len = size;
|
payload_len = map.size;
|
||||||
|
|
||||||
/* FIXME, just error out for now */
|
/* FIXME, just error out for now */
|
||||||
if (payload_len > GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay))
|
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 */
|
/* copy data in payload */
|
||||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||||
memcpy (payload, data, size);
|
memcpy (payload, map.data, map.size);
|
||||||
|
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
|
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),
|
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
|
||||||
("payload_len %u > mtu %u", payload_len,
|
("payload_len %u > mtu %u", payload_len,
|
||||||
GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)));
|
GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)));
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,32 +225,31 @@ gst_rtp_gst_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
|
|
||||||
if (payload[0] & 0x80) {
|
if (payload[0] & 0x80) {
|
||||||
guint b, csize, left, offset;
|
guint b, csize, left, offset;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
GstBuffer *subbuf;
|
GstBuffer *subbuf;
|
||||||
|
|
||||||
/* C bit, we have inline caps */
|
/* 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 */
|
/* start reading the length, we need this to skip to the data later */
|
||||||
csize = offset = 0;
|
csize = offset = 0;
|
||||||
left = size;
|
left = map.size;
|
||||||
do {
|
do {
|
||||||
if (offset >= left) {
|
if (offset >= left) {
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
goto too_small;
|
goto too_small;
|
||||||
}
|
}
|
||||||
b = data[offset++];
|
b = map.data[offset++];
|
||||||
csize = (csize << 7) | (b & 0x7f);
|
csize = (csize << 7) | (b & 0x7f);
|
||||||
} while (b & 0x80);
|
} while (b & 0x80);
|
||||||
|
|
||||||
if (left < csize) {
|
if (left < csize) {
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
goto too_small;
|
goto too_small;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse and store in cache */
|
/* 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);
|
store_cache (rtpgstdepay, CV, outcaps);
|
||||||
|
|
||||||
/* skip caps */
|
/* 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);
|
"inline caps %u, length %u, %" GST_PTR_FORMAT, CV, csize, outcaps);
|
||||||
|
|
||||||
/* create real data buffer when needed */
|
/* create real data buffer when needed */
|
||||||
if (size)
|
if (map.size)
|
||||||
subbuf =
|
subbuf =
|
||||||
gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, offset, left);
|
gst_buffer_copy_region (outbuf, GST_BUFFER_COPY_ALL, offset, left);
|
||||||
else
|
else
|
||||||
subbuf = NULL;
|
subbuf = NULL;
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
gst_buffer_unref (outbuf);
|
gst_buffer_unref (outbuf);
|
||||||
outbuf = subbuf;
|
outbuf = subbuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,8 +126,9 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstRtpGSTPay *rtpgstpay;
|
GstRtpGSTPay *rtpgstpay;
|
||||||
guint8 *data, *ptr;
|
GstMapInfo map;
|
||||||
gsize size, left;
|
guint8 *ptr;
|
||||||
|
gsize left;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
@ -136,7 +137,7 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
rtpgstpay = GST_RTP_GST_PAY (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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
|
@ -156,8 +157,8 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
*/
|
*/
|
||||||
frag_offset = 0;
|
frag_offset = 0;
|
||||||
ptr = data;
|
ptr = map.data;
|
||||||
left = size;
|
left = map.size;
|
||||||
|
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
guint towrite;
|
guint towrite;
|
||||||
|
@ -206,7 +207,7 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -307,7 +307,7 @@ gst_rtp_h263p_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
/* frame is completed: append to previous, push it out */
|
/* frame is completed: append to previous, push it out */
|
||||||
guint len, padlen;
|
guint len, padlen;
|
||||||
guint avail;
|
guint avail;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
GST_LOG_OBJECT (depayload, "Frame complete");
|
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);
|
outbuf = gst_buffer_new_and_alloc (len + padlen);
|
||||||
|
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
memset (data + len, 0, padlen);
|
memset (map.data + len, 0, padlen);
|
||||||
|
|
||||||
/* prepend previous data */
|
/* prepend previous data */
|
||||||
if (avail > 0) {
|
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);
|
gst_adapter_flush (rtph263pdepay->adapter, avail);
|
||||||
}
|
}
|
||||||
memcpy (data + avail, payload, payload_len);
|
memcpy (map.data + avail, payload, payload_len);
|
||||||
gst_buffer_unmap (outbuf, data, len);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
|
|
|
@ -290,7 +290,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
GstRtpH264Depay *rtph264depay;
|
GstRtpH264Depay *rtph264depay;
|
||||||
const gchar *ps, *profile;
|
const gchar *ps, *profile;
|
||||||
GstBuffer *codec_data;
|
GstBuffer *codec_data;
|
||||||
guint8 *ptr, *data;
|
GstMapInfo map;
|
||||||
|
guint8 *ptr;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
rtph264depay = GST_RTP_H264_DEPAY (depayload);
|
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. */
|
/* we seriously overshoot the length, but it's fine. */
|
||||||
codec_data = gst_buffer_new_and_alloc (len);
|
codec_data = gst_buffer_new_and_alloc (len);
|
||||||
|
|
||||||
data = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (codec_data, &map, GST_MAP_WRITE);
|
||||||
ptr = data;
|
ptr = map.data;
|
||||||
total = 0;
|
total = 0;
|
||||||
for (i = 0; params[i]; i++) {
|
for (i = 0; params[i]; i++) {
|
||||||
guint save = 0;
|
guint save = 0;
|
||||||
|
@ -345,7 +346,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
total += len + sizeof (sync_bytes);
|
total += len + sizeof (sync_bytes);
|
||||||
ptr += len;
|
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);
|
g_strfreev (params);
|
||||||
|
|
||||||
/* keep the codec_data, we need to send it as the first buffer. We cannot
|
/* 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);
|
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 */
|
/* 8 bits version == 1 */
|
||||||
*ptr++ = 1;
|
*ptr++ = 1;
|
||||||
|
@ -451,7 +454,8 @@ gst_rtp_h264_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
ptr += len;
|
ptr += len;
|
||||||
}
|
}
|
||||||
g_free (pps);
|
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,
|
gst_caps_set_simple (srccaps,
|
||||||
"codec_data", GST_TYPE_BUFFER, codec_data, NULL);
|
"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);
|
GstRTPBaseDepayload *depayload = GST_RTP_BASE_DEPAYLOAD (rtph264depay);
|
||||||
gint nal_type;
|
gint nal_type;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
|
||||||
GstBuffer *outbuf = NULL;
|
GstBuffer *outbuf = NULL;
|
||||||
GstClockTime out_timestamp;
|
GstClockTime out_timestamp;
|
||||||
gboolean keyframe, out_keyframe;
|
gboolean keyframe, out_keyframe;
|
||||||
|
|
||||||
data = gst_buffer_map (nal, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (nal, &map, GST_MAP_READ);
|
||||||
if (G_UNLIKELY (size < 5))
|
if (G_UNLIKELY (map.size < 5))
|
||||||
goto short_nal;
|
goto short_nal;
|
||||||
|
|
||||||
nal_type = data[4] & 0x1f;
|
nal_type = map.data[4] & 0x1f;
|
||||||
GST_DEBUG_OBJECT (rtph264depay, "handle NAL type %d", nal_type);
|
GST_DEBUG_OBJECT (rtph264depay, "handle NAL type %d", nal_type);
|
||||||
|
|
||||||
keyframe = NAL_TYPE_IS_KEY (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) {
|
if (nal_type == 1 || nal_type == 2 || nal_type == 5) {
|
||||||
/* we have a picture start */
|
/* we have a picture start */
|
||||||
start = TRUE;
|
start = TRUE;
|
||||||
if (data[5] & 0x80) {
|
if (map.data[5] & 0x80) {
|
||||||
/* first_mb_in_slice == 0 completes a picture */
|
/* first_mb_in_slice == 0 completes a picture */
|
||||||
complete = TRUE;
|
complete = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +569,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
||||||
GST_DEBUG_OBJECT (depayload, "using NAL as output");
|
GST_DEBUG_OBJECT (depayload, "using NAL as output");
|
||||||
outbuf = nal;
|
outbuf = nal;
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (nal, data, size);
|
gst_buffer_unmap (nal, &map);
|
||||||
|
|
||||||
if (outbuf) {
|
if (outbuf) {
|
||||||
/* prepend codec_data */
|
/* prepend codec_data */
|
||||||
|
@ -592,7 +595,7 @@ gst_rtp_h264_depay_handle_nal (GstRtpH264Depay * rtph264depay, GstBuffer * nal,
|
||||||
short_nal:
|
short_nal:
|
||||||
{
|
{
|
||||||
GST_WARNING_OBJECT (depayload, "dropping short NAL");
|
GST_WARNING_OBJECT (depayload, "dropping short NAL");
|
||||||
gst_buffer_unmap (nal, data, size);
|
gst_buffer_unmap (nal, &map);
|
||||||
gst_buffer_unref (nal);
|
gst_buffer_unref (nal);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -603,25 +606,25 @@ gst_rtp_h264_push_fragmentation_unit (GstRtpH264Depay * rtph264depay,
|
||||||
gboolean send)
|
gboolean send)
|
||||||
{
|
{
|
||||||
guint outsize;
|
guint outsize;
|
||||||
guint8 *outdata;
|
GstMapInfo map;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
outsize = gst_adapter_available (rtph264depay->adapter);
|
outsize = gst_adapter_available (rtph264depay->adapter);
|
||||||
outbuf = gst_adapter_take_buffer (rtph264depay->adapter, outsize);
|
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);
|
GST_DEBUG_OBJECT (rtph264depay, "output %d bytes", outsize);
|
||||||
|
|
||||||
if (rtph264depay->byte_stream) {
|
if (rtph264depay->byte_stream) {
|
||||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||||
} else {
|
} else {
|
||||||
outsize -= 4;
|
outsize -= 4;
|
||||||
outdata[0] = (outsize >> 24);
|
map.data[0] = (outsize >> 24);
|
||||||
outdata[1] = (outsize >> 16);
|
map.data[1] = (outsize >> 16);
|
||||||
outdata[2] = (outsize >> 8);
|
map.data[2] = (outsize >> 8);
|
||||||
outdata[3] = (outsize);
|
map.data[3] = (outsize);
|
||||||
}
|
}
|
||||||
gst_buffer_unmap (outbuf, outdata, -1);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
rtph264depay->current_fu_type = 0;
|
rtph264depay->current_fu_type = 0;
|
||||||
|
|
||||||
|
@ -660,7 +663,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
guint8 *payload;
|
guint8 *payload;
|
||||||
guint header_len;
|
guint header_len;
|
||||||
guint8 nal_ref_idc;
|
guint8 nal_ref_idc;
|
||||||
guint8 *outdata;
|
GstMapInfo map;
|
||||||
guint outsize, nalu_size;
|
guint outsize, nalu_size;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
gboolean marker;
|
gboolean marker;
|
||||||
|
@ -738,21 +741,21 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
outsize = nalu_size + sizeof (sync_bytes);
|
outsize = nalu_size + sizeof (sync_bytes);
|
||||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
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) {
|
if (rtph264depay->byte_stream) {
|
||||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||||
} else {
|
} else {
|
||||||
outdata[0] = outdata[1] = 0;
|
map.data[0] = map.data[1] = 0;
|
||||||
outdata[2] = payload[0];
|
map.data[2] = payload[0];
|
||||||
outdata[3] = payload[1];
|
map.data[3] = payload[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* strip NALU size */
|
/* strip NALU size */
|
||||||
payload += 2;
|
payload += 2;
|
||||||
payload_len -= 2;
|
payload_len -= 2;
|
||||||
|
|
||||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
gst_adapter_push (rtph264depay->adapter, outbuf);
|
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);
|
outsize = nalu_size + sizeof (sync_bytes);
|
||||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
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);
|
||||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||||
outdata[sizeof (sync_bytes)] = nal_header;
|
map.data[sizeof (sync_bytes)] = nal_header;
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
|
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", outsize);
|
||||||
|
|
||||||
|
@ -842,10 +845,7 @@ gst_rtp_h264_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
|
|
||||||
outsize = payload_len;
|
outsize = payload_len;
|
||||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
outbuf = gst_buffer_new_and_alloc (outsize);
|
||||||
|
gst_buffer_fill (outbuf, 0, payload, outsize);
|
||||||
outdata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
|
||||||
memcpy (outdata, payload, outsize);
|
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtph264depay, "queueing %d bytes", 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);
|
outsize = nalu_size + sizeof (sync_bytes);
|
||||||
outbuf = gst_buffer_new_and_alloc (outsize);
|
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) {
|
if (rtph264depay->byte_stream) {
|
||||||
memcpy (outdata, sync_bytes, sizeof (sync_bytes));
|
memcpy (map.data, sync_bytes, sizeof (sync_bytes));
|
||||||
} else {
|
} else {
|
||||||
outdata[0] = outdata[1] = 0;
|
map.data[0] = map.data[1] = 0;
|
||||||
outdata[2] = nalu_size >> 8;
|
map.data[2] = nalu_size >> 8;
|
||||||
outdata[3] = nalu_size & 0xff;
|
map.data[3] = nalu_size & 0xff;
|
||||||
}
|
}
|
||||||
memcpy (outdata + sizeof (sync_bytes), payload, nalu_size);
|
memcpy (map.data + sizeof (sync_bytes), payload, nalu_size);
|
||||||
gst_buffer_unmap (outbuf, outdata, outsize);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
|
outbuf = gst_rtp_h264_depay_handle_nal (rtph264depay, outbuf, timestamp,
|
||||||
marker);
|
marker);
|
||||||
|
|
|
@ -373,8 +373,7 @@ gst_rtp_h264_pay_set_sps_pps (GstRTPBasePayload * basepayload)
|
||||||
GString *sprops;
|
GString *sprops;
|
||||||
guint count;
|
guint count;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
sprops = g_string_new ("");
|
sprops = g_string_new ("");
|
||||||
count = 0;
|
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)) {
|
for (walk = payloader->sps; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
||||||
|
|
||||||
data = gst_buffer_map (sps_buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (sps_buf, &map, GST_MAP_READ);
|
||||||
set = g_base64_encode (data, size);
|
set = g_base64_encode (map.data, map.size);
|
||||||
gst_buffer_unmap (sps_buf, data, size);
|
gst_buffer_unmap (sps_buf, &map);
|
||||||
|
|
||||||
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
||||||
g_free (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)) {
|
for (walk = payloader->pps; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *pps_buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *pps_buf = GST_BUFFER_CAST (walk->data);
|
||||||
|
|
||||||
data = gst_buffer_map (pps_buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (pps_buf, &map, GST_MAP_READ);
|
||||||
set = g_base64_encode (data, size);
|
set = g_base64_encode (map.data, map.size);
|
||||||
gst_buffer_unmap (pps_buf, data, size);
|
gst_buffer_unmap (pps_buf, &map);
|
||||||
|
|
||||||
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
g_string_append_printf (sprops, "%s%s", count ? "," : "", set);
|
||||||
g_free (set);
|
g_free (set);
|
||||||
|
@ -420,8 +419,9 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
GstRtpH264Pay *rtph264pay;
|
GstRtpH264Pay *rtph264pay;
|
||||||
GstStructure *str;
|
GstStructure *str;
|
||||||
const GValue *value;
|
const GValue *value;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
gsize size, bsize;
|
guint8 *data;
|
||||||
|
gsize size;
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
const gchar *alignment;
|
const gchar *alignment;
|
||||||
|
|
||||||
|
@ -449,9 +449,9 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
|
|
||||||
buffer = gst_value_get_buffer (value);
|
buffer = gst_value_get_buffer (value);
|
||||||
|
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
data = bdata;
|
data = map.data;
|
||||||
size = bsize;
|
size = map.size;
|
||||||
|
|
||||||
/* parse the avcC data */
|
/* parse the avcC data */
|
||||||
if (size < 7)
|
if (size < 7)
|
||||||
|
@ -534,6 +534,7 @@ gst_rtp_h264_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
|
||||||
data += nal_size;
|
data += nal_size;
|
||||||
size -= nal_size;
|
size -= nal_size;
|
||||||
}
|
}
|
||||||
|
gst_buffer_unmap (buffer, &map);
|
||||||
/* and update the caps with the collected data */
|
/* and update the caps with the collected data */
|
||||||
if (!gst_rtp_h264_pay_set_sps_pps (basepayload))
|
if (!gst_rtp_h264_pay_set_sps_pps (basepayload))
|
||||||
goto set_sps_pps_failed;
|
goto set_sps_pps_failed;
|
||||||
|
@ -566,7 +567,7 @@ set_sps_pps_failed:
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,6 +596,7 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
|
||||||
|
|
||||||
for (i = 0; params[i]; i++) {
|
for (i = 0; params[i]; i++) {
|
||||||
gsize nal_len;
|
gsize nal_len;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *nalp;
|
guint8 *nalp;
|
||||||
guint save = 0;
|
guint save = 0;
|
||||||
gint state = 0;
|
gint state = 0;
|
||||||
|
@ -603,10 +605,12 @@ gst_rtp_h264_pay_parse_sprop_parameter_sets (GstRtpH264Pay * rtph264pay)
|
||||||
nal_len = strlen (params[i]);
|
nal_len = strlen (params[i]);
|
||||||
buf = gst_buffer_new_and_alloc (nal_len);
|
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_len = g_base64_decode_step (params[i], nal_len, nalp, &state, &save);
|
||||||
nal_type = nalp[0];
|
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) {
|
if (!nal_len) {
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
@ -792,18 +796,17 @@ gst_rtp_h264_pay_send_sps_pps (GstRTPBasePayload * basepayload,
|
||||||
{
|
{
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GList *walk;
|
GList *walk;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
for (walk = rtph264pay->sps; walk; walk = g_list_next (walk)) {
|
for (walk = rtph264pay->sps; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *sps_buf = GST_BUFFER_CAST (walk->data);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtph264pay, "inserting SPS in the stream");
|
GST_DEBUG_OBJECT (rtph264pay, "inserting SPS in the stream");
|
||||||
/* resend SPS */
|
/* 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,
|
ret = gst_rtp_h264_pay_payload_nal (basepayload,
|
||||||
data, size, timestamp, sps_buf, FALSE);
|
map.data, map.size, timestamp, sps_buf, FALSE);
|
||||||
gst_buffer_unmap (sps_buf, data, size);
|
gst_buffer_unmap (sps_buf, &map);
|
||||||
/* Not critical here; but throw a warning */
|
/* Not critical here; but throw a warning */
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
GST_WARNING ("Problem pushing SPS");
|
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");
|
GST_DEBUG_OBJECT (rtph264pay, "inserting PPS in the stream");
|
||||||
/* resend PPS */
|
/* 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,
|
ret = gst_rtp_h264_pay_payload_nal (basepayload,
|
||||||
data, size, timestamp, pps_buf, FALSE);
|
map.data, map.size, timestamp, pps_buf, FALSE);
|
||||||
gst_buffer_unmap (pps_buf, data, size);
|
gst_buffer_unmap (pps_buf, &map);
|
||||||
/* Not critical here; but throw a warning */
|
/* Not critical here; but throw a warning */
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
GST_WARNING ("Problem pushing PPS");
|
GST_WARNING ("Problem pushing PPS");
|
||||||
|
@ -1082,8 +1085,7 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint nal_len, i;
|
guint nal_len, i;
|
||||||
guint8 *bdata = NULL;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
const guint8 *data, *nal_data;
|
const guint8 *data, *nal_data;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
GArray *nal_queue;
|
GArray *nal_queue;
|
||||||
|
@ -1108,9 +1110,9 @@ gst_rtp_h264_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
if (!GST_CLOCK_TIME_IS_VALID (timestamp))
|
if (!GST_CLOCK_TIME_IS_VALID (timestamp))
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
} else {
|
} else {
|
||||||
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
data = bdata;
|
data = map.data;
|
||||||
size = bsize;
|
size = map.size;
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
|
GST_DEBUG_OBJECT (basepayload, "got %" G_GSIZE_FORMAT " bytes", size);
|
||||||
}
|
}
|
||||||
|
@ -1307,7 +1309,7 @@ done:
|
||||||
gst_adapter_unmap (rtph264pay->adapter);
|
gst_adapter_unmap (rtph264pay->adapter);
|
||||||
gst_adapter_flush (rtph264pay->adapter, pushed);
|
gst_adapter_flush (rtph264pay->adapter, pushed);
|
||||||
} else {
|
} else {
|
||||||
gst_buffer_unmap (buffer, bdata, bsize);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,8 +267,7 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
||||||
GList *packets, *walk;
|
GList *packets, *walk;
|
||||||
guint8 end[2];
|
guint8 end[2];
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
|
rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
|
||||||
|
@ -307,12 +306,12 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
||||||
|
|
||||||
if (walk == packets) {
|
if (walk == packets) {
|
||||||
/* first buffer should contain the SOT */
|
/* 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;
|
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;
|
guint Psot, nPsot;
|
||||||
|
|
||||||
if (end[0] == 0xff && end[1] == J2K_MARKER_EOC)
|
if (end[0] == 0xff && end[1] == J2K_MARKER_EOC)
|
||||||
|
@ -320,19 +319,19 @@ gst_rtp_j2k_depay_flush_tile (GstRTPBaseDepayload * depayload)
|
||||||
else
|
else
|
||||||
nPsot = avail;
|
nPsot = avail;
|
||||||
|
|
||||||
Psot = GST_READ_UINT32_BE (&data[6]);
|
Psot = GST_READ_UINT32_BE (&map.data[6]);
|
||||||
if (Psot != nPsot && Psot != 0) {
|
if (Psot != nPsot && Psot != 0) {
|
||||||
/* Psot must match the size of the tile */
|
/* Psot must match the size of the tile */
|
||||||
GST_DEBUG_OBJECT (rtpj2kdepay, "set Psot from %u to %u", Psot, nPsot);
|
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);
|
buf = gst_buffer_make_writable (buf);
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
||||||
GST_WRITE_UINT32_BE (&data[6], nPsot);
|
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,
|
GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %" G_GSIZE_FORMAT,
|
||||||
|
@ -357,7 +356,7 @@ waiting_header:
|
||||||
invalid_tile:
|
invalid_tile:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE, ("Invalid tile"), (NULL));
|
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);
|
gst_adapter_clear (rtpj2kdepay->t_adapter);
|
||||||
rtpj2kdepay->last_tile = -1;
|
rtpj2kdepay->last_tile = -1;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -335,8 +335,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
#if 0
|
#if 0
|
||||||
GstBufferList *list = NULL;
|
GstBufferList *list = NULL;
|
||||||
#endif
|
#endif
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint mtu, max_size;
|
guint mtu, max_size;
|
||||||
guint offset;
|
guint offset;
|
||||||
guint end, pos;
|
guint end, pos;
|
||||||
|
@ -344,13 +343,13 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
pay = GST_RTP_J2K_PAY (basepayload);
|
pay = GST_RTP_J2K_PAY (basepayload);
|
||||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
|
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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
offset = pos = end = 0;
|
offset = pos = end = 0;
|
||||||
|
|
||||||
GST_LOG_OBJECT (pay,
|
GST_LOG_OBJECT (pay,
|
||||||
"got buffer size %" G_GSIZE_FORMAT ", timestamp %" GST_TIME_FORMAT, size,
|
"got buffer size %" G_GSIZE_FORMAT ", timestamp %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (timestamp));
|
map.size, GST_TIME_ARGS (timestamp));
|
||||||
|
|
||||||
/* do some header defaults first */
|
/* do some header defaults first */
|
||||||
state.header.tp = 0; /* only progressive scan */
|
state.header.tp = 0; /* only progressive scan */
|
||||||
|
@ -413,11 +412,11 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
pos = end;
|
pos = end;
|
||||||
|
|
||||||
/* exit when finished */
|
/* exit when finished */
|
||||||
if (pos == size)
|
if (pos == map.size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* scan next packetization unit and fill in the header */
|
/* 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 (TRUE);
|
||||||
|
|
||||||
while (pu_size > 0) {
|
while (pu_size > 0) {
|
||||||
|
@ -468,7 +467,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
else
|
else
|
||||||
state.header.MHF = 2;
|
state.header.MHF = 2;
|
||||||
}
|
}
|
||||||
if (end >= size)
|
if (end >= map.size)
|
||||||
gst_rtp_buffer_set_marker (&rtp, TRUE);
|
gst_rtp_buffer_set_marker (&rtp, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +517,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* copy payload */
|
/* copy payload */
|
||||||
memcpy (header + HEADER_SIZE, &data[offset], data_size);
|
memcpy (header + HEADER_SIZE, &map.data[offset], data_size);
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||||
|
@ -534,7 +533,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
offset += data_size;
|
offset += data_size;
|
||||||
}
|
}
|
||||||
offset = pos;
|
offset = pos;
|
||||||
} while (offset < size);
|
} while (offset < map.size);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
|
@ -602,8 +602,8 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frag_offset == 0) {
|
if (frag_offset == 0) {
|
||||||
|
GstMapInfo map;
|
||||||
guint size;
|
guint size;
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
|
if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
|
||||||
GstCaps *outcaps;
|
GstCaps *outcaps;
|
||||||
|
@ -645,9 +645,10 @@ gst_rtp_jpeg_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
/* max header length, should be big enough */
|
/* max header length, should be big enough */
|
||||||
outbuf = gst_buffer_new_and_alloc (1000);
|
outbuf = gst_buffer_new_and_alloc (1000);
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
size = MakeHeaders (data, type, width, height, qtable, precision, dri);
|
size = MakeHeaders (map.data, type, width, height, qtable, precision, dri);
|
||||||
gst_buffer_unmap (outbuf, data, size);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
gst_buffer_resize (outbuf, 0, size);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpjpegdepay, "pushing %u bytes of header", 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)) {
|
if (gst_rtp_buffer_get_marker (&rtp)) {
|
||||||
guint avail;
|
guint avail;
|
||||||
guint8 end[2];
|
guint8 end[2];
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
/* last buffer take all data out of the adapter */
|
/* last buffer take all data out of the adapter */
|
||||||
avail = gst_adapter_available (rtpjpegdepay->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 */
|
/* no EOI marker, add one */
|
||||||
outbuf = gst_buffer_new_and_alloc (2);
|
outbuf = gst_buffer_new_and_alloc (2);
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
data[0] = 0xff;
|
map.data[0] = 0xff;
|
||||||
data[1] = 0xd9;
|
map.data[1] = 0xd9;
|
||||||
gst_buffer_unmap (outbuf, data, -1);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
|
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
|
||||||
avail += 2;
|
avail += 2;
|
||||||
|
|
|
@ -607,7 +607,8 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
RtpQuantTable tables[15] = { {0, NULL}, };
|
RtpQuantTable tables[15] = { {0, NULL}, };
|
||||||
CompInfo info[3] = { {0,}, };
|
CompInfo info[3] = { {0,}, };
|
||||||
guint quant_data_size;
|
guint quant_data_size;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint mtu;
|
guint mtu;
|
||||||
guint bytes_left;
|
guint bytes_left;
|
||||||
|
@ -621,7 +622,9 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
pay = GST_RTP_JPEG_PAY (basepayload);
|
pay = GST_RTP_JPEG_PAY (basepayload);
|
||||||
mtu = GST_RTP_BASE_PAYLOAD_MTU (pay);
|
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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
|
@ -835,7 +838,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
ret = gst_rtp_base_payload_push_list (basepayload, list);
|
ret = gst_rtp_base_payload_push_list (basepayload, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -844,28 +847,28 @@ gst_rtp_jpeg_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
unsupported_jpeg:
|
unsupported_jpeg:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
|
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_NOT_SUPPORTED;
|
return GST_FLOW_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
no_dimension:
|
no_dimension:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));
|
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);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_NOT_NEGOTIATED;
|
return GST_FLOW_NOT_NEGOTIATED;
|
||||||
}
|
}
|
||||||
invalid_format:
|
invalid_format:
|
||||||
{
|
{
|
||||||
/* error was posted */
|
/* error was posted */
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
invalid_quant:
|
invalid_quant:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
|
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);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
g_value_init (&v, GST_TYPE_BUFFER);
|
g_value_init (&v, GST_TYPE_BUFFER);
|
||||||
if (gst_value_deserialize (&v, str)) {
|
if (gst_value_deserialize (&v, str)) {
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
gint i;
|
gint i;
|
||||||
|
@ -172,7 +173,9 @@ gst_rtp_mp4a_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
gst_buffer_ref (buffer);
|
gst_buffer_ref (buffer);
|
||||||
g_value_unset (&v);
|
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) {
|
if (size < 2) {
|
||||||
GST_WARNING_OBJECT (depayload, "config too short (%d < 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 */
|
/* 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;
|
data = NULL;
|
||||||
|
|
||||||
gst_caps_set_simple (srccaps,
|
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);
|
"codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
||||||
bad_config:
|
bad_config:
|
||||||
if (data)
|
if (data)
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
} else {
|
} else {
|
||||||
g_warning ("cannot convert config to buffer");
|
g_warning ("cannot convert config to buffer");
|
||||||
|
@ -295,7 +299,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
GstRtpMP4ADepay *rtpmp4adepay;
|
GstRtpMP4ADepay *rtpmp4adepay;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
|
|
||||||
rtpmp4adepay = GST_RTP_MP4A_DEPAY (depayload);
|
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);
|
GST_LOG_OBJECT (rtpmp4adepay, "have marker and %u available", avail);
|
||||||
|
|
||||||
outbuf = gst_adapter_take_buffer (rtpmp4adepay->adapter, 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 */
|
/* position in data we are at */
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
|
@ -387,7 +392,7 @@ gst_rtp_mp4a_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
"possible wrongly encoded packet."));
|
"possible wrongly encoded packet."));
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (outbuf, bdata, -1);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
gst_buffer_unref (outbuf);
|
gst_buffer_unref (outbuf);
|
||||||
}
|
}
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
@ -398,7 +403,7 @@ wrong_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtpmp4adepay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtpmp4adepay, STREAM, DECODE,
|
||||||
("Packet did not validate"), ("wrong packet size"));
|
("Packet did not validate"), ("wrong packet size"));
|
||||||
gst_buffer_unmap (outbuf, bdata, -1);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
gst_buffer_unref (outbuf);
|
gst_buffer_unref (outbuf);
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -132,13 +132,16 @@ static gboolean
|
||||||
gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
|
gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint8 objectType;
|
guint8 objectType;
|
||||||
guint8 samplingIdx;
|
guint8 samplingIdx;
|
||||||
guint8 channelCfg;
|
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)
|
if (size < 2)
|
||||||
goto too_short;
|
goto too_short;
|
||||||
|
@ -182,7 +185,7 @@ gst_rtp_mp4a_pay_parse_audio_config (GstRtpMP4APay * rtpmp4apay,
|
||||||
"objectType: %d, samplingIdx: %d (%d), channelCfg: %d", objectType,
|
"objectType: %d, samplingIdx: %d (%d), channelCfg: %d", objectType,
|
||||||
samplingIdx, rtpmp4apay->rate, channelCfg);
|
samplingIdx, rtpmp4apay->rate, channelCfg);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -193,28 +196,28 @@ too_short:
|
||||||
(NULL),
|
(NULL),
|
||||||
("config string too short, expected 2 bytes, got %" G_GSIZE_FORMAT,
|
("config string too short, expected 2 bytes, got %" G_GSIZE_FORMAT,
|
||||||
size));
|
size));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
invalid_object:
|
invalid_object:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, FORMAT,
|
||||||
(NULL), ("invalid object type 0"));
|
(NULL), ("invalid object type 0"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
wrong_freq:
|
wrong_freq:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
||||||
(NULL), ("unsupported frequency index %d", samplingIdx));
|
(NULL), ("unsupported frequency index %d", samplingIdx));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
wrong_channels:
|
wrong_channels:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
GST_ELEMENT_ERROR (rtpmp4apay, STREAM, NOT_IMPLEMENTED,
|
||||||
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,10 +275,9 @@ gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
||||||
GST_LOG_OBJECT (rtpmp4apay, "got codec_data");
|
GST_LOG_OBJECT (rtpmp4apay, "got codec_data");
|
||||||
if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
|
if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
|
||||||
GstBuffer *buffer, *cbuffer;
|
GstBuffer *buffer, *cbuffer;
|
||||||
guint8 *config;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
GstMapInfo cmap;
|
||||||
guint i;
|
guint i;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
buffer = gst_value_get_buffer (codec_data);
|
buffer = gst_value_get_buffer (codec_data);
|
||||||
GST_LOG_OBJECT (rtpmp4apay, "configuring codec_data");
|
GST_LOG_OBJECT (rtpmp4apay, "configuring codec_data");
|
||||||
|
@ -286,11 +288,11 @@ gst_rtp_mp4a_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
|
||||||
if (!res)
|
if (!res)
|
||||||
goto config_failed;
|
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 */
|
/* make the StreamMuxConfig, we need 15 bits for the header */
|
||||||
cbuffer = gst_buffer_new_and_alloc (size + 2);
|
cbuffer = gst_buffer_new_and_alloc (map.size + 2);
|
||||||
config = gst_buffer_map (cbuffer, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (cbuffer, &cmap, GST_MAP_WRITE);
|
||||||
|
|
||||||
/* Create StreamMuxConfig according to ISO/IEC 14496-3:
|
/* 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)
|
* numProgram == 0 (4 bits)
|
||||||
* numLayer == 0 (3 bits)
|
* numLayer == 0 (3 bits)
|
||||||
*/
|
*/
|
||||||
config[0] = 0x40;
|
cmap.data[0] = 0x40;
|
||||||
config[1] = 0x00;
|
cmap.data[1] = 0x00;
|
||||||
|
|
||||||
/* append the config bits, shifting them 1 bit left */
|
/* append the config bits, shifting them 1 bit left */
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < map.size; i++) {
|
||||||
config[i + 1] |= ((data[i] & 0x80) >> 7);
|
cmap.data[i + 1] |= ((map.data[i] & 0x80) >> 7);
|
||||||
config[i + 2] |= ((data[i] & 0x7f) << 1);
|
cmap.data[i + 2] |= ((map.data[i] & 0x7f) << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (cbuffer, config, -1);
|
gst_buffer_unmap (cbuffer, &cmap);
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
/* now we can configure the buffer */
|
/* now we can configure the buffer */
|
||||||
if (rtpmp4apay->config)
|
if (rtpmp4apay->config)
|
||||||
|
@ -348,8 +350,9 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint count, mtu;
|
guint count, mtu;
|
||||||
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint8 *data, *bdata;
|
guint8 *data;
|
||||||
gboolean fragmented;
|
gboolean fragmented;
|
||||||
GstClockTime timestamp;
|
GstClockTime timestamp;
|
||||||
|
|
||||||
|
@ -357,7 +360,10 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
rtpmp4apay = GST_RTP_MP4A_PAY (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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
fragmented = FALSE;
|
fragmented = FALSE;
|
||||||
|
@ -430,7 +436,7 @@ gst_rtp_mp4a_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
fragmented = TRUE;
|
fragmented = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, bdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -181,16 +181,15 @@ static gboolean
|
||||||
gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
|
gst_rtp_mp4g_pay_parse_audio_config (GstRtpMP4GPay * rtpmp4gpay,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint8 objectType = 0;
|
guint8 objectType = 0;
|
||||||
guint8 samplingIdx = 0;
|
guint8 samplingIdx = 0;
|
||||||
guint8 channelCfg = 0;
|
guint8 channelCfg = 0;
|
||||||
GstBitReader br;
|
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. */
|
/* 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))
|
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,
|
objectType, samplingIdx, rtpmp4gpay->rate, channelCfg,
|
||||||
rtpmp4gpay->frame_len);
|
rtpmp4gpay->frame_len);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ERROR */
|
/* ERROR */
|
||||||
|
@ -269,28 +268,28 @@ too_short:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||||
(NULL), ("config string too short"));
|
(NULL), ("config string too short"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
invalid_object:
|
invalid_object:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||||
(NULL), ("invalid object type"));
|
(NULL), ("invalid object type"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
wrong_freq:
|
wrong_freq:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
||||||
(NULL), ("unsupported frequency index %d", samplingIdx));
|
(NULL), ("unsupported frequency index %d", samplingIdx));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
wrong_channels:
|
wrong_channels:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, NOT_IMPLEMENTED,
|
||||||
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
(NULL), ("unsupported number of channels %d, must < 8", channelCfg));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,21 +300,20 @@ static gboolean
|
||||||
gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
|
gst_rtp_mp4g_pay_parse_video_config (GstRtpMP4GPay * rtpmp4gpay,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint32 code;
|
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;
|
goto too_short;
|
||||||
|
|
||||||
code = GST_READ_UINT32_BE (data);
|
code = GST_READ_UINT32_BE (map.data);
|
||||||
|
|
||||||
g_free (rtpmp4gpay->profile);
|
g_free (rtpmp4gpay->profile);
|
||||||
if (code == VOS_STARTCODE) {
|
if (code == VOS_STARTCODE) {
|
||||||
/* get profile */
|
/* get profile */
|
||||||
rtpmp4gpay->profile = g_strdup_printf ("%d", (gint) data[4]);
|
rtpmp4gpay->profile = g_strdup_printf ("%d", (gint) map.data[4]);
|
||||||
} else {
|
} else {
|
||||||
GST_ELEMENT_WARNING (rtpmp4gpay, STREAM, FORMAT,
|
GST_ELEMENT_WARNING (rtpmp4gpay, STREAM, FORMAT,
|
||||||
(NULL), ("profile not found in config string, assuming \'1\'"));
|
(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_LOG_OBJECT (rtpmp4gpay, "profile %s", rtpmp4gpay->profile);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -342,7 +340,7 @@ too_short:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
GST_ELEMENT_ERROR (rtpmp4gpay, STREAM, FORMAT,
|
||||||
(NULL), ("config string too short"));
|
(NULL), ("config string too short"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
return FALSE;
|
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 config string changed or new profile, make new caps */
|
||||||
if (!equal || newprofile) {
|
if (!equal || newprofile) {
|
||||||
guint8 *bdata;
|
|
||||||
|
|
||||||
if (enc->config)
|
if (enc->config)
|
||||||
gst_buffer_unref (enc->config);
|
gst_buffer_unref (enc->config);
|
||||||
enc->config = gst_buffer_new_and_alloc (i);
|
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_fill (enc->config, 0, data, i);
|
||||||
gst_buffer_unmap (enc->config, bdata, -1);
|
|
||||||
gst_rtp_mp4v_pay_new_caps (enc);
|
gst_rtp_mp4v_pay_new_caps (enc);
|
||||||
}
|
}
|
||||||
*strip = i;
|
*strip = i;
|
||||||
|
@ -444,9 +442,9 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstRtpMP4VPay *rtpmp4vpay;
|
GstRtpMP4VPay *rtpmp4vpay;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
guint avail;
|
guint avail;
|
||||||
gsize size;
|
|
||||||
guint packet_len;
|
guint packet_len;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
gsize size;
|
||||||
gboolean flush;
|
gboolean flush;
|
||||||
gint strip;
|
gint strip;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
|
@ -458,7 +456,8 @@ gst_rtp_mp4v_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
rtpmp4vpay = GST_RTP_MP4V_PAY (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);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
avail = gst_adapter_available (rtpmp4vpay->adapter);
|
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
|
/* depay incomming data and see if we need to start a new RTP
|
||||||
* packet */
|
* packet */
|
||||||
flush = gst_rtp_mp4v_pay_depay_data (rtpmp4vpay, data, size, &strip, &vopi);
|
flush =
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_rtp_mp4v_pay_depay_data (rtpmp4vpay, map.data, size, &strip, &vopi);
|
||||||
data = NULL;
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
if (strip) {
|
if (strip) {
|
||||||
/* strip off config if requested */
|
/* strip off config if requested */
|
||||||
|
|
|
@ -273,8 +273,7 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
|
||||||
rtpmpadepay, GstADUFrame * frame)
|
rtpmpadepay, GstADUFrame * frame)
|
||||||
{
|
{
|
||||||
GstADUFrame *dummy;
|
GstADUFrame *dummy;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
dummy = g_slice_dup (GstADUFrame, frame);
|
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);
|
dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4);
|
||||||
|
|
||||||
data = gst_buffer_map (dummy->buffer, &size, NULL, GST_MAP_WRITE);
|
gst_buffer_map (dummy->buffer, &map, GST_MAP_WRITE);
|
||||||
memset (data, 0, size);
|
memset (map.data, 0, map.size);
|
||||||
GST_WRITE_UINT32_BE (data, dummy->header);
|
GST_WRITE_UINT32_BE (map.data, dummy->header);
|
||||||
gst_buffer_unmap (dummy->buffer, data, size);
|
gst_buffer_unmap (dummy->buffer, &map);
|
||||||
|
|
||||||
GST_BUFFER_TIMESTAMP (dummy->buffer) = GST_BUFFER_TIMESTAMP (frame->buffer);
|
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;
|
GstADUFrame *frame = NULL;
|
||||||
guint version, layer, channels, size;
|
guint version, layer, channels, size;
|
||||||
guint crc;
|
guint crc;
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, FALSE);
|
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;
|
goto corrupt_frame;
|
||||||
|
|
||||||
frame = g_slice_new0 (GstADUFrame);
|
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),
|
size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay),
|
||||||
frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
|
frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
|
||||||
|
@ -341,7 +339,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
||||||
|
|
||||||
/* backpointer */
|
/* backpointer */
|
||||||
if (layer == 3) {
|
if (layer == 3) {
|
||||||
frame->backpointer = GST_READ_UINT16_BE (bdata + 4);
|
frame->backpointer = GST_READ_UINT16_BE (map.data + 4);
|
||||||
frame->backpointer >>= 7;
|
frame->backpointer >>= 7;
|
||||||
GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer);
|
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;
|
frame->data_size = frame->size - 4 - frame->side_info;
|
||||||
|
|
||||||
/* some size validation checks */
|
/* some size validation checks */
|
||||||
if (4 + frame->side_info > bsize)
|
if (4 + frame->side_info > map.size)
|
||||||
goto corrupt_frame;
|
goto corrupt_frame;
|
||||||
|
|
||||||
/* ADU data would then extend past MP3 frame,
|
/* ADU data would then extend past MP3 frame,
|
||||||
* even using past byte reservoir */
|
* even using past byte reservoir */
|
||||||
if (-frame->backpointer + (gint) (bsize) > frame->size)
|
if (-frame->backpointer + (gint) (map.size) > frame->size)
|
||||||
goto corrupt_frame;
|
goto corrupt_frame;
|
||||||
|
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
/* ok, take buffer and queue */
|
/* ok, take buffer and queue */
|
||||||
frame->buffer = buf;
|
frame->buffer = buf;
|
||||||
|
@ -373,7 +371,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
||||||
corrupt_frame:
|
corrupt_frame:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
|
GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
|
||||||
gst_buffer_unmap (buf, bdata, bsize);
|
gst_buffer_unmap (buf, &map);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
if (frame)
|
if (frame)
|
||||||
g_slice_free (GstADUFrame, frame);
|
g_slice_free (GstADUFrame, frame);
|
||||||
|
@ -413,13 +411,12 @@ gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay,
|
||||||
GstBuffer * buf)
|
GstBuffer * buf)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
guint val, iindex, icc;
|
guint val, iindex, icc;
|
||||||
|
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
val = GST_READ_UINT16_BE (data) >> 5;
|
val = GST_READ_UINT16_BE (map.data) >> 5;
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
iindex = val >> 3;
|
iindex = val >> 3;
|
||||||
icc = val & 0x7;
|
icc = val & 0x7;
|
||||||
|
@ -476,8 +473,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
|
if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
|
||||||
rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head;
|
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);
|
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0);
|
||||||
/* bytewriter corresponds to head frame,
|
/* bytewriter corresponds to head frame,
|
||||||
* i.e. the header and the side info must match */
|
* 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,
|
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||||
data, 4 + head->side_info);
|
map.data, 4 + head->side_info);
|
||||||
gst_buffer_unmap (head->buffer, data, size);
|
gst_buffer_unmap (head->buffer, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = frame->buffer;
|
buf = frame->buffer;
|
||||||
|
@ -546,17 +542,17 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
||||||
rtpmpadepay->size);
|
rtpmpadepay->size);
|
||||||
|
|
||||||
if (rtpmpadepay->offset) {
|
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 */
|
/* no need to position, simply append */
|
||||||
g_assert (size > rtpmpadepay->offset);
|
g_assert (map.size > rtpmpadepay->offset);
|
||||||
av = MIN (av, size - rtpmpadepay->offset);
|
av = MIN (av, map.size - rtpmpadepay->offset);
|
||||||
GST_LOG_OBJECT (rtpmpadepay,
|
GST_LOG_OBJECT (rtpmpadepay,
|
||||||
"appending %d bytes from ADU frame at offset %d", av,
|
"appending %d bytes from ADU frame at offset %d", av,
|
||||||
rtpmpadepay->offset);
|
rtpmpadepay->offset);
|
||||||
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||||
data + rtpmpadepay->offset, av);
|
map.data + rtpmpadepay->offset, av);
|
||||||
rtpmpadepay->offset += av;
|
rtpmpadepay->offset += av;
|
||||||
gst_buffer_unmap (buf, data, size);
|
gst_buffer_unmap (buf, &map);
|
||||||
} else {
|
} else {
|
||||||
gint pos, tpos;
|
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);
|
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av);
|
||||||
} else {
|
} else {
|
||||||
/* position and append */
|
/* 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_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame");
|
||||||
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos);
|
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,
|
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;
|
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)
|
create_erasure_buffer (GstRtpQCELPDepay * depay)
|
||||||
{
|
{
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint8 *data;
|
GstMapInfo map;
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (1);
|
outbuf = gst_buffer_new_and_alloc (1);
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
|
||||||
data[0] = 14;
|
map.data[0] = 14;
|
||||||
gst_buffer_unmap (outbuf, data, -1);
|
gst_buffer_unmap (outbuf, &map);
|
||||||
|
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
if (G_UNLIKELY (!rtpqdm2depay->configured)) {
|
if (G_UNLIKELY (!rtpqdm2depay->configured)) {
|
||||||
guint8 *ourdata;
|
guint8 *ourdata;
|
||||||
GstBuffer *codecdata;
|
GstBuffer *codecdata;
|
||||||
guint8 *cdata;
|
GstMapInfo cmap;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
/* First bytes are unknown */
|
/* First bytes are unknown */
|
||||||
|
@ -306,10 +306,10 @@ gst_rtp_qdm2_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
|
|
||||||
/* Caps */
|
/* Caps */
|
||||||
codecdata = gst_buffer_new_and_alloc (48);
|
codecdata = gst_buffer_new_and_alloc (48);
|
||||||
cdata = gst_buffer_map (codecdata, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (codecdata, &cmap, GST_MAP_WRITE);
|
||||||
memcpy (cdata, headheader, 20);
|
memcpy (cmap.data, headheader, 20);
|
||||||
memcpy (cdata + 20, ourdata, 28);
|
memcpy (cmap.data + 20, ourdata, 28);
|
||||||
gst_buffer_unmap (codecdata, cdata, -1);
|
gst_buffer_unmap (codecdata, &cmap);
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("audio/x-qdm2",
|
caps = gst_caps_new_simple ("audio/x-qdm2",
|
||||||
"samplesize", G_TYPE_INT, 16,
|
"samplesize", G_TYPE_INT, 16,
|
||||||
|
|
|
@ -118,7 +118,8 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
GstRtpSPEEXDepay *rtpspeexdepay;
|
GstRtpSPEEXDepay *rtpspeexdepay;
|
||||||
gint clock_rate, nb_channels;
|
gint clock_rate, nb_channels;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
const gchar *params;
|
const gchar *params;
|
||||||
GstCaps *srccaps;
|
GstCaps *srccaps;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
@ -139,7 +140,8 @@ gst_rtp_speex_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
|
||||||
|
|
||||||
/* construct minimal header and comment packet for the decoder */
|
/* construct minimal header and comment packet for the decoder */
|
||||||
buf = gst_buffer_new_and_alloc (80);
|
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);
|
memcpy (data, "Speex ", 8);
|
||||||
data += 8;
|
data += 8;
|
||||||
memcpy (data, "1.1.12", 7);
|
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 */
|
GST_WRITE_UINT32_LE (data, 0); /* reserved1 */
|
||||||
data += 4;
|
data += 4;
|
||||||
GST_WRITE_UINT32_LE (data, 0); /* reserved2 */
|
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");
|
srccaps = gst_caps_new_empty_simple ("audio/x-speex");
|
||||||
res = gst_pad_set_caps (depayload->srcpad, srccaps);
|
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);
|
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpspeexdepay), buf);
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_speex_comment));
|
buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_speex_comment));
|
||||||
bdata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (buf, 0, gst_rtp_speex_comment,
|
||||||
memcpy (bdata, gst_rtp_speex_comment, sizeof (gst_rtp_speex_comment));
|
sizeof (gst_rtp_speex_comment));
|
||||||
gst_buffer_unmap (buf, bdata, -1);
|
|
||||||
|
|
||||||
gst_rtp_base_depayload_push (GST_RTP_BASE_DEPAYLOAD (rtpspeexdepay), buf);
|
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;
|
GstRtpSPEEXPay *rtpspeexpay;
|
||||||
guint payload_len;
|
guint payload_len;
|
||||||
gsize size;
|
GstMapInfo map;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
guint8 *payload, *data;
|
guint8 *payload;
|
||||||
GstClockTime timestamp, duration;
|
GstClockTime timestamp, duration;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstRTPBuffer rtp = { NULL };
|
GstRTPBuffer rtp = { NULL };
|
||||||
|
|
||||||
rtpspeexpay = GST_RTP_SPEEX_PAY (basepayload);
|
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) {
|
switch (rtpspeexpay->packet) {
|
||||||
case 0:
|
case 0:
|
||||||
/* ident packet. We need to parse the headers to construct the RTP
|
/* ident packet. We need to parse the headers to construct the RTP
|
||||||
* properties. */
|
* 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;
|
goto parse_error;
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
|
@ -271,7 +271,7 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
|
|
||||||
/* FIXME, only one SPEEX frame per RTP packet for now */
|
/* 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);
|
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
|
||||||
/* FIXME, assert for now */
|
/* FIXME, assert for now */
|
||||||
|
@ -286,14 +286,14 @@ gst_rtp_speex_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||||
|
|
||||||
/* copy data in payload */
|
/* copy data in payload */
|
||||||
memcpy (&payload[0], data, size);
|
memcpy (&payload[0], map.data, map.size);
|
||||||
|
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
ret = gst_rtp_base_payload_push (basepayload, outbuf);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
rtpspeexpay->packet++;
|
rtpspeexpay->packet++;
|
||||||
|
@ -305,7 +305,7 @@ parse_error:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_ERROR (rtpspeexpay, STREAM, DECODE, (NULL),
|
GST_ELEMENT_ERROR (rtpspeexpay, STREAM, DECODE, (NULL),
|
||||||
("Error parsing first identification packet."));
|
("Error parsing first identification packet."));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,8 +200,8 @@ gst_rtp_sv3v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
if (G_UNLIKELY (C)) {
|
if (G_UNLIKELY (C)) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstBuffer *codec_data;
|
GstBuffer *codec_data;
|
||||||
|
GstMapInfo cmap;
|
||||||
guint8 res;
|
guint8 res;
|
||||||
guint8 *cdata;
|
|
||||||
|
|
||||||
GST_DEBUG ("Configuration packet");
|
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
|
/* CodecData needs to be 'SEQH' + len (32bit) + data according to
|
||||||
* ffmpeg's libavcodec/svq3.c:svq3_decode_init */
|
* ffmpeg's libavcodec/svq3.c:svq3_decode_init */
|
||||||
codec_data = gst_buffer_new_and_alloc (payload_len + 6);
|
codec_data = gst_buffer_new_and_alloc (payload_len + 6);
|
||||||
cdata = gst_buffer_map (codec_data, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (codec_data, &cmap, GST_MAP_WRITE);
|
||||||
memcpy (cdata, "SEQH", 4);
|
memcpy (cmap.data, "SEQH", 4);
|
||||||
GST_WRITE_UINT32_LE (cdata + 4, payload_len - 2);
|
GST_WRITE_UINT32_LE (cmap.data + 4, payload_len - 2);
|
||||||
memcpy (cdata + 8, payload + 2, 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_MEMDUMP ("codec_data", cdata, gst_buffer_get_size (codec_data));
|
gst_buffer_unmap (codec_data, &cmap);
|
||||||
|
|
||||||
gst_buffer_unmap (codec_data, cdata, -1);
|
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("video/x-svq",
|
caps = gst_caps_new_simple ("video/x-svq",
|
||||||
"svqversion", G_TYPE_INT, 3,
|
"svqversion", G_TYPE_INT, 3,
|
||||||
|
|
|
@ -126,11 +126,14 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint32 num_headers;
|
guint32 num_headers;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
gint i, j;
|
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);
|
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++) {
|
for (j = 0; j <= n_headers; j++) {
|
||||||
guint h_size;
|
guint h_size;
|
||||||
guint8 *odata;
|
|
||||||
|
|
||||||
h_size = h_sizes[j];
|
h_size = h_sizes[j];
|
||||||
if (size < h_size) {
|
if (size < h_size) {
|
||||||
|
@ -253,9 +255,7 @@ gst_rtp_theora_depay_parse_configuration (GstRtpTheoraDepay * rtptheoradepay,
|
||||||
h_size);
|
h_size);
|
||||||
|
|
||||||
buf = gst_buffer_new_and_alloc (h_size);
|
buf = gst_buffer_new_and_alloc (h_size);
|
||||||
odata = gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (buf, 0, data, h_size);
|
||||||
memcpy (odata, data, h_size);
|
|
||||||
gst_buffer_unmap (buf, odata, -1);
|
|
||||||
conf->headers = g_list_append (conf->headers, buf);
|
conf->headers = g_list_append (conf->headers, buf);
|
||||||
data += h_size;
|
data += h_size;
|
||||||
size -= 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);
|
rtptheoradepay->configs = g_list_append (rtptheoradepay->configs, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (confbuf, bdata, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
too_small:
|
too_small:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (rtptheoradepay, "configuration too small");
|
GST_DEBUG_OBJECT (rtptheoradepay, "configuration too small");
|
||||||
gst_buffer_unmap (confbuf, bdata, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,23 +281,23 @@ gst_rtp_theora_depay_parse_inband_configuration (GstRtpTheoraDepay *
|
||||||
guint length)
|
guint length)
|
||||||
{
|
{
|
||||||
GstBuffer *confbuf;
|
GstBuffer *confbuf;
|
||||||
guint8 *conf;
|
GstMapInfo map;
|
||||||
|
|
||||||
if (G_UNLIKELY (size < 4))
|
if (G_UNLIKELY (size < 4))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* transform inline to out-of-band and parse that one */
|
/* transform inline to out-of-band and parse that one */
|
||||||
confbuf = gst_buffer_new_and_alloc (size + 9);
|
confbuf = gst_buffer_new_and_alloc (size + 9);
|
||||||
conf = gst_buffer_map (confbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_map (confbuf, &map, GST_MAP_WRITE);
|
||||||
/* 1 header */
|
/* 1 header */
|
||||||
GST_WRITE_UINT32_BE (conf, 1);
|
GST_WRITE_UINT32_BE (map.data, 1);
|
||||||
/* write Ident */
|
/* write Ident */
|
||||||
GST_WRITE_UINT24_BE (conf + 4, ident);
|
GST_WRITE_UINT24_BE (map.data + 4, ident);
|
||||||
/* write sort-of-length */
|
/* write sort-of-length */
|
||||||
GST_WRITE_UINT16_BE (conf + 7, length);
|
GST_WRITE_UINT16_BE (map.data + 7, length);
|
||||||
/* copy remainder */
|
/* copy remainder */
|
||||||
memcpy (conf + 9, configuration, size);
|
memcpy (map.data + 9, configuration, size);
|
||||||
gst_buffer_unmap (confbuf, conf, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
|
|
||||||
return gst_rtp_theora_depay_parse_configuration (rtptheoradepay, confbuf);
|
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));
|
(payload - to_free) + length, payload - to_free, length));
|
||||||
to_free = NULL;
|
to_free = NULL;
|
||||||
} else {
|
} else {
|
||||||
guint8 *odata;
|
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (length);
|
outbuf = gst_buffer_new_and_alloc (length);
|
||||||
odata = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (outbuf, 0, payload, length);
|
||||||
memcpy (odata, payload, length);
|
|
||||||
gst_buffer_unmap (outbuf, odata, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload_len > 0 && (payload[0] & 0xC0) == 0x0)
|
if (payload_len > 0 && (payload[0] & 0xC0) == 0x0)
|
||||||
|
|
|
@ -335,9 +335,8 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
||||||
extralen = 1;
|
extralen = 1;
|
||||||
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||||
|
GstMapInfo map;
|
||||||
guint bsize;
|
guint bsize;
|
||||||
guint8 *data;
|
|
||||||
gsize size;
|
|
||||||
|
|
||||||
bsize = gst_buffer_get_size (buf);
|
bsize = gst_buffer_get_size (buf);
|
||||||
length += bsize;
|
length += bsize;
|
||||||
|
@ -353,9 +352,9 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
||||||
} while (bsize);
|
} while (bsize);
|
||||||
}
|
}
|
||||||
/* update hash */
|
/* update hash */
|
||||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
ident = fnv1_hash_32_update (ident, data, size);
|
ident = fnv1_hash_32_update (ident, map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* packet length is header size + packet length */
|
/* packet length is header size + packet length */
|
||||||
|
@ -421,13 +420,12 @@ gst_rtp_theora_pay_finish_headers (GstRTPBasePayload * basepayload)
|
||||||
/* copy header data */
|
/* copy header data */
|
||||||
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
for (walk = rtptheorapay->headers; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||||
guint8 *bdata;
|
GstMapInfo map;
|
||||||
gsize bsize;
|
|
||||||
|
|
||||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
memcpy (data, bdata, bsize);
|
memcpy (data, map.data, map.size);
|
||||||
gst_buffer_unmap (buf, bdata, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
data += bsize;
|
data += map.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* serialize to base64 */
|
/* serialize to base64 */
|
||||||
|
@ -643,6 +641,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
{
|
{
|
||||||
GstRtpTheoraPay *rtptheorapay;
|
GstRtpTheoraPay *rtptheorapay;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
GstClockTime duration, timestamp;
|
GstClockTime duration, timestamp;
|
||||||
|
@ -651,7 +650,9 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
rtptheorapay = GST_RTP_THEORA_PAY (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);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
|
@ -692,7 +693,7 @@ gst_rtp_theora_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
if (TDT != 0) {
|
if (TDT != 0) {
|
||||||
GST_DEBUG_OBJECT (rtptheorapay, "collecting header, buffer %p", buffer);
|
GST_DEBUG_OBJECT (rtptheorapay, "collecting header, buffer %p", buffer);
|
||||||
/* append header to the list of headers */
|
/* append header to the list of headers */
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer);
|
rtptheorapay->headers = g_list_append (rtptheorapay->headers, buffer);
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
goto done;
|
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,
|
ret = gst_rtp_theora_pay_payload_buffer (rtptheorapay, TDT, data, size,
|
||||||
timestamp, duration, 0);
|
timestamp, duration, 0);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -764,13 +765,13 @@ wrong_size:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||||
("Invalid packet size (%" G_GSIZE_FORMAT " <= 0xffff)", size), (NULL));
|
("Invalid packet size (%" G_GSIZE_FORMAT " <= 0xffff)", size), (NULL));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
parse_id_failed:
|
parse_id_failed:
|
||||||
{
|
{
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -778,7 +779,7 @@ unknown_header:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||||
(NULL), ("Ignoring unknown header received"));
|
(NULL), ("Ignoring unknown header received"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +787,7 @@ header_error:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtptheorapay, STREAM, DECODE,
|
||||||
(NULL), ("Error initializing header config"));
|
(NULL), ("Error initializing header config"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,12 +152,15 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
guint32 num_headers;
|
guint32 num_headers;
|
||||||
guint8 *data, *bdata;
|
GstMapInfo map;
|
||||||
|
guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint offset;
|
guint offset;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
bdata = data = gst_buffer_map (confbuf, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (confbuf, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size);
|
GST_DEBUG_OBJECT (rtpvorbisdepay, "config size %" G_GSIZE_FORMAT, size);
|
||||||
|
|
||||||
|
@ -295,7 +298,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
||||||
rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
|
rtpvorbisdepay->configs = g_list_append (rtpvorbisdepay->configs, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (confbuf, bdata, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
gst_buffer_unref (confbuf);
|
gst_buffer_unref (confbuf);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -304,7 +307,7 @@ gst_rtp_vorbis_depay_parse_configuration (GstRtpVorbisDepay * rtpvorbisdepay,
|
||||||
too_small:
|
too_small:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
|
GST_DEBUG_OBJECT (rtpvorbisdepay, "configuration too small");
|
||||||
gst_buffer_unmap (confbuf, bdata, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
gst_buffer_unref (confbuf);
|
gst_buffer_unref (confbuf);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -316,23 +319,23 @@ gst_rtp_vorbis_depay_parse_inband_configuration (GstRtpVorbisDepay *
|
||||||
guint length)
|
guint length)
|
||||||
{
|
{
|
||||||
GstBuffer *confbuf;
|
GstBuffer *confbuf;
|
||||||
guint8 *conf;
|
GstMapInfo map;
|
||||||
|
|
||||||
if (G_UNLIKELY (size < 4))
|
if (G_UNLIKELY (size < 4))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* transform inline to out-of-band and parse that one */
|
/* transform inline to out-of-band and parse that one */
|
||||||
confbuf = gst_buffer_new_and_alloc (size + 9);
|
confbuf = gst_buffer_new_and_alloc (size + 9);
|
||||||
conf = gst_buffer_map (confbuf, NULL, NULL, -1);
|
gst_buffer_map (confbuf, &map, GST_MAP_WRITE);
|
||||||
/* 1 header */
|
/* 1 header */
|
||||||
GST_WRITE_UINT32_BE (conf, 1);
|
GST_WRITE_UINT32_BE (map.data, 1);
|
||||||
/* write Ident */
|
/* write Ident */
|
||||||
GST_WRITE_UINT24_BE (conf + 4, ident);
|
GST_WRITE_UINT24_BE (map.data + 4, ident);
|
||||||
/* write sort-of-length */
|
/* write sort-of-length */
|
||||||
GST_WRITE_UINT16_BE (conf + 7, length);
|
GST_WRITE_UINT16_BE (map.data + 7, length);
|
||||||
/* copy remainder */
|
/* copy remainder */
|
||||||
memcpy (conf + 9, configuration, size);
|
memcpy (map.data + 9, configuration, size);
|
||||||
gst_buffer_unmap (confbuf, conf, -1);
|
gst_buffer_unmap (confbuf, &map);
|
||||||
|
|
||||||
return gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf);
|
return gst_rtp_vorbis_depay_parse_configuration (rtpvorbisdepay, confbuf);
|
||||||
}
|
}
|
||||||
|
@ -595,12 +598,8 @@ gst_rtp_vorbis_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
|
||||||
(payload - to_free) + length, payload - to_free, length));
|
(payload - to_free) + length, payload - to_free, length));
|
||||||
to_free = NULL;
|
to_free = NULL;
|
||||||
} else {
|
} else {
|
||||||
guint8 *data;
|
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (length);
|
outbuf = gst_buffer_new_and_alloc (length);
|
||||||
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
|
gst_buffer_fill (outbuf, 0, payload, length);
|
||||||
memcpy (data, payload, length);
|
|
||||||
gst_buffer_unmap (outbuf, data, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
payload += length;
|
payload += length;
|
||||||
|
|
|
@ -291,10 +291,10 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
|
||||||
ident = fnv1_hash_32_new ();
|
ident = fnv1_hash_32_new ();
|
||||||
for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
|
for (walk = rtpvorbispay->headers; walk; walk = g_list_next (walk)) {
|
||||||
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
|
||||||
guint bsize, osize;
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint bsize;
|
||||||
|
|
||||||
bsize = osize = gst_buffer_get_size (buf);
|
bsize = gst_buffer_get_size (buf);
|
||||||
length += bsize;
|
length += bsize;
|
||||||
n_headers++;
|
n_headers++;
|
||||||
|
|
||||||
|
@ -307,9 +307,9 @@ gst_rtp_vorbis_pay_finish_headers (GstRTPBasePayload * basepayload)
|
||||||
} while (bsize);
|
} while (bsize);
|
||||||
}
|
}
|
||||||
/* update hash */
|
/* update hash */
|
||||||
data = gst_buffer_map (buf, NULL, NULL, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
ident = fnv1_hash_32_update (ident, data, osize);
|
ident = fnv1_hash_32_update (ident, map.data, map.size);
|
||||||
gst_buffer_unmap (buf, data, -1);
|
gst_buffer_unmap (buf, &map);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* packet length is header size + packet length */
|
/* packet length is header size + packet length */
|
||||||
|
@ -475,6 +475,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
GstRtpVorbisPay *rtpvorbispay;
|
GstRtpVorbisPay *rtpvorbispay;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
guint newsize;
|
guint newsize;
|
||||||
|
GstMapInfo map;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint packet_len;
|
guint packet_len;
|
||||||
|
@ -488,7 +489,9 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
|
|
||||||
rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
|
rtpvorbispay = GST_RTP_VORBIS_PAY (basepayload);
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
duration = GST_BUFFER_DURATION (buffer);
|
duration = GST_BUFFER_DURATION (buffer);
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
timestamp = GST_BUFFER_TIMESTAMP (buffer);
|
||||||
|
|
||||||
|
@ -523,7 +526,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
if (VDT != 0) {
|
if (VDT != 0) {
|
||||||
GST_DEBUG_OBJECT (rtpvorbispay, "collecting header");
|
GST_DEBUG_OBJECT (rtpvorbispay, "collecting header");
|
||||||
/* append header to the list of headers */
|
/* append header to the list of headers */
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer);
|
rtpvorbispay->headers = g_list_append (rtpvorbispay->headers, buffer);
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -623,7 +626,7 @@ gst_rtp_vorbis_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
||||||
if (rtp.buffer)
|
if (rtp.buffer)
|
||||||
gst_rtp_buffer_unmap (&rtp);
|
gst_rtp_buffer_unmap (&rtp);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -635,13 +638,13 @@ wrong_size:
|
||||||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||||
("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 0xffff)", size),
|
("Invalid packet size (1 < %" G_GSIZE_FORMAT " <= 0xffff)", size),
|
||||||
(NULL));
|
(NULL));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
parse_id_failed:
|
parse_id_failed:
|
||||||
{
|
{
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -649,7 +652,7 @@ unknown_header:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||||
(NULL), ("Ignoring unknown header received"));
|
(NULL), ("Ignoring unknown header received"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
@ -657,7 +660,7 @@ header_error:
|
||||||
{
|
{
|
||||||
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
GST_ELEMENT_WARNING (rtpvorbispay, STREAM, DECODE,
|
||||||
(NULL), ("Error initializing header config"));
|
(NULL), ("Error initializing header config"));
|
||||||
gst_buffer_unmap (buffer, data, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2240,7 +2240,8 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
|
||||||
|
|
||||||
if (fci_length > 0) {
|
if (fci_length > 0) {
|
||||||
fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer,
|
fci_buffer = gst_buffer_copy_region (packet->rtcp->buffer,
|
||||||
GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->data, fci_length);
|
GST_BUFFER_COPY_MEMORY, fci_data - packet->rtcp->map.data,
|
||||||
|
fci_length);
|
||||||
GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time;
|
GST_BUFFER_TIMESTAMP (fci_buffer) = arrival->running_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2091,9 +2091,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
GstRTSPSrc *src;
|
GstRTSPSrc *src;
|
||||||
GstRTSPStream *stream;
|
GstRTSPStream *stream;
|
||||||
GstFlowReturn res = GST_FLOW_OK;
|
GstFlowReturn res = GST_FLOW_OK;
|
||||||
|
GstMapInfo map;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint size;
|
guint size;
|
||||||
gsize bsize;
|
|
||||||
GstRTSPResult ret;
|
GstRTSPResult ret;
|
||||||
GstRTSPMessage message = { 0 };
|
GstRTSPMessage message = { 0 };
|
||||||
GstRTSPConnection *conn;
|
GstRTSPConnection *conn;
|
||||||
|
@ -2101,8 +2101,9 @@ gst_rtspsrc_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||||
stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
|
stream = (GstRTSPStream *) gst_pad_get_element_private (pad);
|
||||||
src = stream->parent;
|
src = stream->parent;
|
||||||
|
|
||||||
data = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
size = bsize;
|
size = map.size;
|
||||||
|
data = map.data;
|
||||||
|
|
||||||
gst_rtsp_message_init_data (&message, stream->channel[1]);
|
gst_rtsp_message_init_data (&message, stream->channel[1]);
|
||||||
|
|
||||||
|
@ -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_steal_body (&message, &data, &size);
|
||||||
gst_rtsp_message_unset (&message);
|
gst_rtsp_message_unset (&message);
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, data, size);
|
gst_buffer_unmap (buffer, &map);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -857,14 +857,17 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||||
guint nfft = 2 * bands - 2;
|
guint nfft = 2 * bands - 2;
|
||||||
guint input_pos;
|
guint input_pos;
|
||||||
gfloat *input;
|
gfloat *input;
|
||||||
const guint8 *data, *mdata;
|
GstMapInfo map;
|
||||||
|
const guint8 *data;
|
||||||
gsize size;
|
gsize size;
|
||||||
guint fft_todo, msg_todo, block_size;
|
guint fft_todo, msg_todo, block_size;
|
||||||
gboolean have_full_interval;
|
gboolean have_full_interval;
|
||||||
GstSpectrumChannel *cd;
|
GstSpectrumChannel *cd;
|
||||||
GstSpectrumInputData input_data;
|
GstSpectrumInputData input_data;
|
||||||
|
|
||||||
data = mdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||||
|
data = map.data;
|
||||||
|
size = map.size;
|
||||||
|
|
||||||
GST_LOG_OBJECT (spectrum, "input size: %" G_GSIZE_FORMAT " bytes", size);
|
GST_LOG_OBJECT (spectrum, "input size: %" G_GSIZE_FORMAT " bytes", size);
|
||||||
|
|
||||||
|
@ -993,7 +996,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
||||||
|
|
||||||
spectrum->input_pos = input_pos;
|
spectrum->input_pos = input_pos;
|
||||||
|
|
||||||
gst_buffer_unmap (buffer, (guint8 *) mdata, -1);
|
gst_buffer_unmap (buffer, &map);
|
||||||
|
|
||||||
g_assert (size == 0);
|
g_assert (size == 0);
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue