2001-12-23 14:15:30 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2005-11-25 22:14:47 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-flacdec
|
|
|
|
* @seealso: flacenc
|
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <para>
|
|
|
|
* flacdec decodes FLAC streams.
|
|
|
|
* <ulink url="http://flac.sourceforge.net/">FLAC</ulink>
|
|
|
|
* is a Free Lossless Audio Codec.
|
|
|
|
* </para>
|
|
|
|
* <title>Example launch line</title>
|
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
|
|
|
* gst-launch filesrc location=media/small/dark.441-16-s.flac ! flacdec ! autoaudiosink
|
|
|
|
* </programlisting>
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: this pipeline doesn't work, but we want to use it as example
|
|
|
|
* gst-launch gnomevfssrc location=http://gstreamer.freedesktop.org/media/small/dark.441-16-s.flac ! flacdec ! autoaudiosink
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-23 14:15:30 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gstflacdec.h"
|
2005-09-07 13:49:37 +00:00
|
|
|
#include <gst/gsttagsetter.h>
|
2003-11-28 13:04:21 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2002-09-18 20:56:42 +00:00
|
|
|
#include "flac_compat.h"
|
2001-12-23 14:15:30 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (flacdec_debug);
|
|
|
|
#define GST_CAT_DEFAULT flacdec_debug
|
|
|
|
|
2003-11-01 15:46:35 +00:00
|
|
|
static GstPadTemplate *src_template, *sink_template;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
|
|
|
GstElementDetails flacdec_details = {
|
|
|
|
"FLAC decoder",
|
2003-11-16 22:02:22 +00:00
|
|
|
"Codec/Decoder/Audio",
|
2001-12-23 14:15:30 +00:00
|
|
|
"Decodes FLAC lossless audio streams",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>",
|
|
|
|
};
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_dec_base_init (gpointer g_class);
|
|
|
|
static void gst_flac_dec_class_init (GstFlacDecClass * klass);
|
|
|
|
static void gst_flac_dec_init (GstFlacDec * flacdec);
|
|
|
|
static void gst_flac_dec_finalize (GObject * object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_dec_loop (GstPad * pad);
|
|
|
|
static GstStateChangeReturn gst_flac_dec_change_state (GstElement * element,
|
2005-09-02 15:44:50 +00:00
|
|
|
GstStateChange transition);
|
2005-12-09 19:51:03 +00:00
|
|
|
static const GstQueryType *gst_flac_dec_get_src_query_types (GstPad * pad);
|
|
|
|
static gboolean gst_flac_dec_src_query (GstPad * pad, GstQuery * query);
|
|
|
|
static gboolean gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format,
|
2004-03-14 22:34:33 +00:00
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
2005-12-09 19:51:03 +00:00
|
|
|
static gboolean gst_flac_dec_src_event (GstPad * pad, GstEvent * event);
|
|
|
|
static gboolean gst_flac_dec_sink_activate (GstPad * sinkpad);
|
|
|
|
static gboolean gst_flac_dec_sink_activate_pull (GstPad * sinkpad,
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
gboolean active);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__SeekableStreamDecoderReadStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_read (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderSeekStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 position, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderTellStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 * position, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderLengthStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_length (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 * length, void *client_data);
|
2005-12-09 19:51:03 +00:00
|
|
|
static FLAC__bool gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
void *client_data);
|
|
|
|
static FLAC__StreamDecoderWriteStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_write (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
const FLAC__Frame * frame,
|
|
|
|
const FLAC__int32 * const buffer[], void *client_data);
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_dec_metadata_callback (const FLAC__SeekableStreamDecoder *
|
2004-03-14 22:34:33 +00:00
|
|
|
decoder, const FLAC__StreamMetadata * metadata, void *client_data);
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_dec_error_callback (const FLAC__SeekableStreamDecoder *
|
2004-03-14 22:34:33 +00:00
|
|
|
decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 14:15:30 +00:00
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
flacdec_get_type (void)
|
|
|
|
{
|
2001-12-23 14:15:30 +00:00
|
|
|
static GType flacdec_type = 0;
|
|
|
|
|
|
|
|
if (!flacdec_type) {
|
|
|
|
static const GTypeInfo flacdec_info = {
|
2005-12-09 19:51:03 +00:00
|
|
|
sizeof (GstFlacDecClass),
|
|
|
|
gst_flac_dec_base_init,
|
2001-12-23 14:15:30 +00:00
|
|
|
NULL,
|
2005-12-09 19:51:03 +00:00
|
|
|
(GClassInitFunc) gst_flac_dec_class_init,
|
2001-12-23 14:15:30 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-12-09 19:51:03 +00:00
|
|
|
sizeof (GstFlacDec),
|
2001-12-23 14:15:30 +00:00
|
|
|
0,
|
2005-12-09 19:51:03 +00:00
|
|
|
(GInstanceInitFunc) gst_flac_dec_init,
|
2001-12-23 14:15:30 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flacdec_type =
|
2005-12-09 19:51:03 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstFlacDec", &flacdec_info,
|
|
|
|
0);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (flacdec_debug, "flacdec", 0, "flac decoder");
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
return flacdec_type;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
2003-11-01 15:46:35 +00:00
|
|
|
flac_caps_factory (void)
|
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_caps_new_simple ("audio/x-flac", NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
/* "rate", GST_PROPS_INT_RANGE (11025, 48000),
|
2005-09-06 21:31:25 +00:00
|
|
|
* "channels", GST_PROPS_INT_RANGE (1, 6), */
|
2003-11-01 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
2003-11-01 15:46:35 +00:00
|
|
|
raw_caps_factory (void)
|
|
|
|
{
|
2005-09-06 21:31:25 +00:00
|
|
|
return gst_caps_from_string ("audio/x-raw-int,"
|
|
|
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
|
|
|
"signed = (boolean) true, "
|
|
|
|
"width = (int) { 8, 16, 32 }, "
|
2005-12-09 11:12:48 +00:00
|
|
|
"depth = (int) { 8, 12, 16, 20, 24, 32 }, "
|
|
|
|
"rate = (int) [ 8000, 96000 ], " "channels = (int) [ 1, 8 ]");
|
2003-11-01 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_base_init (gpointer g_class)
|
2003-11-01 15:46:35 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
GstCaps *raw_caps, *flac_caps;
|
|
|
|
|
|
|
|
raw_caps = raw_caps_factory ();
|
|
|
|
flac_caps = flac_caps_factory ();
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS, flac_caps);
|
2004-03-14 22:34:33 +00:00
|
|
|
src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_PAD_ALWAYS, raw_caps);
|
2003-11-01 15:46:35 +00:00
|
|
|
gst_element_class_add_pad_template (element_class, sink_template);
|
|
|
|
gst_element_class_add_pad_template (element_class, src_template);
|
|
|
|
gst_element_class_set_details (element_class, &flacdec_details);
|
|
|
|
}
|
|
|
|
|
2001-12-23 14:15:30 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_class_init (GstFlacDecClass * klass)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
|
|
|
GstElementClass *gstelement_class;
|
2004-01-31 10:25:05 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2003-04-27 12:00:41 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
gobject_class->finalize = gst_flac_dec_finalize;
|
2004-07-03 04:21:39 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
gstelement_class->change_state = gst_flac_dec_change_state;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_init (GstFlacDec * flacdec)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2003-11-01 15:46:35 +00:00
|
|
|
flacdec->sinkpad = gst_pad_new_from_template (sink_template, "sink");
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_pad_set_activate_function (flacdec->sinkpad, gst_flac_dec_sink_activate);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
gst_pad_set_activatepull_function (flacdec->sinkpad,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_sink_activate_pull);
|
2001-12-23 14:15:30 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->sinkpad);
|
|
|
|
|
2003-11-01 15:46:35 +00:00
|
|
|
flacdec->srcpad = gst_pad_new_from_template (src_template, "src");
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_pad_set_query_type_function (flacdec->srcpad,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_get_src_query_types);
|
|
|
|
gst_pad_set_query_function (flacdec->srcpad, gst_flac_dec_src_query);
|
|
|
|
gst_pad_set_event_function (flacdec->srcpad, gst_flac_dec_src_event);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
gst_pad_use_fixed_caps (flacdec->srcpad);
|
|
|
|
gst_element_add_pad (GST_ELEMENT (flacdec), flacdec->srcpad);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
flacdec->decoder = FLAC__seekable_stream_decoder_new ();
|
|
|
|
flacdec->total_samples = 0;
|
|
|
|
flacdec->init = TRUE;
|
|
|
|
flacdec->eos = FALSE;
|
|
|
|
flacdec->seek_pending = FALSE;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_read_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_read);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_seek_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_seek);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_tell_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_tell);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_length_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_length);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_eof_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_eof);
|
2002-09-18 20:56:42 +00:00
|
|
|
#if FLAC_VERSION >= 0x010003
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_write_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_write);
|
2002-09-18 20:56:42 +00:00
|
|
|
#else
|
|
|
|
FLAC__seekable_stream_decoder_set_write_callback (flacdec->decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
(FLAC__StreamDecoderWriteStatus (*)
|
2004-03-15 19:32:27 +00:00
|
|
|
(const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
const FLAC__Frame * frame,
|
|
|
|
const FLAC__int32 * buffer[], void *client_data))
|
2005-12-09 19:51:03 +00:00
|
|
|
(gst_flac_dec_write));
|
2002-09-18 20:56:42 +00:00
|
|
|
#endif
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_metadata_respond (flacdec->decoder,
|
|
|
|
FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
|
|
|
FLAC__seekable_stream_decoder_set_metadata_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_metadata_callback);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_error_callback (flacdec->decoder,
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_error_callback);
|
2002-06-07 20:09:05 +00:00
|
|
|
FLAC__seekable_stream_decoder_set_client_data (flacdec->decoder, flacdec);
|
|
|
|
}
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-05-07 20:26:46 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_finalize (GObject * object)
|
2004-05-07 20:26:46 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2004-05-07 20:26:46 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (object);
|
2004-05-07 20:26:46 +00:00
|
|
|
|
|
|
|
if (flacdec->decoder)
|
|
|
|
FLAC__seekable_stream_decoder_delete (flacdec->decoder);
|
|
|
|
flacdec->decoder = NULL;
|
|
|
|
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2004-05-07 20:26:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-27 12:00:41 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_update_metadata (GstFlacDec * flacdec,
|
2004-03-14 22:34:33 +00:00
|
|
|
const FLAC__StreamMetadata * metadata)
|
2003-04-27 12:00:41 +00:00
|
|
|
{
|
2003-11-28 13:04:21 +00:00
|
|
|
GstTagList *list;
|
2003-04-27 12:00:41 +00:00
|
|
|
guint32 number_of_comments, cursor, str_len;
|
|
|
|
gchar *p_value, *value, *name, *str_ptr;
|
2003-11-28 13:04:21 +00:00
|
|
|
|
|
|
|
list = gst_tag_list_new ();
|
|
|
|
if (list == NULL) {
|
|
|
|
return FALSE;
|
2003-04-27 12:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
number_of_comments = metadata->data.vorbis_comment.num_comments;
|
|
|
|
value = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("%d tag(s) found", number_of_comments);
|
|
|
|
for (cursor = 0; cursor < number_of_comments; cursor++) {
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
str_ptr = (gchar *) metadata->data.vorbis_comment.comments[cursor].entry;
|
2004-01-13 23:59:51 +00:00
|
|
|
str_len = metadata->data.vorbis_comment.comments[cursor].length;
|
2004-03-14 22:34:33 +00:00
|
|
|
p_value = g_strstr_len (str_ptr, str_len, "=");
|
|
|
|
if (p_value) {
|
2003-04-27 12:00:41 +00:00
|
|
|
name = g_strndup (str_ptr, p_value - str_ptr);
|
2003-11-28 13:04:21 +00:00
|
|
|
value = g_strndup (p_value + 1, str_ptr + str_len - p_value - 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("%s : %s", name, value);
|
2005-10-02 15:33:14 +00:00
|
|
|
gst_vorbis_tag_add (list, name, value);
|
2003-04-27 12:00:41 +00:00
|
|
|
g_free (name);
|
|
|
|
g_free (value);
|
|
|
|
}
|
|
|
|
}
|
2004-10-25 16:10:58 +00:00
|
|
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
|
|
|
GST_TAG_AUDIO_CODEC, "FLAC", NULL);
|
2003-11-28 13:04:21 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad, list);
|
|
|
|
|
2003-04-27 12:00:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_metadata_callback (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
const FLAC__StreamMetadata * metadata, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (metadata->type) {
|
2003-04-27 12:00:41 +00:00
|
|
|
case FLAC__METADATA_TYPE_STREAMINFO:
|
2004-03-14 22:34:33 +00:00
|
|
|
flacdec->stream_samples = metadata->data.stream_info.total_samples;
|
|
|
|
break;
|
2003-04-27 12:00:41 +00:00
|
|
|
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_update_metadata (flacdec, metadata);
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2003-04-27 12:00:41 +00:00
|
|
|
default:
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2003-04-27 12:00:41 +00:00
|
|
|
}
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_error_callback (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__StreamDecoderErrorStatus status, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2002-06-07 20:09:05 +00:00
|
|
|
gchar *error;
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
switch (status) {
|
2002-07-08 19:31:49 +00:00
|
|
|
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
|
2002-06-07 20:09:05 +00:00
|
|
|
error = "lost sync";
|
|
|
|
break;
|
2002-07-08 19:31:49 +00:00
|
|
|
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
|
2002-06-07 20:09:05 +00:00
|
|
|
error = "bad header";
|
|
|
|
break;
|
2002-07-08 19:31:49 +00:00
|
|
|
case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
|
2002-06-07 20:09:05 +00:00
|
|
|
error = "CRC mismatch";
|
|
|
|
break;
|
|
|
|
default:
|
2004-02-16 17:09:18 +00:00
|
|
|
error = "unknown error";
|
2002-06-07 20:09:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL), (error));
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__SeekableStreamDecoderSeekStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 position, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("seek %" G_GINT64_FORMAT, position);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
flacdec->offset = position;
|
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__SeekableStreamDecoderTellStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 * position, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
*position = flacdec->offset;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("tell %" G_GINT64_FORMAT, *position);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__SeekableStreamDecoderLengthStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_length (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__uint64 * length, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GstFormat fmt = GST_FORMAT_BYTES;
|
|
|
|
gint64 len;
|
|
|
|
GstPad *peer;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
if (!(peer = gst_pad_get_peer (flacdec->sinkpad)))
|
2002-06-07 20:09:05 +00:00
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
2005-10-19 15:57:04 +00:00
|
|
|
gst_pad_query_duration (peer, &fmt, &len);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
gst_object_unref (peer);
|
|
|
|
if (fmt != GST_FORMAT_BYTES || len == -1)
|
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
|
|
|
|
|
|
|
*length = len;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("length %" G_GINT64_FORMAT, *length);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__bool
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("eof %d", flacdec->eos);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
return flacdec->eos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__SeekableStreamDecoderReadStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_read (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GstBuffer *buf;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
if (gst_pad_pull_range (flacdec->sinkpad, flacdec->offset, *bytes,
|
|
|
|
&buf) != GST_FLOW_OK)
|
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GST_DEBUG ("Read %d bytes at %" G_GUINT64_FORMAT,
|
|
|
|
GST_BUFFER_SIZE (buf), flacdec->offset);
|
|
|
|
memcpy (buffer, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
|
|
|
*bytes = GST_BUFFER_SIZE (buf);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
flacdec->offset += *bytes;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__StreamDecoderWriteStatus
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_write (const FLAC__SeekableStreamDecoder * decoder,
|
2004-03-14 22:34:33 +00:00
|
|
|
const FLAC__Frame * frame,
|
|
|
|
const FLAC__int32 * const buffer[], void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
2001-12-23 14:15:30 +00:00
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint depth = frame->header.bits_per_sample;
|
2005-12-09 11:12:48 +00:00
|
|
|
guint width;
|
2001-12-23 14:15:30 +00:00
|
|
|
guint channels = frame->header.channels;
|
|
|
|
guint samples = frame->header.blocksize;
|
|
|
|
guint j, i;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GstFlowReturn ret;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2005-12-09 11:12:48 +00:00
|
|
|
switch (depth) {
|
|
|
|
case 8:
|
|
|
|
width = 8;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
case 16:
|
|
|
|
width = 16;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
width = 32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
|
|
}
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (client_data);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
if (flacdec->need_discont) {
|
2005-09-06 21:31:25 +00:00
|
|
|
gint64 time = 0;
|
2002-06-07 20:09:05 +00:00
|
|
|
GstFormat format;
|
2005-09-06 21:31:25 +00:00
|
|
|
GstEvent *newsegment;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
flacdec->need_discont = FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-07-03 04:27:18 +00:00
|
|
|
if (flacdec->seek_pending) {
|
|
|
|
flacdec->total_samples = flacdec->seek_value;
|
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-09-06 21:31:25 +00:00
|
|
|
GST_DEBUG ("newsegment from %" G_GUINT64_FORMAT, flacdec->seek_value);
|
2004-03-15 19:32:27 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
format = GST_FORMAT_TIME;
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT,
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
flacdec->total_samples, &format, &time);
|
2005-11-22 11:53:34 +00:00
|
|
|
newsegment = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, time,
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GST_CLOCK_TIME_NONE, 0);
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2005-09-06 21:31:25 +00:00
|
|
|
if (!gst_pad_push_event (flacdec->srcpad, newsegment))
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 14:15:30 +00:00
|
|
|
if (!GST_PAD_CAPS (flacdec->srcpad)) {
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GST_DEBUG ("Negotiating %d Hz @ %d channels",
|
|
|
|
frame->header.sample_rate, channels);
|
|
|
|
|
|
|
|
if (!gst_pad_set_caps (flacdec->srcpad,
|
|
|
|
gst_caps_new_simple ("audio/x-raw-int",
|
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
|
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
2005-09-06 21:31:25 +00:00
|
|
|
"width", G_TYPE_INT, width,
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
"depth", G_TYPE_INT, depth,
|
|
|
|
"rate", G_TYPE_INT, frame->header.sample_rate,
|
|
|
|
"channels", G_TYPE_INT, channels, NULL)))
|
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
flacdec->depth = depth;
|
2005-09-06 21:31:25 +00:00
|
|
|
flacdec->width = width;
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->channels = channels;
|
|
|
|
flacdec->frequency = frame->header.sample_rate;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2005-12-05 13:03:00 +00:00
|
|
|
ret =
|
|
|
|
gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad,
|
|
|
|
flacdec->total_samples, samples * channels * ((width + 7) >> 3),
|
|
|
|
GST_PAD_CAPS (flacdec->srcpad), &outbuf);
|
2005-10-02 23:08:35 +00:00
|
|
|
if (ret != GST_FLOW_NOT_LINKED && ret != GST_FLOW_OK) {
|
|
|
|
GST_DEBUG ("stopping flac decoder engine (%d)", (gint) ret);
|
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
|
|
}
|
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (outbuf) =
|
|
|
|
flacdec->total_samples * GST_SECOND / frame->header.sample_rate;
|
|
|
|
GST_BUFFER_DURATION (outbuf) =
|
|
|
|
samples * GST_SECOND / frame->header.sample_rate;
|
|
|
|
|
|
|
|
if (depth == 8) {
|
|
|
|
guint8 *outbuffer = (guint8 *) GST_BUFFER_DATA (outbuf);
|
|
|
|
|
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
|
|
|
*outbuffer++ = (guint8) buffer[j][i];
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
}
|
2005-12-09 11:12:48 +00:00
|
|
|
} else if (depth == 12 || depth == 16) {
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
guint16 *outbuffer = (guint16 *) GST_BUFFER_DATA (outbuf);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
|
|
|
*outbuffer++ = (guint16) buffer[j][i];
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
2003-06-28 14:21:47 +00:00
|
|
|
}
|
2005-12-09 11:12:48 +00:00
|
|
|
} else if (depth == 20 || depth == 24 || depth == 32) {
|
2005-09-06 21:31:25 +00:00
|
|
|
guint32 *outbuffer = (guint32 *) GST_BUFFER_DATA (outbuf);
|
|
|
|
|
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
|
|
|
*outbuffer++ = (guint32) buffer[j][i];
|
|
|
|
}
|
|
|
|
}
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
} else {
|
|
|
|
g_warning ("flacdec: invalid depth %d found\n", depth);
|
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
|
|
}
|
2005-09-06 21:31:25 +00:00
|
|
|
GST_DEBUG ("Pushing %d samples, %" GST_TIME_FORMAT ":%" GST_TIME_FORMAT,
|
|
|
|
samples, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf)),
|
|
|
|
GST_TIME_ARGS (GST_BUFFER_DURATION (outbuf)));
|
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
ret = gst_pad_push (flacdec->srcpad, outbuf);
|
|
|
|
if (ret != GST_FLOW_NOT_LINKED && ret != GST_FLOW_OK) {
|
2005-09-06 21:31:25 +00:00
|
|
|
GST_DEBUG ("Invalid return code %d", (gint) ret);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->total_samples += samples;
|
|
|
|
|
2002-07-08 19:31:49 +00:00
|
|
|
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_loop (GstPad * sinkpad)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
FLAC__SeekableStreamDecoderState s;
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacdec = GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad));
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("flacdec: entering loop");
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flacdec->init) {
|
|
|
|
GST_DEBUG ("flacdec: initializing decoder");
|
2005-10-02 15:33:14 +00:00
|
|
|
s = FLAC__seekable_stream_decoder_init (flacdec->decoder);
|
|
|
|
if (s != FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
|
|
goto analyze_state;
|
2004-03-14 22:34:33 +00:00
|
|
|
/* FLAC__seekable_stream_decoder_process_metadata (flacdec->decoder); */
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->init = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flacdec->seek_pending) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG ("perform seek to sample %" G_GINT64_FORMAT, flacdec->seek_value);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (FLAC__seekable_stream_decoder_seek_absolute (flacdec->decoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
flacdec->seek_value)) {
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->total_samples = flacdec->seek_value;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
flacdec->need_discont = TRUE;
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("seek done");
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("seek failed");
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
|
|
|
flacdec->seek_pending = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("flacdec: processing single");
|
2005-10-02 15:33:14 +00:00
|
|
|
FLAC__seekable_stream_decoder_process_single (flacdec->decoder);
|
|
|
|
|
|
|
|
analyze_state:
|
|
|
|
GST_DEBUG ("flacdec: done processing, checking encoder state");
|
|
|
|
s = FLAC__seekable_stream_decoder_get_state (flacdec->decoder);
|
|
|
|
switch (s) {
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_OK:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
|
|
|
|
GST_DEBUG ("flacdec: everything ok");
|
|
|
|
return;
|
|
|
|
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:{
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
GST_DEBUG ("flacdec: got EOS, pushing downstream");
|
|
|
|
FLAC__seekable_stream_decoder_reset (flacdec->decoder);
|
|
|
|
|
|
|
|
event = gst_event_new_eos ();
|
|
|
|
gst_pad_push_event (flacdec->srcpad, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("pausing");
|
|
|
|
gst_pad_pause_task (sinkpad);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
|
|
|
|
case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
|
|
|
|
default:{
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
/* fixme: this error sucks -- should try to figure out when/if an more
|
|
|
|
specific error was already sent via the callback */
|
|
|
|
GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
|
|
|
|
("%s", FLAC__SeekableStreamDecoderStateString[s]));
|
|
|
|
|
|
|
|
event = gst_event_new_eos ();
|
|
|
|
gst_pad_push_event (flacdec->srcpad, event);
|
|
|
|
|
|
|
|
GST_DEBUG ("pausing");
|
|
|
|
gst_pad_pause_task (sinkpad);
|
|
|
|
return;
|
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
}
|
2004-02-04 19:28:51 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
#if 0
|
2004-02-04 19:28:51 +00:00
|
|
|
static const GstFormat *
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_get_src_formats (GstPad * pad)
|
2004-03-14 22:34:33 +00:00
|
|
|
{
|
2004-02-04 19:28:51 +00:00
|
|
|
static const GstFormat formats[] = {
|
|
|
|
GST_FORMAT_DEFAULT,
|
|
|
|
GST_FORMAT_BYTES,
|
|
|
|
GST_FORMAT_TIME,
|
|
|
|
0,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-02-04 19:28:51 +00:00
|
|
|
return formats;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
#endif
|
2002-07-25 18:12:46 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
|
2004-03-14 22:34:33 +00:00
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec = GST_FLAC_DEC (gst_pad_get_parent (pad));
|
2002-06-07 20:09:05 +00:00
|
|
|
guint scale = 1;
|
|
|
|
gint bytes_per_sample;
|
|
|
|
|
2005-09-06 21:31:25 +00:00
|
|
|
bytes_per_sample = flacdec->channels * ((flacdec->width + 7) >> 3);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
switch (src_format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
if (bytes_per_sample == 0)
|
|
|
|
return FALSE;
|
|
|
|
*dest_value = src_value / bytes_per_sample;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
{
|
|
|
|
gint byterate = bytes_per_sample * flacdec->frequency;
|
|
|
|
|
|
|
|
if (byterate == 0)
|
|
|
|
return FALSE;
|
|
|
|
*dest_value = src_value * GST_SECOND / byterate;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-05-24 10:41:21 +00:00
|
|
|
case GST_FORMAT_DEFAULT:
|
2002-06-07 20:09:05 +00:00
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
*dest_value = src_value * bytes_per_sample;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
if (flacdec->frequency == 0)
|
|
|
|
return FALSE;
|
|
|
|
*dest_value = src_value * GST_SECOND / flacdec->frequency;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
switch (*dest_format) {
|
2004-03-15 19:32:27 +00:00
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
scale = bytes_per_sample;
|
|
|
|
case GST_FORMAT_DEFAULT:
|
|
|
|
*dest_value = src_value * scale * flacdec->frequency / GST_SECOND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2004-02-04 19:28:51 +00:00
|
|
|
static const GstQueryType *
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_get_src_query_types (GstPad * pad)
|
2004-03-14 22:34:33 +00:00
|
|
|
{
|
2004-02-04 19:28:51 +00:00
|
|
|
static const GstQueryType types[] = {
|
|
|
|
GST_QUERY_POSITION,
|
|
|
|
0,
|
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-02-04 19:28:51 +00:00
|
|
|
return types;
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
2002-07-25 18:12:46 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_src_query (GstPad * pad, GstQuery * query)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec = GST_FLAC_DEC (gst_pad_get_parent (pad));
|
2002-06-07 20:09:05 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_POSITION:{
|
2005-10-19 15:57:04 +00:00
|
|
|
gint64 pos;
|
|
|
|
GstFormat fmt = GST_FORMAT_TIME;
|
|
|
|
|
|
|
|
pos = flacdec->total_samples;
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
if (gst_flac_dec_convert_src (flacdec->srcpad,
|
2005-10-19 15:57:04 +00:00
|
|
|
GST_FORMAT_DEFAULT, pos, &fmt, &pos))
|
|
|
|
gst_query_set_position (query, GST_FORMAT_TIME, pos);
|
|
|
|
else
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_QUERY_DURATION:{
|
|
|
|
gint64 len;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
GstFormat fmt = GST_FORMAT_TIME;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
if (flacdec->stream_samples == 0)
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
len = flacdec->total_samples;
|
2002-06-07 20:09:05 +00:00
|
|
|
else
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
len = flacdec->stream_samples;
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
if (gst_flac_dec_convert_src (flacdec->srcpad,
|
2005-10-19 15:57:04 +00:00
|
|
|
GST_FORMAT_DEFAULT, len, &fmt, &len))
|
|
|
|
gst_query_set_duration (query, GST_FORMAT_TIME, len);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
else
|
|
|
|
res = FALSE;
|
2002-06-07 20:09:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_src_event (GstPad * pad, GstEvent * event)
|
2004-03-14 22:34:33 +00:00
|
|
|
{
|
2002-06-07 20:09:05 +00:00
|
|
|
gboolean res = TRUE;
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec = GST_FLAC_DEC (gst_pad_get_parent (pad));
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
case GST_EVENT_SEEK:{
|
|
|
|
GstFormat format, seek_fmt;
|
|
|
|
GstSeekType type;
|
|
|
|
gint64 pos;
|
|
|
|
|
|
|
|
gst_event_parse_seek (event, NULL, &seek_fmt, NULL, &type, &pos,
|
|
|
|
NULL, NULL);
|
|
|
|
|
2003-05-24 10:41:21 +00:00
|
|
|
format = GST_FORMAT_DEFAULT;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
if (type == GST_SEEK_TYPE_SET &&
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_convert_src (flacdec->srcpad, seek_fmt, pos,
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
&format, &pos)) {
|
|
|
|
GST_DEBUG ("Initializing seek");
|
|
|
|
g_print ("Grab seek lock\n");
|
|
|
|
gst_pad_push_event (flacdec->srcpad, gst_event_new_flush_start ());
|
2005-11-21 18:09:02 +00:00
|
|
|
GST_PAD_STREAM_LOCK (flacdec->sinkpad);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
g_print ("Got seek lock\n");
|
|
|
|
gst_pad_push_event (flacdec->srcpad, gst_event_new_flush_stop ());
|
|
|
|
GST_DEBUG ("Ready");
|
2004-03-15 19:32:27 +00:00
|
|
|
flacdec->seek_pending = TRUE;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
flacdec->seek_value = pos;
|
|
|
|
gst_pad_start_task (flacdec->sinkpad,
|
2005-12-09 19:51:03 +00:00
|
|
|
(GstTaskFunction) gst_flac_dec_loop, flacdec->sinkpad);
|
2005-11-21 18:09:02 +00:00
|
|
|
GST_PAD_STREAM_UNLOCK (flacdec->sinkpad);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
} else
|
2004-03-15 19:32:27 +00:00
|
|
|
res = FALSE;
|
2002-06-07 20:09:05 +00:00
|
|
|
break;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
default:
|
|
|
|
res = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2002-07-08 19:31:49 +00:00
|
|
|
gst_event_unref (event);
|
2002-06-07 20:09:05 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_sink_activate (GstPad * sinkpad)
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
{
|
|
|
|
if (gst_pad_check_pull_range (sinkpad))
|
|
|
|
return gst_pad_activate_pull (sinkpad, TRUE);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_sink_activate_pull (GstPad * sinkpad, gboolean active)
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
{
|
|
|
|
if (active) {
|
|
|
|
/* if we have a scheduler we can start the task */
|
2005-12-09 19:51:03 +00:00
|
|
|
GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad))->offset = 0;
|
|
|
|
return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flac_dec_loop,
|
2005-10-02 23:08:35 +00:00
|
|
|
sinkpad);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
} else {
|
2005-10-02 23:08:35 +00:00
|
|
|
return gst_pad_stop_task (sinkpad);
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_dec_change_state (GstElement * element, GstStateChange transition)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacDec *flacdec = GST_FLAC_DEC (element);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->seek_pending = FALSE;
|
|
|
|
flacdec->total_samples = 0;
|
|
|
|
flacdec->eos = FALSE;
|
Port flacdec (seeking is still slow'ish).
Original commit message from CVS:
* configure.ac:
* ext/Makefile.am:
* ext/flac/Makefile.am:
* ext/flac/gstflac.c: (plugin_init):
* ext/flac/gstflacdec.c: (flacdec_get_type), (gst_flacdec_init),
(gst_flacdec_update_metadata), (gst_flacdec_seek),
(gst_flacdec_tell), (gst_flacdec_length), (gst_flacdec_read),
(gst_flacdec_write), (gst_flacdec_loop),
(gst_flacdec_get_src_query_types), (gst_flacdec_src_query),
(gst_flacdec_src_event), (gst_flacdec_sink_activate),
(gst_flacdec_sink_activate_pull), (gst_flacdec_change_state):
* ext/flac/gstflacdec.h:
Port flacdec (seeking is still slow'ish).
2005-08-22 11:20:18 +00:00
|
|
|
flacdec->need_discont = TRUE;
|
2003-11-22 13:17:51 +00:00
|
|
|
if (flacdec->init == FALSE) {
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_decoder_reset (flacdec->decoder);
|
2003-11-22 13:17:51 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
break;
|
2005-09-02 15:44:50 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec->eos = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2005-09-02 15:44:50 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|