2003-12-07 22:49:04 +00:00
|
|
|
/* GStreamer RIFF I/O
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
*
|
|
|
|
* riff-read.c: RIFF input file parsing
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
#include <gst/gstutils.h>
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
#include "riff-ids.h"
|
|
|
|
#include "riff-read.h"
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-12-07 22:49:04 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_METADATA
|
2004-03-14 22:34:33 +00:00
|
|
|
/* FILL ME */
|
2003-12-07 22:49:04 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_riff_read_class_init (GstRiffReadClass * klass);
|
|
|
|
static void gst_riff_read_init (GstRiffRead * riff);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstElementStateReturn gst_riff_read_change_state (GstElement * element);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_get_type (void)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
static GType gst_riff_read_type = 0;
|
|
|
|
|
|
|
|
if (!gst_riff_read_type) {
|
|
|
|
static const GTypeInfo gst_riff_read_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstRiffReadClass),
|
2003-12-07 22:49:04 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_riff_read_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstRiffRead),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_riff_read_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_riff_read_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstRiffRead",
|
|
|
|
&gst_riff_read_info, 0);
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_riff_read_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_class_init (GstRiffReadClass * klass)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
gstelement_class->change_state = gst_riff_read_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_init (GstRiffRead * riff)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
riff->sinkpad = NULL;
|
|
|
|
riff->bs = NULL;
|
|
|
|
riff->level = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_change_state (GstElement * element)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
GstRiffRead *riff = GST_RIFF_READ (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
if (!riff->sinkpad)
|
2004-03-15 19:32:27 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2003-12-07 22:49:04 +00:00
|
|
|
riff->bs = gst_bytestream_new (riff->sinkpad);
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
gst_bytestream_destroy (riff->bs);
|
|
|
|
while (riff->level) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GstRiffLevel *level = riff->level->data;
|
2003-12-07 22:49:04 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
riff->level = g_list_remove (riff->level, level);
|
|
|
|
g_free (level);
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return: the amount of levels in the hierarchy that the
|
|
|
|
* current element lies higher than the previous one.
|
|
|
|
* The opposite isn't done - that's auto-done using list
|
|
|
|
* element reading.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static guint
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_element_level_up (GstRiffRead * riff)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint num = 0;
|
|
|
|
guint64 pos = gst_bytestream_tell (riff->bs);
|
|
|
|
|
|
|
|
while (riff->level != NULL) {
|
|
|
|
GList *last = g_list_last (riff->level);
|
|
|
|
GstRiffLevel *level = last->data;
|
|
|
|
|
|
|
|
if (pos >= level->start + level->length) {
|
|
|
|
riff->level = g_list_remove (riff->level, level);
|
|
|
|
g_free (level);
|
|
|
|
num++;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next tag plus length (may be NULL). Return
|
|
|
|
* TRUE on success or FALSE on failure.
|
|
|
|
*/
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_peek_head (GstRiffRead * riff,
|
|
|
|
guint32 * tag, guint32 * length, guint * level_up)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
2004-05-09 15:49:25 +00:00
|
|
|
GList *last;
|
2003-12-07 22:49:04 +00:00
|
|
|
guint8 *data;
|
|
|
|
|
2004-05-09 15:49:25 +00:00
|
|
|
/* if we're at the end of a chunk, but unaligned, then re-align.
|
|
|
|
* Those are essentially broken files, but unfortunately they
|
|
|
|
* exist. */
|
|
|
|
if ((last = g_list_last (riff->level)) != NULL) {
|
|
|
|
GstRiffLevel *level = last->data;
|
|
|
|
guint64 pos = gst_bytestream_tell (riff->bs);
|
|
|
|
|
|
|
|
if (level->start + level->length - pos < 8) {
|
|
|
|
if (!gst_bytestream_flush (riff->bs, level->start + level->length - pos)) {
|
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
/* read */
|
2004-01-30 12:37:58 +00:00
|
|
|
while (gst_bytestream_peek_bytes (riff->bs, &data, 8) != 8) {
|
2003-12-07 22:49:04 +00:00
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 remaining;
|
|
|
|
|
|
|
|
/* Here, we might encounter EOS */
|
|
|
|
gst_bytestream_get_status (riff->bs, &remaining, &event);
|
2004-02-14 18:37:48 +00:00
|
|
|
if (GST_IS_EVENT (event)) {
|
2004-06-15 21:58:18 +00:00
|
|
|
gboolean eos = (GST_EVENT_TYPE (event) == GST_EVENT_EOS);
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_pad_event_default (riff->sinkpad, event);
|
2004-06-15 21:58:18 +00:00
|
|
|
if (eos)
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2003-12-07 22:49:04 +00:00
|
|
|
} else {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
2004-01-30 12:37:58 +00:00
|
|
|
return FALSE;
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parse tag + length (if wanted) */
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
*tag = GST_READ_UINT32_LE (data);
|
2003-12-07 22:49:04 +00:00
|
|
|
if (length)
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
*length = GST_READ_UINT32_LE (((guint32 *) data) + 1);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
/* level */
|
|
|
|
if (level_up)
|
|
|
|
*level_up = gst_riff_read_element_level_up (riff);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read: the actual data (plus alignment and flush).
|
|
|
|
* Return: the data, as a GstBuffer.
|
|
|
|
*/
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
GstBuffer *
|
|
|
|
gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf = NULL;
|
2004-05-08 00:33:39 +00:00
|
|
|
guint32 got;
|
2003-12-07 22:49:04 +00:00
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
while ((got = gst_bytestream_peek (riff->bs, &buf, length)) != length) {
|
|
|
|
/*GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL)); */
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 remaining;
|
|
|
|
|
|
|
|
gst_bytestream_get_status (riff->bs, &remaining, &event);
|
|
|
|
if (GST_IS_EVENT (event)) {
|
|
|
|
gst_pad_event_default (riff->sinkpad, event);
|
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
|
|
|
|
|
|
|
if (buf)
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
if (got_bytes)
|
|
|
|
*got_bytes = got;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
|
|
|
if (buf)
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
if (got_bytes)
|
|
|
|
*got_bytes = got;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we need 16-bit alignment */
|
|
|
|
if (length & 1)
|
|
|
|
length++;
|
|
|
|
|
|
|
|
gst_bytestream_flush (riff->bs, length);
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
if (got_bytes)
|
|
|
|
*got_bytes = got;
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Seek.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GstEvent *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_seek (GstRiffRead * riff, guint64 offset)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint64 length = gst_bytestream_length (riff->bs);
|
|
|
|
guint32 remaining;
|
2004-01-30 12:37:58 +00:00
|
|
|
GstEvent *event = NULL;
|
2003-12-07 22:49:04 +00:00
|
|
|
guchar *data;
|
|
|
|
|
|
|
|
/* hack for AVI files with broken idx1 size chunk markers */
|
|
|
|
if (offset > length)
|
|
|
|
offset = length;
|
|
|
|
|
|
|
|
/* first, flush remaining buffers */
|
|
|
|
gst_bytestream_get_status (riff->bs, &remaining, &event);
|
|
|
|
if (event) {
|
|
|
|
g_warning ("Unexpected event before seek");
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
if (remaining)
|
|
|
|
gst_bytestream_flush_fast (riff->bs, remaining);
|
|
|
|
|
|
|
|
/* now seek */
|
|
|
|
if (!gst_bytestream_seek (riff->bs, offset, GST_SEEK_METHOD_SET)) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, SEEK, (NULL), (NULL));
|
2003-12-07 22:49:04 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* and now, peek a new byte. This will fail because there's a
|
|
|
|
* pending event. Then, take the event and return it. */
|
2004-01-30 12:37:58 +00:00
|
|
|
while (!event) {
|
|
|
|
if (gst_bytestream_peek_bytes (riff->bs, &data, 1)) {
|
|
|
|
GST_WARNING ("Unexpected data after seek - this means seek failed");
|
|
|
|
break;
|
|
|
|
}
|
2003-12-07 22:49:04 +00:00
|
|
|
|
2004-01-30 12:37:58 +00:00
|
|
|
/* get the discont event and return */
|
|
|
|
gst_bytestream_get_status (riff->bs, &remaining, &event);
|
|
|
|
if (!event) {
|
|
|
|
GST_WARNING ("No discontinuity event after seek - seek failed");
|
|
|
|
break;
|
|
|
|
} else if (GST_EVENT_TYPE (event) != GST_EVENT_DISCONTINUOUS) {
|
2004-05-16 20:06:35 +00:00
|
|
|
GstEventType type = GST_EVENT_TYPE (event);
|
|
|
|
|
2004-01-30 12:37:58 +00:00
|
|
|
gst_pad_event_default (riff->sinkpad, event);
|
2004-05-16 20:06:35 +00:00
|
|
|
if (type == GST_EVENT_EOS)
|
2004-03-15 19:32:27 +00:00
|
|
|
return NULL;
|
2004-01-30 12:37:58 +00:00
|
|
|
event = NULL;
|
|
|
|
}
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gives the tag of the next RIFF element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint32
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_peek_tag (GstRiffRead * riff, guint * level_up)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
|
|
|
|
if (!gst_riff_peek_head (riff, &tag, NULL, level_up))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gives the tag of the next LIST/RIFF element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint32
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_peek_list (GstRiffRead * riff)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 lst;
|
|
|
|
guint8 *data;
|
|
|
|
|
|
|
|
if (!gst_riff_peek_head (riff, &lst, NULL, NULL))
|
|
|
|
return FALSE;
|
|
|
|
if (lst != GST_RIFF_TAG_LIST) {
|
|
|
|
g_warning ("Not a LIST object");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gst_bytestream_peek_bytes (riff->bs, &data, 12) != 12) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
2003-12-07 22:49:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
return GST_READ_UINT32_LE (((guint32 *) data) + 2);
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't read data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_skip (GstRiffRead * riff)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag, length;
|
|
|
|
GstEvent *event;
|
|
|
|
guint32 remaining;
|
|
|
|
|
|
|
|
if (!gst_riff_peek_head (riff, &tag, &length, NULL))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* 16-bit alignment */
|
|
|
|
if (length & 1)
|
|
|
|
length++;
|
|
|
|
|
|
|
|
/* header itself */
|
|
|
|
length += 8;
|
|
|
|
|
|
|
|
/* see if we have that much data available */
|
|
|
|
gst_bytestream_get_status (riff->bs, &remaining, &event);
|
|
|
|
if (event) {
|
|
|
|
g_warning ("Unexpected event in skip");
|
|
|
|
gst_event_unref (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* yes */
|
|
|
|
if (remaining >= length) {
|
|
|
|
gst_bytestream_flush_fast (riff->bs, length);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no */
|
|
|
|
if (!(event = gst_riff_read_seek (riff,
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_bytestream_tell (riff->bs) + length)))
|
2003-12-07 22:49:04 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read any type of data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 length;
|
|
|
|
|
|
|
|
if (!gst_riff_peek_head (riff, tag, &length, NULL))
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (riff->bs, 8);
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
return ((*buf = gst_riff_read_element_data (riff, length, NULL)) != NULL);
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_ascii (GstRiffRead * riff, guint32 * tag, gchar ** str)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
if (!gst_riff_read_data (riff, tag, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*str = g_malloc (GST_BUFFER_SIZE (buf) + 1);
|
|
|
|
memcpy (*str, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
|
|
|
(*str)[GST_BUFFER_SIZE (buf)] = '\0';
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read media structs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_strh (GstRiffRead * riff, gst_riff_strh ** header)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gst_riff_strh *strh;
|
|
|
|
|
|
|
|
if (!gst_riff_read_data (riff, &tag, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (tag != GST_RIFF_TAG_strh) {
|
|
|
|
g_warning ("Not a strh chunk");
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strh)) {
|
|
|
|
g_warning ("Too small strh (%d available, %d needed)",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strh));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
strh = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
strh->type = GUINT32_FROM_LE (strh->type);
|
2003-12-07 22:49:04 +00:00
|
|
|
strh->fcc_handler = GUINT32_FROM_LE (strh->fcc_handler);
|
2004-03-14 22:34:33 +00:00
|
|
|
strh->flags = GUINT32_FROM_LE (strh->flags);
|
|
|
|
strh->priority = GUINT32_FROM_LE (strh->priority);
|
2003-12-07 22:49:04 +00:00
|
|
|
strh->init_frames = GUINT32_FROM_LE (strh->init_frames);
|
2004-03-14 22:34:33 +00:00
|
|
|
strh->scale = GUINT32_FROM_LE (strh->scale);
|
|
|
|
strh->rate = GUINT32_FROM_LE (strh->rate);
|
|
|
|
strh->start = GUINT32_FROM_LE (strh->start);
|
|
|
|
strh->length = GUINT32_FROM_LE (strh->length);
|
|
|
|
strh->bufsize = GUINT32_FROM_LE (strh->bufsize);
|
|
|
|
strh->quality = GUINT32_FROM_LE (strh->quality);
|
|
|
|
strh->samplesize = GUINT32_FROM_LE (strh->samplesize);
|
2003-12-07 22:49:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* avoid divisions by zero */
|
|
|
|
if (!strh->scale)
|
|
|
|
strh->scale = 1;
|
|
|
|
if (!strh->rate)
|
|
|
|
strh->rate = 1;
|
|
|
|
|
|
|
|
/* debug */
|
|
|
|
GST_INFO ("strh tag found");
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_INFO (" type " GST_FOURCC_FORMAT, GST_FOURCC_ARGS (strh->type));
|
2003-12-07 22:49:04 +00:00
|
|
|
GST_INFO (" fcc_handler " GST_FOURCC_FORMAT,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_FOURCC_ARGS (strh->fcc_handler));
|
2003-12-07 22:49:04 +00:00
|
|
|
GST_INFO (" flags 0x%08x", strh->flags);
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_INFO (" priority %d", strh->priority);
|
|
|
|
GST_INFO (" init_frames %d", strh->init_frames);
|
|
|
|
GST_INFO (" scale %d", strh->scale);
|
|
|
|
GST_INFO (" rate %d", strh->rate);
|
|
|
|
GST_INFO (" start %d", strh->start);
|
|
|
|
GST_INFO (" length %d", strh->length);
|
|
|
|
GST_INFO (" bufsize %d", strh->bufsize);
|
|
|
|
GST_INFO (" quality %d", strh->quality);
|
|
|
|
GST_INFO (" samplesize %d", strh->samplesize);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
*header = strh;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
gst_riff_read_strf_vids_with_data (GstRiffRead * riff,
|
|
|
|
gst_riff_strf_vids ** header, GstBuffer ** extradata)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gst_riff_strf_vids *strf;
|
|
|
|
|
|
|
|
if (!gst_riff_read_data (riff, &tag, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (tag != GST_RIFF_TAG_strf) {
|
|
|
|
g_warning ("Not a strf chunk");
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_vids)) {
|
|
|
|
g_warning ("Too small strf_vids (%d available, %d needed)",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_vids));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->size = GUINT32_FROM_LE (strf->size);
|
|
|
|
strf->width = GUINT32_FROM_LE (strf->width);
|
|
|
|
strf->height = GUINT32_FROM_LE (strf->height);
|
|
|
|
strf->planes = GUINT16_FROM_LE (strf->planes);
|
|
|
|
strf->bit_cnt = GUINT16_FROM_LE (strf->bit_cnt);
|
2003-12-07 22:49:04 +00:00
|
|
|
strf->compression = GUINT32_FROM_LE (strf->compression);
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->image_size = GUINT32_FROM_LE (strf->image_size);
|
2003-12-07 22:49:04 +00:00
|
|
|
strf->xpels_meter = GUINT32_FROM_LE (strf->xpels_meter);
|
|
|
|
strf->ypels_meter = GUINT32_FROM_LE (strf->ypels_meter);
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->num_colors = GUINT32_FROM_LE (strf->num_colors);
|
|
|
|
strf->imp_colors = GUINT32_FROM_LE (strf->imp_colors);
|
2003-12-07 22:49:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* size checking */
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
*extradata = NULL;
|
2003-12-07 22:49:04 +00:00
|
|
|
if (strf->size > GST_BUFFER_SIZE (buf)) {
|
|
|
|
g_warning ("strf_vids header gave %d bytes data, only %d available",
|
2004-03-15 19:32:27 +00:00
|
|
|
strf->size, GST_BUFFER_SIZE (buf));
|
2003-12-07 22:49:04 +00:00
|
|
|
strf->size = GST_BUFFER_SIZE (buf);
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
} else if (strf->size < GST_BUFFER_SIZE (buf)) {
|
2004-07-16 10:50:49 +00:00
|
|
|
gint len;
|
|
|
|
|
|
|
|
len = GST_BUFFER_SIZE (buf) - strf->size - 2;
|
|
|
|
if (len > 0) {
|
|
|
|
*extradata = gst_buffer_create_sub (buf, strf->size + 2, len);
|
|
|
|
}
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* debug */
|
|
|
|
GST_INFO ("strf tag found in context vids:");
|
|
|
|
GST_INFO (" size %d", strf->size);
|
|
|
|
GST_INFO (" width %d", strf->width);
|
|
|
|
GST_INFO (" height %d", strf->height);
|
|
|
|
GST_INFO (" planes %d", strf->planes);
|
|
|
|
GST_INFO (" bit_cnt %d", strf->bit_cnt);
|
|
|
|
GST_INFO (" compression " GST_FOURCC_FORMAT,
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_FOURCC_ARGS (strf->compression));
|
2003-12-07 22:49:04 +00:00
|
|
|
GST_INFO (" image_size %d", strf->image_size);
|
|
|
|
GST_INFO (" xpels_meter %d", strf->xpels_meter);
|
|
|
|
GST_INFO (" ypels_meter %d", strf->ypels_meter);
|
|
|
|
GST_INFO (" num_colors %d", strf->num_colors);
|
|
|
|
GST_INFO (" imp_colors %d", strf->imp_colors);
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
if (*extradata)
|
|
|
|
GST_INFO (" %d bytes extra_data", GST_BUFFER_SIZE (*extradata));
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
*header = strf;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
gst/: Add MS RLE support. I added some functions to read out strf chunks into strf chunks and the data behind it. Thi...
Original commit message from CVS:
reviewed by: <delete if not using a buddy>
* gst-libs/gst/riff/riff-media.c:
(gst_riff_create_video_caps_with_data),
(gst_riff_create_video_caps), (gst_riff_create_audio_caps),
(gst_riff_create_video_template_caps),
(gst_riff_create_audio_template_caps):
* gst-libs/gst/riff/riff-media.h:
* gst-libs/gst/riff/riff-read.c:
(gst_riff_read_strf_vids_with_data), (gst_riff_read_strf_vids):
* gst-libs/gst/riff/riff-read.h:
* gst/avi/gstavidemux.c: (gst_avi_demux_add_stream):
Add MS RLE support. I added some functions to read out strf chunks
into strf chunks and the data behind it. This is usually color
palettes (as in RLE, but also in 8-bit RGB). Also use those during
caps creation. Lastly, add ADPCM (similar to wavparse - which
should eventually be rifflib based).
* gst/matroska/matroska-demux.c: (gst_matroska_demux_class_init),
(gst_matroska_demux_init), (gst_matroska_demux_reset):
* gst/matroska/matroska-demux.h:
Remove placeholders for some prehistoric tagging system. Didn't add
support for any tag system really anyway.
* gst/qtdemux/qtdemux.c:
Add support for audio/x-m4a (MPEG-4) through spider.
* gst/wavparse/gstwavparse.c: (gst_wavparse_parse_fmt),
(gst_wavparse_loop):
ADPCM support (#135862). Increase max. buffer size because we
cannot split buffers for ADPCM (screws references) and I've seen
files with 2048 byte chunks. 4096 seems safe for now.
2004-04-16 01:20:44 +00:00
|
|
|
/*
|
|
|
|
* Obsolete, use gst_riff_read_strf_vids_with_data ().
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_riff_read_strf_vids (GstRiffRead * riff, gst_riff_strf_vids ** header)
|
|
|
|
{
|
|
|
|
GstBuffer *data = NULL;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
ret = gst_riff_read_strf_vids_with_data (riff, header, &data);
|
|
|
|
if (data)
|
|
|
|
gst_buffer_unref (data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
gboolean
|
2004-07-13 10:24:29 +00:00
|
|
|
gst_riff_read_strf_auds_with_data (GstRiffRead * riff,
|
|
|
|
gst_riff_strf_auds ** header, GstBuffer ** extradata)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gst_riff_strf_auds *strf;
|
|
|
|
|
|
|
|
if (!gst_riff_read_data (riff, &tag, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
2004-05-08 00:33:39 +00:00
|
|
|
if (tag != GST_RIFF_TAG_strf && tag != GST_RIFF_TAG_fmt) {
|
2003-12-07 22:49:04 +00:00
|
|
|
g_warning ("Not a strf chunk");
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_auds)) {
|
|
|
|
g_warning ("Too small strf_auds (%d available, %d needed)",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_auds));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->format = GUINT16_FROM_LE (strf->format);
|
|
|
|
strf->channels = GUINT16_FROM_LE (strf->channels);
|
|
|
|
strf->rate = GUINT32_FROM_LE (strf->rate);
|
|
|
|
strf->av_bps = GUINT32_FROM_LE (strf->av_bps);
|
2003-12-07 22:49:04 +00:00
|
|
|
strf->blockalign = GUINT16_FROM_LE (strf->blockalign);
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->size = GUINT16_FROM_LE (strf->size);
|
2003-12-07 22:49:04 +00:00
|
|
|
#endif
|
|
|
|
|
2004-07-13 10:24:29 +00:00
|
|
|
/* size checking */
|
|
|
|
*extradata = NULL;
|
|
|
|
if (strf->size > GST_BUFFER_SIZE (buf)) {
|
|
|
|
g_warning ("strf_auds header gave %d bytes data, only %d available",
|
|
|
|
strf->size, GST_BUFFER_SIZE (buf));
|
|
|
|
strf->size = GST_BUFFER_SIZE (buf);
|
|
|
|
} else if (strf->size < GST_BUFFER_SIZE (buf)) {
|
2004-07-16 10:50:49 +00:00
|
|
|
gint len;
|
|
|
|
|
|
|
|
len = GST_BUFFER_SIZE (buf) - strf->size - 2;
|
|
|
|
if (len > 0) {
|
|
|
|
*extradata = gst_buffer_create_sub (buf, strf->size + 2, len);
|
|
|
|
}
|
2004-07-13 10:24:29 +00:00
|
|
|
}
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
/* debug */
|
|
|
|
GST_INFO ("strf tag found in context auds:");
|
|
|
|
GST_INFO (" format %d", strf->format);
|
|
|
|
GST_INFO (" channels %d", strf->channels);
|
|
|
|
GST_INFO (" rate %d", strf->rate);
|
|
|
|
GST_INFO (" av_bps %d", strf->av_bps);
|
|
|
|
GST_INFO (" blockalign %d", strf->blockalign);
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_INFO (" size %d", strf->size); /* wordsize, not extrasize! */
|
2004-07-13 10:24:29 +00:00
|
|
|
if (*extradata)
|
|
|
|
GST_INFO (" %d bytes extra_data", GST_BUFFER_SIZE (*extradata));
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
*header = strf;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-13 10:24:29 +00:00
|
|
|
/*
|
|
|
|
* Obsolete, use gst_riff_read_strf_auds_with_data ().
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
|
|
|
|
{
|
|
|
|
GstBuffer *data = NULL;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
ret = gst_riff_read_strf_auds_with_data (riff, header, &data);
|
|
|
|
if (data)
|
|
|
|
gst_buffer_unref (data);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-12-07 22:49:04 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_strf_iavs (GstRiffRead * riff, gst_riff_strf_iavs ** header)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gst_riff_strf_iavs *strf;
|
|
|
|
|
|
|
|
if (!gst_riff_read_data (riff, &tag, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (tag != GST_RIFF_TAG_strf) {
|
|
|
|
g_warning ("Not a strf chunk");
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (GST_BUFFER_SIZE (buf) < sizeof (gst_riff_strf_iavs)) {
|
|
|
|
g_warning ("Too small strf_iavs (%d available, %d needed)",
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_BUFFER_SIZE (buf), (int) sizeof (gst_riff_strf_iavs));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
strf = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
2003-12-07 22:49:04 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
strf->DVAAuxSrc = GUINT32_FROM_LE (strf->DVAAuxSrc);
|
|
|
|
strf->DVAAuxCtl = GUINT32_FROM_LE (strf->DVAAuxCtl);
|
|
|
|
strf->DVAAuxSrc1 = GUINT32_FROM_LE (strf->DVAAuxSrc1);
|
|
|
|
strf->DVAAuxCtl1 = GUINT32_FROM_LE (strf->DVAAuxCtl1);
|
|
|
|
strf->DVVAuxSrc = GUINT32_FROM_LE (strf->DVVAuxSrc);
|
|
|
|
strf->DVVAuxCtl = GUINT32_FROM_LE (strf->DVVAuxCtl);
|
2003-12-07 22:49:04 +00:00
|
|
|
strf->DVReserved1 = GUINT32_FROM_LE (strf->DVReserved1);
|
|
|
|
strf->DVReserved2 = GUINT32_FROM_LE (strf->DVReserved2);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* debug */
|
|
|
|
GST_INFO ("strf tag found in context iavs");
|
|
|
|
GST_INFO (" DVAAuxSrc %08x", strf->DVAAuxSrc);
|
|
|
|
GST_INFO (" DVAAuxCtl %08x", strf->DVAAuxCtl);
|
|
|
|
GST_INFO (" DVAAuxSrc1 %08x", strf->DVAAuxSrc1);
|
|
|
|
GST_INFO (" DVAAuxCtl1 %08x", strf->DVAAuxCtl1);
|
|
|
|
GST_INFO (" DVVAuxSrc %08x", strf->DVVAuxSrc);
|
|
|
|
GST_INFO (" DVVAuxCtl %08x", strf->DVVAuxCtl);
|
|
|
|
GST_INFO (" DVReserved1 %08x", strf->DVReserved1);
|
|
|
|
GST_INFO (" DVReserved2 %08x", strf->DVReserved2);
|
|
|
|
|
|
|
|
*header = strf;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read a list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_list (GstRiffRead * riff, guint32 * tag)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 length, lst;
|
|
|
|
GstRiffLevel *level;
|
|
|
|
guint8 *data;
|
|
|
|
|
|
|
|
if (!gst_riff_peek_head (riff, &lst, &length, NULL))
|
|
|
|
return FALSE;
|
|
|
|
if (lst != GST_RIFF_TAG_LIST) {
|
|
|
|
g_warning ("Not a LIST object");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gst_bytestream_flush_fast (riff->bs, 8);
|
|
|
|
if (gst_bytestream_peek_bytes (riff->bs, &data, 4) != 4) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
2003-12-07 22:49:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gst_bytestream_flush_fast (riff->bs, 4);
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
*tag = GST_READ_UINT32_LE (data);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
/* remember level */
|
|
|
|
level = g_new (GstRiffLevel, 1);
|
|
|
|
level->start = gst_bytestream_tell (riff->bs);
|
|
|
|
level->length = length - 4;
|
|
|
|
riff->level = g_list_append (riff->level, level);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Utility function for reading metadata in a RIFF file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_info (GstRiffRead * riff)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
guint32 tag;
|
|
|
|
guint64 end;
|
|
|
|
GstRiffLevel *level;
|
|
|
|
GList *last;
|
|
|
|
gchar *name, *type;
|
2004-01-23 13:22:16 +00:00
|
|
|
GstTagList *taglist;
|
|
|
|
gboolean have_tags = FALSE;
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
/* What we're doing here is ugly (oh no!); we look
|
|
|
|
* at our LIST tag size and assure that we do not
|
|
|
|
* cross boundaries. This is to maintain the level
|
|
|
|
* counter for the client app. */
|
|
|
|
last = g_list_last (riff->level);
|
|
|
|
level = last->data;
|
|
|
|
riff->level = g_list_remove (riff->level, level);
|
|
|
|
end = level->start + level->length;
|
|
|
|
g_free (level);
|
|
|
|
|
2004-01-23 13:22:16 +00:00
|
|
|
taglist = gst_tag_list_new ();
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
while (gst_bytestream_tell (riff->bs) < end) {
|
|
|
|
if (!gst_riff_peek_head (riff, &tag, NULL, NULL)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find out the type of metadata */
|
|
|
|
switch (tag) {
|
|
|
|
case GST_RIFF_INFO_IARL:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_LOCATION;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IART:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_ARTIST;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ICMS:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Commissioner"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ICMT:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_COMMENT;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ICOP:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_COPYRIGHT;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ICRD:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_DATE;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ICRP:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Cropped"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IDIM:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Dimensions"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IDPI:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Dots per Inch"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IENG:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Engineer"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IGNR:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_GENRE;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IKEY:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Keywords"; */ ;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ILGT:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Lightness"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IMED:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Medium"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_INAM:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_TITLE;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IPLT:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Palette"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_IPRD:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Product"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ISBJ:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Subject"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ISFT:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_ENCODER;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ISHP:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Sharpness"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ISRC:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = GST_TAG_ISRC;
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ISRF:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Source Form"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
case GST_RIFF_INFO_ITCH:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL; /*"Technician"; */
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
default:
|
2004-03-15 19:32:27 +00:00
|
|
|
type = NULL;
|
|
|
|
GST_WARNING ("Unknown INFO (metadata) tag entry " GST_FOURCC_FORMAT,
|
|
|
|
GST_FOURCC_ARGS (tag));
|
|
|
|
break;
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (type) {
|
2004-01-23 13:22:16 +00:00
|
|
|
name = NULL;
|
2003-12-07 22:49:04 +00:00
|
|
|
if (!gst_riff_read_ascii (riff, &tag, &name)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2003-12-07 22:49:04 +00:00
|
|
|
}
|
|
|
|
|
2004-01-23 13:22:16 +00:00
|
|
|
if (name && name[0] != '\0') {
|
2004-03-15 19:32:27 +00:00
|
|
|
GValue src = { 0 }
|
|
|
|
, dest =
|
|
|
|
{
|
|
|
|
0};
|
|
|
|
GType dest_type = gst_tag_get_type (type);
|
|
|
|
|
|
|
|
have_tags = TRUE;
|
|
|
|
g_value_init (&src, G_TYPE_STRING);
|
|
|
|
g_value_set_string (&src, name);
|
|
|
|
g_value_init (&dest, dest_type);
|
|
|
|
g_value_transform (&src, &dest);
|
|
|
|
g_value_unset (&src);
|
|
|
|
gst_tag_list_add_values (taglist, GST_TAG_MERGE_APPEND,
|
|
|
|
type, &dest, NULL);
|
|
|
|
g_value_unset (&dest);
|
2004-01-23 13:22:16 +00:00
|
|
|
}
|
|
|
|
g_free (name);
|
2003-12-07 22:49:04 +00:00
|
|
|
} else {
|
|
|
|
gst_riff_read_skip (riff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-23 13:22:16 +00:00
|
|
|
if (have_tags) {
|
|
|
|
GstElement *element = GST_ELEMENT (riff);
|
|
|
|
GstEvent *event = gst_event_new_tag (taglist);
|
|
|
|
const GList *padlist;
|
|
|
|
|
|
|
|
/* let the world know about this wonderful thing */
|
|
|
|
for (padlist = gst_element_get_pad_list (element);
|
2004-03-15 19:32:27 +00:00
|
|
|
padlist != NULL; padlist = padlist->next) {
|
2004-03-14 22:34:33 +00:00
|
|
|
if (GST_PAD_IS_SRC (padlist->data) && GST_PAD_IS_USABLE (padlist->data)) {
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_event_ref (event);
|
|
|
|
gst_pad_push (GST_PAD (padlist->data), GST_DATA (event));
|
2004-01-23 13:22:16 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-14 17:23:08 +00:00
|
|
|
|
|
|
|
gst_element_found_tags (element, taglist);
|
|
|
|
|
2004-01-23 13:22:16 +00:00
|
|
|
gst_event_unref (event);
|
2004-05-14 17:23:08 +00:00
|
|
|
} else {
|
|
|
|
gst_tag_list_free (taglist);
|
2004-01-23 13:22:16 +00:00
|
|
|
}
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read RIFF header and document type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_riff_read_header (GstRiffRead * riff, guint32 * doctype)
|
2003-12-07 22:49:04 +00:00
|
|
|
{
|
|
|
|
GstRiffLevel *level;
|
|
|
|
guint32 tag, length;
|
|
|
|
guint8 *data;
|
|
|
|
|
|
|
|
/* We ignore size for openDML-2.0 support */
|
|
|
|
if (!gst_riff_peek_head (riff, &tag, &length, NULL))
|
|
|
|
return FALSE;
|
|
|
|
if (tag != GST_RIFF_TAG_RIFF) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, STREAM, WRONG_TYPE, (NULL), (NULL));
|
2003-12-07 22:49:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gst_bytestream_flush_fast (riff->bs, 8);
|
|
|
|
|
|
|
|
/* doctype */
|
|
|
|
if (gst_bytestream_peek_bytes (riff->bs, &data, 4) != 4) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
|
2003-12-07 22:49:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
gst_bytestream_flush_fast (riff->bs, 4);
|
configure.ac: bump required gstreamer version to 0.8.1.1 because of following changes [--ds]
Original commit message from CVS:
reviewed by David Schleef
* configure.ac: bump required gstreamer version to 0.8.1.1
because of following changes [--ds]
* gst-libs/gst/riff/riff-read.c: Include gst/gstutils.h.
(gst_riff_peek_head, gst_riff_peek_list, gst_riff_read_list)
(gst_riff_read_header): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/typefind/gsttypefindfunctions.c: Include gst/gstutils.h.
(mp3_type_find): Use GST_READ_UINT*
macros to access possibly unaligned memory.
(mp3_type_find, mpeg1_parse_header, qt_type_find)
(speex_type_find): Likewise
* gst/tags/gstvorbistag.c: (ADVANCE): Likewise
* gst/qtdemux/qtdemux.c: Include stdlib.h (needed by realloc).
(QTDEMUX_GUINT32_GET, QTDEMUX_GUINT16_GET, QTDEMUX_FP32_GET)
(QTDEMUX_FP16_GET, QTDEMUX_FOURCC_GET)
(gst_qtdemux_loop_header, gst_qtdemux_loop_header)
(qtdemux_node_dump_foreach, qtdemux_tree_get_child_by_type)
(qtdemux_tree_get_sibling_by_type): Use GST_READ_UINT*
macros to access possibly unaligned memory.
* gst/mpegstream/gstmpegpacketize.c: (parse_generic, parse_chunk):
Likewise.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_parse_syshead)
(gst_mpeg_demux_parse_packet, gst_mpeg_demux_parse_pes): Likewise.
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Likewise.
* gst/mpeg2sub/gstmpeg2subt.c: (GST_BUFFER_DATA)
(gst_mpeg2subt_chain_subtitle): Likewise.
* gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_parse_seq)
(gst_mp1videoparse_time_code, gst_mp1videoparse_real_chain):
Likewise.
* gst/mpeg1sys/buffer.c: (mpeg1mux_buffer_update_audio_info):
Likewise.
* gst/cdxaparse/gstcdxaparse.c: (gst_bytestream_peek_bytes):
Likewise.
* gst/asfdemux/gstasfdemux.c: (_read_var_length, _read_uint):
Likewise.
2004-04-20 21:04:22 +00:00
|
|
|
*doctype = GST_READ_UINT32_LE (data);
|
2003-12-07 22:49:04 +00:00
|
|
|
|
|
|
|
/* remember level */
|
|
|
|
level = g_new (GstRiffLevel, 1);
|
|
|
|
level->start = gst_bytestream_tell (riff->bs);
|
|
|
|
level->length = length - 4;
|
|
|
|
riff->level = g_list_append (riff->level, level);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|