2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-23 13:56:23 +00:00
|
|
|
* 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 13:56:23 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gstflacenc.h>
|
2003-12-14 19:09:23 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2003-11-28 13:04:21 +00:00
|
|
|
#include <gst/gsttaginterface.h>
|
2002-09-18 20:56:42 +00:00
|
|
|
#include "flac_compat.h"
|
|
|
|
|
2003-11-01 15:46:35 +00:00
|
|
|
static GstPadTemplate *src_template, *sink_template;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
/* elementfactory information */
|
|
|
|
GstElementDetails flacenc_details = {
|
|
|
|
"FLAC encoder",
|
2003-11-16 22:02:22 +00:00
|
|
|
"Codec/Encoder/Audio",
|
2001-12-23 13:56:23 +00:00
|
|
|
"Encodes audio with the FLAC lossless audio encoder",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* FlacEnc signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 13:56:23 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-12-23 13:56:23 +00:00
|
|
|
ARG_0,
|
2002-09-15 22:26:33 +00:00
|
|
|
ARG_QUALITY,
|
|
|
|
ARG_STREAMABLE_SUBSET,
|
|
|
|
ARG_MID_SIDE_STEREO,
|
|
|
|
ARG_LOOSE_MID_SIDE_STEREO,
|
|
|
|
ARG_BLOCKSIZE,
|
|
|
|
ARG_MAX_LPC_ORDER,
|
|
|
|
ARG_QLP_COEFF_PRECISION,
|
|
|
|
ARG_QLP_COEFF_PREC_SEARCH,
|
|
|
|
ARG_ESCAPE_CODING,
|
|
|
|
ARG_EXHAUSTIVE_MODEL_SEARCH,
|
|
|
|
ARG_MIN_RESIDUAL_PARTITION_ORDER,
|
|
|
|
ARG_MAX_RESIDUAL_PARTITION_ORDER,
|
2004-05-21 23:28:57 +00:00
|
|
|
ARG_RICE_PARAMETER_SEARCH_DIST
|
2001-12-23 13:56:23 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void gst_flacenc_base_init (gpointer g_class);
|
|
|
|
static void gst_flacenc_init (FlacEnc * flacenc);
|
|
|
|
static void gst_flacenc_class_init (FlacEncClass * klass);
|
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_flacenc_finalize (GObject * object);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_sinkconnect (GstPad * pad, const GstCaps * caps);
|
|
|
|
static void gst_flacenc_chain (GstPad * pad, GstData * _data);
|
|
|
|
|
|
|
|
static gboolean gst_flacenc_update_quality (FlacEnc * flacenc, gint quality);
|
|
|
|
static void gst_flacenc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_flacenc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
static GstElementStateReturn gst_flacenc_change_state (GstElement * element);
|
|
|
|
|
|
|
|
static FLAC__StreamEncoderWriteStatus
|
|
|
|
gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|
|
|
const FLAC__byte buffer[], unsigned bytes,
|
|
|
|
unsigned samples, unsigned current_frame, void *client_data);
|
2003-05-11 17:18:17 +00:00
|
|
|
static FLAC__SeekableStreamEncoderSeekStatus
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|
|
|
FLAC__uint64 absolute_byte_offset, void *client_data);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-03-19 04:10:05 +00:00
|
|
|
/*static guint gst_flacenc_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
flacenc_get_type (void)
|
|
|
|
{
|
|
|
|
static GType flacenc_type = 0;
|
|
|
|
|
|
|
|
if (!flacenc_type) {
|
|
|
|
static const GTypeInfo flacenc_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (FlacEncClass),
|
2003-11-01 15:46:35 +00:00
|
|
|
gst_flacenc_base_init,
|
2001-12-23 13:56:23 +00:00
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_flacenc_class_init,
|
2001-12-23 13:56:23 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (FlacEnc),
|
2001-12-23 13:56:23 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_flacenc_init,
|
2001-12-23 13:56:23 +00:00
|
|
|
};
|
2003-11-28 13:04:21 +00:00
|
|
|
|
|
|
|
static const GInterfaceInfo tag_setter_info = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flacenc_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "FlacEnc", &flacenc_info, 0);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_type_add_interface_static (flacenc_type, GST_TYPE_TAG_SETTER,
|
2004-03-15 19:32:27 +00:00
|
|
|
&tag_setter_info);
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
return flacenc_type;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gboolean exhaustive_model_search;
|
|
|
|
gboolean escape_coding;
|
|
|
|
gboolean mid_side;
|
|
|
|
gboolean loose_mid_side;
|
|
|
|
guint qlp_coeff_precision;
|
|
|
|
gboolean qlp_coeff_prec_search;
|
|
|
|
guint min_residual_partition_order;
|
|
|
|
guint max_residual_partition_order;
|
|
|
|
guint rice_parameter_search_dist;
|
|
|
|
guint max_lpc_order;
|
|
|
|
guint blocksize;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
|
|
|
FlacEncParams;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static const FlacEncParams flacenc_params[] = {
|
|
|
|
{FALSE, FALSE, FALSE, FALSE, 0, FALSE, 2, 2, 0, 0, 1152},
|
|
|
|
{FALSE, FALSE, TRUE, TRUE, 0, FALSE, 2, 2, 0, 0, 1152},
|
|
|
|
{FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 3, 0, 0, 1152},
|
|
|
|
{FALSE, FALSE, FALSE, FALSE, 0, FALSE, 3, 3, 0, 6, 4608},
|
|
|
|
{FALSE, FALSE, TRUE, TRUE, 0, FALSE, 3, 3, 0, 8, 4608},
|
|
|
|
{FALSE, FALSE, TRUE, FALSE, 0, FALSE, 3, 3, 0, 8, 4608},
|
|
|
|
{FALSE, FALSE, TRUE, FALSE, 0, FALSE, 0, 4, 0, 8, 4608},
|
|
|
|
{TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 8, 4608},
|
|
|
|
{TRUE, FALSE, TRUE, FALSE, 0, FALSE, 0, 6, 0, 12, 4608},
|
|
|
|
{TRUE, TRUE, TRUE, FALSE, 0, FALSE, 0, 16, 0, 32, 4608},
|
2002-09-15 22:26:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFAULT_QUALITY 5
|
|
|
|
|
|
|
|
#define GST_TYPE_FLACENC_QUALITY (gst_flacenc_quality_get_type ())
|
|
|
|
GType
|
|
|
|
gst_flacenc_quality_get_type (void)
|
|
|
|
{
|
|
|
|
static GType qtype = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
if (qtype == 0) {
|
|
|
|
static const GEnumValue values[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{0, "0", "0 - Fastest compression"},
|
|
|
|
{1, "1", "1"},
|
|
|
|
{2, "2", "2"},
|
|
|
|
{3, "3", "3"},
|
|
|
|
{4, "4", "4"},
|
|
|
|
{5, "5", "5 - Default"},
|
|
|
|
{6, "6", "6"},
|
|
|
|
{7, "7", "7"},
|
|
|
|
{8, "8", "8 - Highest compression "},
|
|
|
|
{9, "9", "9 - Insane"},
|
|
|
|
{0, NULL, NULL}
|
2002-09-15 22:26:33 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
qtype = g_enum_register_static ("FlacEncQuality", values);
|
|
|
|
}
|
|
|
|
return qtype;
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
* "channels", GST_PROPS_INT_RANGE (1, 2), */
|
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)
|
|
|
|
{
|
2003-12-22 01:47:09 +00:00
|
|
|
return gst_caps_new_simple ("audio/x-raw-int",
|
2004-03-14 22:34:33 +00:00
|
|
|
"endianness", G_TYPE_INT, G_BYTE_ORDER,
|
|
|
|
"signed", G_TYPE_BOOLEAN, TRUE,
|
|
|
|
"width", G_TYPE_INT, 16,
|
|
|
|
"depth", G_TYPE_INT, 16,
|
|
|
|
"rate", GST_TYPE_INT_RANGE, 11025, 48000,
|
|
|
|
"channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
|
2003-11-01 15:46:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_flacenc_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-08 12:41:02 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS, raw_caps);
|
|
|
|
src_template = gst_pad_template_new ("src", GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS, flac_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, &flacenc_details);
|
|
|
|
}
|
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_class_init (FlacEncClass * klass)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2002-03-19 04:10:05 +00:00
|
|
|
/* we have no properties atm so this is a bit silly */
|
2001-12-23 13:56:23 +00:00
|
|
|
gobject_class->set_property = gst_flacenc_set_property;
|
|
|
|
gobject_class->get_property = gst_flacenc_get_property;
|
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_flacenc_finalize;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUALITY,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_enum ("quality",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Quality",
|
|
|
|
"Speed versus compression tradeoff",
|
|
|
|
GST_TYPE_FLACENC_QUALITY, DEFAULT_QUALITY, G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_STREAMABLE_SUBSET, g_param_spec_boolean ("streamable_subset",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Streamable subset",
|
|
|
|
"true to limit encoder to generating a Subset stream, else false",
|
|
|
|
TRUE, G_PARAM_READWRITE));
|
2002-09-15 22:26:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MID_SIDE_STEREO,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_boolean ("mid_side_stereo", "Do mid side stereo",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Do mid side stereo (only for stereo input)",
|
|
|
|
flacenc_params[DEFAULT_QUALITY].mid_side, G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_LOOSE_MID_SIDE_STEREO, g_param_spec_boolean ("loose_mid_side_stereo",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Loose mid side stereo", "Loose mid side stereo",
|
|
|
|
flacenc_params[DEFAULT_QUALITY].loose_mid_side, G_PARAM_READWRITE));
|
2002-09-15 22:26:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_uint ("blocksize", "Blocksize", "Blocksize in samples",
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__MIN_BLOCK_SIZE, FLAC__MAX_BLOCK_SIZE,
|
|
|
|
flacenc_params[DEFAULT_QUALITY].blocksize, G_PARAM_READWRITE));
|
2002-09-15 22:26:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_LPC_ORDER,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_uint ("max_lpc_order", "Max LPC order",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Max LPC order; 0 => use only fixed predictors", 0,
|
|
|
|
FLAC__MAX_LPC_ORDER, flacenc_params[DEFAULT_QUALITY].max_lpc_order,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_QLP_COEFF_PRECISION, g_param_spec_uint ("qlp_coeff_precision",
|
2004-03-15 19:32:27 +00:00
|
|
|
"QLP coefficients precision",
|
|
|
|
"Precision in bits of quantized linear-predictor coefficients; 0 = automatic",
|
|
|
|
0, 32, flacenc_params[DEFAULT_QUALITY].qlp_coeff_precision,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_QLP_COEFF_PREC_SEARCH, g_param_spec_boolean ("qlp_coeff_prec_search",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Do QLP coefficients precision search",
|
|
|
|
"false = use qlp_coeff_precision, "
|
|
|
|
"true = search around qlp_coeff_precision, take best",
|
|
|
|
flacenc_params[DEFAULT_QUALITY].qlp_coeff_prec_search,
|
|
|
|
G_PARAM_READWRITE));
|
2002-09-15 22:26:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ESCAPE_CODING,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_boolean ("escape_coding", "Do Escape coding",
|
2004-03-15 19:32:27 +00:00
|
|
|
"search for escape codes in the entropy coding stage "
|
|
|
|
"for slightly better compression",
|
|
|
|
flacenc_params[DEFAULT_QUALITY].escape_coding, G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_EXHAUSTIVE_MODEL_SEARCH,
|
|
|
|
g_param_spec_boolean ("exhaustive_model_search",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Do exhaustive model search",
|
|
|
|
"do exhaustive search of LP coefficient quantization (expensive!)",
|
|
|
|
flacenc_params[DEFAULT_QUALITY].exhaustive_model_search,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_MIN_RESIDUAL_PARTITION_ORDER,
|
|
|
|
g_param_spec_uint ("min_residual_partition_order",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Min residual partition order",
|
|
|
|
"Min residual partition order (above 4 doesn't usually help much)", 0,
|
|
|
|
16, flacenc_params[DEFAULT_QUALITY].min_residual_partition_order,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_MAX_RESIDUAL_PARTITION_ORDER,
|
|
|
|
g_param_spec_uint ("max_residual_partition_order",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Max residual partition order",
|
|
|
|
"Max residual partition order (above 4 doesn't usually help much)", 0,
|
|
|
|
16, flacenc_params[DEFAULT_QUALITY].max_residual_partition_order,
|
|
|
|
G_PARAM_READWRITE));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
ARG_RICE_PARAMETER_SEARCH_DIST,
|
|
|
|
g_param_spec_uint ("rice_parameter_search_dist",
|
2004-03-15 19:32:27 +00:00
|
|
|
"rice_parameter_search_dist",
|
|
|
|
"0 = try only calc'd parameter k; else try all [k-dist..k+dist] "
|
|
|
|
"parameters, use best", 0, FLAC__MAX_RICE_PARTITION_ORDER,
|
|
|
|
flacenc_params[DEFAULT_QUALITY].rice_parameter_search_dist,
|
|
|
|
G_PARAM_READWRITE));
|
2002-09-15 17:48:42 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_flacenc_change_state;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_init (FlacEnc * flacenc)
|
2002-09-15 22:26:33 +00:00
|
|
|
{
|
2003-11-01 15:46:35 +00:00
|
|
|
flacenc->sinkpad = gst_pad_new_from_template (sink_template, "sink");
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (flacenc), flacenc->sinkpad);
|
|
|
|
gst_pad_set_chain_function (flacenc->sinkpad, gst_flacenc_chain);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_set_link_function (flacenc->sinkpad, gst_flacenc_sinkconnect);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2003-11-01 15:46:35 +00:00
|
|
|
flacenc->srcpad = gst_pad_new_from_template (src_template, "src");
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (flacenc), flacenc->srcpad);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
GST_FLAG_SET (flacenc, GST_ELEMENT_EVENT_AWARE);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flacenc->encoder = FLAC__seekable_stream_encoder_new ();
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
flacenc->negotiated = FALSE;
|
2005-01-09 20:01:59 +00:00
|
|
|
flacenc->offset = 0;
|
2002-09-15 22:26:33 +00:00
|
|
|
flacenc->first = TRUE;
|
|
|
|
flacenc->first_buf = NULL;
|
|
|
|
flacenc->data = NULL;
|
|
|
|
gst_flacenc_update_quality (flacenc, DEFAULT_QUALITY);
|
2003-11-28 13:04:21 +00:00
|
|
|
flacenc->tags = gst_tag_list_new ();
|
2002-09-15 22:26:33 +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_flacenc_finalize (GObject * object)
|
2002-09-15 22:26:33 +00:00
|
|
|
{
|
|
|
|
FlacEnc *flacenc = GST_FLACENC (object);
|
|
|
|
|
2003-05-11 17:18:17 +00:00
|
|
|
FLAC__seekable_stream_encoder_delete (flacenc->encoder);
|
2004-03-14 22:34:33 +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
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-09-15 22:26:33 +00:00
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_sinkconnect (GstPad * pad, const GstCaps * caps)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2003-07-06 20:49:52 +00:00
|
|
|
GstPadLinkReturn ret;
|
2001-12-23 13:56:23 +00:00
|
|
|
FlacEnc *flacenc;
|
2003-12-22 01:47:09 +00:00
|
|
|
GstStructure *structure;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
flacenc = GST_FLACENC (gst_pad_get_parent (pad));
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2002-01-13 22:27:25 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_structure_get_int (structure, "channels", &flacenc->channels);
|
|
|
|
gst_structure_get_int (structure, "depth", &flacenc->depth);
|
|
|
|
gst_structure_get_int (structure, "rate", &flacenc->sample_rate);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
caps = gst_caps_new_simple ("audio/x-flac",
|
|
|
|
"channels", G_TYPE_INT, flacenc->channels,
|
|
|
|
"rate", G_TYPE_INT, flacenc->sample_rate, NULL);
|
2004-08-17 12:38:33 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
ret = gst_pad_try_set_caps (flacenc->srcpad, caps);
|
|
|
|
if (ret <= 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_bits_per_sample (flacenc->encoder,
|
|
|
|
flacenc->depth);
|
|
|
|
FLAC__seekable_stream_encoder_set_sample_rate (flacenc->encoder,
|
|
|
|
flacenc->sample_rate);
|
|
|
|
FLAC__seekable_stream_encoder_set_channels (flacenc->encoder,
|
|
|
|
flacenc->channels);
|
2002-09-15 17:48:42 +00:00
|
|
|
|
|
|
|
flacenc->negotiated = TRUE;
|
2002-01-13 22:27:25 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
return ret;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_update_quality (FlacEnc * flacenc, gint quality)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2002-09-15 22:26:33 +00:00
|
|
|
flacenc->quality = quality;
|
|
|
|
|
2002-09-21 11:14:39 +00:00
|
|
|
#define DO_UPDATE(name, val, str) \
|
2002-09-19 15:17:02 +00:00
|
|
|
G_STMT_START { \
|
2003-05-11 17:18:17 +00:00
|
|
|
if (FLAC__seekable_stream_encoder_get_##name (flacenc->encoder) != \
|
2002-09-19 15:17:02 +00:00
|
|
|
flacenc_params[quality].val) { \
|
2003-05-11 17:18:17 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_##name (flacenc->encoder, \
|
2002-09-19 15:17:02 +00:00
|
|
|
flacenc_params[quality].val); \
|
|
|
|
g_object_notify (G_OBJECT (flacenc), str); \
|
|
|
|
} \
|
|
|
|
} G_STMT_END
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (flacenc));
|
|
|
|
|
2004-08-17 12:38:33 +00:00
|
|
|
if (flacenc->channels == 2) {
|
|
|
|
DO_UPDATE (do_mid_side_stereo, mid_side, "mid_side_stereo");
|
|
|
|
DO_UPDATE (loose_mid_side_stereo, loose_mid_side, "loose_mid_side");
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
DO_UPDATE (blocksize, blocksize, "blocksize");
|
|
|
|
DO_UPDATE (max_lpc_order, max_lpc_order, "max_lpc_order");
|
|
|
|
DO_UPDATE (qlp_coeff_precision, qlp_coeff_precision, "qlp_coeff_precision");
|
|
|
|
DO_UPDATE (do_qlp_coeff_prec_search, qlp_coeff_prec_search,
|
|
|
|
"qlp_coeff_prec_search");
|
|
|
|
DO_UPDATE (do_escape_coding, escape_coding, "escape_coding");
|
|
|
|
DO_UPDATE (do_exhaustive_model_search, exhaustive_model_search,
|
|
|
|
"exhaustive_model_search");
|
|
|
|
DO_UPDATE (min_residual_partition_order, min_residual_partition_order,
|
|
|
|
"min_residual_partition_order");
|
|
|
|
DO_UPDATE (max_residual_partition_order, max_residual_partition_order,
|
|
|
|
"max_residual_partition_order");
|
|
|
|
DO_UPDATE (rice_parameter_search_dist, rice_parameter_search_dist,
|
|
|
|
"rice_parameter_search_dist");
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
#undef DO_UPDATE
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (flacenc));
|
|
|
|
|
|
|
|
return TRUE;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2003-05-11 17:18:17 +00:00
|
|
|
static FLAC__SeekableStreamEncoderSeekStatus
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|
|
|
FLAC__uint64 absolute_byte_offset, void *client_data)
|
2003-05-11 17:18:17 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
FlacEnc *flacenc;
|
|
|
|
GstEvent *event;
|
2003-05-11 17:18:17 +00:00
|
|
|
|
|
|
|
flacenc = GST_FLACENC (client_data);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flacenc->stopped)
|
2003-05-11 17:18:17 +00:00
|
|
|
return FLAC__STREAM_ENCODER_OK;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
event =
|
|
|
|
gst_event_new_seek ((GstSeekType) (int) (GST_FORMAT_BYTES |
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_SEEK_METHOD_SET), absolute_byte_offset);
|
2003-05-11 17:18:17 +00:00
|
|
|
|
2005-01-09 20:01:59 +00:00
|
|
|
if (event) {
|
2003-10-08 16:08:18 +00:00
|
|
|
gst_pad_push (flacenc->srcpad, GST_DATA (event));
|
2005-01-09 20:01:59 +00:00
|
|
|
flacenc->offset = absolute_byte_offset;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
return FLAC__STREAM_ENCODER_OK;
|
2003-05-11 17:18:17 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static FLAC__StreamEncoderWriteStatus
|
|
|
|
gst_flacenc_write_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|
|
|
const FLAC__byte buffer[], unsigned bytes,
|
|
|
|
unsigned samples, unsigned current_frame, void *client_data)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
|
|
|
FlacEnc *flacenc;
|
|
|
|
GstBuffer *outbuf;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
flacenc = GST_FLACENC (client_data);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flacenc->stopped)
|
2002-09-29 20:51:19 +00:00
|
|
|
return FLAC__STREAM_ENCODER_OK;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
|
|
|
outbuf = gst_buffer_new_and_alloc (bytes);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
memcpy (GST_BUFFER_DATA (outbuf), buffer, bytes);
|
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
if (flacenc->first) {
|
|
|
|
flacenc->first_buf = outbuf;
|
|
|
|
gst_buffer_ref (outbuf);
|
|
|
|
flacenc->first = FALSE;
|
|
|
|
}
|
|
|
|
|
2003-10-08 16:08:18 +00:00
|
|
|
gst_pad_push (flacenc->srcpad, GST_DATA (outbuf));
|
2005-01-09 20:01:59 +00:00
|
|
|
flacenc->offset += bytes;
|
|
|
|
|
|
|
|
return FLAC__STREAM_ENCODER_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static FLAC__SeekableStreamEncoderTellStatus
|
|
|
|
gst_flacenc_tell_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|
|
|
FLAC__uint64 * absolute_byte_offset, void *client_data)
|
|
|
|
{
|
|
|
|
FlacEnc *flacenc = GST_FLACENC (client_data);
|
|
|
|
|
|
|
|
*absolute_byte_offset = flacenc->offset;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2002-09-29 20:51:19 +00:00
|
|
|
return FLAC__STREAM_ENCODER_OK;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
|
2003-11-28 13:04:21 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GList *comments;
|
|
|
|
GList *it;
|
|
|
|
FlacEnc *flacenc = GST_FLACENC (user_data);
|
|
|
|
|
|
|
|
comments = gst_tag_to_vorbis_comments (list, tag);
|
|
|
|
for (it = comments; it != NULL; it = it->next) {
|
|
|
|
FLAC__StreamMetadata_VorbisComment_Entry commment_entry;
|
|
|
|
|
|
|
|
commment_entry.length = strlen (it->data);
|
|
|
|
commment_entry.entry = it->data;
|
|
|
|
FLAC__metadata_object_vorbiscomment_insert_comment (flacenc->meta[0],
|
2004-03-15 19:32:27 +00:00
|
|
|
flacenc->meta[0]->data.vorbis_comment.num_comments,
|
|
|
|
commment_entry, TRUE);
|
2004-03-14 22:34:33 +00:00
|
|
|
g_free (it->data);
|
|
|
|
}
|
|
|
|
g_list_free (comments);
|
2003-11-28 13:04:21 +00:00
|
|
|
}
|
|
|
|
|
2003-05-11 17:18:17 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_set_metadata (FlacEnc * flacenc)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2003-11-28 13:04:21 +00:00
|
|
|
const GstTagList *user_tags;
|
|
|
|
GstTagList *copy;
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2003-05-11 17:18:17 +00:00
|
|
|
g_return_if_fail (flacenc != NULL);
|
2003-11-28 13:04:21 +00:00
|
|
|
user_tags = gst_tag_setter_get_list (GST_TAG_SETTER (flacenc));
|
|
|
|
if ((flacenc->tags == NULL) && (user_tags == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
copy = gst_tag_list_merge (user_tags, flacenc->tags,
|
|
|
|
gst_tag_setter_get_merge_mode (GST_TAG_SETTER (flacenc)));
|
2003-05-11 17:18:17 +00:00
|
|
|
flacenc->meta = g_malloc (sizeof (FLAC__StreamMetadata **));
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
flacenc->meta[0] =
|
|
|
|
FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
2004-01-14 16:08:47 +00:00
|
|
|
gst_tag_list_foreach (copy, add_one_tag, flacenc);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (FLAC__seekable_stream_encoder_set_metadata (flacenc->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
flacenc->meta, 1) != true)
|
2004-01-14 16:08:47 +00:00
|
|
|
g_warning ("Dude, i'm already initialized!");
|
2003-11-28 13:04:21 +00:00
|
|
|
gst_tag_list_free (copy);
|
2003-05-11 17:18:17 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
|
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_chain (GstPad * pad, GstData * _data)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2003-10-08 16:08:18 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-23 13:56:23 +00:00
|
|
|
FlacEnc *flacenc;
|
2002-09-15 22:26:33 +00:00
|
|
|
FLAC__int32 *data;
|
2001-12-23 13:56:23 +00:00
|
|
|
gulong insize;
|
2002-09-15 22:26:33 +00:00
|
|
|
gint samples, depth;
|
|
|
|
gulong i;
|
|
|
|
FLAC__bool res;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (buf != NULL);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
|
|
|
flacenc = GST_FLACENC (gst_pad_get_parent (pad));
|
|
|
|
|
2002-06-07 20:09:05 +00:00
|
|
|
if (GST_IS_EVENT (buf)) {
|
|
|
|
GstEvent *event = GST_EVENT (buf);
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_finish (flacenc->encoder);
|
|
|
|
break;
|
2003-11-28 13:04:21 +00:00
|
|
|
case GST_EVENT_TAG:
|
2004-03-15 19:32:27 +00:00
|
|
|
if (flacenc->tags) {
|
|
|
|
gst_tag_list_insert (flacenc->tags, gst_event_tag_get_list (event),
|
|
|
|
GST_TAG_MERGE_REPLACE);
|
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
break;
|
2002-06-07 20:09:05 +00:00
|
|
|
default:
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2002-06-07 20:09:05 +00:00
|
|
|
}
|
2003-11-28 13:04:21 +00:00
|
|
|
gst_pad_event_default (pad, event);
|
2002-06-07 20:09:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-15 17:48:42 +00:00
|
|
|
if (!flacenc->negotiated) {
|
2004-02-02 17:23:33 +00:00
|
|
|
GST_ELEMENT_ERROR (flacenc, CORE, NEGOTIATION, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("format wasn't negotiated before chain function"));
|
2002-09-15 17:48:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
depth = flacenc->depth;
|
|
|
|
|
|
|
|
insize = GST_BUFFER_SIZE (buf);
|
2004-03-14 22:34:33 +00:00
|
|
|
samples = insize / ((depth + 7) >> 3);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) ==
|
|
|
|
FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED) {
|
2003-05-11 17:18:17 +00:00
|
|
|
FLAC__SeekableStreamEncoderState state;
|
2003-12-02 02:34:37 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_write_callback (flacenc->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_flacenc_write_callback);
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_seek_callback (flacenc->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_flacenc_seek_callback);
|
2005-01-09 20:01:59 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_tell_callback (flacenc->encoder,
|
|
|
|
gst_flacenc_tell_callback);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
FLAC__seekable_stream_encoder_set_client_data (flacenc->encoder, flacenc);
|
|
|
|
|
2003-11-28 13:04:21 +00:00
|
|
|
gst_flacenc_set_metadata (flacenc);
|
2003-05-11 17:18:17 +00:00
|
|
|
state = FLAC__seekable_stream_encoder_init (flacenc->encoder);
|
2002-09-15 22:26:33 +00:00
|
|
|
if (state != FLAC__STREAM_ENCODER_OK) {
|
2004-02-22 15:31:30 +00:00
|
|
|
GST_ELEMENT_ERROR (flacenc, LIBRARY, INIT, (NULL),
|
2004-03-15 19:32:27 +00:00
|
|
|
("could not initialize encoder (wrong parameters?)"));
|
2002-09-15 22:26:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
/* we keep a pointer in the flacenc struct because we are freeing the data
|
|
|
|
* after a push opreration that might never return */
|
|
|
|
data = flacenc->data = g_malloc (samples * sizeof (FLAC__int32));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
if (depth == 8) {
|
|
|
|
gint8 *indata = (gint8 *) GST_BUFFER_DATA (buf);
|
2003-05-11 17:18:17 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
data[i] = (FLAC__int32) * indata++;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
} else if (depth == 16) {
|
2001-12-23 13:56:23 +00:00
|
|
|
gint16 *indata = (gint16 *) GST_BUFFER_DATA (buf);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
data[i] = (FLAC__int32) * indata++;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_buffer_unref (buf);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
res = FLAC__seekable_stream_encoder_process_interleaved (flacenc->encoder,
|
|
|
|
(const FLAC__int32 *) data, samples / flacenc->channels);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
g_free (flacenc->data);
|
|
|
|
flacenc->data = NULL;
|
|
|
|
|
|
|
|
if (!res) {
|
2004-02-22 15:31:30 +00:00
|
|
|
GST_ELEMENT_ERROR (flacenc, STREAM, ENCODE, (NULL), (NULL));
|
2002-09-15 22:26:33 +00:00
|
|
|
}
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
|
|
|
FlacEnc *this;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
this = (FlacEnc *) object;
|
2001-12-23 13:56:23 +00:00
|
|
|
switch (prop_id) {
|
2002-09-15 22:26:33 +00:00
|
|
|
case ARG_QUALITY:
|
|
|
|
gst_flacenc_update_quality (this, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
case ARG_STREAMABLE_SUBSET:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_streamable_subset (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MID_SIDE_STEREO:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_do_mid_side_stereo (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_LOOSE_MID_SIDE_STEREO:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_BLOCKSIZE:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_blocksize (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAX_LPC_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_max_lpc_order (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_QLP_COEFF_PRECISION:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_qlp_coeff_precision (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_QLP_COEFF_PREC_SEARCH:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_ESCAPE_CODING:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_do_escape_coding (this->encoder,
|
2004-03-15 19:32:27 +00:00
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_EXHAUSTIVE_MODEL_SEARCH:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search (this->
|
2004-03-15 19:32:27 +00:00
|
|
|
encoder, g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MIN_RESIDUAL_PARTITION_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_min_residual_partition_order (this->
|
2004-03-15 19:32:27 +00:00
|
|
|
encoder, g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAX_RESIDUAL_PARTITION_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_max_residual_partition_order (this->
|
2004-03-15 19:32:27 +00:00
|
|
|
encoder, g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_RICE_PARAMETER_SEARCH_DIST:
|
2004-03-14 22:34:33 +00:00
|
|
|
FLAC__seekable_stream_encoder_set_rice_parameter_search_dist (this->
|
2004-03-15 19:32:27 +00:00
|
|
|
encoder, g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
return;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
|
|
|
FlacEnc *this;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
this = (FlacEnc *) object;
|
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
switch (prop_id) {
|
2002-09-15 22:26:33 +00:00
|
|
|
case ARG_QUALITY:
|
|
|
|
g_value_set_enum (value, this->quality);
|
|
|
|
break;
|
|
|
|
case ARG_STREAMABLE_SUBSET:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_streamable_subset (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MID_SIDE_STEREO:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_do_mid_side_stereo (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_LOOSE_MID_SIDE_STEREO:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_BLOCKSIZE:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_blocksize (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAX_LPC_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_max_lpc_order (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_QLP_COEFF_PRECISION:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_qlp_coeff_precision (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_QLP_COEFF_PREC_SEARCH:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_ESCAPE_CODING:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_do_escape_coding (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_EXHAUSTIVE_MODEL_SEARCH:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_boolean (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MIN_RESIDUAL_PARTITION_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_min_residual_partition_order (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_MAX_RESIDUAL_PARTITION_ORDER:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_max_residual_partition_order (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
case ARG_RICE_PARAMETER_SEARCH_DIST:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_value_set_uint (value,
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__seekable_stream_encoder_get_rice_parameter_search_dist (this->
|
|
|
|
encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-15 17:48:42 +00:00
|
|
|
static GstElementStateReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_flacenc_change_state (GstElement * element)
|
2002-09-15 17:48:42 +00:00
|
|
|
{
|
|
|
|
FlacEnc *flacenc = GST_FLACENC (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2002-09-15 22:26:33 +00:00
|
|
|
flacenc->first = TRUE;
|
|
|
|
flacenc->stopped = FALSE;
|
2002-09-15 17:48:42 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
2004-03-14 22:34:33 +00:00
|
|
|
if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) !=
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__STREAM_ENCODER_UNINITIALIZED) {
|
|
|
|
flacenc->stopped = TRUE;
|
|
|
|
FLAC__seekable_stream_encoder_finish (flacenc->encoder);
|
2002-09-15 22:26:33 +00:00
|
|
|
}
|
2002-09-15 17:48:42 +00:00
|
|
|
flacenc->negotiated = FALSE;
|
2005-01-09 20:01:59 +00:00
|
|
|
flacenc->offset = 0;
|
2002-09-15 22:26:33 +00:00
|
|
|
if (flacenc->first_buf)
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_buffer_unref (flacenc->first_buf);
|
2002-09-15 22:26:33 +00:00
|
|
|
flacenc->first_buf = NULL;
|
|
|
|
g_free (flacenc->data);
|
|
|
|
flacenc->data = NULL;
|
2003-11-22 01:04:57 +00:00
|
|
|
if (flacenc->meta) {
|
2004-03-15 19:32:27 +00:00
|
|
|
FLAC__metadata_object_delete (flacenc->meta[0]);
|
|
|
|
g_free (flacenc->meta);
|
|
|
|
flacenc->meta = NULL;
|
2003-11-22 01:04:57 +00:00
|
|
|
}
|
2002-09-15 17:48:42 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_NULL:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
|
|
|
|
|
|
|
return GST_STATE_SUCCESS;
|
|
|
|
}
|