Commit 935969b8 authored by Iain Holmes's avatar Iain Holmes
Browse files

Rewrote wavparse to use riff-read instead of doing bytestream stuff by hand.

Original commit message from CVS:
Rewrote wavparse to use riff-read instead of doing bytestream stuff by hand.
Made some useful functions in riff-read non-static.
parent bcd67755
2004-05-08 Iain <iain@prettypeople.org>
* gst/wavparse/gstwavparse.[ch]: Rewrote to use RiffRead instead.
* gst-libs/gst/riff/riff-read.c (gst_riff_read_peek_head): Unstatic it
(gst_riff_read_element_data): Ditto, and added a got_bytes argument to
return the length that was read.
(gst_riff_read_strf_auds): Allow fmt tags as well.
2004-05-07 David Schleef <ds@schleef.org>
* ext/faad/gstfaad.c: (gst_faad_sinkconnect): HACK to correct
......
......@@ -44,7 +44,7 @@
/* WAV stuff */
#define GST_RIFF_TAG_fmt GST_MAKE_FOURCC ('f','m','t',' ')
#define GST_RIFF_TAG_data GST_MAKE_FOURCC ('d','a','t','a')
#define GST_RIFF_TAG_cue GST_MAKE_FOURCC ('c','u','e',' ')
/* LIST types */
#define GST_RIFF_LIST_movi GST_MAKE_FOURCC ('m','o','v','i')
#define GST_RIFF_LIST_hdrl GST_MAKE_FOURCC ('h','d','r','l')
......@@ -52,6 +52,7 @@
#define GST_RIFF_LIST_strl GST_MAKE_FOURCC ('s','t','r','l')
#define GST_RIFF_LIST_INFO GST_MAKE_FOURCC ('I','N','F','O')
#define GST_RIFF_LIST_AVIX GST_MAKE_FOURCC ('A','V','I','X')
#define GST_RIFF_LIST_adtl GST_MAKE_FOURCC ('a','d','t','l')
/* fcc types */
#define GST_RIFF_FCC_vids GST_MAKE_FOURCC ('v','i','d','s')
......
......@@ -150,7 +150,7 @@ gst_riff_read_element_level_up (GstRiffRead * riff)
* TRUE on success or FALSE on failure.
*/
static gboolean
gboolean
gst_riff_peek_head (GstRiffRead * riff,
guint32 * tag, guint32 * length, guint * level_up)
{
......@@ -190,16 +190,40 @@ gst_riff_peek_head (GstRiffRead * riff,
* Return: the data, as a GstBuffer.
*/
static GstBuffer *
gst_riff_read_element_data (GstRiffRead * riff, guint length)
GstBuffer *
gst_riff_read_element_data (GstRiffRead * riff, guint length, guint * got_bytes)
{
GstBuffer *buf = NULL;
guint32 got;
if (gst_bytestream_peek (riff->bs, &buf, length) != length) {
GST_ELEMENT_ERROR (riff, RESOURCE, READ, (NULL), (NULL));
if (buf)
gst_buffer_unref (buf);
return NULL;
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;
}
}
/* we need 16-bit alignment */
......@@ -208,6 +232,9 @@ gst_riff_read_element_data (GstRiffRead * riff, guint length)
gst_bytestream_flush (riff->bs, length);
if (got_bytes)
*got_bytes = got;
return buf;
}
......@@ -363,7 +390,7 @@ gst_riff_read_data (GstRiffRead * riff, guint32 * tag, GstBuffer ** buf)
return FALSE;
gst_bytestream_flush_fast (riff->bs, 8);
return ((*buf = gst_riff_read_element_data (riff, length)) != NULL);
return ((*buf = gst_riff_read_element_data (riff, length, NULL)) != NULL);
}
/*
......@@ -559,7 +586,7 @@ gst_riff_read_strf_auds (GstRiffRead * riff, gst_riff_strf_auds ** header)
if (!gst_riff_read_data (riff, &tag, &buf))
return FALSE;
if (tag != GST_RIFF_TAG_strf) {
if (tag != GST_RIFF_TAG_strf && tag != GST_RIFF_TAG_fmt) {
g_warning ("Not a strf chunk");
gst_buffer_unref (buf);
return FALSE;
......
......@@ -64,6 +64,10 @@ GType gst_riff_read_get_type (void);
guint32 gst_riff_peek_tag (GstRiffRead *riff,
guint *level_up);
guint32 gst_riff_peek_list (GstRiffRead *riff);
gboolean gst_riff_peek_head (GstRiffRead *riff,
guint32 *tag,
guint32 *length,
guint *level_up);
GstEvent *gst_riff_read_seek (GstRiffRead *riff,
guint64 offset);
......@@ -78,7 +82,9 @@ gboolean gst_riff_read_list (GstRiffRead *riff,
guint32 *tag);
gboolean gst_riff_read_header (GstRiffRead *read,
guint32 *doctype);
GstBuffer *gst_riff_read_element_data (GstRiffRead *riff,
guint length,
guint *got_bytes);
/*
* Utility functions (including byteswapping).
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment