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.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
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
|
|
|
//#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>",
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_flacdec_base_init (gpointer g_class);
|
|
|
|
static void gst_flacdec_class_init (FlacDecClass * klass);
|
|
|
|
static void gst_flacdec_init (FlacDec * flacdec);
|
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
|
|
|
static void gst_flacdec_finalize (GObject * object);
|
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
|
|
|
static void gst_flacdec_loop (GstPad * pad);
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn gst_flacdec_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
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 const GstQueryType *gst_flacdec_get_src_query_types (GstPad * pad);
|
|
|
|
static gboolean gst_flacdec_src_query (GstPad * pad, GstQuery * query);
|
2004-03-14 22:34:33 +00:00
|
|
|
static gboolean gst_flacdec_convert_src (GstPad * pad, GstFormat src_format,
|
|
|
|
gint64 src_value, GstFormat * dest_format, gint64 * dest_value);
|
|
|
|
static gboolean gst_flacdec_src_event (GstPad * pad, GstEvent * 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
|
|
|
static gboolean gst_flacdec_sink_activate (GstPad * sinkpad);
|
|
|
|
static gboolean gst_flacdec_sink_activate_pull (GstPad * sinkpad,
|
|
|
|
gboolean active);
|
2001-12-23 14:15:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__SeekableStreamDecoderReadStatus
|
|
|
|
gst_flacdec_read (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderSeekStatus
|
|
|
|
gst_flacdec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 position, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderTellStatus
|
|
|
|
gst_flacdec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 * position, void *client_data);
|
|
|
|
static FLAC__SeekableStreamDecoderLengthStatus
|
|
|
|
gst_flacdec_length (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 * length, void *client_data);
|
|
|
|
static FLAC__bool gst_flacdec_eof (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
void *client_data);
|
|
|
|
static FLAC__StreamDecoderWriteStatus
|
|
|
|
gst_flacdec_write (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
const FLAC__Frame * frame,
|
|
|
|
const FLAC__int32 * const buffer[], void *client_data);
|
|
|
|
static void gst_flacdec_metadata_callback (const FLAC__SeekableStreamDecoder *
|
|
|
|
decoder, const FLAC__StreamMetadata * metadata, void *client_data);
|
|
|
|
static void gst_flacdec_error_callback (const FLAC__SeekableStreamDecoder *
|
|
|
|
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 = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (FlacDecClass),
|
2003-11-01 15:46:35 +00:00
|
|
|
gst_flacdec_base_init,
|
2001-12-23 14:15:30 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_flacdec_class_init,
|
2001-12-23 14:15:30 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (FlacDec),
|
2001-12-23 14:15:30 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_flacdec_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 =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "FlacDec", &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 }, "
|
|
|
|
"depth = (int) { 8, 16, 24, 32 }, "
|
|
|
|
"rate = (int) [ 11025, 48000 ], " "channels = (int) [ 1, 6 ]");
|
2003-11-01 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flacdec_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_class_init (FlacDecClass * 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
|
|
|
|
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
|
|
|
gobject_class->finalize = gst_flacdec_finalize;
|
2004-07-03 04:21:39 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
gstelement_class->change_state = gst_flacdec_change_state;
|
2001-12-23 14:15:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_flacdec_init (FlacDec * 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");
|
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_activate_function (flacdec->sinkpad, gst_flacdec_sink_activate);
|
|
|
|
gst_pad_set_activatepull_function (flacdec->sinkpad,
|
|
|
|
gst_flacdec_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,
|
|
|
|
gst_flacdec_get_src_query_types);
|
2002-07-25 18:12:46 +00:00
|
|
|
gst_pad_set_query_function (flacdec->srcpad, gst_flacdec_src_query);
|
2002-06-07 20:09:05 +00:00
|
|
|
gst_pad_set_event_function (flacdec->srcpad, gst_flacdec_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,
|
|
|
|
gst_flacdec_read);
|
|
|
|
FLAC__seekable_stream_decoder_set_seek_callback (flacdec->decoder,
|
|
|
|
gst_flacdec_seek);
|
|
|
|
FLAC__seekable_stream_decoder_set_tell_callback (flacdec->decoder,
|
|
|
|
gst_flacdec_tell);
|
|
|
|
FLAC__seekable_stream_decoder_set_length_callback (flacdec->decoder,
|
|
|
|
gst_flacdec_length);
|
|
|
|
FLAC__seekable_stream_decoder_set_eof_callback (flacdec->decoder,
|
|
|
|
gst_flacdec_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,
|
|
|
|
gst_flacdec_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))
|
2004-03-14 22:34:33 +00:00
|
|
|
(gst_flacdec_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,
|
|
|
|
gst_flacdec_metadata_callback);
|
|
|
|
FLAC__seekable_stream_decoder_set_error_callback (flacdec->decoder,
|
|
|
|
gst_flacdec_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
|
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
|
|
|
gst_flacdec_finalize (GObject * object)
|
2004-05-07 20:26:46 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (object);
|
|
|
|
|
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_update_metadata (FlacDec * flacdec,
|
|
|
|
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);
|
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_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
|
|
|
|
gst_flacdec_metadata_callback (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
const FLAC__StreamMetadata * metadata, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
flacdec = GST_FLACDEC (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:
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_update_metadata (flacdec, metadata);
|
|
|
|
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
|
|
|
|
gst_flacdec_error_callback (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__StreamDecoderErrorStatus status, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2002-06-07 20:09:05 +00:00
|
|
|
FlacDec *flacdec;
|
|
|
|
gchar *error;
|
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
|
|
|
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
|
|
|
|
gst_flacdec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 position, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
2002-06-07 20:09:05 +00:00
|
|
|
FlacDec *flacdec;
|
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
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
|
|
|
|
gst_flacdec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 * position, void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
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
|
|
|
|
gst_flacdec_length (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__uint64 * length, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
FlacDec *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
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
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;
|
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_query_position (peer, &fmt, NULL, &len);
|
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_eof (const FLAC__SeekableStreamDecoder * decoder, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_read (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
FlacDec *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
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_write (const FLAC__SeekableStreamDecoder * decoder,
|
|
|
|
const FLAC__Frame * frame,
|
|
|
|
const FLAC__int32 * const buffer[], void *client_data)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
guint depth = frame->header.bits_per_sample;
|
2005-09-06 21:31:25 +00:00
|
|
|
guint width = (depth == 24) ? 32 : depth;
|
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
|
|
|
|
|
|
|
flacdec = GST_FLACDEC (client_data);
|
|
|
|
|
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;
|
|
|
|
gst_flacdec_convert_src (flacdec->srcpad, GST_FORMAT_DEFAULT,
|
|
|
|
flacdec->total_samples, &format, &time);
|
2005-09-06 21:31:25 +00:00
|
|
|
newsegment = gst_event_new_newsegment (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
|
|
|
}
|
|
|
|
|
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_alloc_buffer (flacdec->srcpad, flacdec->total_samples,
|
2005-09-06 21:31:25 +00:00
|
|
|
samples * channels * ((width + 7) >> 3), 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
|
|
|
&outbuf);
|
|
|
|
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
|
|
|
}
|
|
|
|
} else if (depth == 16) {
|
|
|
|
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-09-06 21:31:25 +00:00
|
|
|
} else if (depth == 24 || depth == 32) {
|
|
|
|
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
|
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_flacdec_loop (GstPad * sinkpad)
|
2001-12-23 14:15:30 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec;
|
2002-06-07 20:09:05 +00:00
|
|
|
gboolean 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
|
|
|
FLAC__SeekableStreamDecoderState s;
|
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
|
|
|
flacdec = GST_FLACDEC (GST_OBJECT_PARENT (sinkpad));
|
|
|
|
|
|
|
|
GST_STREAM_LOCK (sinkpad);
|
2002-06-07 20:09:05 +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) {
|
2003-11-22 13:17:51 +00:00
|
|
|
FLAC__StreamDecoderState res;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("flacdec: initializing decoder");
|
2003-11-22 13:17:51 +00:00
|
|
|
res = FLAC__seekable_stream_decoder_init (flacdec->decoder);
|
|
|
|
if (res != FLAC__SEEKABLE_STREAM_DECODER_OK) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (flacdec, LIBRARY, INIT, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
(FLAC__SeekableStreamDecoderStateString[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
|
|
|
goto end;
|
2003-11-22 13:17:51 +00:00
|
|
|
}
|
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");
|
2002-09-29 20:51:19 +00:00
|
|
|
res = FLAC__seekable_stream_decoder_process_single (flacdec->decoder);
|
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 (!res)
|
|
|
|
goto end;
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("flacdec: checking for EOS");
|
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 ((s = FLAC__seekable_stream_decoder_get_state (flacdec->decoder)) ==
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) {
|
2002-06-07 20:09:05 +00:00
|
|
|
GstEvent *event;
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("flacdec: sending EOS event");
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_decoder_reset (flacdec->decoder);
|
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
|
|
|
event = gst_event_new_eos ();
|
|
|
|
if (!gst_pad_push_event (flacdec->srcpad, event))
|
|
|
|
goto end;
|
|
|
|
} else if (s >= FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR &&
|
|
|
|
s <= FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK) {
|
|
|
|
GST_DEBUG ("Error: %d", s);
|
|
|
|
goto end;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
2003-06-29 19:46:12 +00:00
|
|
|
GST_DEBUG ("flacdec: _loop end");
|
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_STREAM_UNLOCK (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
|
|
|
end:
|
|
|
|
GST_DEBUG ("pausing");
|
|
|
|
gst_pad_pause_task (sinkpad);
|
|
|
|
GST_STREAM_UNLOCK (sinkpad);
|
|
|
|
}
|
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 *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_get_src_formats (GstPad * pad)
|
|
|
|
{
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_convert_src (GstPad * pad, GstFormat src_format, gint64 src_value,
|
|
|
|
GstFormat * dest_format, gint64 * dest_value)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
FlacDec *flacdec = GST_FLACDEC (gst_pad_get_parent (pad));
|
|
|
|
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 *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_get_src_query_types (GstPad * pad)
|
|
|
|
{
|
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
|
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_flacdec_src_query (GstPad * pad, GstQuery * query)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
gboolean res = TRUE;
|
|
|
|
FlacDec *flacdec = GST_FLACDEC (gst_pad_get_parent (pad));
|
|
|
|
|
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:{
|
|
|
|
gint64 len, pos;
|
|
|
|
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;
|
|
|
|
pos = flacdec->total_samples;
|
|
|
|
|
|
|
|
if (gst_flacdec_convert_src (flacdec->srcpad,
|
|
|
|
GST_FORMAT_DEFAULT, len, &fmt, &len) &&
|
|
|
|
gst_flacdec_convert_src (flacdec->srcpad,
|
|
|
|
GST_FORMAT_DEFAULT, pos, &fmt, &pos))
|
|
|
|
gst_query_set_position (query, GST_FORMAT_TIME, pos, len);
|
|
|
|
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
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacdec_src_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
2002-06-07 20:09:05 +00:00
|
|
|
gboolean res = TRUE;
|
|
|
|
FlacDec *flacdec = GST_FLACDEC (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
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 &&
|
|
|
|
gst_flacdec_convert_src (flacdec->srcpad, seek_fmt, pos,
|
|
|
|
&format, &pos)) {
|
|
|
|
GST_DEBUG ("Initializing seek");
|
|
|
|
g_print ("Grab seek lock\n");
|
|
|
|
gst_pad_push_event (flacdec->srcpad, gst_event_new_flush_start ());
|
|
|
|
GST_STREAM_LOCK (flacdec->sinkpad);
|
|
|
|
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,
|
|
|
|
(GstTaskFunction) gst_flacdec_loop, flacdec->sinkpad);
|
|
|
|
GST_STREAM_UNLOCK (flacdec->sinkpad);
|
|
|
|
} 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
|
|
|
|
gst_flacdec_sink_activate (GstPad * sinkpad)
|
|
|
|
{
|
|
|
|
if (gst_pad_check_pull_range (sinkpad))
|
|
|
|
return gst_pad_activate_pull (sinkpad, TRUE);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_flacdec_sink_activate_pull (GstPad * sinkpad, gboolean active)
|
|
|
|
{
|
|
|
|
if (active) {
|
|
|
|
/* if we have a scheduler we can start the task */
|
|
|
|
GST_FLACDEC (GST_OBJECT_PARENT (sinkpad))->offset = 0;
|
|
|
|
gst_pad_start_task (sinkpad, (GstTaskFunction) gst_flacdec_loop, sinkpad);
|
|
|
|
} else {
|
|
|
|
gst_pad_stop_task (sinkpad);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-02 15:44:50 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_flacdec_change_state (GstElement * element, GstStateChange transition)
|
2002-06-07 20:09:05 +00:00
|
|
|
{
|
|
|
|
FlacDec *flacdec = GST_FLACDEC (element);
|
|
|
|
|
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
|
|
|
}
|