diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2003-01-18 18:09:47 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2003-01-18 18:09:47 +0000 |
commit | 93f27006cfa693626e10fa4aacb036f1ade85a77 (patch) | |
tree | d1b5d05975cbb0b0bdab983f16359650c6815f4e /gst/avi/riff.c | |
parent | 5d90723aed08efcb80d17be11ffb122823e106e0 (diff) |
Added first unusable code that should become the base element for a new aviparser
Original commit message from CVS:
Added first unusable code that should become the base element for a new
aviparser
Diffstat (limited to 'gst/avi/riff.c')
-rw-r--r-- | gst/avi/riff.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/gst/avi/riff.c b/gst/avi/riff.c new file mode 100644 index 00000000..5138b8dc --- /dev/null +++ b/gst/avi/riff.c @@ -0,0 +1,115 @@ +/* GStreamer + * 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 "riff.h" + +GstRiffParse* +gst_riff_parse_new (GstPad *pad) +{ + GstRiffParse *parse; + + parse = g_new0 (GstRiffParse, 1); + parse->pad = pad; + parse->bs = gst_bytestream_new (pad); + + return parse; +} + +void +gst_riff_parse_free (GstRiffParse *parse) +{ + gst_bytestream_destroy (parse->bs); + g_free (parse); +} + + +static GstRiffReturn +gst_riff_parse_handle_sink_event (GstRiffParse *parse) +{ + guint32 remaining; + GstEvent *event; + GstEventType type; + GstRiffReturn ret = GST_RIFF_OK; + + gst_bytestream_get_status (parse->bs, &remaining, &event); + + type = event? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; + + switch (type) { + case GST_EVENT_EOS: + ret = GST_RIFF_EOS; + break; + default: + g_warning ("unhandled event %d", type); + break; + } + + gst_event_unref (event); + + return ret; +} + +GstRiffReturn +gst_riff_parse_next_chunk (GstRiffParse *parse, guint32 *id, GstBuffer **buf) +{ + GstByteStream *bs; + guint32 got_bytes; + gint skipsize; + gst_riff_chunk *chunk; + + bs = parse->bs; + + do { + got_bytes = gst_bytestream_peek_bytes (bs, (guint8 **) &chunk, sizeof (gst_riff_chunk)); + if (got_bytes < sizeof (gst_riff_chunk)) { + GstRiffReturn ret; + + ret = gst_riff_parse_handle_sink_event (parse); + + if (ret == GST_RIFF_EOS) + return ret; + } + } while (got_bytes != sizeof (gst_riff_chunk)); + + *id = chunk->id; + + switch (chunk->id) { + case GST_RIFF_TAG_RIFF: + case GST_RIFF_TAG_LIST: + skipsize = sizeof (gst_riff_list); + break; + default: + skipsize = (chunk->size + 8 + 1) & ~1; + break; + } + + do { + got_bytes = gst_bytestream_read (bs, buf, skipsize); + if (got_bytes < skipsize) { + GstRiffReturn ret; + + ret = gst_riff_parse_handle_sink_event (parse); + + if (ret == GST_RIFF_EOS) + return ret; + } + } while (got_bytes != skipsize); + + return GST_RIFF_OK; +} |