diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 5d25c00e4b613b9cdf2c04fa3a68dffa03834a68 (patch) | |
tree | 74a5b1eaf3a324b520e64e87404fd0b3018a7829 /gst/wavparse | |
parent | 1e83b097f7b732ae49e294a5a398bdc3e88854a8 (diff) |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'gst/wavparse')
-rw-r--r-- | gst/wavparse/gstwavparse.c | 1090 | ||||
-rw-r--r-- | gst/wavparse/gstwavparse.h | 114 | ||||
-rw-r--r-- | gst/wavparse/riff.h | 171 |
3 files changed, 695 insertions, 680 deletions
diff --git a/gst/wavparse/gstwavparse.c b/gst/wavparse/gstwavparse.c index 889d6514..c2f6a00f 100644 --- a/gst/wavparse/gstwavparse.c +++ b/gst/wavparse/gstwavparse.c @@ -26,161 +26,161 @@ #include <gstwavparse.h> -static void gst_wavparse_base_init (gpointer g_class); -static void gst_wavparse_class_init (GstWavParseClass *klass); -static void gst_wavparse_init (GstWavParse *wavparse); - -static GstElementStateReturn - gst_wavparse_change_state (GstElement *element); - -static const GstFormat* gst_wavparse_get_formats (GstPad *pad); -static const GstQueryType * - gst_wavparse_get_query_types (GstPad *pad); -static gboolean gst_wavparse_pad_query (GstPad *pad, - GstQueryType type, - GstFormat *format, - gint64 *value); -static gboolean gst_wavparse_pad_convert (GstPad *pad, - GstFormat src_format, - gint64 src_value, - GstFormat *dest_format, - gint64 *dest_value); - -static void gst_wavparse_loop (GstElement *element); -static const GstEventMask* - gst_wavparse_get_event_masks (GstPad *pad); -static gboolean gst_wavparse_srcpad_event (GstPad *pad, GstEvent *event); -static void gst_wavparse_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_wavparse_base_init (gpointer g_class); +static void gst_wavparse_class_init (GstWavParseClass * klass); +static void gst_wavparse_init (GstWavParse * wavparse); + +static GstElementStateReturn gst_wavparse_change_state (GstElement * element); + +static const GstFormat *gst_wavparse_get_formats (GstPad * pad); +static const GstQueryType *gst_wavparse_get_query_types (GstPad * pad); +static gboolean gst_wavparse_pad_query (GstPad * pad, + GstQueryType type, GstFormat * format, gint64 * value); +static gboolean gst_wavparse_pad_convert (GstPad * pad, + GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value); + +static void gst_wavparse_loop (GstElement * element); +static const GstEventMask *gst_wavparse_get_event_masks (GstPad * pad); +static gboolean gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event); +static void gst_wavparse_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); /* elementfactory information */ -static GstElementDetails gst_wavparse_details = GST_ELEMENT_DETAILS ( - ".wav demuxer", - "Codec/Demuxer", - "Parse a .wav file into raw audio", - "Erik Walthinsen <omega@cse.ogi.edu>" -); +static GstElementDetails gst_wavparse_details = +GST_ELEMENT_DETAILS (".wav demuxer", + "Codec/Demuxer", + "Parse a .wav file into raw audio", + "Erik Walthinsen <omega@cse.ogi.edu>"); static GstStaticPadTemplate sink_template_factory = -GST_STATIC_PAD_TEMPLATE ( - "wavparse_sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-wav") -); +GST_STATIC_PAD_TEMPLATE ("wavparse_sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-wav") + ); static GstStaticPadTemplate src_template_factory = -GST_STATIC_PAD_TEMPLATE ( - "wavparse_src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "audio/x-raw-int, " - "endianness = (int) little_endian, " - "signed = (boolean) { true, false }, " - "width = (int) { 8, 16 }, " - "depth = (int) { 8, 16 }, " - "rate = (int) [ 8000, 48000 ], " - "channels = (int) [ 1, 2 ]; " - "audio/mpeg, " - "mpegversion = (int) 1, " - "layer = (int) [ 1, 3 ], " - "rate = (int) [ 8000, 48000 ], " - "channels = (int) [ 1, 2 ]; " - "audio/x-alaw, " - "rate = (int) [ 8000, 48000 ], " - "channels = (int) [ 1, 2 ]; " - "audio/x-mulaw, " - "rate = (int) [ 8000, 48000 ], " - "channels = (int) [ 1, 2 ]" - ) -); + GST_STATIC_PAD_TEMPLATE ("wavparse_src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) little_endian, " + "signed = (boolean) { true, false }, " + "width = (int) { 8, 16 }, " + "depth = (int) { 8, 16 }, " + "rate = (int) [ 8000, 48000 ], " + "channels = (int) [ 1, 2 ]; " + "audio/mpeg, " + "mpegversion = (int) 1, " + "layer = (int) [ 1, 3 ], " + "rate = (int) [ 8000, 48000 ], " + "channels = (int) [ 1, 2 ]; " + "audio/x-alaw, " + "rate = (int) [ 8000, 48000 ], " + "channels = (int) [ 1, 2 ]; " + "audio/x-mulaw, " + "rate = (int) [ 8000, 48000 ], " "channels = (int) [ 1, 2 ]") + ); /* WavParse signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ PROP_0, }; static GstElementClass *parent_class = NULL; + /*static guint gst_wavparse_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_wavparse_get_type (void) +gst_wavparse_get_type (void) { static GType wavparse_type = 0; if (!wavparse_type) { static const GTypeInfo wavparse_info = { - sizeof(GstWavParseClass), + sizeof (GstWavParseClass), gst_wavparse_base_init, NULL, (GClassInitFunc) gst_wavparse_class_init, NULL, NULL, - sizeof(GstWavParse), + sizeof (GstWavParse), 0, (GInstanceInitFunc) gst_wavparse_init, }; - wavparse_type = g_type_register_static (GST_TYPE_ELEMENT, "GstWavParse", &wavparse_info, 0); + wavparse_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstWavParse", &wavparse_info, + 0); } return wavparse_type; } static void -gst_wavparse_base_init (gpointer g_class) +gst_wavparse_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (element_class, &gst_wavparse_details); /* register src pads */ - gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_template_factory)); - gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template_factory)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_template_factory)); } static void -gst_wavparse_class_init (GstWavParseClass *klass) +gst_wavparse_class_init (GstWavParseClass * klass) { GstElementClass *gstelement_class; GObjectClass *object_class; - - gstelement_class = (GstElementClass*) klass; + + gstelement_class = (GstElementClass *) klass; object_class = (GObjectClass *) klass; - + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); object_class->get_property = gst_wavparse_get_property; gstelement_class->change_state = gst_wavparse_change_state; } -static void -gst_wavparse_init (GstWavParse *wavparse) +static void +gst_wavparse_init (GstWavParse * wavparse) { /* sink */ - wavparse->sinkpad = gst_pad_new_from_template (gst_static_pad_template_get (&sink_template_factory), "sink"); + wavparse->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&sink_template_factory), "sink"); gst_element_add_pad (GST_ELEMENT (wavparse), wavparse->sinkpad); gst_pad_set_formats_function (wavparse->sinkpad, gst_wavparse_get_formats); gst_pad_set_convert_function (wavparse->sinkpad, gst_wavparse_pad_convert); - gst_pad_set_query_type_function (wavparse->sinkpad, - gst_wavparse_get_query_types); + gst_pad_set_query_type_function (wavparse->sinkpad, + gst_wavparse_get_query_types); gst_pad_set_query_function (wavparse->sinkpad, gst_wavparse_pad_query); /* source */ - wavparse->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&src_template_factory), "src"); + wavparse->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&src_template_factory), "src"); gst_pad_use_explicit_caps (wavparse->srcpad); gst_element_add_pad (GST_ELEMENT (wavparse), wavparse->srcpad); gst_pad_set_formats_function (wavparse->srcpad, gst_wavparse_get_formats); gst_pad_set_convert_function (wavparse->srcpad, gst_wavparse_pad_convert); gst_pad_set_query_type_function (wavparse->srcpad, - gst_wavparse_get_query_types); + gst_wavparse_get_query_types); gst_pad_set_query_function (wavparse->srcpad, gst_wavparse_pad_query); gst_pad_set_event_function (wavparse->srcpad, gst_wavparse_srcpad_event); - gst_pad_set_event_mask_function (wavparse->srcpad, gst_wavparse_get_event_masks); + gst_pad_set_event_mask_function (wavparse->srcpad, + gst_wavparse_get_event_masks); gst_element_set_loop_function (GST_ELEMENT (wavparse), gst_wavparse_loop); @@ -191,25 +191,22 @@ gst_wavparse_init (GstWavParse *wavparse) } static void -gst_wavparse_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_wavparse_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GstWavParse *wavparse; wavparse = GST_WAVPARSE (object); switch (prop_id) { - default: - break; + default: + break; } } #if 0 static void -gst_wavparse_parse_adtl (GstWavParse *wavparse, - int len) +gst_wavparse_parse_adtl (GstWavParse * wavparse, int len) { guint32 got_bytes; GstByteStream *bs = wavparse->bs; @@ -225,14 +222,15 @@ gst_wavparse_parse_adtl (GstWavParse *wavparse, GList *caps = NULL; props = wavparse->metadata->properties; - + while (len > 0) { - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); if (got_bytes != sizeof (gst_riff_chunk)) { return; } temp_chunk = (gst_riff_chunk *) tempdata; - + chunk.id = GUINT32_FROM_LE (temp_chunk->id); chunk.size = GUINT32_FROM_LE (temp_chunk->size); @@ -241,148 +239,149 @@ gst_wavparse_parse_adtl (GstWavParse *wavparse, len -= sizeof (gst_riff_chunk); continue; } - - switch (chunk.id) { - case GST_RIFF_adtl_labl: - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (struct _gst_riff_labl)); - if (got_bytes != sizeof (struct _gst_riff_labl)) { - return; - } - - temp_labl = (struct _gst_riff_labl *) tempdata; - labl.id = GUINT32_FROM_LE (temp_labl->id); - labl.size = GUINT32_FROM_LE (temp_labl->size); - labl.identifier = GUINT32_FROM_LE (temp_labl->identifier); - - gst_bytestream_flush (bs, sizeof (struct _gst_riff_labl)); - len -= sizeof (struct _gst_riff_labl); - - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, labl.size - 4); - if (got_bytes != labl.size - 4) { - return; - } - label_name = (char *) tempdata; - - gst_bytestream_flush (bs, ((labl.size - 4) + 1) & ~1); - len -= (( (labl.size - 4) + 1) & ~1); - - new_caps = gst_caps_new ("label", - "application/x-gst-metadata", - gst_props_new ( - "identifier", G_TYPE_INT (labl.identifier), - "name", G_TYPE_STRING (label_name), - NULL)); - - if (gst_props_get (props, "labels", &caps, NULL)) { - caps = g_list_append (caps, new_caps); - } else { - caps = g_list_append (NULL, new_caps); - - entry = gst_props_entry_new ("labels", GST_PROPS_GLIST (caps)); - gst_props_add_entry (props, entry); - } - - break; - - case GST_RIFF_adtl_ltxt: - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (struct _gst_riff_ltxt)); - if (got_bytes != sizeof (struct _gst_riff_ltxt)) { + switch (chunk.id) { + case GST_RIFF_adtl_labl: + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, + sizeof (struct _gst_riff_labl)); + if (got_bytes != sizeof (struct _gst_riff_labl)) { + return; + } + + temp_labl = (struct _gst_riff_labl *) tempdata; + labl.id = GUINT32_FROM_LE (temp_labl->id); + labl.size = GUINT32_FROM_LE (temp_labl->size); + labl.identifier = GUINT32_FROM_LE (temp_labl->identifier); + + gst_bytestream_flush (bs, sizeof (struct _gst_riff_labl)); + len -= sizeof (struct _gst_riff_labl); + + got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, labl.size - 4); + if (got_bytes != labl.size - 4) { + return; + } + + label_name = (char *) tempdata; + + gst_bytestream_flush (bs, ((labl.size - 4) + 1) & ~1); + len -= (((labl.size - 4) + 1) & ~1); + + new_caps = gst_caps_new ("label", + "application/x-gst-metadata", + gst_props_new ("identifier", G_TYPE_INT (labl.identifier), + "name", G_TYPE_STRING (label_name), NULL)); + + if (gst_props_get (props, "labels", &caps, NULL)) { + caps = g_list_append (caps, new_caps); + } else { + caps = g_list_append (NULL, new_caps); + + entry = gst_props_entry_new ("labels", GST_PROPS_GLIST (caps)); + gst_props_add_entry (props, entry); + } + + break; + + case GST_RIFF_adtl_ltxt: + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, + sizeof (struct _gst_riff_ltxt)); + if (got_bytes != sizeof (struct _gst_riff_ltxt)) { + return; + } + + temp_ltxt = (struct _gst_riff_ltxt *) tempdata; + ltxt.id = GUINT32_FROM_LE (temp_ltxt->id); + ltxt.size = GUINT32_FROM_LE (temp_ltxt->size); + ltxt.identifier = GUINT32_FROM_LE (temp_ltxt->identifier); + ltxt.length = GUINT32_FROM_LE (temp_ltxt->length); + ltxt.purpose = GUINT32_FROM_LE (temp_ltxt->purpose); + ltxt.country = GUINT16_FROM_LE (temp_ltxt->country); + ltxt.language = GUINT16_FROM_LE (temp_ltxt->language); + ltxt.dialect = GUINT16_FROM_LE (temp_ltxt->dialect); + ltxt.codepage = GUINT16_FROM_LE (temp_ltxt->codepage); + + gst_bytestream_flush (bs, sizeof (struct _gst_riff_ltxt)); + len -= sizeof (struct _gst_riff_ltxt); + + if (ltxt.size - 20 > 0) { + got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, ltxt.size - 20); + if (got_bytes != ltxt.size - 20) { + return; + } + + gst_bytestream_flush (bs, ((ltxt.size - 20) + 1) & ~1); + len -= (((ltxt.size - 20) + 1) & ~1); + + label_name = (char *) tempdata; + } else { + label_name = ""; + } + + new_caps = gst_caps_new ("ltxt", + "application/x-gst-metadata", + gst_props_new ("identifier", G_TYPE_INT (ltxt.identifier), + "name", G_TYPE_STRING (label_name), + "length", G_TYPE_INT (ltxt.length), NULL)); + + if (gst_props_get (props, "ltxts", &caps, NULL)) { + caps = g_list_append (caps, new_caps); + } else { + caps = g_list_append (NULL, new_caps); + + entry = gst_props_entry_new ("ltxts", GST_PROPS_GLIST (caps)); + gst_props_add_entry (props, entry); + } + + break; + + case GST_RIFF_adtl_note: + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, + sizeof (struct _gst_riff_note)); + if (got_bytes != sizeof (struct _gst_riff_note)) { + return; + } + + temp_note = (struct _gst_riff_note *) tempdata; + note.id = GUINT32_FROM_LE (temp_note->id); + note.size = GUINT32_FROM_LE (temp_note->size); + note.identifier = GUINT32_FROM_LE (temp_note->identifier); + + gst_bytestream_flush (bs, sizeof (struct _gst_riff_note)); + len -= sizeof (struct _gst_riff_note); + + got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, note.size - 4); + if (got_bytes != note.size - 4) { + return; + } + + gst_bytestream_flush (bs, ((note.size - 4) + 1) & ~1); + len -= (((note.size - 4) + 1) & ~1); + + label_name = (char *) tempdata; + + new_caps = gst_caps_new ("note", + "application/x-gst-metadata", + gst_props_new ("identifier", G_TYPE_INT (note.identifier), + "name", G_TYPE_STRING (label_name), NULL)); + + if (gst_props_get (props, "notes", &caps, NULL)) { + caps = g_list_append (caps, new_caps); + } else { + caps = g_list_append (NULL, new_caps); + + entry = gst_props_entry_new ("notes", GST_PROPS_GLIST (caps)); + gst_props_add_entry (props, entry); + } + + break; + + default: + g_print ("Unknown chunk: " GST_FOURCC_FORMAT "\n", + GST_FOURCC_ARGS (chunk.id)); return; - } - - temp_ltxt = (struct _gst_riff_ltxt *) tempdata; - ltxt.id = GUINT32_FROM_LE (temp_ltxt->id); - ltxt.size = GUINT32_FROM_LE (temp_ltxt->size); - ltxt.identifier = GUINT32_FROM_LE (temp_ltxt->identifier); - ltxt.length = GUINT32_FROM_LE (temp_ltxt->length); - ltxt.purpose = GUINT32_FROM_LE (temp_ltxt->purpose); - ltxt.country = GUINT16_FROM_LE (temp_ltxt->country); - ltxt.language = GUINT16_FROM_LE (temp_ltxt->language); - ltxt.dialect = GUINT16_FROM_LE (temp_ltxt->dialect); - ltxt.codepage = GUINT16_FROM_LE (temp_ltxt->codepage); - - gst_bytestream_flush (bs, sizeof (struct _gst_riff_ltxt)); - len -= sizeof (struct _gst_riff_ltxt); - - if (ltxt.size - 20 > 0) { - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, ltxt.size - 20); - if (got_bytes != ltxt.size - 20) { - return; - } - - gst_bytestream_flush (bs, ((ltxt.size - 20) + 1) & ~1); - len -= (( (ltxt.size - 20) + 1) & ~1); - - label_name = (char *) tempdata; - } else { - label_name = ""; - } - - new_caps = gst_caps_new ("ltxt", - "application/x-gst-metadata", - gst_props_new ( - "identifier", G_TYPE_INT (ltxt.identifier), - "name", G_TYPE_STRING (label_name), - "length", G_TYPE_INT (ltxt.length), - NULL)); - - if (gst_props_get (props, "ltxts", &caps, NULL)) { - caps = g_list_append (caps, new_caps); - } else { - caps = g_list_append (NULL, new_caps); - - entry = gst_props_entry_new ("ltxts", GST_PROPS_GLIST (caps)); - gst_props_add_entry (props, entry); - } - - break; - - case GST_RIFF_adtl_note: - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (struct _gst_riff_note)); - if (got_bytes != sizeof (struct _gst_riff_note)) { - return; - } - - temp_note = (struct _gst_riff_note *) tempdata; - note.id = GUINT32_FROM_LE (temp_note->id); - note.size = GUINT32_FROM_LE (temp_note->size); - note.identifier = GUINT32_FROM_LE (temp_note->identifier); - - gst_bytestream_flush (bs, sizeof (struct _gst_riff_note)); - len -= sizeof (struct _gst_riff_note); - - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, note.size - 4); - if (got_bytes != note.size - 4) { - return; - } - - gst_bytestream_flush (bs, ((note.size - 4) + 1) & ~1); - len -= (( (note.size - 4) + 1) & ~1); - - label_name = (char *) tempdata; - - new_caps = gst_caps_new ("note", - "application/x-gst-metadata", - gst_props_new ( - "identifier", G_TYPE_INT (note.identifier), - "name", G_TYPE_STRING (label_name), - NULL)); - - if (gst_props_get (props, "notes", &caps, NULL)) { - caps = g_list_append (caps, new_caps); - } else { - caps = g_list_append (NULL, new_caps); - - entry = gst_props_entry_new ("notes", GST_PROPS_GLIST (caps)); - gst_props_add_entry (props, entry); - } - - break; - - default: - g_print ("Unknown chunk: " GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS(chunk.id)); - return; } } @@ -392,19 +391,19 @@ gst_wavparse_parse_adtl (GstWavParse *wavparse, #if 0 static void -gst_wavparse_parse_info (GstWavParse *wavparse, - int len) +gst_wavparse_parse_info (GstWavParse * wavparse, int len) { gst_riff_chunk *temp_chunk, chunk; GstByteStream *bs = wavparse->bs; guint8 *tempdata; guint32 got_bytes; char *name, *type; - + while (len > 0) { - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); temp_chunk = (gst_riff_chunk *) tempdata; - + chunk.id = GUINT32_FROM_LE (temp_chunk->id); chunk.size = GUINT32_FROM_LE (temp_chunk->size); @@ -412,87 +411,87 @@ gst_wavparse_parse_info (GstWavParse *wavparse, if (got_bytes != sizeof (gst_riff_chunk)) { return; } - + /* move our pointer on past the header */ len -= sizeof (gst_riff_chunk); - + if (chunk.size == 0) { continue; } - + got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, chunk.size); name = (char *) tempdata; if (got_bytes != chunk.size) { return; } - + /* move our pointer on past the data ... on an even boundary */ - gst_bytestream_flush (bs, (chunk.size + 1) & ~1); + gst_bytestream_flush (bs, (chunk.size + 1) & ~1); len -= ((chunk.size + 1) & ~1); /* We now have an info string in 'name' of type chunk.id - find type */ switch (chunk.id) { - case GST_RIFF_INFO_IARL: - type = "Location"; - break; - - case GST_RIFF_INFO_IART: - type = "Artist"; - break; - - case GST_RIFF_INFO_ICMS: - type = "Commissioner"; - break; - - case GST_RIFF_INFO_ICMT: - type = "Comment"; - break; - - case GST_RIFF_INFO_ICOP: - type = "Copyright"; - break; - - case GST_RIFF_INFO_ICRD: - type = "Creation Date"; - break; - - case GST_RIFF_INFO_IENG: - type = "Engineer"; - break; - - case GST_RIFF_INFO_IGNR: - type = "Genre"; - break; - - case GST_RIFF_INFO_IKEY: - type = "Keywords"; - break; - - case GST_RIFF_INFO_INAM: - type = "Title"; /* name */ - break; - - case GST_RIFF_INFO_IPRD: - type = "Product"; - break; - - case GST_RIFF_INFO_ISBJ: - type = "Subject"; - break; - - case GST_RIFF_INFO_ISFT: - type = "Software"; - break; - - case GST_RIFF_INFO_ITCH: - type = "Technician"; - break; - - default: - g_print ("Unknown: %4.4s\n", (char *) &chunk.id); - type = NULL; - break; + case GST_RIFF_INFO_IARL: + type = "Location"; + break; + + case GST_RIFF_INFO_IART: + type = "Artist"; + break; + + case GST_RIFF_INFO_ICMS: + type = "Commissioner"; + break; + + case GST_RIFF_INFO_ICMT: + type = "Comment"; + break; + + case GST_RIFF_INFO_ICOP: + type = "Copyright"; + break; + + case GST_RIFF_INFO_ICRD: + type = "Creation Date"; + break; + + case GST_RIFF_INFO_IENG: + type = "Engineer"; + break; + + case GST_RIFF_INFO_IGNR: + type = "Genre"; + break; + + case GST_RIFF_INFO_IKEY: + type = "Keywords"; + break; + + case GST_RIFF_INFO_INAM: + type = "Title"; /* name */ + break; + + case GST_RIFF_INFO_IPRD: + type = "Product"; + break; + + case GST_RIFF_INFO_ISBJ: + type = "Subject"; + break; + + case GST_RIFF_INFO_ISFT: + type = "Software"; + break; + + case GST_RIFF_INFO_ITCH: + type = "Technician"; + break; + + default: + g_print ("Unknown: %4.4s\n", (char *) &chunk.id); + type = NULL; + break; } if (type) { @@ -509,8 +508,7 @@ gst_wavparse_parse_info (GstWavParse *wavparse, #if 0 static void -gst_wavparse_parse_cues (GstWavParse *wavparse, - int len) +gst_wavparse_parse_cues (GstWavParse * wavparse, int len) { guint32 got_bytes; GstByteStream *bs = wavparse->bs; @@ -523,8 +521,10 @@ gst_wavparse_parse_cues (GstWavParse *wavparse, while (len > 0) { int required; - - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (struct _gst_riff_cue)); + + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, + sizeof (struct _gst_riff_cue)); temp_cue = (struct _gst_riff_cue *) tempdata; /* fixup for our big endian friends */ @@ -548,33 +548,31 @@ gst_wavparse_parse_cues (GstWavParse *wavparse, return; } - len -= ( ((cue.size - 4) + 1) & ~1); + len -= (((cue.size - 4) + 1) & ~1); /* now we have an array of struct _gst_riff_cuepoints in tempdata */ points = (struct _gst_riff_cuepoints *) tempdata; - + for (i = 0; i < cue.cuepoints; i++) { GstCaps *caps; caps = gst_caps_new ("cues", - "application/x-gst-metadata", - gst_props_new ( - "identifier", G_TYPE_INT (points[i].identifier), - "position", G_TYPE_INT (points[i].offset), - NULL)); + "application/x-gst-metadata", + gst_props_new ("identifier", G_TYPE_INT (points[i].identifier), + "position", G_TYPE_INT (points[i].offset), NULL)); cues = g_list_append (cues, caps); } - + entry = gst_props_entry_new ("cues", GST_PROPS_GLIST (cues)); gst_props_add_entry (wavparse->metadata->properties, entry); } - + g_object_notify (G_OBJECT (wavparse), "metadata"); } #endif static void -gst_wavparse_parse_fmt (GstWavParse *wavparse, guint size) +gst_wavparse_parse_fmt (GstWavParse * wavparse, guint size) { GstWavParseFormat *format; GstCaps *caps = NULL; @@ -582,7 +580,8 @@ gst_wavparse_parse_fmt (GstWavParse *wavparse, guint size) GstByteStream *bs = wavparse->bs; guint32 got_bytes; - got_bytes = gst_bytestream_peek_bytes (bs, &fmtdata, sizeof (GstWavParseFormat)); + got_bytes = + gst_bytestream_peek_bytes (bs, &fmtdata, sizeof (GstWavParseFormat)); format = (GstWavParseFormat *) fmtdata; if (got_bytes == sizeof (GstWavParseFormat)) { @@ -596,49 +595,47 @@ gst_wavparse_parse_fmt (GstWavParse *wavparse, guint size) /* set the caps on the src pad */ /* FIXME: handle all of the other formats as well */ switch (wavparse->format) { - case GST_RIFF_WAVE_FORMAT_ALAW: - case GST_RIFF_WAVE_FORMAT_MULAW: { - char *mime = (wavparse->format == GST_RIFF_WAVE_FORMAT_ALAW) ? - "audio/x-alaw" : "audio/x-mulaw"; - if (wavparse->width != 8) { - g_warning ("Ignoring invalid width %d", wavparse->width); - return; + case GST_RIFF_WAVE_FORMAT_ALAW: + case GST_RIFF_WAVE_FORMAT_MULAW:{ + char *mime = (wavparse->format == GST_RIFF_WAVE_FORMAT_ALAW) ? + "audio/x-alaw" : "audio/x-mulaw"; + if (wavparse->width != 8) { + g_warning ("Ignoring invalid width %d", wavparse->width); + return; + } + + caps = gst_caps_new_simple (mime, + "rate", G_TYPE_INT, wavparse->rate, + "channels", G_TYPE_INT, wavparse->channels, NULL); } - - caps = gst_caps_new_simple (mime, - "rate", G_TYPE_INT, wavparse->rate, - "channels", G_TYPE_INT, wavparse->channels, - NULL); - } - break; - - case GST_RIFF_WAVE_FORMAT_PCM: - caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, - "signed", G_TYPE_BOOLEAN, (wavparse->width > 8) ? TRUE : FALSE, - "width", G_TYPE_INT, wavparse->width, - "depth", G_TYPE_INT, wavparse->width, - "rate", G_TYPE_INT, wavparse->rate, - "channels", G_TYPE_INT, wavparse->channels, - NULL); - break; - - case GST_RIFF_WAVE_FORMAT_MPEGL12: - case GST_RIFF_WAVE_FORMAT_MPEGL3: { - int layer = (wavparse->format == GST_RIFF_WAVE_FORMAT_MPEGL12) ? 2 : 3; - - caps = gst_caps_new_simple ("audio/mpeg", - "mpegversion", G_TYPE_INT, 1, - "layer", G_TYPE_INT, layer, - "rate", G_TYPE_INT, wavparse->rate, - "channels", G_TYPE_INT, wavparse->channels, - NULL); - } - break; - - default: - GST_ELEMENT_ERROR (wavparse, STREAM, NOT_IMPLEMENTED, (NULL), ("format %d not handled", wavparse->format)); - return; + break; + + case GST_RIFF_WAVE_FORMAT_PCM: + caps = gst_caps_new_simple ("audio/x-raw-int", + "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, + "signed", G_TYPE_BOOLEAN, (wavparse->width > 8) ? TRUE : FALSE, + "width", G_TYPE_INT, wavparse->width, + "depth", G_TYPE_INT, wavparse->width, + "rate", G_TYPE_INT, wavparse->rate, + "channels", G_TYPE_INT, wavparse->channels, NULL); + break; + + case GST_RIFF_WAVE_FORMAT_MPEGL12: + case GST_RIFF_WAVE_FORMAT_MPEGL3:{ + int layer = (wavparse->format == GST_RIFF_WAVE_FORMAT_MPEGL12) ? 2 : 3; + + caps = gst_caps_new_simple ("audio/mpeg", + "mpegversion", G_TYPE_INT, 1, + "layer", G_TYPE_INT, layer, + "rate", G_TYPE_INT, wavparse->rate, + "channels", G_TYPE_INT, wavparse->channels, NULL); + } + break; + + default: + GST_ELEMENT_ERROR (wavparse, STREAM, NOT_IMPLEMENTED, (NULL), + ("format %d not handled", wavparse->format)); + return; } if (caps) { @@ -651,42 +648,42 @@ gst_wavparse_parse_fmt (GstWavParse *wavparse, guint size) } static gboolean -gst_wavparse_handle_sink_event (GstWavParse *wavparse) +gst_wavparse_handle_sink_event (GstWavParse * wavparse) { guint32 remaining; GstEvent *event; GstEventType type; gboolean res = TRUE; - + gst_bytestream_get_status (wavparse->bs, &remaining, &event); - + type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; GST_DEBUG ("wavparse: event %p %d", event, type); - + switch (type) { - case GST_EVENT_EOS: - gst_bytestream_flush (wavparse->bs, remaining); - gst_pad_event_default (wavparse->sinkpad, event); - res = FALSE; - goto done; - - case GST_EVENT_FLUSH: - g_warning ("Wavparse: Flush event"); - break; - - default: - g_warning ("Wavparse: Unhandled event %d", type); - break; + case GST_EVENT_EOS: + gst_bytestream_flush (wavparse->bs, remaining); + gst_pad_event_default (wavparse->sinkpad, event); + res = FALSE; + goto done; + + case GST_EVENT_FLUSH: + g_warning ("Wavparse: Flush event"); + break; + + default: + g_warning ("Wavparse: Unhandled event %d", type); + break; } gst_event_unref (event); - done: +done: return res; } - + static void -gst_wavparse_loop (GstElement *element) +gst_wavparse_loop (GstElement * element) { GstWavParse *wavparse; gst_riff_riff chunk; @@ -700,25 +697,24 @@ gst_wavparse_loop (GstElement *element) if (wavparse->seek_pending) { GST_DEBUG ("wavparse: seek pending to %" G_GINT64_FORMAT " %08llx", - wavparse->seek_offset, - (unsigned long long) wavparse->seek_offset); - + wavparse->seek_offset, (unsigned long long) wavparse->seek_offset); + if (!gst_bytestream_seek (bs, wavparse->seek_offset, GST_SEEK_METHOD_SET)) { GST_INFO ("wavparse: Could not seek"); } - + wavparse->seek_pending = FALSE; } - + if (wavparse->state == GST_WAVPARSE_DATA) { GstBuffer *buf; int desired; - + /* This seems to want the whole chunk, Will this screw up streaming? Does anyone care about streaming wavs? FIXME: Should we have a decent buffer size? */ - + #define MAX_BUFFER_SIZE 1024 if (wavparse->dataleft > 0) { @@ -726,15 +722,16 @@ gst_wavparse_loop (GstElement *element) got_bytes = gst_bytestream_peek (bs, &buf, desired); if (got_bytes != desired) { - /* EOS? */ - GstEvent *event; - guint32 remaining; - gst_bytestream_get_status (bs, &remaining, &event); - if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) { - gst_pad_event_default (wavparse->sinkpad, event); - } else { - GST_ELEMENT_ERROR (element, RESOURCE, READ, (NULL), (NULL)); - } + /* EOS? */ + GstEvent *event; + guint32 remaining; + + gst_bytestream_get_status (bs, &remaining, &event); + if (event && GST_EVENT_TYPE (event) == GST_EVENT_EOS) { + gst_pad_event_default (wavparse->sinkpad, event); + } else { + GST_ELEMENT_ERROR (element, RESOURCE, READ, (NULL), (NULL)); + } return; } @@ -742,7 +739,7 @@ gst_wavparse_loop (GstElement *element) wavparse->byteoffset += got_bytes; gst_bytestream_flush (bs, got_bytes); - + gst_pad_push (wavparse->srcpad, GST_DATA (buf)); return; } else { @@ -754,51 +751,53 @@ gst_wavparse_loop (GstElement *element) gst_riff_riff *temp_chunk; guint8 *tempdata; guint32 skipsize; - + /* read first two dwords to get chunktype and size */ while (TRUE) { - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_chunk)); temp_chunk = (gst_riff_riff *) tempdata; if (got_bytes < sizeof (gst_riff_chunk)) { - if (!gst_wavparse_handle_sink_event (wavparse)) { - return; - } + if (!gst_wavparse_handle_sink_event (wavparse)) { + return; + } } else { - break; + break; } } - + chunk.id = GUINT32_FROM_LE (temp_chunk->id); chunk.size = GUINT32_FROM_LE (temp_chunk->size); switch (chunk.id) { - case GST_RIFF_TAG_RIFF: - case GST_RIFF_TAG_LIST: - /* Read complete list chunk */ - while (TRUE) { - got_bytes = gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_list)); - temp_chunk = (gst_riff_riff *) tempdata; - if (got_bytes < sizeof (gst_riff_list)) { - if (!gst_wavparse_handle_sink_event (wavparse)) { - return; + case GST_RIFF_TAG_RIFF: + case GST_RIFF_TAG_LIST: + /* Read complete list chunk */ + while (TRUE) { + got_bytes = + gst_bytestream_peek_bytes (bs, &tempdata, sizeof (gst_riff_list)); + temp_chunk = (gst_riff_riff *) tempdata; + if (got_bytes < sizeof (gst_riff_list)) { + if (!gst_wavparse_handle_sink_event (wavparse)) { + return; + } + } else { + break; } - } else { - break; } - } - - chunk.type = GUINT32_FROM_LE (temp_chunk->type); - skipsize = sizeof (gst_riff_list); - break; - case GST_RIFF_TAG_cue: - skipsize = 0; - break; - - default: - skipsize = sizeof (gst_riff_chunk); - break; + chunk.type = GUINT32_FROM_LE (temp_chunk->type); + skipsize = sizeof (gst_riff_list); + break; + + case GST_RIFF_TAG_cue: + skipsize = 0; + break; + + default: + skipsize = sizeof (gst_riff_chunk); + break; } gst_bytestream_flush (bs, skipsize); } while (FALSE); @@ -807,75 +806,74 @@ gst_wavparse_loop (GstElement *element) flush = (chunk.size + 1) & ~1; switch (wavparse->state) { - case GST_WAVPARSE_START: - if (chunk.id != GST_RIFF_TAG_RIFF && - chunk.type != GST_RIFF_RIFF_WAVE) { - GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL), - ("chunk.id %08x chunk.type %08x", chunk.id, chunk.type)); - return; - } - - wavparse->state = GST_WAVPARSE_OTHER; - /* We are not going to flush lists */ - flush = 0; - break; - - case GST_WAVPARSE_OTHER: - GST_DEBUG ("riff tag: %4.4s %08x", (char *) &chunk.id, chunk.size); - - switch (chunk.id) { - case GST_RIFF_TAG_data: - wavparse->state = GST_WAVPARSE_DATA; - wavparse->dataleft = chunk.size; - wavparse->byteoffset = 0; - flush = 0; - break; - - case GST_RIFF_TAG_fmt: - gst_wavparse_parse_fmt (wavparse, chunk.size); + case GST_WAVPARSE_START: + if (chunk.id != GST_RIFF_TAG_RIFF && chunk.type != GST_RIFF_RIFF_WAVE) { + GST_ELEMENT_ERROR (element, STREAM, WRONG_TYPE, (NULL), + ("chunk.id %08x chunk.type %08x", chunk.id, chunk.type)); + return; + } + + wavparse->state = GST_WAVPARSE_OTHER; + /* We are not going to flush lists */ flush = 0; break; - case GST_RIFF_TAG_cue: - //gst_wavparse_parse_cues (wavparse, chunk.size); - break; - - case GST_RIFF_TAG_LIST: - GST_DEBUG ("list type: %4.4s", (char *) &chunk.type); - switch (chunk.type) { - case GST_RIFF_LIST_INFO: - //gst_wavparse_parse_info (wavparse, chunk.size - 4); - //flush = 0; + case GST_WAVPARSE_OTHER: + GST_DEBUG ("riff tag: %4.4s %08x", (char *) &chunk.id, chunk.size); - break; - - case GST_RIFF_LIST_adtl: - //gst_wavparse_parse_adtl (wavparse, chunk.size - 4); - //flush = 0; - break; + switch (chunk.id) { + case GST_RIFF_TAG_data: + wavparse->state = GST_WAVPARSE_DATA; + wavparse->dataleft = chunk.size; + wavparse->byteoffset = 0; + flush = 0; + break; - default: - //flush = 0; - break; + case GST_RIFF_TAG_fmt: + gst_wavparse_parse_fmt (wavparse, chunk.size); + flush = 0; + break; + + case GST_RIFF_TAG_cue: + //gst_wavparse_parse_cues (wavparse, chunk.size); + break; + + case GST_RIFF_TAG_LIST: + GST_DEBUG ("list type: %4.4s", (char *) &chunk.type); + switch (chunk.type) { + case GST_RIFF_LIST_INFO: + //gst_wavparse_parse_info (wavparse, chunk.size - 4); + //flush = 0; + + break; + + case GST_RIFF_LIST_adtl: + //gst_wavparse_parse_adtl (wavparse, chunk.size - 4); + //flush = 0; + break; + + default: + //flush = 0; + break; + } + + default: + GST_DEBUG (" ***** unknown chunkid %08x", chunk.id); + //flush = 0; + break; } - + break; + + case GST_WAVPARSE_DATA: + /* Should have been handled up there ^^^^ */ + flush = 0; + break; + default: - GST_DEBUG (" ***** unknown chunkid %08x", chunk.id); - //flush = 0; - break; - } - break; - - case GST_WAVPARSE_DATA: - /* Should have been handled up there ^^^^ */ - flush = 0; - break; - - default: - /* Unknown */ - g_warning ("Unknown state %d\n", wavparse->state); - //GST_DEBUG (" ***** unknown chunkid %08x", chunk.id); - break; + /* Unknown */ + g_warning ("Unknown state %d\n", wavparse->state); + //GST_DEBUG (" ***** unknown chunkid %08x", chunk.id); + break; } if (flush > 0) { @@ -888,18 +886,18 @@ gst_wavparse_loop (GstElement *element) gst_bytestream_get_status (bs, &remaining, &event); gst_event_unref (event); - } + } } } /* convert and query stuff */ static const GstFormat * -gst_wavparse_get_formats (GstPad *pad) +gst_wavparse_get_formats (GstPad * pad) { static GstFormat formats[] = { GST_FORMAT_TIME, GST_FORMAT_BYTES, - GST_FORMAT_DEFAULT, /* a "frame", ie a set of samples per Hz */ + GST_FORMAT_DEFAULT, /* a "frame", ie a set of samples per Hz */ 0, 0 }; @@ -907,9 +905,9 @@ gst_wavparse_get_formats (GstPad *pad) } static gboolean -gst_wavparse_pad_convert (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_wavparse_pad_convert (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { gint bytes_per_sample; glong byterate; @@ -919,11 +917,11 @@ gst_wavparse_pad_convert (GstPad *pad, gboolean dest_format_ok = FALSE; wavparse = GST_WAVPARSE (gst_pad_get_parent (pad)); - + bytes_per_sample = wavparse->channels * wavparse->width / 8; if (bytes_per_sample == 0) { GST_DEBUG ("bytes_per_sample 0, probably an mp3 - channels %d, width %d", - wavparse->channels, wavparse->width); + wavparse->channels, wavparse->width); return FALSE; } byterate = (glong) (bytes_per_sample * wavparse->rate); @@ -936,8 +934,12 @@ gst_wavparse_pad_convert (GstPad *pad, formats = gst_pad_get_formats (pad); while (formats && *formats) { - if (src_format == *formats) { src_format_ok = TRUE; } - if (*dest_format == *formats) { dest_format_ok = TRUE; } + if (src_format == *formats) { + src_format_ok = TRUE; + } + if (*dest_format == *formats) { + dest_format_ok = TRUE; + } formats++; } if (!src_format_ok || !dest_format_ok) { @@ -949,23 +951,23 @@ gst_wavparse_pad_convert (GstPad *pad, switch (src_format) { case GST_FORMAT_BYTES: if (*dest_format == GST_FORMAT_DEFAULT) - *dest_value = src_value / bytes_per_sample; + *dest_value = src_value / bytes_per_sample; else if (*dest_format == GST_FORMAT_TIME) - *dest_value = src_value * GST_SECOND / byterate; + *dest_value = src_value * GST_SECOND / byterate; else { - GST_DEBUG ("can't convert from bytes to other than units/time"); - return FALSE; + GST_DEBUG ("can't convert from bytes to other than units/time"); + return FALSE; } break; case GST_FORMAT_DEFAULT: if (*dest_format == GST_FORMAT_BYTES) - *dest_value = src_value * bytes_per_sample; + *dest_value = src_value * bytes_per_sample; else if (*dest_format == GST_FORMAT_TIME) - *dest_value = src_value * GST_SECOND / wavparse->rate; + *dest_value = src_value * GST_SECOND / wavparse->rate; else { - GST_DEBUG ("can't convert from units to other than bytes/time"); - return FALSE; + GST_DEBUG ("can't convert from units to other than bytes/time"); + return FALSE; } break; case GST_FORMAT_TIME: @@ -974,8 +976,8 @@ gst_wavparse_pad_convert (GstPad *pad, else if (*dest_format == GST_FORMAT_DEFAULT) *dest_value = src_value * wavparse->rate / GST_SECOND; else { - GST_DEBUG ("can't convert from time to other than bytes/units"); - return FALSE; + GST_DEBUG ("can't convert from time to other than bytes/units"); + return FALSE; } *dest_value = *dest_value & ~(bytes_per_sample - 1); @@ -986,9 +988,9 @@ gst_wavparse_pad_convert (GstPad *pad, } return TRUE; } - + static const GstQueryType * -gst_wavparse_get_query_types (GstPad *pad) +gst_wavparse_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -1000,8 +1002,8 @@ gst_wavparse_get_query_types (GstPad *pad) /* handle queries for location and length in requested format */ static gboolean -gst_wavparse_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_wavparse_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFormat peer_format = GST_FORMAT_BYTES; gint64 peer_value; @@ -1010,16 +1012,16 @@ gst_wavparse_pad_query (GstPad *pad, GstQueryType type, /* probe sink's peer pad, convert value, and that's it :) */ /* FIXME: ideally we'd loop over possible formats of peer instead * of only using BYTE */ - + /* only support byte, time and unit queries */ wavparse = GST_WAVPARSE (gst_pad_get_parent (pad)); - if (!gst_pad_query (GST_PAD_PEER (wavparse->sinkpad), type, - &peer_format, &peer_value)) { + if (!gst_pad_query (GST_PAD_PEER (wavparse->sinkpad), type, + &peer_format, &peer_value)) { GST_DEBUG ("Could not query sink pad's peer"); return FALSE; } if (!gst_pad_convert (wavparse->sinkpad, peer_format, peer_value, - format, value)) { + format, value)) { GST_DEBUG ("Could not convert sink pad's peer"); return FALSE; } @@ -1027,19 +1029,18 @@ gst_wavparse_pad_query (GstPad *pad, GstQueryType type, return TRUE; } -static const GstEventMask* -gst_wavparse_get_event_masks (GstPad *pad) -{ +static const GstEventMask * +gst_wavparse_get_event_masks (GstPad * pad) +{ static const GstEventMask gst_wavparse_src_event_masks[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH }, - { 0, } + {GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH}, + {0,} }; return gst_wavparse_src_event_masks; -} +} static gboolean -gst_wavparse_srcpad_event (GstPad *pad, GstEvent *event) +gst_wavparse_srcpad_event (GstPad * pad, GstEvent * event) { #if 0 GstWavParse *wavparse = GST_WAVPARSE (GST_PAD_PARENT (pad)); @@ -1059,15 +1060,13 @@ gst_wavparse_srcpad_event (GstPad *pad, GstEvent *event) } format = GST_FORMAT_BYTES; - + /* bring format to bytes for the peer element, * FIXME be smarter here */ - res = gst_pad_convert (pad, - GST_EVENT_SEEK_FORMAT (event), - GST_EVENT_SEEK_OFFSET (event), - &format, - &byteoffset); - + res = gst_pad_convert (pad, + GST_EVENT_SEEK_FORMAT (event), + GST_EVENT_SEEK_OFFSET (event), &format, &byteoffset); + if (res) { /* ok, seek worked, update our state */ wavparse->seek_offset = byteoffset; @@ -1088,7 +1087,7 @@ gst_wavparse_srcpad_event (GstPad *pad, GstEvent *event) } static GstElementStateReturn -gst_wavparse_change_state (GstElement *element) +gst_wavparse_change_state (GstElement * element) { GstWavParse *wavparse = GST_WAVPARSE (element); @@ -1121,23 +1120,18 @@ gst_wavparse_change_state (GstElement *element) } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { if (!gst_library_load ("gstbytestream")) { return FALSE; } - return gst_element_register (plugin, "wavparse", GST_RANK_SECONDARY, GST_TYPE_WAVPARSE); + return gst_element_register (plugin, "wavparse", GST_RANK_SECONDARY, + GST_TYPE_WAVPARSE); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "wavparse", - "Parse a .wav file into raw audio", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "wavparse", + "Parse a .wav file into raw audio", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/gst/wavparse/gstwavparse.h b/gst/wavparse/gstwavparse.h index 3893a293..b8cdd2de 100644 --- a/gst/wavparse/gstwavparse.h +++ b/gst/wavparse/gstwavparse.h @@ -27,8 +27,9 @@ #include <gst/bytestream/bytestream.h> #ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +extern "C" +{ +#endif /* __cplusplus */ #define GST_TYPE_WAVPARSE \ @@ -44,59 +45,62 @@ extern "C" { #define GST_WAVPARSE_UNKNOWN 0 /* initialized state */ -#define GST_WAVPARSE_START 1 /* At the start */ +#define GST_WAVPARSE_START 1 /* At the start */ #define GST_WAVPARSE_DATA 2 /* in data region */ #define GST_WAVPARSE_OTHER 3 /* in unknown region */ - -typedef struct _GstWavParse GstWavParse; -typedef struct _GstWavParseClass GstWavParseClass; - -struct _GstWavParse { - GstElement element; - - GstByteStream *bs; - /* pads */ - GstPad *sinkpad,*srcpad; - - /* WAVE decoding state */ - gint state; - - /* format of audio, see defines below */ - gint format; - - /* useful audio data */ - gint bps; - gint rate; - gint channels; - gint width; - - int dataleft; - int byteoffset; - - gboolean seek_pending; - guint64 seek_offset; - - GstBuffer *buf; -}; - -struct _GstWavParseClass { - GstElementClass parent_class; -}; - -GType gst_wavparse_get_type(void); - -typedef struct _GstWavParseFormat GstWavParseFormat; - -struct _GstWavParseFormat { - gint16 wFormatTag; - guint16 wChannels; - guint32 dwSamplesPerSec; - guint32 dwAvgBytesPerSec; - guint16 wBlockAlign; - guint16 wBitsPerSample; -}; - - + + typedef struct _GstWavParse GstWavParse; + typedef struct _GstWavParseClass GstWavParseClass; + + struct _GstWavParse + { + GstElement element; + + GstByteStream *bs; + /* pads */ + GstPad *sinkpad, *srcpad; + + /* WAVE decoding state */ + gint state; + + /* format of audio, see defines below */ + gint format; + + /* useful audio data */ + gint bps; + gint rate; + gint channels; + gint width; + + int dataleft; + int byteoffset; + + gboolean seek_pending; + guint64 seek_offset; + + GstBuffer *buf; + }; + + struct _GstWavParseClass + { + GstElementClass parent_class; + }; + + GType gst_wavparse_get_type (void); + + typedef struct _GstWavParseFormat GstWavParseFormat; + + struct _GstWavParseFormat + { + gint16 wFormatTag; + guint16 wChannels; + guint32 dwSamplesPerSec; + guint32 dwAvgBytesPerSec; + guint16 wBlockAlign; + guint16 wBitsPerSample; + }; + + /**** from public Microsoft RIFF docs ******/ #define GST_RIFF_WAVE_FORMAT_UNKNOWN (0x0000) #define GST_RIFF_WAVE_FORMAT_PCM (0x0001) @@ -129,7 +133,7 @@ struct _GstWavParseFormat { #ifdef __cplusplus } -#endif /* __cplusplus */ +#endif /* __cplusplus */ -#endif /* __GST_WAVPARSE_H__ */ +#endif /* __GST_WAVPARSE_H__ */ diff --git a/gst/wavparse/riff.h b/gst/wavparse/riff.h index 141ed1fa..bf18a1fe 100644 --- a/gst/wavparse/riff.h +++ b/gst/wavparse/riff.h @@ -24,11 +24,12 @@ #include <gst/gst.h> -typedef enum { - GST_RIFF_OK = 0, +typedef enum +{ + GST_RIFF_OK = 0, GST_RIFF_ENOTRIFF = -1, - GST_RIFF_EINVAL = -2, - GST_RIFF_ENOMEM = -3 + GST_RIFF_EINVAL = -2, + GST_RIFF_ENOMEM = -3 } GstRiffReturn; #define MAKE_FOUR_CC(a,b,c,d) GST_MAKE_FOURCC(a,b,c,d) @@ -81,29 +82,29 @@ typedef enum { #define GST_RIFF_FCCH_MSVC MAKE_FOUR_CC('M','S','V','C') /* INFO types - see http://www.saettler.com/RIFFMCI/riffmci.html */ -#define GST_RIFF_INFO_IARL MAKE_FOUR_CC('I','A','R','L') /* location */ -#define GST_RIFF_INFO_IART MAKE_FOUR_CC('I','A','R','T') /* artist */ -#define GST_RIFF_INFO_ICMS MAKE_FOUR_CC('I','C','M','S') /* commissioned */ -#define GST_RIFF_INFO_ICMT MAKE_FOUR_CC('I','C','M','T') /* comment */ -#define GST_RIFF_INFO_ICOP MAKE_FOUR_CC('I','C','O','P') /* copyright */ -#define GST_RIFF_INFO_ICRD MAKE_FOUR_CC('I','C','R','D') /* creation date */ -#define GST_RIFF_INFO_ICRP MAKE_FOUR_CC('I','C','R','P') /* cropped */ -#define GST_RIFF_INFO_IDIM MAKE_FOUR_CC('I','D','I','M') /* dimensions */ -#define GST_RIFF_INFO_IDPI MAKE_FOUR_CC('I','D','P','I') /* dots-per-inch */ -#define GST_RIFF_INFO_IENG MAKE_FOUR_CC('I','E','N','G') /* engineer(s) */ -#define GST_RIFF_INFO_IGNR MAKE_FOUR_CC('I','G','N','R') /* genre */ -#define GST_RIFF_INFO_IKEY MAKE_FOUR_CC('I','K','E','Y') /* keywords */ -#define GST_RIFF_INFO_ILGT MAKE_FOUR_CC('I','L','G','T') /* lightness */ -#define GST_RIFF_INFO_IMED MAKE_FOUR_CC('I','M','E','D') /* medium */ -#define GST_RIFF_INFO_INAM MAKE_FOUR_CC('I','N','A','M') /* name */ -#define GST_RIFF_INFO_IPLT MAKE_FOUR_CC('I','P','L','T') /* palette setting */ -#define GST_RIFF_INFO_IPRD MAKE_FOUR_CC('I','P','R','D') /* product */ -#define GST_RIFF_INFO_ISBJ MAKE_FOUR_CC('I','S','B','J') /* subject */ -#define GST_RIFF_INFO_ISFT MAKE_FOUR_CC('I','S','F','T') /* software */ -#define GST_RIFF_INFO_ISHP MAKE_FOUR_CC('I','S','H','P') /* sharpness */ -#define GST_RIFF_INFO_ISRC MAKE_FOUR_CC('I','S','R','C') /* source */ -#define GST_RIFF_INFO_ISRF MAKE_FOUR_CC('I','S','R','F') /* source form */ -#define GST_RIFF_INFO_ITCH MAKE_FOUR_CC('I','T','C','H') /* technician(s) */ +#define GST_RIFF_INFO_IARL MAKE_FOUR_CC('I','A','R','L') /* location */ +#define GST_RIFF_INFO_IART MAKE_FOUR_CC('I','A','R','T') /* artist */ +#define GST_RIFF_INFO_ICMS MAKE_FOUR_CC('I','C','M','S') /* commissioned */ +#define GST_RIFF_INFO_ICMT MAKE_FOUR_CC('I','C','M','T') /* comment */ +#define GST_RIFF_INFO_ICOP MAKE_FOUR_CC('I','C','O','P') /* copyright */ +#define GST_RIFF_INFO_ICRD MAKE_FOUR_CC('I','C','R','D') /* creation date */ +#define GST_RIFF_INFO_ICRP MAKE_FOUR_CC('I','C','R','P') /* cropped */ +#define GST_RIFF_INFO_IDIM MAKE_FOUR_CC('I','D','I','M') /* dimensions */ +#define GST_RIFF_INFO_IDPI MAKE_FOUR_CC('I','D','P','I') /* dots-per-inch */ +#define GST_RIFF_INFO_IENG MAKE_FOUR_CC('I','E','N','G') /* engineer(s) */ +#define GST_RIFF_INFO_IGNR MAKE_FOUR_CC('I','G','N','R') /* genre */ +#define GST_RIFF_INFO_IKEY MAKE_FOUR_CC('I','K','E','Y') /* keywords */ +#define GST_RIFF_INFO_ILGT MAKE_FOUR_CC('I','L','G','T') /* lightness */ +#define GST_RIFF_INFO_IMED MAKE_FOUR_CC('I','M','E','D') /* medium */ +#define GST_RIFF_INFO_INAM MAKE_FOUR_CC('I','N','A','M') /* name */ +#define GST_RIFF_INFO_IPLT MAKE_FOUR_CC('I','P','L','T') /* palette setting */ +#define GST_RIFF_INFO_IPRD MAKE_FOUR_CC('I','P','R','D') /* product */ +#define GST_RIFF_INFO_ISBJ MAKE_FOUR_CC('I','S','B','J') /* subject */ +#define GST_RIFF_INFO_ISFT MAKE_FOUR_CC('I','S','F','T') /* software */ +#define GST_RIFF_INFO_ISHP MAKE_FOUR_CC('I','S','H','P') /* sharpness */ +#define GST_RIFF_INFO_ISRC MAKE_FOUR_CC('I','S','R','C') /* source */ +#define GST_RIFF_INFO_ISRF MAKE_FOUR_CC('I','S','R','F') /* source form */ +#define GST_RIFF_INFO_ITCH MAKE_FOUR_CC('I','T','C','H') /* technician(s) */ /*********Chunk Names***************/ #define GST_RIFF_FF00 MAKE_FOUR_CC(0xFF,0xFF,0x00,0x00) @@ -182,7 +183,7 @@ typedef enum { #define GST_RIFF_v422 MAKE_FOUR_CC( 'v', '4', '2', '2') #define GST_RIFF_V422 MAKE_FOUR_CC( 'V', '4', '2', '2') #define GST_RIFF_mvi1 MAKE_FOUR_CC( 'm', 'v', 'i', '1') -#define GST_RIFF_MPIX MAKE_FOUR_CC(0x04,0x00, 'i', '1') /* MotionPixels munged their id */ +#define GST_RIFF_MPIX MAKE_FOUR_CC(0x04,0x00, 'i', '1') /* MotionPixels munged their id */ #define GST_RIFF_AURA MAKE_FOUR_CC( 'A', 'U', 'R', 'A') #define GST_RIFF_DMB1 MAKE_FOUR_CC( 'D', 'M', 'B', '1') #define GST_RIFF_dmb1 MAKE_FOUR_CC( 'd', 'm', 'b', '1') @@ -218,7 +219,7 @@ typedef enum { #define GST_RIFF_rpza MAKE_FOUR_CC( 'r', 'p', 'z', 'a') /* And this here's the mistakes that need to be supported */ -#define GST_RIFF_azpr MAKE_FOUR_CC( 'a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */ +#define GST_RIFF_azpr MAKE_FOUR_CC( 'a', 'z', 'p', 'r') /* recognize Apple's rpza mangled? */ /*********** FND in MJPG **********/ #define GST_RIFF_ISFT MAKE_FOUR_CC( 'I', 'S', 'F', 'T') @@ -231,21 +232,22 @@ typedef enum { #define GST_RIFF_rec MAKE_FOUR_CC( 'r', 'e', 'c', ' ') /* common data structures */ -struct _gst_riff_avih { - guint32 us_frame; /* microsec per frame */ - guint32 max_bps; /* byte/s overall */ - guint32 pad_gran; /* pad_gran (???) */ +struct _gst_riff_avih +{ + guint32 us_frame; /* microsec per frame */ + guint32 max_bps; /* byte/s overall */ + guint32 pad_gran; /* pad_gran (???) */ guint32 flags; /* flags values */ -#define GST_RIFF_AVIH_HASINDEX 0x00000010 /* has idx1 chunk */ -#define GST_RIFF_AVIH_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */ -#define GST_RIFF_AVIH_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */ -#define GST_RIFF_AVIH_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */ -#define GST_RIFF_AVIH_COPYRIGHTED 0x00020000 /* contains copyrighted data */ - guint32 tot_frames; /* # of frames (all) */ - guint32 init_frames; /* initial frames (???) */ +#define GST_RIFF_AVIH_HASINDEX 0x00000010 /* has idx1 chunk */ +#define GST_RIFF_AVIH_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */ +#define GST_RIFF_AVIH_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */ +#define GST_RIFF_AVIH_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */ +#define GST_RIFF_AVIH_COPYRIGHTED 0x00020000 /* contains copyrighted data */ + guint32 tot_frames; /* # of frames (all) */ + guint32 init_frames; /* initial frames (???) */ guint32 streams; - guint32 bufsize; /* suggested buffer size */ + guint32 bufsize; /* suggested buffer size */ guint32 width; guint32 height; guint32 scale; @@ -254,26 +256,28 @@ struct _gst_riff_avih { guint32 length; }; -struct _gst_riff_strh { - guint32 type; /* stream type */ - guint32 fcc_handler; /* fcc_handler */ +struct _gst_riff_strh +{ + guint32 type; /* stream type */ + guint32 fcc_handler; /* fcc_handler */ guint32 flags; /* flags values */ #define GST_RIFF_STRH_DISABLED 0x000000001 #define GST_RIFF_STRH_VIDEOPALCHANGES 0x000010000 guint32 priority; - guint32 init_frames; /* initial frames (???) */ + guint32 init_frames; /* initial frames (???) */ guint32 scale; guint32 rate; guint32 start; guint32 length; - guint32 bufsize; /* suggested buffer size */ + guint32 bufsize; /* suggested buffer size */ guint32 quality; guint32 samplesize; /* XXX 16 bytes ? */ }; -struct _gst_riff_strf_vids { /* == BitMapInfoHeader */ +struct _gst_riff_strf_vids +{ /* == BitMapInfoHeader */ guint32 size; guint32 width; guint32 height; @@ -283,13 +287,14 @@ struct _gst_riff_strf_vids { /* == BitMapInfoHeader */ guint32 image_size; guint32 xpels_meter; guint32 ypels_meter; - guint32 num_colors; /* used colors */ - guint32 imp_colors; /* important colors */ + guint32 num_colors; /* used colors */ + guint32 imp_colors; /* important colors */ /* may be more for some codecs */ }; -struct _gst_riff_strf_auds { /* == WaveHeader (?) */ +struct _gst_riff_strf_auds +{ /* == WaveHeader (?) */ guint16 format; /**** from public Microsoft RIFF docs ******/ #define GST_RIFF_WAVE_FORMAT_UNKNOWN (0x0000) @@ -328,7 +333,8 @@ struct _gst_riff_strf_auds { /* == WaveHeader (?) */ guint16 size; }; -struct _gst_riff_strf_iavs { +struct _gst_riff_strf_iavs +{ guint32 DVAAuxSrc; guint32 DVAAuxCtl; guint32 DVAAuxSrc1; @@ -339,26 +345,30 @@ struct _gst_riff_strf_iavs { guint32 DVReserved2; }; -struct _gst_riff_riff { +struct _gst_riff_riff +{ guint32 id; guint32 size; guint32 type; }; -struct _gst_riff_list { +struct _gst_riff_list +{ guint32 id; guint32 size; guint32 type; }; -struct _gst_riff_labl { +struct _gst_riff_labl +{ guint32 id; guint32 size; guint32 identifier; }; -struct _gst_riff_ltxt { +struct _gst_riff_ltxt +{ guint32 id; guint32 size; @@ -371,14 +381,16 @@ struct _gst_riff_ltxt { guint16 codepage; }; -struct _gst_riff_note { +struct _gst_riff_note +{ guint32 id; guint32 size; guint32 identifier; }; -struct _gst_riff_cuepoints { +struct _gst_riff_cuepoints +{ guint32 identifier; guint32 position; guint32 id; @@ -387,19 +399,22 @@ struct _gst_riff_cuepoints { guint32 offset; }; -struct _gst_riff_cue { +struct _gst_riff_cue +{ guint32 id; guint32 size; - guint32 cuepoints; /* Number of cue points held in the data */ + guint32 cuepoints; /* Number of cue points held in the data */ }; -struct _gst_riff_chunk { +struct _gst_riff_chunk +{ guint32 id; guint32 size; }; -struct _gst_riff_index_entry { +struct _gst_riff_index_entry +{ guint32 id; guint32 flags; #define GST_RIFF_IF_LIST (0x00000001L) @@ -410,29 +425,31 @@ struct _gst_riff_index_entry { guint32 size; }; -struct _gst_riff_dmlh { +struct _gst_riff_dmlh +{ guint32 totalframes; }; -typedef struct _gst_riff_riff gst_riff_riff; -typedef struct _gst_riff_list gst_riff_list; -typedef struct _gst_riff_chunk gst_riff_chunk; -typedef struct _gst_riff_index_entry gst_riff_index_entry; - -typedef struct _gst_riff_avih gst_riff_avih; -typedef struct _gst_riff_strh gst_riff_strh; -typedef struct _gst_riff_strf_vids gst_riff_strf_vids; -typedef struct _gst_riff_strf_auds gst_riff_strf_auds; -typedef struct _gst_riff_strf_iavs gst_riff_strf_iavs; -typedef struct _gst_riff_dmlh gst_riff_dmlh; -typedef struct _GstRiffChunk GstRiffChunk; - -struct _GstRiffChunk { +typedef struct _gst_riff_riff gst_riff_riff; +typedef struct _gst_riff_list gst_riff_list; +typedef struct _gst_riff_chunk gst_riff_chunk; +typedef struct _gst_riff_index_entry gst_riff_index_entry; + +typedef struct _gst_riff_avih gst_riff_avih; +typedef struct _gst_riff_strh gst_riff_strh; +typedef struct _gst_riff_strf_vids gst_riff_strf_vids; +typedef struct _gst_riff_strf_auds gst_riff_strf_auds; +typedef struct _gst_riff_strf_iavs gst_riff_strf_iavs; +typedef struct _gst_riff_dmlh gst_riff_dmlh; +typedef struct _GstRiffChunk GstRiffChunk; + +struct _GstRiffChunk +{ gulong offset; guint32 id; guint32 size; - guint32 form; /* for list chunks */ + guint32 form; /* for list chunks */ gchar *data; }; |