2003-11-21 21:34:27 +00:00
|
|
|
/* GStreamer EBML I/O
|
|
|
|
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
*
|
|
|
|
* ebml-read.c: read EBML data from file/stream
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "ebml-read.h"
|
|
|
|
#include "ebml-ids.h"
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-11-21 21:34:27 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_ebml_read_class_init (GstEbmlReadClass * klass);
|
|
|
|
static void gst_ebml_read_init (GstEbmlRead * ebml);
|
|
|
|
static GstElementStateReturn gst_ebml_read_change_state (GstElement * element);
|
2003-11-21 21:34:27 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_get_type (void)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
static GType gst_ebml_read_type = 0;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_type) {
|
|
|
|
static const GTypeInfo gst_ebml_read_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstEbmlReadClass),
|
2003-11-21 21:34:27 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_ebml_read_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstEbmlRead),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_ebml_read_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_ebml_read_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstEbmlRead",
|
|
|
|
&gst_ebml_read_info, 0);
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_ebml_read_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_class_init (GstEbmlReadClass * klass)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
|
|
|
|
|
|
|
gstelement_class->change_state = gst_ebml_read_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_init (GstEbmlRead * ebml)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
ebml->sinkpad = NULL;
|
|
|
|
ebml->bs = NULL;
|
|
|
|
ebml->level = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_change_state (GstElement * element)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstEbmlRead *ebml = GST_EBML_READ (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
if (!ebml->sinkpad)
|
2004-03-15 19:32:27 +00:00
|
|
|
return GST_STATE_FAILURE;
|
2003-11-21 21:34:27 +00:00
|
|
|
ebml->bs = gst_bytestream_new (ebml->sinkpad);
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
gst_bytestream_destroy (ebml->bs);
|
|
|
|
while (ebml->level) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GstEbmlLevel *level = ebml->level->data;
|
2003-11-21 21:34:27 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
ebml->level = g_list_remove (ebml->level, level);
|
|
|
|
g_free (level);
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
/*
|
|
|
|
* Event handler. Basic:
|
|
|
|
* - EOS: end-of-file, stop processing, forward EOS.
|
|
|
|
* - Interrupt: stop processing.
|
|
|
|
* - Discont: shouldn't be handled here but in the seek handler. Error.
|
|
|
|
* - Flush: ignore, since we check for flush flags manually. Don't forward.
|
|
|
|
* - Others: warn, ignore.
|
|
|
|
* Return value indicates whether to continue processing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ebml_read_use_event (GstEbmlRead * ebml, GstEvent * event)
|
|
|
|
{
|
|
|
|
if (!event) {
|
|
|
|
GST_ELEMENT_ERROR (ebml, RESOURCE, READ, (NULL), (NULL));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
gst_pad_event_default (ebml->sinkpad, event);
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case GST_EVENT_INTERRUPT:
|
|
|
|
gst_event_unref (event);
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
case GST_EVENT_DISCONTINUOUS:
|
|
|
|
GST_WARNING_OBJECT (ebml, "Unexected discont - might lose sync");
|
|
|
|
gst_pad_event_default (ebml->sinkpad, event);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GST_EVENT_FLUSH:
|
|
|
|
gst_event_unref (event);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
GST_WARNING ("don't know how to handle event %d", GST_EVENT_TYPE (event));
|
|
|
|
gst_pad_event_default (ebml->sinkpad, event);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* happy */
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ebml_read_handle_event (GstEbmlRead * ebml)
|
|
|
|
{
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
guint32 remaining;
|
|
|
|
|
|
|
|
gst_bytestream_get_status (ebml->bs, &remaining, &event);
|
|
|
|
|
|
|
|
return gst_ebml_read_use_event (ebml, event);
|
|
|
|
}
|
|
|
|
|
2003-11-21 21:34:27 +00:00
|
|
|
/*
|
|
|
|
* Return: the amount of levels in the hierarchy that the
|
|
|
|
* current element lies higher than the previous one.
|
|
|
|
* The opposite isn't done - that's auto-done using master
|
|
|
|
* element reading.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static guint
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_element_level_up (GstEbmlRead * ebml)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
guint num = 0;
|
|
|
|
guint64 pos = gst_bytestream_tell (ebml->bs);
|
|
|
|
|
|
|
|
while (ebml->level != NULL) {
|
|
|
|
GList *last = g_list_last (ebml->level);
|
|
|
|
GstEbmlLevel *level = last->data;
|
|
|
|
|
|
|
|
if (pos >= level->start + level->length) {
|
|
|
|
ebml->level = g_list_remove (ebml->level, level);
|
|
|
|
g_free (level);
|
|
|
|
num++;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read: the element content data ID.
|
|
|
|
* Return: the number of bytes read or -1 on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gint
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_element_id (GstEbmlRead * ebml, guint32 * id, guint * level_up)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
gint len_mask = 0x80, read = 1, n = 1;
|
|
|
|
guint32 total;
|
|
|
|
|
2004-01-30 12:37:58 +00:00
|
|
|
while (gst_bytestream_peek_bytes (ebml->bs, &data, 1) != 1) {
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
if (!gst_ebml_read_handle_event (ebml))
|
2004-01-30 12:37:58 +00:00
|
|
|
return -1;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
total = data[0];
|
|
|
|
while (read <= 4 && !(total & len_mask)) {
|
|
|
|
read++;
|
|
|
|
len_mask >>= 1;
|
|
|
|
}
|
|
|
|
if (read > 4) {
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
guint64 pos = gst_bytestream_tell (ebml->bs);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, DEMUX, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Invalid EBML ID size tag (0x%x) at position %llu (0x%llx)",
|
|
|
|
data[0], pos, pos));
|
2003-11-21 21:34:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
while (gst_bytestream_peek_bytes (ebml->bs, &data, read) != read) {
|
|
|
|
if (!gst_ebml_read_handle_event (ebml))
|
|
|
|
return -1;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
while (n < read)
|
|
|
|
total = (total << 8) | data[n++];
|
|
|
|
|
|
|
|
*id = total;
|
|
|
|
|
|
|
|
/* level */
|
|
|
|
if (level_up)
|
|
|
|
*level_up = gst_ebml_read_element_level_up (ebml);
|
|
|
|
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read: element content length.
|
|
|
|
* Return: the number of bytes read or -1 on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gint
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_element_length (GstEbmlRead * ebml, guint64 * length)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
guint8 *data;
|
|
|
|
gint len_mask = 0x80, read = 1, n = 1, num_ffs = 0;
|
|
|
|
guint64 total;
|
2004-01-18 21:46:58 +00:00
|
|
|
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
while (gst_bytestream_peek_bytes (ebml->bs, &data, 1) != 1) {
|
|
|
|
if (!gst_ebml_read_handle_event (ebml))
|
|
|
|
return -1;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
total = data[0];
|
|
|
|
while (read <= 8 && !(total & len_mask)) {
|
|
|
|
read++;
|
|
|
|
len_mask >>= 1;
|
|
|
|
}
|
|
|
|
if (read > 8) {
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
guint64 pos = gst_bytestream_tell (ebml->bs);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, DEMUX, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Invalid EBML length size tag (0x%x) at position %llu (0x%llx)",
|
|
|
|
data[0], pos, pos));
|
2003-11-21 21:34:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((total &= (len_mask - 1)) == len_mask - 1)
|
|
|
|
num_ffs++;
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
while (gst_bytestream_peek_bytes (ebml->bs, &data, read) != read) {
|
|
|
|
if (!gst_ebml_read_handle_event (ebml))
|
|
|
|
return -1;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
while (n < read) {
|
|
|
|
if (data[n] == 0xff)
|
|
|
|
num_ffs++;
|
|
|
|
total = (total << 8) | data[n];
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (read == num_ffs)
|
|
|
|
*length = G_MAXUINT64;
|
|
|
|
else
|
|
|
|
*length = total;
|
|
|
|
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read: the actual data.
|
|
|
|
* Return: the data, as a GstBuffer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static GstBuffer *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_element_data (GstEbmlRead * ebml, guint64 length)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf = NULL;
|
|
|
|
|
|
|
|
if (gst_bytestream_peek (ebml->bs, &buf, length) != length) {
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
if (!gst_ebml_read_handle_event (ebml))
|
|
|
|
return NULL;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, length);
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return: the ID of the next element.
|
|
|
|
* Level_up contains the amount of levels that this
|
|
|
|
* next element lies higher than the previous one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
guint32
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_peek_id (GstEbmlRead * ebml, guint * level_up)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
guint32 id;
|
|
|
|
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
g_assert (level_up);
|
2003-11-21 21:34:27 +00:00
|
|
|
|
2004-08-27 14:10:09 +00:00
|
|
|
if (gst_ebml_read_element_id (ebml, &id, level_up) <= 0)
|
2003-11-21 21:34:27 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Seek to a given offset.
|
|
|
|
*/
|
|
|
|
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
GstEvent *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_seek (GstEbmlRead * ebml, guint64 offset)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
guint32 remaining;
|
2004-01-30 12:37:58 +00:00
|
|
|
GstEvent *event = NULL;
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
guchar *data;
|
|
|
|
|
|
|
|
/* first, flush remaining buffers */
|
|
|
|
gst_bytestream_get_status (ebml->bs, &remaining, &event);
|
|
|
|
if (event) {
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
GST_WARNING ("Unexpected event before seek");
|
|
|
|
if (!gst_ebml_read_use_event (ebml, event))
|
|
|
|
return NULL;
|
|
|
|
event = NULL;
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
}
|
|
|
|
if (remaining)
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, remaining);
|
|
|
|
|
|
|
|
/* now seek */
|
|
|
|
if (!gst_bytestream_seek (ebml->bs, offset, GST_SEEK_METHOD_SET)) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, RESOURCE, SEEK, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Seek to position %llu (0x%llx) failed", offset, offset));
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-01-30 12:37:58 +00:00
|
|
|
while (!event) {
|
|
|
|
/* and now, peek a new byte. This will fail because there's a
|
|
|
|
* pending event. Then, take the event and return it. */
|
|
|
|
if (gst_bytestream_peek_bytes (ebml->bs, &data, 1)) {
|
|
|
|
GST_WARNING ("Unexpected data after seek - this means seek failed");
|
|
|
|
break;
|
|
|
|
}
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
|
2004-01-30 12:37:58 +00:00
|
|
|
/* get the discont event and return */
|
|
|
|
gst_bytestream_get_status (ebml->bs, &remaining, &event);
|
|
|
|
if (!event) {
|
|
|
|
GST_WARNING ("No discontinuity event after seek - seek failed");
|
|
|
|
break;
|
|
|
|
} else if (GST_EVENT_TYPE (event) != GST_EVENT_DISCONTINUOUS) {
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
if (!gst_ebml_read_use_event (ebml, event))
|
ext/dirac/: Do something. Don't actually know if this works because I don't have a demuxer yet.
Original commit message from CVS:
* ext/dirac/Makefile.am:
* ext/dirac/gstdirac.cc:
* ext/dirac/gstdiracdec.cc:
* ext/dirac/gstdiracdec.h:
Do something. Don't actually know if this works because I don't
have a demuxer yet.
* ext/gsm/gstgsmdec.c: (gst_gsmdec_getcaps):
Add channels=1 to caps returned from _getcaps().
* ext/ogg/gstogmparse.c: (gst_ogm_audio_parse_get_type),
(gst_ogm_video_parse_get_type), (gst_ogm_audio_parse_base_init),
(gst_ogm_video_parse_base_init), (gst_ogm_parse_init),
(gst_ogm_audio_parse_init), (gst_ogm_video_parse_init),
(gst_ogm_parse_sink_convert), (gst_ogm_parse_chain),
(gst_ogm_parse_change_state):
Separate between audio/video so ogmaudioparse actually uses the
audio pad templates. Both audio and video work now, including
autoplugging. Also use sometimes-srcpad hack.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Handle events better. Don't hang on infinite loops.
* gst/avi/gstavidemux.c: (gst_avi_demux_class_init),
(gst_avi_demux_init), (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_stream_header), (gst_avi_demux_stream_data),
(gst_avi_demux_change_state):
* gst/avi/gstavidemux.h:
Improve A/V sync. Still not perfect.
* gst/matroska/ebml-read.c: (gst_ebml_read_seek),
(gst_ebml_read_skip):
Handle events better.
* gst/qtdemux/qtdemux.c: (gst_qtdemux_handle_sink_event),
(gst_qtdemux_loop_header), (qtdemux_parse_trak),
(qtdemux_audio_caps):
Add IMA4. Improve event handling. Save offset after a seek when
the headers are at the end of the file so that we don't end up in
an infinite loop.
* gst/typefind/gsttypefindfunctions.c: (qt_type_find):
Add low-priority typefind support for files with no length.
2004-09-23 14:59:22 +00:00
|
|
|
return NULL;
|
2004-01-30 12:37:58 +00:00
|
|
|
event = NULL;
|
|
|
|
}
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip the next element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_skip (GstEbmlRead * ebml)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
gint bytes;
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
guint32 id, remaining;
|
2003-11-21 21:34:27 +00:00
|
|
|
guint64 length;
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
GstEvent *event;
|
2003-11-21 21:34:27 +00:00
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_id (ebml, &id, NULL)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_length (ebml, &length)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
/* do we have enough bytes left to skip? */
|
|
|
|
gst_bytestream_get_status (ebml->bs, &remaining, &event);
|
|
|
|
if (event) {
|
|
|
|
g_warning ("Unexpected event before skip");
|
ext/dvdread/dvdreadsrc.c: Fix. Don't do one big huge loop around the whole DVD, that will cache all data and thus eat...
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_init), (dvdreadsrc_dispose), (dvdreadsrc_set_property),
(dvdreadsrc_get_property), (_open), (_seek), (_read),
(dvdreadsrc_get), (dvdreadsrc_open_file),
(dvdreadsrc_change_state):
Fix. Don't do one big huge loop around the whole DVD, that will
cache all data and thus eat sizeof(dvd) (several GB) before we
see something.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Actually NULL'ify event after using it.
* gst/matroska/ebml-read.c: (gst_ebml_read_use_event),
(gst_ebml_read_handle_event), (gst_ebml_read_element_id),
(gst_ebml_read_element_length), (gst_ebml_read_element_data),
(gst_ebml_read_seek), (gst_ebml_read_skip):
Handle events.
* gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_base_init),
(gst_dvd_demux_init), (gst_dvd_demux_get_audio_stream),
(gst_dvd_demux_get_subpicture_stream), (gst_dvd_demux_plugin_init):
Fix timing (this will probably break if I seek using menus, but
I didn't get there yet). VOBs and normal DVDs should now work.
Add a mpeg2-only pad with high rank so this get autoplugged for
MPEG-2 movies.
* gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_base_init),
(gst_mpeg_demux_class_init), (gst_mpeg_demux_init),
(gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_get_video_stream),
(gst_mpeg_demux_get_audio_stream),
(gst_mpeg_demux_get_private_stream), (gst_mpeg_demux_parse_packet),
(gst_mpeg_demux_parse_pes), (gst_mpeg_demux_plugin_init):
Use this as second rank for MPEG-1 and MPEG-2. Still use this for
MPEG-1 but use dvddemux for MPEG-2.
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_class_init),
(gst_mpeg_parse_init), (gst_mpeg_parse_new_pad),
(gst_mpeg_parse_parse_packhead):
Timing. Only add pad template if it exists. Add sink template from
class and not from ourselves. This means we will always use the
correct sink template even if it is not the one defined in this
file.
2004-10-01 08:42:56 +00:00
|
|
|
if (!gst_ebml_read_use_event (ebml, event))
|
|
|
|
return FALSE;
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (remaining >= length)
|
|
|
|
return gst_bytestream_flush (ebml->bs, length);
|
|
|
|
|
|
|
|
if (!(event = gst_ebml_read_seek (ebml,
|
ext/dirac/: Do something. Don't actually know if this works because I don't have a demuxer yet.
Original commit message from CVS:
* ext/dirac/Makefile.am:
* ext/dirac/gstdirac.cc:
* ext/dirac/gstdiracdec.cc:
* ext/dirac/gstdiracdec.h:
Do something. Don't actually know if this works because I don't
have a demuxer yet.
* ext/gsm/gstgsmdec.c: (gst_gsmdec_getcaps):
Add channels=1 to caps returned from _getcaps().
* ext/ogg/gstogmparse.c: (gst_ogm_audio_parse_get_type),
(gst_ogm_video_parse_get_type), (gst_ogm_audio_parse_base_init),
(gst_ogm_video_parse_base_init), (gst_ogm_parse_init),
(gst_ogm_audio_parse_init), (gst_ogm_video_parse_init),
(gst_ogm_parse_sink_convert), (gst_ogm_parse_chain),
(gst_ogm_parse_change_state):
Separate between audio/video so ogmaudioparse actually uses the
audio pad templates. Both audio and video work now, including
autoplugging. Also use sometimes-srcpad hack.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Handle events better. Don't hang on infinite loops.
* gst/avi/gstavidemux.c: (gst_avi_demux_class_init),
(gst_avi_demux_init), (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_stream_header), (gst_avi_demux_stream_data),
(gst_avi_demux_change_state):
* gst/avi/gstavidemux.h:
Improve A/V sync. Still not perfect.
* gst/matroska/ebml-read.c: (gst_ebml_read_seek),
(gst_ebml_read_skip):
Handle events better.
* gst/qtdemux/qtdemux.c: (gst_qtdemux_handle_sink_event),
(gst_qtdemux_loop_header), (qtdemux_parse_trak),
(qtdemux_audio_caps):
Add IMA4. Improve event handling. Save offset after a seek when
the headers are at the end of the file so that we don't end up in
an infinite loop.
* gst/typefind/gsttypefindfunctions.c: (qt_type_find):
Add low-priority typefind support for files with no length.
2004-09-23 14:59:22 +00:00
|
|
|
gst_bytestream_tell (ebml->bs) + length))) {
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
return FALSE;
|
ext/dirac/: Do something. Don't actually know if this works because I don't have a demuxer yet.
Original commit message from CVS:
* ext/dirac/Makefile.am:
* ext/dirac/gstdirac.cc:
* ext/dirac/gstdiracdec.cc:
* ext/dirac/gstdiracdec.h:
Do something. Don't actually know if this works because I don't
have a demuxer yet.
* ext/gsm/gstgsmdec.c: (gst_gsmdec_getcaps):
Add channels=1 to caps returned from _getcaps().
* ext/ogg/gstogmparse.c: (gst_ogm_audio_parse_get_type),
(gst_ogm_video_parse_get_type), (gst_ogm_audio_parse_base_init),
(gst_ogm_video_parse_base_init), (gst_ogm_parse_init),
(gst_ogm_audio_parse_init), (gst_ogm_video_parse_init),
(gst_ogm_parse_sink_convert), (gst_ogm_parse_chain),
(gst_ogm_parse_change_state):
Separate between audio/video so ogmaudioparse actually uses the
audio pad templates. Both audio and video work now, including
autoplugging. Also use sometimes-srcpad hack.
* gst-libs/gst/riff/riff-read.c: (gst_riff_read_seek):
Handle events better. Don't hang on infinite loops.
* gst/avi/gstavidemux.c: (gst_avi_demux_class_init),
(gst_avi_demux_init), (gst_avi_demux_reset),
(gst_avi_demux_src_convert), (gst_avi_demux_handle_src_query),
(gst_avi_demux_stream_header), (gst_avi_demux_stream_data),
(gst_avi_demux_change_state):
* gst/avi/gstavidemux.h:
Improve A/V sync. Still not perfect.
* gst/matroska/ebml-read.c: (gst_ebml_read_seek),
(gst_ebml_read_skip):
Handle events better.
* gst/qtdemux/qtdemux.c: (gst_qtdemux_handle_sink_event),
(gst_qtdemux_loop_header), (qtdemux_parse_trak),
(qtdemux_audio_caps):
Add IMA4. Improve event handling. Save offset after a seek when
the headers are at the end of the file so that we don't end up in
an infinite loop.
* gst/typefind/gsttypefindfunctions.c: (qt_type_find):
Add low-priority typefind support for files with no length.
2004-09-23 14:59:22 +00:00
|
|
|
}
|
Riff, EBML, fourcc etc. work. Not fully finished, but better than what we used to have and definately worth a first b...
Original commit message from CVS:
Riff, EBML, fourcc etc. work. Not fully finished, but better than
what we used to have and definately worth a first broad testing.
I've revived rifflib. Rifflib used to be a bytestream-for-riff, which
just dup'ed bytestream. I've rewritten rifflib to be a modern riff-
chunk parser that uses bytestream fully, plus adds some extra functions
so that riff file parsing becomes extremely easy. It also contains some
small usability functions for strh/strf and metadata parsing. Note that
it doesn't use the new tagging yet, that's a TODO.
Avidemux has been rewritten to use this. I think we all agreed that
avidemux was pretty much a big mess, which is because it used all
sort of bytestream magic all around the place. It was just ugly.
This is a lot nicer, very complete and safe. I think this is far more
robust than what the old avidemux could ever have been. Of course, it
might contain bugs, please let me know.
EBML writing has also been implemented. This is useful for matroska.
I'm intending to modify avidemux (with a riffwriter) similarly. Maybe
I'll change wavparse/-enc too to use rifflib.
Lastly, several plugins have been modified to use rifflib's fourcc
parsing instead of their own. this puts fourcc parsing in one central
place, which should make it a lot simpler to add new fourccs. We might
want to move this to its own lib instead of rifflib.
Enjoy!
2003-12-07 20:00:41 +00:00
|
|
|
|
|
|
|
gst_event_unref (event);
|
|
|
|
|
|
|
|
return TRUE;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as a GstBuffer (binary).
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_buffer (GstEbmlRead * ebml, guint32 * id, GstBuffer ** buf)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
gint bytes;
|
|
|
|
guint64 length;
|
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_id (ebml, id, NULL)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_length (ebml, &length)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
|
|
|
return ((*buf = gst_ebml_read_element_data (ebml, length)) != NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as an unsigned int.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_uint (GstEbmlRead * ebml, guint32 * id, guint64 * num)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_buffer (ebml, id, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
if (size < 1 || size > 8) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, DEMUX, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Invalid integer element size %d at position %llu (0x%llu)",
|
|
|
|
size, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf)));
|
2003-11-21 21:34:27 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*num = 0;
|
|
|
|
while (size > 0) {
|
|
|
|
*num = (*num << 8) | data[GST_BUFFER_SIZE (buf) - size];
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as a signed int.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_sint (GstEbmlRead * ebml, guint32 * id, gint64 * num)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
guint8 *data;
|
2004-01-02 20:38:59 +00:00
|
|
|
guint size, negative = 0, n = 0;
|
2003-11-21 21:34:27 +00:00
|
|
|
|
|
|
|
if (!gst_ebml_read_buffer (ebml, id, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
if (size < 1 || size > 8) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, DEMUX, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Invalid integer element size %d at position %llu (0x%llx)",
|
|
|
|
size, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf)));
|
2003-11-21 21:34:27 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-02 20:38:59 +00:00
|
|
|
if (data[0] & 0x80) {
|
|
|
|
negative = 1;
|
|
|
|
data[0] &= ~0x80;
|
|
|
|
}
|
2003-11-21 21:34:27 +00:00
|
|
|
*num = 0;
|
2004-01-02 20:38:59 +00:00
|
|
|
while (n < size) {
|
|
|
|
*num = (*num << 8) | data[n++];
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* make signed */
|
2004-01-02 20:38:59 +00:00
|
|
|
if (negative) {
|
|
|
|
*num = *num - (1LL << ((8 * size) - 1));
|
|
|
|
}
|
2003-11-21 21:34:27 +00:00
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as a float.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_float (GstEbmlRead * ebml, guint32 * id, gdouble * num)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
guint8 *data;
|
|
|
|
guint size;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_buffer (ebml, id, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
data = GST_BUFFER_DATA (buf);
|
|
|
|
size = GST_BUFFER_SIZE (buf);
|
|
|
|
|
|
|
|
if (size != 4 && size != 8 && size != 10) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, DEMUX, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("Invalid float element size %d at position %llu (0x%llx)",
|
|
|
|
size, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET (buf)));
|
2003-11-21 21:34:27 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == 10) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, CORE, NOT_IMPLEMENTED, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("FIXME! 10-byte floats unimplemented"));
|
2003-11-21 21:34:27 +00:00
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size == 4) {
|
|
|
|
gfloat f;
|
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
f = *(gfloat *) data;
|
2003-11-21 21:34:27 +00:00
|
|
|
#else
|
|
|
|
while (size > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
((guint8 *) & f)[size - 1] = data[4 - size];
|
2003-11-21 21:34:27 +00:00
|
|
|
size--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
*num = f;
|
|
|
|
} else {
|
|
|
|
gdouble d;
|
|
|
|
|
|
|
|
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
2004-03-14 22:34:33 +00:00
|
|
|
d = *(gdouble *) data;
|
2003-11-21 21:34:27 +00:00
|
|
|
#else
|
|
|
|
while (size > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
((guint8 *) & d)[size - 1] = data[8 - size];
|
2003-11-21 21:34:27 +00:00
|
|
|
size--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
*num = d;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as an ASCII string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_ascii (GstEbmlRead * ebml, guint32 * id, gchar ** str)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_buffer (ebml, id, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*str = g_malloc (GST_BUFFER_SIZE (buf) + 1);
|
|
|
|
memcpy (*str, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
|
|
|
(*str)[GST_BUFFER_SIZE (buf)] = '\0';
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as a UTF-8 string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_utf8 (GstEbmlRead * ebml, guint32 * id, gchar ** str)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
return gst_ebml_read_ascii (ebml, id, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-09-01 12:10:21 +00:00
|
|
|
* Read the next element as a date.
|
|
|
|
* Returns the seconds since the unix epoch.
|
2003-11-21 21:34:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_date (GstEbmlRead * ebml, guint32 * id, gint64 * date)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
2004-09-01 12:10:21 +00:00
|
|
|
gint64 ebml_date;
|
|
|
|
gboolean res = gst_ebml_read_sint (ebml, id, &ebml_date);
|
|
|
|
|
|
|
|
*date = (ebml_date / GST_SECOND) + GST_EBML_DATE_OFFSET;
|
|
|
|
return res;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element, but only the header. The contents
|
|
|
|
* are supposed to be sub-elements which can be read separately.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_master (GstEbmlRead * ebml, guint32 * id)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
gint bytes;
|
|
|
|
guint64 length;
|
|
|
|
GstEbmlLevel *level;
|
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_id (ebml, id, NULL)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
|
|
|
if ((bytes = gst_ebml_read_element_length (ebml, &length)) < 0)
|
|
|
|
return FALSE;
|
|
|
|
gst_bytestream_flush_fast (ebml->bs, bytes);
|
|
|
|
|
|
|
|
/* remember level */
|
|
|
|
level = g_new (GstEbmlLevel, 1);
|
|
|
|
level->start = gst_bytestream_tell (ebml->bs);
|
|
|
|
level->length = length;
|
|
|
|
ebml->level = g_list_append (ebml->level, level);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the next element as binary data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_binary (GstEbmlRead * ebml,
|
|
|
|
guint32 * id, guint8 ** binary, guint64 * length)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_buffer (ebml, id, &buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*length = GST_BUFFER_SIZE (buf);
|
|
|
|
*binary = g_memdup (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
|
|
|
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read an EBML header.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_ebml_read_header (GstEbmlRead * ebml, gchar ** doctype, guint * version)
|
2003-11-21 21:34:27 +00:00
|
|
|
{
|
|
|
|
/* this function is the first to be called */
|
|
|
|
guint32 id;
|
|
|
|
guint level_up;
|
|
|
|
|
|
|
|
/* default init */
|
|
|
|
if (doctype)
|
|
|
|
*doctype = NULL;
|
|
|
|
if (version)
|
|
|
|
*version = 1;
|
|
|
|
|
|
|
|
if (!(id = gst_ebml_peek_id (ebml, &level_up)))
|
|
|
|
return FALSE;
|
|
|
|
if (level_up != 0 || id != GST_EBML_ID_HEADER) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (ebml, STREAM, WRONG_TYPE, (NULL), (NULL));
|
2003-11-21 21:34:27 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!gst_ebml_read_master (ebml, &id))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_HEADER);
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
if (!(id = gst_ebml_peek_id (ebml, &level_up)))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* end-of-header */
|
|
|
|
if (level_up)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (id) {
|
2004-03-15 19:32:27 +00:00
|
|
|
/* is our read version uptodate? */
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_EBML_ID_EBMLREADVERSION:{
|
2004-03-15 19:32:27 +00:00
|
|
|
guint64 num;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_uint (ebml, &id, &num))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_EBMLREADVERSION);
|
|
|
|
if (num != GST_EBML_VERSION)
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* we only handle 8 byte lengths at max */
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_EBML_ID_EBMLMAXSIZELENGTH:{
|
2004-03-15 19:32:27 +00:00
|
|
|
guint64 num;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_uint (ebml, &id, &num))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_EBMLMAXSIZELENGTH);
|
|
|
|
if (num != sizeof (guint64))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* we handle 4 byte IDs at max */
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_EBML_ID_EBMLMAXIDLENGTH:{
|
2004-03-15 19:32:27 +00:00
|
|
|
guint64 num;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_uint (ebml, &id, &num))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_EBMLMAXIDLENGTH);
|
|
|
|
if (num != sizeof (guint32))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_EBML_ID_DOCTYPE:{
|
2004-03-15 19:32:27 +00:00
|
|
|
gchar *text;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_ascii (ebml, &id, &text))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_DOCTYPE);
|
|
|
|
if (doctype) {
|
|
|
|
if (doctype)
|
|
|
|
g_free (*doctype);
|
|
|
|
*doctype = text;
|
|
|
|
} else
|
|
|
|
g_free (text);
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_EBML_ID_DOCTYPEREADVERSION:{
|
2004-03-15 19:32:27 +00:00
|
|
|
guint64 num;
|
|
|
|
|
|
|
|
if (!gst_ebml_read_uint (ebml, &id, &num))
|
|
|
|
return FALSE;
|
|
|
|
g_assert (id == GST_EBML_ID_DOCTYPEREADVERSION);
|
|
|
|
if (version)
|
|
|
|
*version = num;
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_WARNING ("Unknown data type 0x%x in EBML header (ignored)", id);
|
|
|
|
/* pass-through */
|
2003-11-21 21:34:27 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* we ignore these two, as they don't tell us anything we care about */
|
2003-11-21 21:34:27 +00:00
|
|
|
case GST_EBML_ID_VOID:
|
|
|
|
case GST_EBML_ID_EBMLVERSION:
|
|
|
|
case GST_EBML_ID_DOCTYPEVERSION:
|
2004-03-15 19:32:27 +00:00
|
|
|
if (!gst_ebml_read_skip (ebml))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2003-11-21 21:34:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|