summaryrefslogtreecommitdiffstats
path: root/gst-libs/gst
diff options
context:
space:
mode:
authorIain Holmes <iain@prettypeople.org>2004-05-08 00:33:39 +0000
committerIain Holmes <iain@prettypeople.org>2004-05-08 00:33:39 +0000
commit3a1737c07699370279eae64a71dded925c8be1d4 (patch)
tree842183888e6662ae265779778b6c9cdfa7c02984 /gst-libs/gst
parent5093ae66b9fb4b124a28976a9a4cb58c12ab8f75 (diff)
downloadgst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.tar.gz
gst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.tar.bz2
gst-plugins-bad-3a1737c07699370279eae64a71dded925c8be1d4.zip
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.
Diffstat (limited to 'gst-libs/gst')
-rw-r--r--gst-libs/gst/riff/riff-ids.h3
-rw-r--r--gst-libs/gst/riff/riff-read.c47
-rw-r--r--gst-libs/gst/riff/riff-read.h8
3 files changed, 46 insertions, 12 deletions
diff --git a/gst-libs/gst/riff/riff-ids.h b/gst-libs/gst/riff/riff-ids.h
index da465c2d..65fbd30f 100644
--- a/gst-libs/gst/riff/riff-ids.h
+++ b/gst-libs/gst/riff/riff-ids.h
@@ -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')
diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c
index fa153e68..388ea753 100644
--- a/gst-libs/gst/riff/riff-read.c
+++ b/gst-libs/gst/riff/riff-read.c
@@ -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;
diff --git a/gst-libs/gst/riff/riff-read.h b/gst-libs/gst/riff/riff-read.h
index d0c09b8c..f3a6feb9 100644
--- a/gst-libs/gst/riff/riff-read.h
+++ b/gst-libs/gst/riff/riff-read.h
@@ -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).
*/