2004-01-29 02:50:20 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2004 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
|
|
|
*
|
|
|
|
* 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 "vorbisdec.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <gst/tag/tag.h>
|
|
|
|
|
2004-03-06 16:41:39 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (vorbisdec_debug);
|
|
|
|
#define GST_CAT_DEFAULT vorbisdec_debug
|
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
static GstElementDetails vorbis_dec_details = {
|
|
|
|
"VorbisDec",
|
2004-02-20 15:49:27 +00:00
|
|
|
"Codec/Decoder/Audio",
|
2004-01-29 02:50:20 +00:00
|
|
|
"decode raw vorbis streams to float audio",
|
|
|
|
"Benjamin Otte <in7y118@public.uni-hamburg.de>",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Filter signals and args */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-01-29 02:50:20 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-01-29 02:50:20 +00:00
|
|
|
ARG_0
|
|
|
|
};
|
|
|
|
|
|
|
|
static GstStaticPadTemplate vorbis_dec_src_factory =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-float, "
|
2004-03-15 19:32:28 +00:00
|
|
|
"rate = (int) [ 11025, 48000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ], " "endianness = (int) BYTE_ORDER, "
|
2004-01-30 03:59:03 +00:00
|
|
|
/* no ifdef in macros, please
|
2004-01-29 02:50:20 +00:00
|
|
|
#ifdef GST_VORBIS_DEC_SEQUENTIAL
|
|
|
|
"layout = \"sequential\", "
|
|
|
|
#endif
|
2004-01-30 03:59:03 +00:00
|
|
|
*/
|
2004-03-15 19:32:28 +00:00
|
|
|
"width = (int) 32, " "buffer-frames = (int) 0")
|
2004-03-14 22:34:34 +00:00
|
|
|
);
|
2004-01-29 02:50:20 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate vorbis_dec_sink_factory =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-vorbis")
|
|
|
|
);
|
2004-01-29 02:50:20 +00:00
|
|
|
|
|
|
|
GST_BOILERPLATE (GstVorbisDec, gst_vorbis_dec, GstElement, GST_TYPE_ELEMENT);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
|
|
|
static void vorbis_dec_chain (GstPad * pad, GstData * data);
|
|
|
|
static GstElementStateReturn vorbis_dec_change_state (GstElement * element);
|
|
|
|
static const GstFormat *vorbis_dec_get_formats (GstPad * pad);
|
|
|
|
|
|
|
|
static gboolean vorbis_dec_src_event (GstPad * pad, GstEvent * event);
|
|
|
|
static gboolean vorbis_dec_src_query (GstPad * pad,
|
|
|
|
GstQueryType query, GstFormat * format, gint64 * value);
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
static gboolean vorbis_dec_convert (GstPad * pad,
|
|
|
|
GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value);
|
2004-01-29 02:50:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_vorbis_dec_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_static_pad_template_get (&vorbis_dec_src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&vorbis_dec_sink_factory));
|
|
|
|
gst_element_class_set_details (element_class, &vorbis_dec_details);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
|
|
|
gstelement_class->change_state = vorbis_dec_change_state;
|
|
|
|
}
|
|
|
|
|
2004-03-06 16:41:39 +00:00
|
|
|
static const GstFormat *
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_get_formats (GstPad * pad)
|
2004-03-06 16:41:39 +00:00
|
|
|
{
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
static GstFormat src_formats[] = {
|
2004-03-06 16:41:39 +00:00
|
|
|
GST_FORMAT_BYTES,
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
GST_FORMAT_DEFAULT, /* samples in the audio case */
|
2004-03-06 16:41:39 +00:00
|
|
|
GST_FORMAT_TIME,
|
|
|
|
0
|
|
|
|
};
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
static GstFormat sink_formats[] = {
|
2004-03-06 16:41:39 +00:00
|
|
|
GST_FORMAT_BYTES,
|
|
|
|
GST_FORMAT_TIME,
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
GST_FORMAT_DEFAULT, /* granulepos or samples */
|
2004-03-06 16:41:39 +00:00
|
|
|
0
|
|
|
|
};
|
2004-03-15 19:32:28 +00:00
|
|
|
|
2004-03-06 16:41:39 +00:00
|
|
|
return (GST_PAD_IS_SRC (pad) ? src_formats : sink_formats);
|
|
|
|
}
|
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
static const GstEventMask *
|
|
|
|
vorbis_get_event_masks (GstPad * pad)
|
|
|
|
{
|
|
|
|
static const GstEventMask vorbis_dec_src_event_masks[] = {
|
|
|
|
{GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH},
|
|
|
|
{0,}
|
|
|
|
};
|
|
|
|
|
|
|
|
return vorbis_dec_src_event_masks;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const GstQueryType *
|
|
|
|
vorbis_get_query_types (GstPad * pad)
|
|
|
|
{
|
|
|
|
static const GstQueryType vorbis_dec_src_query_types[] = {
|
|
|
|
GST_QUERY_TOTAL,
|
|
|
|
GST_QUERY_POSITION,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
return vorbis_dec_src_query_types;
|
|
|
|
}
|
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_vorbis_dec_init (GstVorbisDec * dec)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
dec->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&vorbis_dec_sink_factory), "sink");
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_pad_set_chain_function (dec->sinkpad, vorbis_dec_chain);
|
2004-03-06 16:41:39 +00:00
|
|
|
gst_pad_set_formats_function (dec->sinkpad, vorbis_dec_get_formats);
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad);
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
dec->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get
|
|
|
|
(&vorbis_dec_src_factory), "src");
|
2004-06-06 19:36:08 +00:00
|
|
|
gst_pad_use_explicit_caps (dec->srcpad);
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
gst_pad_set_event_mask_function (dec->srcpad, vorbis_get_event_masks);
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_pad_set_event_function (dec->srcpad, vorbis_dec_src_event);
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
gst_pad_set_query_type_function (dec->srcpad, vorbis_get_query_types);
|
2004-01-30 03:51:04 +00:00
|
|
|
gst_pad_set_query_function (dec->srcpad, vorbis_dec_src_query);
|
2004-03-06 16:41:39 +00:00
|
|
|
gst_pad_set_formats_function (dec->srcpad, vorbis_dec_get_formats);
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
gst_pad_set_convert_function (dec->srcpad, vorbis_dec_convert);
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad);
|
|
|
|
|
|
|
|
GST_FLAG_SET (dec, GST_ELEMENT_EVENT_AWARE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
vorbis_dec_convert (GstPad * pad,
|
|
|
|
GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
gboolean res = TRUE;
|
|
|
|
GstVorbisDec *dec;
|
|
|
|
guint64 scale = 1;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
|
2004-01-29 02:50:20 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
if (dec->packetno < 1)
|
|
|
|
return FALSE;
|
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
switch (src_format) {
|
2004-01-30 03:51:04 +00:00
|
|
|
case GST_FORMAT_TIME:
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
scale = sizeof (float) * dec->vi.channels;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value = scale * (src_value * dec->vi.rate / GST_SECOND);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2004-01-30 03:51:04 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*dest_value = src_value * sizeof (float) * dec->vi.channels;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = src_value * GST_SECOND / dec->vi.rate;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2004-01-30 03:51:04 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
switch (*dest_format) {
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value = src_value / (sizeof (float) * dec->vi.channels);
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
*dest_value = src_value * GST_SECOND /
|
|
|
|
(dec->vi.rate * sizeof (float) * dec->vi.channels);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2004-01-30 03:51:04 +00:00
|
|
|
default:
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
res = FALSE;
|
2004-01-30 03:51:04 +00:00
|
|
|
}
|
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
return res;
|
|
|
|
}
|
2004-01-30 03:51:04 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
|
|
|
|
gint64 * value)
|
2004-01-30 03:51:04 +00:00
|
|
|
{
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
gint64 granulepos = 0;
|
2004-01-30 03:51:04 +00:00
|
|
|
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
|
|
|
|
GstFormat my_format = GST_FORMAT_DEFAULT;
|
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
if (query == GST_QUERY_POSITION) {
|
|
|
|
granulepos = dec->granulepos;
|
|
|
|
} else {
|
|
|
|
/* query peer in default format */
|
|
|
|
if (!gst_pad_query (GST_PAD_PEER (dec->sinkpad), query, &my_format,
|
|
|
|
&granulepos))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-30 03:51:04 +00:00
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
/* and convert to the final format */
|
ext/: More seeking fixes, oggdemux now supports seeking to time and uses the downstream element to convert granulepos...
Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_init),
(gst_ogg_demux_get_formats), (gst_ogg_demux_src_query),
(gst_ogg_demux_src_event), (gst_ogg_demux_src_convert),
(gst_ogg_demux_handle_event), (gst_ogg_demux_seek_before),
(_find_chain_get_unknown_part), (_find_streams_check),
(gst_ogg_demux_push), (gst_ogg_pad_push):
* ext/theora/theoradec.c: (theora_get_formats),
(theora_dec_src_convert), (theora_dec_sink_convert),
(theora_dec_src_query), (theora_dec_src_event), (theora_dec_event),
(theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_dec_convert), (vorbis_dec_src_query),
(vorbis_dec_src_event), (vorbis_dec_event):
More seeking fixes, oggdemux now supports seeking to time and
uses the downstream element to convert granulepos to time.
Seeking in theora-only ogg files now works.
2004-07-21 16:48:20 +00:00
|
|
|
if (!gst_pad_convert (pad, GST_FORMAT_DEFAULT, granulepos, format, value))
|
2004-01-30 03:51:04 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_LOG_OBJECT (dec,
|
|
|
|
"query %u: peer returned granulepos: %llu - we return %llu (format %u)\n",
|
2004-01-31 11:24:18 +00:00
|
|
|
query, granulepos, *value, *format);
|
2004-01-30 03:51:04 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_src_event (GstPad * pad, GstEvent * event)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
2004-01-30 03:51:04 +00:00
|
|
|
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
|
2004-01-29 02:50:20 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_EVENT_SEEK:{
|
2004-01-29 02:50:20 +00:00
|
|
|
guint64 value;
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
GstFormat my_format = GST_FORMAT_DEFAULT;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
/* convert to granulepos */
|
|
|
|
res = vorbis_dec_convert (pad, GST_EVENT_SEEK_FORMAT (event),
|
|
|
|
GST_EVENT_SEEK_OFFSET (event), &my_format, &value);
|
2004-01-29 02:50:20 +00:00
|
|
|
if (res) {
|
2004-03-15 19:32:28 +00:00
|
|
|
GstEvent *real_seek = gst_event_new_seek (
|
|
|
|
(GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) |
|
|
|
|
GST_FORMAT_DEFAULT,
|
|
|
|
value);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-03-15 19:32:28 +00:00
|
|
|
res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
|
2004-01-29 02:50:20 +00:00
|
|
|
}
|
2004-01-31 11:24:18 +00:00
|
|
|
gst_event_unref (event);
|
2004-01-29 02:50:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_event (GstVorbisDec * dec, GstEvent * event)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
2004-01-31 17:19:21 +00:00
|
|
|
guint64 value, time, bytes;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
GST_LOG_OBJECT (dec, "handling event");
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_DISCONTINUOUS:
|
2004-06-02 11:47:10 +00:00
|
|
|
if (gst_event_discont_get_value (event, GST_FORMAT_DEFAULT,
|
|
|
|
(gint64 *) & value)) {
|
2004-03-15 19:32:28 +00:00
|
|
|
dec->granulepos = value;
|
|
|
|
GST_DEBUG_OBJECT (dec,
|
|
|
|
"setting granuleposition to %" G_GUINT64_FORMAT " after discont",
|
|
|
|
value);
|
2004-01-29 02:50:20 +00:00
|
|
|
} else {
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_WARNING_OBJECT (dec,
|
|
|
|
"discont event didn't include offset, we might set it wrong now");
|
2004-01-29 02:50:20 +00:00
|
|
|
}
|
2004-01-31 17:19:21 +00:00
|
|
|
if (dec->packetno < 3) {
|
2004-03-15 19:32:28 +00:00
|
|
|
if (dec->granulepos != 0)
|
|
|
|
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL),
|
|
|
|
("can't handle discont before parsing first 3 packets"));
|
|
|
|
dec->packetno = 0;
|
|
|
|
gst_pad_push (dec->srcpad, GST_DATA (gst_event_new_discontinuous (FALSE,
|
|
|
|
GST_FORMAT_TIME, (guint64) 0, GST_FORMAT_DEFAULT,
|
|
|
|
(guint64) 0, GST_FORMAT_BYTES, (guint64) 0, 0)));
|
2004-01-31 17:19:21 +00:00
|
|
|
} else {
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
GstFormat time_format, default_format, bytes_format;
|
|
|
|
|
|
|
|
time_format = GST_FORMAT_TIME;
|
|
|
|
default_format = GST_FORMAT_DEFAULT;
|
|
|
|
bytes_format = GST_FORMAT_BYTES;
|
|
|
|
|
2004-03-15 19:32:28 +00:00
|
|
|
dec->packetno = 3;
|
|
|
|
/* if one of them works, all of them work */
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
if (vorbis_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT,
|
|
|
|
dec->granulepos, &time_format, &time)
|
|
|
|
&& vorbis_dec_convert (dec->srcpad, GST_FORMAT_DEFAULT,
|
|
|
|
dec->granulepos, &bytes_format, &bytes)) {
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_pad_push (dec->srcpad,
|
|
|
|
GST_DATA (gst_event_new_discontinuous (FALSE, GST_FORMAT_TIME,
|
ext/: Added query/convert/formats functions to vorbis and theora decoders so that the outside world can use them too....
Original commit message from CVS:
* ext/theora/theoradec.c: (gst_theora_dec_init),
(theora_get_formats), (theora_get_event_masks),
(theora_get_query_types), (theora_dec_src_convert),
(theora_dec_sink_convert), (theora_dec_src_query),
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain):
* ext/vorbis/vorbisdec.c: (vorbis_dec_get_formats),
(vorbis_get_event_masks), (vorbis_get_query_types),
(gst_vorbis_dec_init), (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event), (vorbis_dec_event):
Added query/convert/formats functions to vorbis and theora decoders
so that the outside world can use them too. Fixed seeking on an
ogg/theora/vorbis file by disabling the seeking on the
theora srcpad.
2004-07-21 13:28:23 +00:00
|
|
|
time, GST_FORMAT_DEFAULT, dec->granulepos,
|
|
|
|
GST_FORMAT_BYTES, bytes, 0)));
|
2004-03-15 19:32:28 +00:00
|
|
|
} else {
|
|
|
|
GST_ERROR_OBJECT (dec,
|
|
|
|
"failed to parse data for DISCONT event, not sending any");
|
|
|
|
}
|
2004-02-01 19:21:01 +00:00
|
|
|
#ifdef HAVE_VORBIS_SYNTHESIS_RESTART
|
2004-03-15 19:32:28 +00:00
|
|
|
vorbis_synthesis_restart (&dec->vd);
|
2004-02-01 19:21:01 +00:00
|
|
|
#endif
|
2004-01-31 17:19:21 +00:00
|
|
|
}
|
2004-05-08 16:30:03 +00:00
|
|
|
gst_data_unref (GST_DATA (event));
|
2004-01-29 02:50:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-01-31 17:19:21 +00:00
|
|
|
gst_pad_event_default (dec->sinkpad, event);
|
2004-01-29 02:50:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_chain (GstPad * pad, GstData * data)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
GstVorbisDec *vd;
|
2004-03-15 19:32:28 +00:00
|
|
|
ogg_packet packet; /* lol */
|
2004-01-29 02:50:20 +00:00
|
|
|
|
|
|
|
vd = GST_VORBIS_DEC (gst_pad_get_parent (pad));
|
|
|
|
if (GST_IS_EVENT (data)) {
|
|
|
|
vorbis_dec_event (vd, GST_EVENT (data));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = GST_BUFFER (data);
|
|
|
|
/* make ogg_packet out of the buffer */
|
|
|
|
packet.packet = GST_BUFFER_DATA (buf);
|
|
|
|
packet.bytes = GST_BUFFER_SIZE (buf);
|
|
|
|
packet.granulepos = GST_BUFFER_OFFSET_END (buf);
|
2004-03-14 22:34:34 +00:00
|
|
|
packet.packetno = vd->packetno++;
|
2004-05-31 04:56:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME. Is there anyway to know that this is the last packet and
|
|
|
|
* set e_o_s??
|
|
|
|
*/
|
|
|
|
packet.e_o_s = 0;
|
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
/* switch depending on packet type */
|
|
|
|
if (packet.packet[0] & 1) {
|
|
|
|
/* header packet */
|
|
|
|
if (packet.packet[0] / 2 != packet.packetno) {
|
|
|
|
/* FIXME: just skip? */
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
|
2004-03-15 19:32:28 +00:00
|
|
|
(NULL), ("unexpected packet type %d, expected %d",
|
|
|
|
(gint) packet.packet[0], (gint) packet.packetno));
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_data_unref (data);
|
|
|
|
return;
|
|
|
|
}
|
2004-05-31 04:56:55 +00:00
|
|
|
/* Packetno = 0 if the first byte is exactly 0x01 */
|
|
|
|
packet.b_o_s = (packet.packet[0] == 0x1) ? 1 : 0;
|
2004-01-29 02:50:20 +00:00
|
|
|
if (vorbis_synthesis_headerin (&vd->vi, &vd->vc, &packet)) {
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
|
2004-03-15 19:32:28 +00:00
|
|
|
(NULL), ("couldn't read header packet"));
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_data_unref (data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (packet.packetno == 1) {
|
2004-01-31 11:24:18 +00:00
|
|
|
gchar *encoder = NULL;
|
2004-03-14 22:34:34 +00:00
|
|
|
GstTagList *list =
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_tag_list_from_vorbiscomment_buffer (buf, "\003vorbis", 7,
|
|
|
|
&encoder);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-01-31 11:24:18 +00:00
|
|
|
if (!list) {
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_ERROR_OBJECT (vd, "couldn't decode comments");
|
|
|
|
list = gst_tag_list_new ();
|
2004-01-31 11:24:18 +00:00
|
|
|
}
|
|
|
|
if (encoder) {
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_ENCODER, encoder, NULL);
|
|
|
|
g_free (encoder);
|
2004-01-31 11:24:18 +00:00
|
|
|
}
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TAG_ENCODER_VERSION, vd->vi.version, NULL);
|
2004-02-24 17:34:48 +00:00
|
|
|
if (vd->vi.bitrate_upper > 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_MAXIMUM_BITRATE, (guint) vd->vi.bitrate_upper, NULL);
|
2004-02-24 17:34:48 +00:00
|
|
|
if (vd->vi.bitrate_nominal > 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_NOMINAL_BITRATE, (guint) vd->vi.bitrate_nominal, NULL);
|
2004-02-24 17:34:48 +00:00
|
|
|
if (vd->vi.bitrate_lower > 0)
|
2004-03-15 19:32:28 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_MINIMUM_BITRATE, (guint) vd->vi.bitrate_lower, NULL);
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_element_found_tags_for_pad (GST_ELEMENT (vd), vd->srcpad, 0, list);
|
|
|
|
} else if (packet.packetno == 2) {
|
2004-06-06 19:36:08 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
/* done */
|
|
|
|
vorbis_synthesis_init (&vd->vd, &vd->vi);
|
|
|
|
vorbis_block_init (&vd->vd, &vd->vb);
|
2004-06-06 19:36:08 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-raw-float",
|
|
|
|
"rate", G_TYPE_INT, vd->vi.rate,
|
|
|
|
"channels", G_TYPE_INT, vd->vi.channels,
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
|
|
"width", G_TYPE_INT, 32, "buffer-frames", G_TYPE_INT, 0, NULL);
|
|
|
|
if (!gst_pad_set_explicit_caps (vd->srcpad, caps)) {
|
|
|
|
gst_caps_free (caps);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gst_caps_free (caps);
|
2004-01-29 02:50:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
float **pcm;
|
|
|
|
guint sample_count;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-05-04 18:38:39 +00:00
|
|
|
if (packet.packetno < 3) {
|
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
|
|
|
|
(NULL), ("no header sent yet (packet no is %d)", packet.packetno));
|
|
|
|
gst_data_unref (data);
|
|
|
|
return;
|
|
|
|
}
|
2004-01-29 02:50:20 +00:00
|
|
|
/* normal data packet */
|
|
|
|
if (vorbis_synthesis (&vd->vb, &packet)) {
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
|
2004-03-15 19:32:28 +00:00
|
|
|
(NULL), ("couldn't read data packet"));
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_data_unref (data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (vorbis_synthesis_blockin (&vd->vd, &vd->vb) < 0) {
|
2004-01-29 23:20:45 +00:00
|
|
|
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
|
2004-03-15 19:32:28 +00:00
|
|
|
(NULL), ("vorbis decoder did not accept data packet"));
|
2004-01-29 02:50:20 +00:00
|
|
|
gst_data_unref (data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sample_count = vorbis_synthesis_pcmout (&vd->vd, &pcm);
|
|
|
|
if (sample_count > 0) {
|
|
|
|
int i, j;
|
2004-03-14 22:34:34 +00:00
|
|
|
GstBuffer *out = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE,
|
2004-03-15 19:32:28 +00:00
|
|
|
sample_count * vd->vi.channels * sizeof (float));
|
2004-01-29 02:50:20 +00:00
|
|
|
float *out_data = (float *) GST_BUFFER_DATA (out);
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2004-01-29 02:50:20 +00:00
|
|
|
#ifdef GST_VORBIS_DEC_SEQUENTIAL
|
|
|
|
for (i = 0; i < vd->vi.channels; i++) {
|
2004-03-15 19:32:28 +00:00
|
|
|
memcpy (out_data, pcm[i], sample_count * sizeof (float));
|
|
|
|
out_data += sample_count;
|
2004-01-29 02:50:20 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
for (j = 0; j < sample_count; j++) {
|
2004-03-15 19:32:28 +00:00
|
|
|
for (i = 0; i < vd->vi.channels; i++) {
|
|
|
|
*out_data = pcm[i][j];
|
|
|
|
out_data++;
|
|
|
|
}
|
2004-01-29 02:50:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
GST_BUFFER_OFFSET (out) = vd->granulepos;
|
|
|
|
GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count;
|
|
|
|
GST_BUFFER_TIMESTAMP (out) = vd->granulepos * GST_SECOND / vd->vi.rate;
|
|
|
|
GST_BUFFER_DURATION (out) = sample_count * GST_SECOND / vd->vi.rate;
|
|
|
|
gst_pad_push (vd->srcpad, GST_DATA (out));
|
|
|
|
vorbis_synthesis_read (&vd->vd, sample_count);
|
|
|
|
vd->granulepos += sample_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_data_unref (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:34 +00:00
|
|
|
vorbis_dec_change_state (GstElement * element)
|
2004-01-29 02:50:20 +00:00
|
|
|
{
|
|
|
|
GstVorbisDec *vd = GST_VORBIS_DEC (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
|
|
|
vorbis_info_init (&vd->vi);
|
|
|
|
vorbis_comment_init (&vd->vc);
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
vorbis_block_clear (&vd->vb);
|
|
|
|
vorbis_dsp_clear (&vd->vd);
|
|
|
|
vorbis_comment_clear (&vd->vc);
|
|
|
|
vorbis_info_clear (&vd->vi);
|
|
|
|
vd->packetno = 0;
|
|
|
|
vd->granulepos = 0;
|
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent_class->change_state (element);
|
|
|
|
}
|