diff --git a/gst/wavparse/Makefile.am b/gst/wavparse/Makefile.am index dfd9d61a1f..af79efd4cd 100644 --- a/gst/wavparse/Makefile.am +++ b/gst/wavparse/Makefile.am @@ -1,7 +1,7 @@ plugin_LTLIBRARIES = libgstwavparse.la -libgstwavparse_la_SOURCES = gstwavparse.c gstriff.c +libgstwavparse_la_SOURCES = gstwavparse.c libgstwavparse_la_CFLAGS = $(GST_CFLAGS) libgstwavparse_la_LIBADD = libgstwavparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) diff --git a/gst/wavparse/gstriff.c b/gst/wavparse/gstriff.c deleted file mode 100644 index bc4558d661..0000000000 --- a/gst/wavparse/gstriff.c +++ /dev/null @@ -1,144 +0,0 @@ -/* GStreamer - * Copyright (C) <1999> Erik Walthinsen - * - * 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 -#include - - -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 = GUINT32_FROM_LE(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]),chunk->size); */ - 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 GUINT32_FROM_LE((gulong)(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); - id = GUINT32_FROM_LE(id); - - 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 deleted file mode 100644 index 42959fe9c1..0000000000 --- a/gst/wavparse/gstriff.h +++ /dev/null @@ -1,67 +0,0 @@ -/* GStreamer - * Copyright (C) <1999> Erik Walthinsen - * - * 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 -#include - - -#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 index 52ee103add..2849b6e965 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -318,10 +318,10 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) GST_DEBUG ("GstWavParse: checking for RIFF format"); /* create a new RIFF parser */ - wavparse->riff = gst_riff_new (); + wavparse->riff = gst_riff_parser_new (NULL, NULL); /* give it the current buffer to start parsing */ - retval = gst_riff_next_buffer (wavparse->riff, buf, 0); + retval = gst_riff_parser_next_buffer (wavparse->riff, buf, 0); buffer_riffed = TRUE; if (retval < 0) { GST_DEBUG ("sorry, isn't RIFF"); @@ -347,12 +347,12 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) /* there's a good possibility we may not have parsed this buffer */ if (buffer_riffed == FALSE) { - gst_riff_next_buffer (wavparse->riff, buf, GST_BUFFER_OFFSET (buf)); + gst_riff_parser_next_buffer (wavparse->riff, buf, GST_BUFFER_OFFSET (buf)); buffer_riffed = TRUE; } /* see if the fmt chunk is available yet */ - fmt = gst_riff_get_chunk (wavparse->riff, "fmt "); + fmt = gst_riff_parser_get_chunk (wavparse->riff, GST_RIFF_TAG_fmt); /* if we've got something, deal with it */ if (fmt != NULL) { @@ -444,11 +444,11 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) /* again, we might need to parse the buffer */ if (buffer_riffed == FALSE) { - gst_riff_next_buffer (wavparse->riff, buf, GST_BUFFER_OFFSET (buf)); + gst_riff_parser_next_buffer (wavparse->riff, buf, GST_BUFFER_OFFSET (buf)); buffer_riffed = TRUE; } - datachunk = gst_riff_get_chunk (wavparse->riff, "data"); + datachunk = gst_riff_parser_get_chunk (wavparse->riff, GST_RIFF_TAG_data); if (datachunk != NULL) { gulong subsize; @@ -480,7 +480,7 @@ gst_wavparse_chain (GstPad *pad, GstBuffer *buf) wavparse->state = GST_WAVPARSE_DATA; /* however, we may be expecting another chunk at some point */ - wavparse->riff_nextlikely = gst_riff_get_nextlikely (wavparse->riff); + wavparse->riff_nextlikely = gst_riff_parser_get_nextlikely (wavparse->riff); } else { /* otherwise we just sort of give up for this buffer */ gst_buffer_unref (buf); @@ -705,6 +705,10 @@ plugin_init (GModule *module, GstPlugin *plugin) GstElementFactory *factory; GstTypeFactory *type; + if(gst_library_load("gstriff") == FALSE){ + return FALSE; + } + /* create an elementfactory for the wavparse element */ factory = gst_element_factory_new ("wavparse", GST_TYPE_WAVPARSE, &gst_wavparse_details); diff --git a/gst/wavparse/gstwavparse.h b/gst/wavparse/gstwavparse.h index 3c09734704..4678750e09 100644 --- a/gst/wavparse/gstwavparse.h +++ b/gst/wavparse/gstwavparse.h @@ -24,7 +24,7 @@ #include #include -#include +#include #ifdef __cplusplus