From ef502795dc4f65de800a4bc6615c8a275474535d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 30 Jan 2004 03:51:04 +0000 Subject: [PATCH] ext/ffmpeg/gstffmpegcodecmap.c: removee video/x-theora from vp3 decoder, it doesn't handle raw theora streams Original commit message from CVS: 2004-01-30 Benjamin Otte * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps): removee video/x-theora from vp3 decoder, it doesn't handle raw theora streams * ext/ogg/gstoggdemux.c: (gst_ogg_demux_init): fix bug with finalizing element that never went to PAUSED * ext/ogg/gstoggdemux.c: (gst_ogg_demux_src_query): length and position queries were swapped * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init), (vorbis_dec_from_granulepos), (vorbis_dec_src_query), (vorbis_dec_src_event): implement querying time and bytes --- ChangeLog | 14 ++++++++++++ ext/ogg/gstoggdemux.c | 5 +++-- ext/vorbis/vorbisdec.c | 48 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index faabab4814..f30f9341bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-01-30 Benjamin Otte + + * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps): + removee video/x-theora from vp3 decoder, it doesn't handle raw + theora streams + * ext/ogg/gstoggdemux.c: (gst_ogg_demux_init): + fix bug with finalizing element that never went to PAUSED + * ext/ogg/gstoggdemux.c: (gst_ogg_demux_src_query): + length and position queries were swapped + * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init), + (vorbis_dec_from_granulepos), (vorbis_dec_src_query), + (vorbis_dec_src_event): + implement querying time and bytes + 2004-01-30 Thomas Vander Stichele * just about every source file: diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index cf023ae686..9eb79fd8de 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -211,6 +211,7 @@ gst_ogg_demux_init (GstOggDemux *ogg) /* initalize variables */ GST_OGG_SET_STATE (ogg, GST_OGG_STATE_START); ogg->chains = g_array_new (TRUE, TRUE, sizeof (GstOggChain)); + ogg->current_chain = -1; GST_FLAG_SET (ogg, GST_ELEMENT_EVENT_AWARE); } @@ -273,14 +274,14 @@ gst_ogg_demux_src_query (GstPad *pad, GstQueryType type, switch (type) { case GST_QUERY_TOTAL: { if (*format == GST_FORMAT_DEFAULT) { - *value = cur->known_offset; + *value = cur->length; res = TRUE; } break; } case GST_QUERY_POSITION: if (*format == GST_FORMAT_DEFAULT && cur->length != 0) { - *value = cur->length; + *value = cur->known_offset; res = TRUE; } break; diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index 0b750241a1..b8219a5bc2 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -78,6 +78,10 @@ static GstElementStateReturn vorbis_dec_change_state (GstElement * element); static gboolean vorbis_dec_src_event (GstPad * pad, GstEvent * event); +static gboolean vorbis_dec_src_query (GstPad * pad, + GstQueryType query, + GstFormat * format, + gint64 * value); static void @@ -144,11 +148,13 @@ gst_vorbis_dec_init (GstVorbisDec *dec) gst_pad_set_link_function (dec->srcpad, vorbis_dec_link); gst_pad_set_getcaps_function (dec->srcpad, vorbis_dec_getcaps); gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event); + gst_pad_set_query_function (dec->srcpad, vorbis_dec_src_query); gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad); GST_FLAG_SET (dec, GST_ELEMENT_EVENT_AWARE); } +/* FIXME: plug this to the pad convert function */ static gboolean vorbis_dec_to_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to) { @@ -169,13 +175,49 @@ vorbis_dec_to_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, gui } } +static gboolean +vorbis_dec_from_granulepos (GstVorbisDec *dec, GstFormat format, guint64 from, guint64 *to) +{ + if (dec->packetno < 1) return FALSE; + + switch (format) { + case GST_FORMAT_TIME: + *to = from * GST_SECOND / dec->vi.rate; + return TRUE; + case GST_FORMAT_DEFAULT: + *to = from; + return TRUE; + case GST_FORMAT_BYTES: + *to = from * sizeof (float) * dec->vi.channels; + return TRUE; + default: + return FALSE; + } +} + + +static gboolean +vorbis_dec_src_query (GstPad *pad, GstQueryType query, GstFormat *format, gint64 *value) +{ + gint64 granulepos; + GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); + GstFormat my_format = GST_FORMAT_DEFAULT; + + if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format, &granulepos)) + return FALSE; + + if (!vorbis_dec_from_granulepos (dec, *format, granulepos, value)) + return FALSE; + + g_print ("peer returned granulepos: %llu - we return %llu\n", granulepos, *value); + return TRUE; +} + static gboolean vorbis_dec_src_event (GstPad *pad, GstEvent *event) { gboolean res = TRUE; - GstVorbisDec *dec; - - dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); + GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: {