summaryrefslogtreecommitdiffstats
path: root/gst/wavparse
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2001-12-22 23:27:31 +0000
committerAndy Wingo <wingo@pobox.com>2001-12-22 23:27:31 +0000
commit185612aae3b8acae2b32e0e6561691a7c640cd0d (patch)
tree7cd1990c3df5c63f402f3e0bdf6b51b3ed58fc41 /gst/wavparse
parent87dab192cf5792f847a22e0c3e9afe78553739b5 (diff)
Initial revision
Original commit message from CVS: Initial revision
Diffstat (limited to 'gst/wavparse')
-rw-r--r--gst/wavparse/.gitignore7
-rw-r--r--gst/wavparse/Makefile.am8
-rw-r--r--gst/wavparse/gstriff.c144
-rw-r--r--gst/wavparse/gstriff.h67
-rw-r--r--gst/wavparse/gstwavparse.c367
-rw-r--r--gst/wavparse/gstwavparse.h99
6 files changed, 692 insertions, 0 deletions
diff --git a/gst/wavparse/.gitignore b/gst/wavparse/.gitignore
new file mode 100644
index 00000000..08f5ed37
--- /dev/null
+++ b/gst/wavparse/.gitignore
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+*.o
+*.lo
+*.la
+.deps
+.libs
diff --git a/gst/wavparse/Makefile.am b/gst/wavparse/Makefile.am
new file mode 100644
index 00000000..d9c8e4df
--- /dev/null
+++ b/gst/wavparse/Makefile.am
@@ -0,0 +1,8 @@
+filterdir = $(libdir)/gst
+
+filter_LTLIBRARIES = libgstwavparse.la
+
+libgstwavparse_la_SOURCES = gstwavparse.c gstriff.c
+libgstwavparse_la_CFLAGS = $(GST_CFLAGS)
+
+noinst_HEADERS = gstwavparse.h gstriff.h
diff --git a/gst/wavparse/gstriff.c b/gst/wavparse/gstriff.c
new file mode 100644
index 00000000..d343568c
--- /dev/null
+++ b/gst/wavparse/gstriff.c
@@ -0,0 +1,144 @@
+/* Gnome-Streamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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.
+ */
+
+
+#include <stdlib.h>
+#include <gstriff.h>
+
+
+GstRiff *gst_riff_new() {
+ GstRiff *riff;
+
+ riff = (GstRiff *)malloc(sizeof(GstRiff));
+ g_return_val_if_fail(riff != NULL, NULL);
+
+ riff->form = 0;
+ riff->chunks = NULL;
+ riff->state = 0;
+ riff->curoffset = 0;
+ riff->nextlikely = 0;
+
+ return riff;
+}
+
+gint gst_riff_next_buffer(GstRiff *riff,GstBuffer *buf,gulong off) {
+ gulong last;
+ GstRiffChunk *chunk;
+
+ g_return_val_if_fail(riff != NULL, 0);
+ g_return_val_if_fail(buf != NULL, 0);
+ g_return_val_if_fail(GST_BUFFER_DATA(buf) != NULL, 0);
+
+ last = off + GST_BUFFER_SIZE(buf);
+
+ if (off == 0) {
+ gulong *words = (gulong *)GST_BUFFER_DATA(buf);
+
+ /* verify this is a valid RIFF file, first of all */
+ if (words[0] != gst_riff_fourcc_to_id("RIFF")) {
+ riff->state = GST_RIFF_ENOTRIFF;
+ return riff->state;
+ }
+ riff->form = words[2];
+// g_print("form is 0x%08x '%s'\n",words[2],gst_riff_id_to_fourcc(words[2]));
+ riff->nextlikely = 12; /* skip 'RIFF', length, and form */
+ }
+
+ /* loop while the next likely chunk header is in this buffer */
+ while ((riff->nextlikely+8) < last) {
+ gulong *words = (gulong *)((guchar *)GST_BUFFER_DATA(buf) + riff->nextlikely);
+
+// g_print("next likely chunk is at offset 0x%08x\n",riff->nextlikely);
+ chunk = (GstRiffChunk *)malloc(sizeof(GstRiffChunk));
+ g_return_val_if_fail(chunk != NULL,0);
+ chunk->offset = riff->nextlikely+8; /* point to the actual data */
+ chunk->id = words[0];
+ chunk->size = words[1];
+// g_print("chunk id is 0x%08x '%s' and is 0x%08x long\n",words[0],
+// gst_riff_id_to_fourcc(words[0]),words[1]);
+ riff->nextlikely += 8 + chunk->size; /* doesn't include hdr */
+ riff->chunks = g_list_prepend(riff->chunks,chunk);
+ }
+
+ return 0;
+}
+
+
+gulong gst_riff_fourcc_to_id(gchar *fourcc) {
+ g_return_val_if_fail(fourcc != NULL,0);
+
+ return (fourcc[0] << 0) | (fourcc[1] << 8) |
+ (fourcc[2] << 16) | (fourcc[3] << 24);
+}
+
+gchar *gst_riff_id_to_fourcc(gulong id) {
+ gchar *fourcc = (gchar *)malloc(5);
+
+ g_return_val_if_fail(fourcc != NULL, NULL);
+
+ fourcc[0] = (id >> 0) & 0xff;
+ fourcc[1] = (id >> 8) & 0xff;
+ fourcc[2] = (id >> 16) & 0xff;
+ fourcc[3] = (id >> 24) & 0xff;
+ fourcc[4] = 0;
+
+ return fourcc;
+}
+
+GList *gst_riff_get_chunk_list(GstRiff *riff) {
+ g_return_val_if_fail(riff != NULL, NULL);
+
+ return riff->chunks;
+}
+
+GstRiffChunk *gst_riff_get_chunk(GstRiff *riff,gchar *fourcc) {
+ GList *chunk;
+
+ g_return_val_if_fail(riff != NULL, NULL);
+ g_return_val_if_fail(fourcc != NULL, NULL);
+
+ chunk = riff->chunks;
+ while (chunk) {
+ if (((GstRiffChunk *)(chunk->data))->id == gst_riff_fourcc_to_id(fourcc))
+ return (GstRiffChunk *)(chunk->data);
+ chunk = g_list_next(chunk);
+ }
+
+ return NULL;
+}
+
+gulong gst_riff_get_nextlikely(GstRiff *riff) {
+ g_return_val_if_fail(riff != NULL, 0);
+
+ return riff->nextlikely;
+}
+
+/*
+ guchar *hchar = (guchar *)(buf->data);
+ gulong hlong = *(gulong *)(buf->data);
+
+ g_print("header is 0x%08x native, %02x %02x %02x %02x, '%c%c%c%c'\n",
+ hlong,
+ hchar[0],hchar[1],hchar[2],hchar[3],
+ hchar[0],hchar[1],hchar[2],hchar[3]);
+ g_print("header 0x%08x translates to '%s'\n",hlong,
+ gst_riff_id_to_fourcc(hlong));
+ g_print("header 0x%08x trancodes to 0x%08x\n",hlong,
+ gst_riff_fourcc_to_id(gst_riff_id_to_fourcc(hlong)));
+*/
diff --git a/gst/wavparse/gstriff.h b/gst/wavparse/gstriff.h
new file mode 100644
index 00000000..de959fdc
--- /dev/null
+++ b/gst/wavparse/gstriff.h
@@ -0,0 +1,67 @@
+/* Gnome-Streamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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.
+ */
+
+
+#ifndef __GST_RIFF_H__
+#define __GST_RIFF_H__
+
+
+#include <gst/gstbuffer.h>
+#include <gst/gstplugin.h>
+
+
+#define GST_RIFF_ENOTRIFF -1 /* not a RIFF file */
+
+
+typedef struct _GstRiff GstRiff;
+typedef struct _GstRiffChunk GstRiffChunk;
+
+struct _GstRiff {
+ guint32 form;
+
+ /* list of chunks, most recent at the head */
+ GList *chunks;
+
+ /* parse state */
+ gint state;
+ guint32 curoffset;
+ guint32 nextlikely;
+};
+
+struct _GstRiffChunk {
+ gulong offset;
+
+ guint32 id;
+ guint32 size;
+};
+
+
+GstRiff *gst_riff_new();
+gint gst_riff_next_buffer(GstRiff *riff,GstBuffer *buf,gulong off);
+GList *gst_riff_get_chunk_list(GstRiff *riff);
+GstRiffChunk *gst_riff_get_chunk(GstRiff *riff,gchar *fourcc);
+GstRiffChunk *gst_riff_get_chunk_number(GstRiff *riff,gint number);
+
+gulong gst_riff_get_nextlikely(GstRiff *riff);
+
+gulong gst_riff_fourcc_to_id(gchar *fourcc);
+gchar *gst_riff_id_to_fourcc(gulong id);
+
+
+#endif /* __GST_RIFF_H__ */
diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c
new file mode 100644
index 00000000..2e57da83
--- /dev/null
+++ b/gst/wavparse/gstwavparse.c
@@ -0,0 +1,367 @@
+/* Gnome-Streamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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.
+ */
+
+
+#include <string.h>
+
+#include <gstwavparse.h>
+
+static void gst_parsewav_class_init (GstParseWavClass *klass);
+static void gst_parsewav_init (GstParseWav *parsewav);
+
+static GstCaps* wav_typefind (GstBuffer *buf, gpointer private);
+
+static void gst_parsewav_chain (GstPad *pad, GstBuffer *buf);
+
+/* elementfactory information */
+static GstElementDetails gst_parsewav_details = {
+ ".wav parser",
+ "Parser/Audio",
+ "Parse a .wav file into raw audio",
+ VERSION,
+ "Erik Walthinsen <omega@cse.ogi.edu>",
+ "(C) 1999",
+};
+
+GST_PADTEMPLATE_FACTORY (sink_template_factory,
+ "parsewav_sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW (
+ "parsewav_wav",
+ "audio/wav",
+ NULL
+ )
+)
+
+GST_PADTEMPLATE_FACTORY (src_template_factory,
+ "parsewav_src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_CAPS_NEW (
+ "parsewav_raw",
+ "audio/raw",
+ "format", GST_PROPS_STRING ("int"),
+ "law", GST_PROPS_INT (0),
+ "endianness", GST_PROPS_INT (G_BYTE_ORDER),
+ "signed", GST_PROPS_BOOLEAN (TRUE),
+ "width", GST_PROPS_LIST (
+ GST_PROPS_INT (8),
+ GST_PROPS_INT (16)
+ ),
+ "depth", GST_PROPS_LIST (
+ GST_PROPS_INT (8),
+ GST_PROPS_INT (16)
+ ),
+ "rate", GST_PROPS_INT_RANGE (8000, 48000),
+ "channels", GST_PROPS_INT_RANGE (1, 2)
+ )
+)
+
+/* typefactory for 'wav' */
+static GstTypeDefinition
+wavdefinition =
+{
+ "parsewav_audio/wav",
+ "audio/wav",
+ ".wav",
+ wav_typefind,
+};
+
+
+/* ParseWav signals and args */
+enum {
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum {
+ ARG_0,
+ /* FILL ME */
+};
+
+static GstElementClass *parent_class = NULL;
+//static guint gst_parsewav_signals[LAST_SIGNAL] = { 0 };
+
+GType
+gst_parsewav_get_type (void)
+{
+ static GType parsewav_type = 0;
+
+ if (!parsewav_type) {
+ static const GTypeInfo parsewav_info = {
+ sizeof(GstParseWavClass), NULL,
+ NULL,
+ (GClassInitFunc) gst_parsewav_class_init,
+ NULL,
+ NULL,
+ sizeof(GstParseWav),
+ 0,
+ (GInstanceInitFunc) gst_parsewav_init,
+ };
+ parsewav_type = g_type_register_static (GST_TYPE_ELEMENT, "GstParseWav", &parsewav_info, 0);
+ }
+ return parsewav_type;
+}
+
+static void
+gst_parsewav_class_init (GstParseWavClass *klass)
+{
+ GstElementClass *gstelement_class;
+
+ gstelement_class = (GstElementClass*) klass;
+
+ parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+}
+
+static void
+gst_parsewav_init (GstParseWav *parsewav)
+{
+ parsewav->sinkpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (sink_template_factory), "sink");
+ gst_element_add_pad (GST_ELEMENT (parsewav), parsewav->sinkpad);
+ gst_pad_set_chain_function (parsewav->sinkpad, gst_parsewav_chain);
+
+ parsewav->srcpad = gst_pad_new_from_template (GST_PADTEMPLATE_GET (src_template_factory), "src");
+ gst_element_add_pad (GST_ELEMENT (parsewav), parsewav->srcpad);
+
+ parsewav->riff = NULL;
+
+ parsewav->state = GST_PARSEWAV_UNKNOWN;
+ parsewav->riff = NULL;
+ parsewav->riff_nextlikely = 0;
+ parsewav->size = 0;
+ parsewav->bps = 0;
+}
+
+static GstCaps*
+wav_typefind (GstBuffer *buf, gpointer private)
+{
+ gchar *data = GST_BUFFER_DATA (buf);
+
+ if (strncmp (&data[0], "RIFF", 4)) return NULL;
+ if (strncmp (&data[8], "WAVE", 4)) return NULL;
+
+ return gst_caps_new ("wav_typefind", "audio/wav", NULL);
+}
+
+
+static void
+gst_parsewav_chain (GstPad *pad, GstBuffer *buf)
+{
+ GstParseWav *parsewav;
+ gboolean buffer_riffed = FALSE; /* so we don't parse twice */
+ gchar *data;
+ gulong size;
+
+ g_return_if_fail (pad != NULL);
+ g_return_if_fail (GST_IS_PAD (pad));
+ g_return_if_fail (buf != NULL);
+ g_return_if_fail (GST_BUFFER_DATA (buf) != NULL);
+
+ parsewav = GST_PARSEWAV (gst_pad_get_parent (pad));
+ GST_DEBUG (0, "gst_parsewav_chain: got buffer in '%s'\n",
+ gst_object_get_name (GST_OBJECT (parsewav)));
+ data = (guchar *) GST_BUFFER_DATA (buf);
+ size = GST_BUFFER_SIZE (buf);
+
+ /* walk through the states in priority order */
+ /* we're in the data region */
+ if (parsewav->state == GST_PARSEWAV_DATA) {
+ /* if we're expected to see a new chunk in this buffer */
+ if ((parsewav->riff_nextlikely - GST_BUFFER_OFFSET (buf)) < GST_BUFFER_SIZE (buf)) {
+
+ GST_BUFFER_SIZE (buf) = parsewav->riff_nextlikely - GST_BUFFER_OFFSET (buf);
+
+ parsewav->state = GST_PARSEWAV_OTHER;
+ /* I suppose we could signal an EOF at this point, but that may be
+ premature. We've stopped data flow, that's the main thing. */
+ }
+ gst_pad_push (parsewav->srcpad, buf);
+ return;
+ }
+
+ if (parsewav->state == GST_PARSEWAV_OTHER) {
+ GST_DEBUG (0, "we're in unknown territory here, not passing on\n");
+ return;
+ }
+
+
+ /* here we deal with parsing out the primary state */
+ /* these are sequenced such that in the normal case each (RIFF/WAVE,
+ fmt, data) will fire in sequence, as they should */
+
+ /* we're in null state now, look for the RIFF header, start parsing */
+ if (parsewav->state == GST_PARSEWAV_UNKNOWN) {
+ gint retval;
+
+ GST_DEBUG (0, "GstParseWav: checking for RIFF format\n");
+
+ /* create a new RIFF parser */
+ parsewav->riff = gst_riff_new ();
+
+ /* give it the current buffer to start parsing */
+ retval = gst_riff_next_buffer (parsewav->riff, buf, 0);
+ buffer_riffed = TRUE;
+ if (retval < 0) {
+ GST_DEBUG (0, "sorry, isn't RIFF\n");
+ return;
+ }
+
+ /* this has to be a file of form WAVE for us to deal with it */
+ if (parsewav->riff->form != gst_riff_fourcc_to_id ("WAVE")) {
+ GST_DEBUG (0, "sorry, isn't WAVE\n");
+ return;
+ }
+
+ /* at this point we're waiting for the 'fmt ' chunk */
+ parsewav->state = GST_PARSEWAV_CHUNK_FMT;
+ }
+
+ /* we're now looking for the 'fmt ' chunk to get the audio info */
+ if (parsewav->state == GST_PARSEWAV_CHUNK_FMT) {
+ GstRiffChunk *fmt;
+ GstParseWavFormat *format;
+
+ GST_DEBUG (0, "GstParseWav: looking for fmt chunk\n");
+
+ /* there's a good possibility we may not have parsed this buffer */
+ if (buffer_riffed == FALSE) {
+ gst_riff_next_buffer (parsewav->riff, buf, GST_BUFFER_OFFSET (buf));
+ buffer_riffed = TRUE;
+ }
+
+ /* see if the fmt chunk is available yet */
+ fmt = gst_riff_get_chunk (parsewav->riff, "fmt ");
+
+ /* if we've got something, deal with it */
+ if (fmt != NULL) {
+
+ /* we can gather format information now */
+ format = (GstParseWavFormat *)((guchar *) GST_BUFFER_DATA (buf) + fmt->offset);
+
+ /* set the caps on the src pad */
+ gst_pad_set_caps (parsewav->srcpad, gst_caps_new (
+ "parsewav_src",
+ "audio/raw",
+ gst_props_new (
+ "format", GST_PROPS_STRING ("int"),
+ "law", GST_PROPS_INT (0), //FIXME
+ "endianness", GST_PROPS_INT (G_BYTE_ORDER),
+ "signed", GST_PROPS_BOOLEAN (TRUE), //FIXME
+ "width", GST_PROPS_INT (format->wBitsPerSample),
+ "depth", GST_PROPS_INT (format->wBitsPerSample),
+ "rate", GST_PROPS_INT (format->dwSamplesPerSec),
+ "channels", GST_PROPS_INT (format->wChannels),
+ NULL
+ )
+ ));
+
+ parsewav->bps = format->wBlockAlign;
+ GST_DEBUG (0, "frequency %d, channels %d\n",
+ format->dwSamplesPerSec, format->wChannels);
+
+ /* we're now looking for the data chunk */
+ parsewav->state = GST_PARSEWAV_CHUNK_DATA;
+ } else {
+ /* otherwise we just sort of give up for this buffer */
+ gst_buffer_unref (buf);
+ return;
+ }
+ }
+
+ /* now we look for the data chunk */
+ if (parsewav->state == GST_PARSEWAV_CHUNK_DATA) {
+ GstBuffer *newbuf;
+ GstRiffChunk *datachunk;
+
+ GST_DEBUG (0, "GstParseWav: looking for data chunk\n");
+
+ /* again, we might need to parse the buffer */
+ if (buffer_riffed == FALSE) {
+ gst_riff_next_buffer (parsewav->riff, buf, GST_BUFFER_OFFSET (buf));
+ buffer_riffed = TRUE;
+ }
+
+ datachunk = gst_riff_get_chunk (parsewav->riff, "data");
+
+ if (datachunk != NULL) {
+ gulong subsize;
+
+ GST_DEBUG (0, "data begins at %ld\n", datachunk->offset);
+
+ /* at this point we can ACK that we have data */
+ parsewav->state = GST_PARSEWAV_DATA;
+
+ /* now we construct a new buffer for the remainder */
+ subsize = size - datachunk->offset;
+ GST_DEBUG (0, "sending last %ld bytes along as audio\n", subsize);
+
+ newbuf = gst_buffer_new ();
+ GST_BUFFER_DATA (newbuf) = g_malloc (subsize);
+ GST_BUFFER_SIZE (newbuf) = subsize;
+
+ memcpy (GST_BUFFER_DATA (newbuf), GST_BUFFER_DATA (buf) + datachunk->offset, subsize);
+
+ gst_buffer_unref (buf);
+
+ gst_pad_push (parsewav->srcpad, newbuf);
+
+ /* now we're ready to go, the next buffer should start data */
+ parsewav->state = GST_PARSEWAV_DATA;
+
+ /* however, we may be expecting another chunk at some point */
+ parsewav->riff_nextlikely = gst_riff_get_nextlikely (parsewav->riff);
+ } else {
+ /* otherwise we just sort of give up for this buffer */
+ gst_buffer_unref (buf);
+ return;
+ }
+ }
+}
+
+
+static gboolean
+plugin_init (GModule *module, GstPlugin *plugin)
+{
+ GstElementFactory *factory;
+ GstTypeFactory *type;
+
+ /* create an elementfactory for the parsewav element */
+ factory = gst_elementfactory_new ("parsewav", GST_TYPE_PARSEWAV,
+ &gst_parsewav_details);
+ g_return_val_if_fail(factory != NULL, FALSE);
+
+ /* register src pads */
+ gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (sink_template_factory));
+ gst_elementfactory_add_padtemplate (factory, GST_PADTEMPLATE_GET (src_template_factory));
+
+ gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
+
+ type = gst_typefactory_new (&wavdefinition);
+ gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
+
+ return TRUE;
+}
+
+GstPluginDesc plugin_desc = {
+ GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "parsewav",
+ plugin_init
+};
diff --git a/gst/wavparse/gstwavparse.h b/gst/wavparse/gstwavparse.h
new file mode 100644
index 00000000..55cb4913
--- /dev/null
+++ b/gst/wavparse/gstwavparse.h
@@ -0,0 +1,99 @@
+/* Gnome-Streamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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.
+ */
+
+
+#ifndef __GST_PARSEWAV_H__
+#define __GST_PARSEWAV_H__
+
+
+#include <config.h>
+#include <gst/gst.h>
+#include <gstriff.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#define GST_TYPE_PARSEWAV \
+ (gst_parsewav_get_type())
+#define GST_PARSEWAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PARSEWAV,GstParseWav))
+#define GST_PARSEWAV_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PARSEWAV,GstParseWav))
+#define GST_IS_PARSEWAV(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PARSEWAV))
+#define GST_IS_PARSEWAV_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PARSEWAV))
+
+
+#define GST_PARSEWAV_UNKNOWN 0 /* initialized state */
+#define GST_PARSEWAV_CHUNK_FMT 1 /* searching for fmt */
+#define GST_PARSEWAV_CHUNK_DATA 2 /* searching for data */
+#define GST_PARSEWAV_DATA 3 /* in data region */
+#define GST_PARSEWAV_OTHER 4 /* in unknown region */
+
+typedef struct _GstParseWav GstParseWav;
+typedef struct _GstParseWavClass GstParseWavClass;
+
+struct _GstParseWav {
+ GstElement element;
+
+ /* pads */
+ GstPad *sinkpad,*srcpad;
+
+ /* WAVE decoding state */
+ gint state;
+
+ /* RIFF decoding state */
+ GstRiff *riff;
+ gulong riff_nextlikely;
+
+ /* expected length of audio */
+ gulong size;
+
+ /* useful audio data */
+ gint bps;
+
+};
+
+struct _GstParseWavClass {
+ GstElementClass parent_class;
+};
+
+GType gst_parsewav_get_type(void);
+
+typedef struct _GstParseWavFormat GstParseWavFormat;
+
+struct _GstParseWavFormat {
+ gint16 wFormatTag;
+ guint16 wChannels;
+ guint32 dwSamplesPerSec;
+ guint32 dwAvgBytesPerSec;
+ guint16 wBlockAlign;
+ guint16 wBitsPerSample;
+};
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __GST_PARSEAU_H__ */