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
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2001-12-23 13:56:23 +00:00
|
|
|
*/
|
2009-01-28 15:46:06 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-flacenc
|
|
|
|
* @see_also: #GstFlacDec
|
|
|
|
*
|
|
|
|
* flacenc encodes FLAC streams.
|
|
|
|
* <ulink url="http://flac.sourceforge.net/">FLAC</ulink>
|
2013-03-23 13:11:02 +00:00
|
|
|
* is a Free Lossless Audio Codec. FLAC audio can directly be written into
|
|
|
|
* a file, or embedded into containers such as oggmux or matroskamux.
|
2009-01-28 15:46:06 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <title>Example launch line</title>
|
|
|
|
* |[
|
2012-08-26 21:39:55 +00:00
|
|
|
* gst-launch-1.0 audiotestsrc num-buffers=100 ! flacenc ! filesink location=beep.flac
|
2013-03-23 13:11:02 +00:00
|
|
|
* ]| Encode a short sine wave into FLAC
|
|
|
|
* |[
|
|
|
|
* gst-launch-1.0 cdparanoiasrc mode=continuous ! queue ! audioconvert ! flacenc ! filesink location=cd.flac
|
|
|
|
* ]| Rip a whole audio CD into a single FLAC file, with the track table saved as a CUE sheet inside the FLAC file
|
|
|
|
* |[
|
|
|
|
* gst-launch-1.0 cdparanoiasrc track=5 ! queue ! audioconvert ! flacenc ! filesink location=track5.flac
|
|
|
|
* ]| Rip track 5 of an audio CD and encode it losslessly to a FLAC file
|
2009-01-28 15:46:06 +00:00
|
|
|
* </refsect2>
|
|
|
|
*/
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2008-08-08 15:20:24 +00:00
|
|
|
/* TODO: - We currently don't handle discontinuities in the stream in a useful
|
|
|
|
* way and instead rely on the developer plugging in audiorate if
|
|
|
|
* the stream contains discontinuities.
|
2007-05-25 16:02:51 +00:00
|
|
|
*/
|
2001-12-23 13:56:23 +00:00
|
|
|
|
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>
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2003-12-14 19:09:23 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2005-09-07 13:49:37 +00:00
|
|
|
#include <gst/gsttagsetter.h>
|
2002-09-18 20:56:42 +00:00
|
|
|
|
2008-08-03 09:23:14 +00:00
|
|
|
/* Taken from http://flac.sourceforge.net/format.html#frame_header */
|
|
|
|
static const GstAudioChannelPosition channel_positions[8][8] = {
|
2012-01-06 08:40:22 +00:00
|
|
|
{GST_AUDIO_CHANNEL_POSITION_MONO},
|
2008-08-03 09:23:14 +00:00
|
|
|
{GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2012-01-06 08:40:22 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2008-08-03 09:23:14 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT},
|
|
|
|
/* FIXME: 7/8 channel layouts are not defined in the FLAC specs */
|
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2012-01-06 08:40:22 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2008-08-03 09:23:14 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, {
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2012-01-06 08:40:22 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2008-08-03 09:23:14 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}
|
|
|
|
};
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
2014-02-04 20:26:56 +00:00
|
|
|
#define FORMATS "{ S24LE, S24_32LE, S16LE, S8 } "
|
2012-01-06 08:40:22 +00:00
|
|
|
#else
|
2014-02-04 20:26:56 +00:00
|
|
|
#define FORMATS "{ S24BE, S24_32BE, S16BE, S8 } "
|
2012-01-06 08:40:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FLAC_SINK_CAPS \
|
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) " FORMATS ", " \
|
|
|
|
"layout = (string) interleaved, " \
|
|
|
|
"rate = (int) [ 1, 655350 ], " \
|
|
|
|
"channels = (int) [ 1, 8 ]"
|
2005-10-02 15:33:14 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-flac")
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
GST_STATIC_CAPS (FLAC_SINK_CAPS)
|
2005-10-02 15:33:14 +00:00
|
|
|
);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2005-10-02 15:33:14 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_QUALITY,
|
|
|
|
PROP_STREAMABLE_SUBSET,
|
|
|
|
PROP_MID_SIDE_STEREO,
|
|
|
|
PROP_LOOSE_MID_SIDE_STEREO,
|
|
|
|
PROP_BLOCKSIZE,
|
|
|
|
PROP_MAX_LPC_ORDER,
|
|
|
|
PROP_QLP_COEFF_PRECISION,
|
|
|
|
PROP_QLP_COEFF_PREC_SEARCH,
|
|
|
|
PROP_ESCAPE_CODING,
|
|
|
|
PROP_EXHAUSTIVE_MODEL_SEARCH,
|
|
|
|
PROP_MIN_RESIDUAL_PARTITION_ORDER,
|
|
|
|
PROP_MAX_RESIDUAL_PARTITION_ORDER,
|
2009-07-16 18:44:40 +00:00
|
|
|
PROP_RICE_PARAMETER_SEARCH_DIST,
|
2010-01-06 16:06:53 +00:00
|
|
|
PROP_PADDING,
|
|
|
|
PROP_SEEKPOINTS
|
2001-12-23 13:56:23 +00:00
|
|
|
};
|
|
|
|
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (flacenc_debug);
|
|
|
|
#define GST_CAT_DEFAULT flacenc_debug
|
|
|
|
|
2011-04-19 16:55:31 +00:00
|
|
|
#define gst_flac_enc_parent_class parent_class
|
2011-10-13 15:12:23 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstFlacEnc, gst_flac_enc, GST_TYPE_AUDIO_ENCODER,
|
2012-07-26 13:19:57 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL)
|
|
|
|
G_IMPLEMENT_INTERFACE (GST_TYPE_TOC_SETTER, NULL)
|
|
|
|
);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
static gboolean gst_flac_enc_start (GstAudioEncoder * enc);
|
|
|
|
static gboolean gst_flac_enc_stop (GstAudioEncoder * enc);
|
|
|
|
static gboolean gst_flac_enc_set_format (GstAudioEncoder * enc,
|
|
|
|
GstAudioInfo * info);
|
|
|
|
static GstFlowReturn gst_flac_enc_handle_frame (GstAudioEncoder * enc,
|
|
|
|
GstBuffer * in_buf);
|
2011-09-28 15:39:12 +00:00
|
|
|
static GstCaps *gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter);
|
2011-09-28 14:09:58 +00:00
|
|
|
static gboolean gst_flac_enc_sink_event (GstAudioEncoder * enc,
|
|
|
|
GstEvent * event);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_enc_finalize (GObject * object);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
static gboolean gst_flac_enc_update_quality (GstFlacEnc * flacenc,
|
|
|
|
gint quality);
|
|
|
|
static void gst_flac_enc_set_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:33 +00:00
|
|
|
const GValue * value, GParamSpec * pspec);
|
2005-12-09 19:51:03 +00:00
|
|
|
static void gst_flac_enc_get_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:33 +00:00
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
static FLAC__StreamEncoderWriteStatus
|
|
|
|
gst_flac_enc_write_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
const FLAC__byte buffer[], size_t bytes,
|
|
|
|
unsigned samples, unsigned current_frame, void *client_data);
|
|
|
|
static FLAC__StreamEncoderSeekStatus
|
|
|
|
gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
FLAC__uint64 absolute_byte_offset, void *client_data);
|
|
|
|
static FLAC__StreamEncoderTellStatus
|
|
|
|
gst_flac_enc_tell_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
FLAC__uint64 * absolute_byte_offset, void *client_data);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
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
|
|
|
}
|
2005-10-02 15:33:14 +00:00
|
|
|
GstFlacEncParams;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static const GstFlacEncParams flacenc_params[] = {
|
2004-03-14 22:34:33 +00:00
|
|
|
{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
|
2009-07-16 18:44:40 +00:00
|
|
|
#define DEFAULT_PADDING 0
|
2012-03-12 14:27:27 +00:00
|
|
|
#define DEFAULT_SEEKPOINTS -10
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
#define GST_TYPE_FLAC_ENC_QUALITY (gst_flac_enc_quality_get_type ())
|
2010-03-17 17:23:00 +00:00
|
|
|
static GType
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_quality_get_type (void)
|
2002-09-15 22:26:33 +00:00
|
|
|
{
|
|
|
|
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[] = {
|
2005-11-22 18:11:58 +00:00
|
|
|
{0, "0 - Fastest compression", "0"},
|
2004-03-14 22:34:33 +00:00
|
|
|
{1, "1", "1"},
|
|
|
|
{2, "2", "2"},
|
|
|
|
{3, "3", "3"},
|
|
|
|
{4, "4", "4"},
|
2005-11-22 18:11:58 +00:00
|
|
|
{5, "5 - Default", "5"},
|
2004-03-14 22:34:33 +00:00
|
|
|
{6, "6", "6"},
|
|
|
|
{7, "7", "7"},
|
2005-11-22 18:11:58 +00:00
|
|
|
{8, "8 - Highest compression", "8"},
|
|
|
|
{9, "9 - Insane", "9"},
|
2004-03-14 22:34:33 +00:00
|
|
|
{0, NULL, NULL}
|
2002-09-15 22:26:33 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
qtype = g_enum_register_static ("GstFlacEncQuality", values);
|
2002-09-15 22:26:33 +00:00
|
|
|
}
|
|
|
|
return qtype;
|
|
|
|
}
|
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_class_init (GstFlacEncClass * klass)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2011-09-28 14:09:58 +00:00
|
|
|
GstAudioEncoderClass *base_class;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2011-09-28 14:09:58 +00:00
|
|
|
base_class = (GstAudioEncoderClass *) (klass);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2011-04-19 16:55:31 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (flacenc_debug, "flacenc", 0,
|
|
|
|
"Flac encoding element");
|
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
gobject_class->set_property = gst_flac_enc_set_property;
|
|
|
|
gobject_class->get_property = gst_flac_enc_get_property;
|
|
|
|
gobject_class->finalize = gst_flac_enc_finalize;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_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",
|
2008-09-04 09:25:59 +00:00
|
|
|
GST_TYPE_FLAC_ENC_QUALITY, DEFAULT_QUALITY,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2010-10-07 20:12:48 +00:00
|
|
|
PROP_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",
|
2010-10-13 13:25:15 +00:00
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2005-10-02 15:33:14 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MID_SIDE_STEREO,
|
2010-10-07 20:12:48 +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)",
|
2008-09-04 09:25:59 +00:00
|
|
|
flacenc_params[DEFAULT_QUALITY].mid_side,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2010-10-07 20:12:48 +00:00
|
|
|
PROP_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",
|
2008-09-04 09:25:59 +00:00
|
|
|
flacenc_params[DEFAULT_QUALITY].loose_mid_side,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2005-10-02 15:33:14 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_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,
|
2008-09-04 09:25:59 +00:00
|
|
|
flacenc_params[DEFAULT_QUALITY].blocksize,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2005-10-02 15:33:14 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_LPC_ORDER,
|
2010-10-07 20:12:48 +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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2010-10-07 20:12:48 +00:00
|
|
|
PROP_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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2010-10-07 20:12:48 +00:00
|
|
|
PROP_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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2005-10-02 15:33:14 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_ESCAPE_CODING,
|
2010-10-07 20:12:48 +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",
|
2008-09-04 09:25:59 +00:00
|
|
|
flacenc_params[DEFAULT_QUALITY].escape_coding,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2005-10-02 15:33:14 +00:00
|
|
|
PROP_EXHAUSTIVE_MODEL_SEARCH,
|
2010-10-07 20:12:48 +00:00
|
|
|
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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2005-10-02 15:33:14 +00:00
|
|
|
PROP_MIN_RESIDUAL_PARTITION_ORDER,
|
2010-10-07 20:12:48 +00:00
|
|
|
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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2005-10-02 15:33:14 +00:00
|
|
|
PROP_MAX_RESIDUAL_PARTITION_ORDER,
|
2010-10-07 20:12:48 +00:00
|
|
|
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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
2005-10-02 15:33:14 +00:00
|
|
|
PROP_RICE_PARAMETER_SEARCH_DIST,
|
2010-10-07 20:12:48 +00:00
|
|
|
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,
|
2010-10-13 13:25:15 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2009-07-16 18:44:40 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
PROP_PADDING,
|
|
|
|
g_param_spec_uint ("padding",
|
|
|
|
"Padding",
|
|
|
|
"Write a PADDING block with this length in bytes", 0, G_MAXUINT,
|
2010-10-13 13:25:15 +00:00
|
|
|
DEFAULT_PADDING,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2010-01-06 16:06:53 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
|
|
PROP_SEEKPOINTS,
|
|
|
|
g_param_spec_int ("seekpoints",
|
|
|
|
"Seekpoints",
|
|
|
|
"Add SEEKTABLE metadata (if > 0, number of entries, if < 0, interval in sec)",
|
|
|
|
-G_MAXINT, G_MAXINT,
|
2010-10-13 13:25:15 +00:00
|
|
|
DEFAULT_SEEKPOINTS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
|
2010-01-06 16:06:53 +00:00
|
|
|
|
2011-04-19 16:55:31 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&src_factory));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sink_factory));
|
|
|
|
|
2012-04-09 23:51:41 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class, "FLAC audio encoder",
|
2011-04-19 16:55:31 +00:00
|
|
|
"Codec/Encoder/Audio",
|
|
|
|
"Encodes audio with the FLAC lossless audio encoder",
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2011-09-28 15:39:12 +00:00
|
|
|
|
|
|
|
base_class->start = GST_DEBUG_FUNCPTR (gst_flac_enc_start);
|
|
|
|
base_class->stop = GST_DEBUG_FUNCPTR (gst_flac_enc_stop);
|
|
|
|
base_class->set_format = GST_DEBUG_FUNCPTR (gst_flac_enc_set_format);
|
|
|
|
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_flac_enc_handle_frame);
|
|
|
|
base_class->getcaps = GST_DEBUG_FUNCPTR (gst_flac_enc_getcaps);
|
2012-03-30 10:18:45 +00:00
|
|
|
base_class->sink_event = GST_DEBUG_FUNCPTR (gst_flac_enc_sink_event);
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
static void
|
2011-04-19 16:55:31 +00:00
|
|
|
gst_flac_enc_init (GstFlacEnc * flacenc)
|
2002-09-15 22:26:33 +00:00
|
|
|
{
|
2011-09-28 14:09:58 +00:00
|
|
|
GstAudioEncoder *enc = GST_AUDIO_ENCODER (flacenc);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
flacenc->encoder = FLAC__stream_encoder_new ();
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_update_quality (flacenc, DEFAULT_QUALITY);
|
2011-09-28 14:09:58 +00:00
|
|
|
|
|
|
|
/* arrange granulepos marking (and required perfect ts) */
|
|
|
|
gst_audio_encoder_set_mark_granule (enc, TRUE);
|
|
|
|
gst_audio_encoder_set_perfect_timestamp (enc, TRUE);
|
2002-09-15 22:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_finalize (GObject * object)
|
2002-09-15 22:26:33 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacEnc *flacenc = GST_FLAC_ENC (object);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__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
|
|
|
}
|
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
static gboolean
|
|
|
|
gst_flac_enc_start (GstAudioEncoder * enc)
|
|
|
|
{
|
|
|
|
GstFlacEnc *flacenc = GST_FLAC_ENC (enc);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (enc, "start");
|
|
|
|
flacenc->stopped = TRUE;
|
|
|
|
flacenc->got_headers = FALSE;
|
|
|
|
flacenc->last_flow = GST_FLOW_OK;
|
|
|
|
flacenc->offset = 0;
|
|
|
|
flacenc->eos = FALSE;
|
2011-10-30 11:44:53 +00:00
|
|
|
flacenc->tags = gst_tag_list_new_empty ();
|
2012-07-26 13:19:57 +00:00
|
|
|
flacenc->toc = NULL;
|
2014-06-10 09:59:13 +00:00
|
|
|
flacenc->samples_in = 0;
|
|
|
|
flacenc->samples_out = 0;
|
2011-09-28 14:09:58 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_flac_enc_stop (GstAudioEncoder * enc)
|
|
|
|
{
|
|
|
|
GstFlacEnc *flacenc = GST_FLAC_ENC (enc);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (enc, "stop");
|
2012-08-04 15:10:16 +00:00
|
|
|
gst_tag_list_unref (flacenc->tags);
|
2011-09-28 14:09:58 +00:00
|
|
|
flacenc->tags = NULL;
|
2012-07-26 13:19:57 +00:00
|
|
|
if (flacenc->toc)
|
|
|
|
gst_toc_unref (flacenc->toc);
|
|
|
|
flacenc->toc = NULL;
|
2011-09-28 14:09:58 +00:00
|
|
|
if (FLAC__stream_encoder_get_state (flacenc->encoder) !=
|
|
|
|
FLAC__STREAM_ENCODER_UNINITIALIZED) {
|
|
|
|
flacenc->stopped = TRUE;
|
|
|
|
FLAC__stream_encoder_finish (flacenc->encoder);
|
|
|
|
}
|
|
|
|
if (flacenc->meta) {
|
|
|
|
FLAC__metadata_object_delete (flacenc->meta[0]);
|
|
|
|
|
|
|
|
if (flacenc->meta[1])
|
|
|
|
FLAC__metadata_object_delete (flacenc->meta[1]);
|
|
|
|
|
|
|
|
if (flacenc->meta[2])
|
|
|
|
FLAC__metadata_object_delete (flacenc->meta[2]);
|
|
|
|
|
2012-07-26 13:19:57 +00:00
|
|
|
if (flacenc->meta[3])
|
|
|
|
FLAC__metadata_object_delete (flacenc->meta[3]);
|
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
g_free (flacenc->meta);
|
|
|
|
flacenc->meta = NULL;
|
|
|
|
}
|
|
|
|
g_list_foreach (flacenc->headers, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (flacenc->headers);
|
|
|
|
flacenc->headers = NULL;
|
|
|
|
|
2011-11-16 17:57:21 +00:00
|
|
|
gst_tag_setter_reset_tags (GST_TAG_SETTER (enc));
|
2012-07-26 13:19:57 +00:00
|
|
|
gst_toc_setter_reset (GST_TOC_SETTER (enc));
|
2011-11-16 17:57:21 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static void
|
|
|
|
add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
|
|
|
|
{
|
|
|
|
GList *comments;
|
|
|
|
GList *it;
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacEnc *flacenc = GST_FLAC_ENC (user_data);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2011-04-13 14:09:04 +00:00
|
|
|
/* IMAGE and PREVIEW_IMAGE tags are already written
|
|
|
|
* differently, no need to store them inside the
|
|
|
|
* vorbiscomments too */
|
2011-04-13 14:17:41 +00:00
|
|
|
if (strcmp (tag, GST_TAG_IMAGE) == 0
|
|
|
|
|| strcmp (tag, GST_TAG_PREVIEW_IMAGE) == 0)
|
2011-04-13 14:09:04 +00:00
|
|
|
return;
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
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],
|
|
|
|
flacenc->meta[0]->data.vorbis_comment.num_comments,
|
|
|
|
commment_entry, TRUE);
|
|
|
|
g_free (it->data);
|
|
|
|
}
|
|
|
|
g_list_free (comments);
|
|
|
|
}
|
|
|
|
|
2012-07-26 13:19:57 +00:00
|
|
|
static gboolean
|
|
|
|
add_cuesheet (const GstToc * toc, guint sample_rate,
|
|
|
|
FLAC__StreamMetadata * cuesheet)
|
|
|
|
{
|
|
|
|
gint8 track_num = 0;
|
|
|
|
gint64 start, stop;
|
|
|
|
gchar *isrc = NULL;
|
|
|
|
const gchar *is_legal;
|
|
|
|
GList *list;
|
|
|
|
GstTagList *tags;
|
2012-08-09 16:41:34 +00:00
|
|
|
GstTocEntry *entry, *subentry = NULL;
|
2012-07-26 13:19:57 +00:00
|
|
|
FLAC__StreamMetadata_CueSheet *cs;
|
|
|
|
FLAC__StreamMetadata_CueSheet_Track *track;
|
|
|
|
|
|
|
|
cs = &cuesheet->data.cue_sheet;
|
|
|
|
if (!cs)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* check if the TOC entries is valid */
|
|
|
|
list = gst_toc_get_entries (toc);
|
2012-08-09 16:41:34 +00:00
|
|
|
entry = list->data;
|
|
|
|
if (gst_toc_entry_is_alternative (entry)) {
|
|
|
|
list = gst_toc_entry_get_sub_entries (entry);
|
|
|
|
while (list) {
|
|
|
|
subentry = list->data;
|
|
|
|
if (!gst_toc_entry_is_sequence (subentry))
|
|
|
|
return FALSE;
|
|
|
|
list = g_list_next (list);
|
|
|
|
}
|
|
|
|
list = gst_toc_entry_get_sub_entries (entry);
|
|
|
|
}
|
|
|
|
if (gst_toc_entry_is_sequence (entry)) {
|
|
|
|
while (list) {
|
|
|
|
entry = list->data;
|
|
|
|
if (!gst_toc_entry_is_sequence (entry))
|
|
|
|
return FALSE;
|
|
|
|
list = g_list_next (list);
|
|
|
|
}
|
|
|
|
list = gst_toc_get_entries (toc);
|
2012-07-26 13:19:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add tracks in cuesheet */
|
|
|
|
while (list) {
|
|
|
|
entry = list->data;
|
|
|
|
gst_toc_entry_get_start_stop_times (entry, &start, &stop);
|
|
|
|
tags = gst_toc_entry_get_tags (entry);
|
|
|
|
if (tags)
|
|
|
|
gst_tag_list_get_string (tags, GST_TAG_ISRC, &isrc);
|
|
|
|
track = FLAC__metadata_object_cuesheet_track_new ();
|
|
|
|
track->offset =
|
|
|
|
(FLAC__uint64) gst_util_uint64_scale_round (start, sample_rate,
|
|
|
|
GST_SECOND);
|
|
|
|
track->number = (FLAC__byte) track_num + 1;
|
|
|
|
if (isrc)
|
|
|
|
strcpy (track->isrc, isrc);
|
|
|
|
if (track->number <= 0)
|
|
|
|
return FALSE;
|
|
|
|
if (!FLAC__metadata_object_cuesheet_insert_track (cuesheet, track_num,
|
|
|
|
track, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
if (!FLAC__metadata_object_cuesheet_track_insert_blank_index (cuesheet,
|
|
|
|
track_num, 0))
|
|
|
|
return FALSE;
|
|
|
|
track_num++;
|
|
|
|
list = g_list_next (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cs->num_tracks <= 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* add lead-out track in cuesheet */
|
|
|
|
track = FLAC__metadata_object_cuesheet_track_new ();
|
|
|
|
track->offset =
|
|
|
|
(FLAC__uint64) gst_util_uint64_scale_round (stop, sample_rate,
|
|
|
|
GST_SECOND);
|
|
|
|
track->number = 255;
|
|
|
|
if (!FLAC__metadata_object_cuesheet_insert_track (cuesheet, cs->num_tracks,
|
|
|
|
track, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* check if the cuesheet is valid */
|
|
|
|
if (!FLAC__metadata_object_cuesheet_is_legal (cuesheet, FALSE, &is_legal)) {
|
|
|
|
g_warning ("%s\n", is_legal);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static void
|
2012-07-26 13:19:57 +00:00
|
|
|
gst_flac_enc_set_metadata (GstFlacEnc * flacenc, GstAudioInfo * info,
|
|
|
|
guint64 total_samples)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2005-10-02 15:33:14 +00:00
|
|
|
const GstTagList *user_tags;
|
|
|
|
GstTagList *copy;
|
2010-01-06 16:06:53 +00:00
|
|
|
gint entries = 1;
|
2011-04-01 11:18:55 +00:00
|
|
|
gint n_images, n_preview_images;
|
2012-07-26 13:19:57 +00:00
|
|
|
FLAC__StreamMetadata *cuesheet;
|
2005-10-02 15:33:14 +00:00
|
|
|
|
|
|
|
g_return_if_fail (flacenc != NULL);
|
2012-07-26 13:19:57 +00:00
|
|
|
|
2005-11-22 12:38:33 +00:00
|
|
|
user_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (flacenc));
|
2005-10-02 15:33:14 +00:00
|
|
|
if ((flacenc->tags == NULL) && (user_tags == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
copy = gst_tag_list_merge (user_tags, flacenc->tags,
|
2005-11-22 12:38:33 +00:00
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (flacenc)));
|
2011-04-01 11:18:55 +00:00
|
|
|
n_images = gst_tag_list_get_tag_size (copy, GST_TAG_IMAGE);
|
|
|
|
n_preview_images = gst_tag_list_get_tag_size (copy, GST_TAG_PREVIEW_IMAGE);
|
|
|
|
|
|
|
|
flacenc->meta =
|
2012-07-26 13:19:57 +00:00
|
|
|
g_new0 (FLAC__StreamMetadata *, 4 + n_images + n_preview_images);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
|
|
|
flacenc->meta[0] =
|
|
|
|
FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
|
|
|
gst_tag_list_foreach (copy, add_one_tag, flacenc);
|
|
|
|
|
2012-07-26 13:19:57 +00:00
|
|
|
if (!flacenc->toc)
|
|
|
|
flacenc->toc = gst_toc_setter_get_toc (GST_TOC_SETTER (flacenc));
|
|
|
|
|
|
|
|
if (flacenc->toc) {
|
|
|
|
cuesheet = FLAC__metadata_object_new (FLAC__METADATA_TYPE_CUESHEET);
|
|
|
|
if (add_cuesheet (flacenc->toc, GST_AUDIO_INFO_RATE (info), cuesheet)) {
|
|
|
|
flacenc->meta[entries] = cuesheet;
|
|
|
|
entries++;
|
|
|
|
} else {
|
|
|
|
FLAC__metadata_object_delete (cuesheet);
|
|
|
|
flacenc->meta[entries] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
if (n_images + n_preview_images > 0) {
|
2012-07-27 08:14:23 +00:00
|
|
|
GstSample *sample;
|
2011-04-01 11:18:55 +00:00
|
|
|
GstBuffer *buffer;
|
2013-07-28 16:09:33 +00:00
|
|
|
GstCaps *caps;
|
2012-07-27 09:26:18 +00:00
|
|
|
const GstStructure *structure;
|
2011-04-01 11:18:55 +00:00
|
|
|
GstTagImageType image_type = GST_TAG_IMAGE_TYPE_NONE;
|
|
|
|
gint i;
|
2012-01-24 13:38:58 +00:00
|
|
|
GstMapInfo map;
|
2011-04-01 11:18:55 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n_images + n_preview_images; i++) {
|
|
|
|
if (i < n_images) {
|
2012-07-27 08:14:23 +00:00
|
|
|
if (!gst_tag_list_get_sample_index (copy, GST_TAG_IMAGE, i, &sample))
|
2011-04-01 11:18:55 +00:00
|
|
|
continue;
|
|
|
|
} else {
|
2012-07-27 08:14:23 +00:00
|
|
|
if (!gst_tag_list_get_sample_index (copy, GST_TAG_PREVIEW_IMAGE,
|
|
|
|
i - n_images, &sample))
|
2011-04-01 11:18:55 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-07-28 16:04:32 +00:00
|
|
|
structure = gst_sample_get_info (sample);
|
2013-07-28 16:09:33 +00:00
|
|
|
caps = gst_sample_get_caps (sample);
|
|
|
|
if (!caps) {
|
|
|
|
GST_FIXME_OBJECT (flacenc, "Image tag without caps");
|
|
|
|
gst_sample_unref (sample);
|
2013-07-28 16:04:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
flacenc->meta[entries] =
|
|
|
|
FLAC__metadata_object_new (FLAC__METADATA_TYPE_PICTURE);
|
|
|
|
|
2013-07-28 16:09:33 +00:00
|
|
|
if (structure)
|
|
|
|
gst_structure_get (structure, "image-type", GST_TYPE_TAG_IMAGE_TYPE,
|
|
|
|
&image_type, NULL);
|
|
|
|
else
|
|
|
|
image_type = GST_TAG_IMAGE_TYPE_NONE;
|
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
/* Convert to ID3v2 APIC image type */
|
|
|
|
if (image_type == GST_TAG_IMAGE_TYPE_NONE)
|
|
|
|
image_type = (i < n_images) ? 0x00 : 0x01;
|
|
|
|
else
|
|
|
|
image_type = image_type + 2;
|
|
|
|
|
2012-07-27 08:14:23 +00:00
|
|
|
buffer = gst_sample_get_buffer (sample);
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
2011-04-01 11:18:55 +00:00
|
|
|
FLAC__metadata_object_picture_set_data (flacenc->meta[entries],
|
2012-01-24 13:38:58 +00:00
|
|
|
map.data, map.size, TRUE);
|
|
|
|
gst_buffer_unmap (buffer, &map);
|
2011-04-19 16:55:31 +00:00
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
/* FIXME: There's no way to set the picture type in libFLAC */
|
|
|
|
flacenc->meta[entries]->data.picture.type = image_type;
|
2013-07-28 16:09:33 +00:00
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
FLAC__metadata_object_picture_set_mime_type (flacenc->meta[entries],
|
|
|
|
(char *) gst_structure_get_name (structure), TRUE);
|
2011-09-28 15:39:12 +00:00
|
|
|
|
2012-07-27 08:14:23 +00:00
|
|
|
gst_sample_unref (sample);
|
2011-04-01 11:18:55 +00:00
|
|
|
entries++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-06 16:06:53 +00:00
|
|
|
if (flacenc->seekpoints && total_samples != GST_CLOCK_TIME_NONE) {
|
|
|
|
gboolean res;
|
|
|
|
guint samples;
|
|
|
|
|
2011-04-01 11:18:55 +00:00
|
|
|
flacenc->meta[entries] =
|
2010-01-06 16:06:53 +00:00
|
|
|
FLAC__metadata_object_new (FLAC__METADATA_TYPE_SEEKTABLE);
|
|
|
|
if (flacenc->seekpoints > 0) {
|
|
|
|
res =
|
|
|
|
FLAC__metadata_object_seektable_template_append_spaced_points
|
2011-04-01 11:18:55 +00:00
|
|
|
(flacenc->meta[entries], flacenc->seekpoints, total_samples);
|
2010-01-06 16:06:53 +00:00
|
|
|
} else {
|
2012-01-06 08:40:22 +00:00
|
|
|
samples = -flacenc->seekpoints * GST_AUDIO_INFO_RATE (info);
|
2010-01-06 16:06:53 +00:00
|
|
|
res =
|
|
|
|
FLAC__metadata_object_seektable_template_append_spaced_points_by_samples
|
2011-04-01 11:18:55 +00:00
|
|
|
(flacenc->meta[entries], samples, total_samples);
|
2010-01-06 16:06:53 +00:00
|
|
|
}
|
|
|
|
if (!res) {
|
|
|
|
GST_DEBUG_OBJECT (flacenc, "adding seekpoint template %d failed",
|
|
|
|
flacenc->seekpoints);
|
|
|
|
FLAC__metadata_object_delete (flacenc->meta[1]);
|
2011-04-01 11:18:55 +00:00
|
|
|
flacenc->meta[entries] = NULL;
|
2010-01-06 16:06:53 +00:00
|
|
|
} else {
|
|
|
|
entries++;
|
|
|
|
}
|
|
|
|
} else if (flacenc->seekpoints && total_samples == GST_CLOCK_TIME_NONE) {
|
|
|
|
GST_WARNING_OBJECT (flacenc, "total time unknown; can not add seekpoints");
|
|
|
|
}
|
|
|
|
|
2009-07-16 18:44:40 +00:00
|
|
|
if (flacenc->padding > 0) {
|
2010-01-06 16:06:53 +00:00
|
|
|
flacenc->meta[entries] =
|
|
|
|
FLAC__metadata_object_new (FLAC__METADATA_TYPE_PADDING);
|
|
|
|
flacenc->meta[entries]->length = flacenc->padding;
|
|
|
|
entries++;
|
2009-07-16 18:44:40 +00:00
|
|
|
}
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
if (FLAC__stream_encoder_set_metadata (flacenc->encoder,
|
2010-01-06 16:06:53 +00:00
|
|
|
flacenc->meta, entries) != true)
|
2005-10-02 15:33:14 +00:00
|
|
|
g_warning ("Dude, i'm already initialized!");
|
2010-01-06 16:06:53 +00:00
|
|
|
|
2012-08-04 15:10:16 +00:00
|
|
|
gst_tag_list_unref (copy);
|
2005-10-02 15:33:14 +00:00
|
|
|
}
|
|
|
|
|
2008-08-03 09:23:14 +00:00
|
|
|
static GstCaps *
|
2011-09-28 15:39:12 +00:00
|
|
|
gst_flac_enc_getcaps (GstAudioEncoder * enc, GstCaps * filter)
|
2008-08-03 09:23:14 +00:00
|
|
|
{
|
2011-09-28 14:09:58 +00:00
|
|
|
GstCaps *ret = NULL, *caps = NULL;
|
|
|
|
GstPad *pad;
|
|
|
|
|
|
|
|
pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
|
2008-08-03 09:23:14 +00:00
|
|
|
|
2011-09-28 15:39:12 +00:00
|
|
|
if (gst_pad_has_current_caps (pad)) {
|
|
|
|
ret = gst_pad_get_current_caps (pad);
|
2008-08-03 09:23:14 +00:00
|
|
|
} else {
|
2012-01-06 08:40:22 +00:00
|
|
|
gint i;
|
2012-02-22 17:03:42 +00:00
|
|
|
GValue v_list = { 0, };
|
2012-01-06 08:40:22 +00:00
|
|
|
GValue v = { 0, };
|
|
|
|
GstStructure *s, *s2;
|
|
|
|
|
2012-02-22 17:03:42 +00:00
|
|
|
g_value_init (&v_list, GST_TYPE_LIST);
|
2012-01-06 08:40:22 +00:00
|
|
|
g_value_init (&v, G_TYPE_STRING);
|
|
|
|
|
2014-02-04 12:43:56 +00:00
|
|
|
g_value_set_static_string (&v, "S8");
|
2012-02-22 17:03:42 +00:00
|
|
|
gst_value_list_append_value (&v_list, &v);
|
2012-02-22 17:09:25 +00:00
|
|
|
g_value_set_static_string (&v, GST_AUDIO_NE (S16));
|
2012-02-22 17:03:42 +00:00
|
|
|
gst_value_list_append_value (&v_list, &v);
|
2012-02-22 17:09:25 +00:00
|
|
|
g_value_set_static_string (&v, GST_AUDIO_NE (S24));
|
2012-02-22 17:03:42 +00:00
|
|
|
gst_value_list_append_value (&v_list, &v);
|
2012-03-13 11:40:37 +00:00
|
|
|
g_value_set_static_string (&v, GST_AUDIO_NE (S24_32));
|
2012-02-22 17:03:42 +00:00
|
|
|
gst_value_list_append_value (&v_list, &v);
|
2012-01-06 08:40:22 +00:00
|
|
|
g_value_unset (&v);
|
|
|
|
|
|
|
|
s = gst_structure_new_empty ("audio/x-raw");
|
2012-02-22 17:09:25 +00:00
|
|
|
gst_structure_take_value (s, "format", &v_list);
|
2012-01-06 08:40:22 +00:00
|
|
|
|
|
|
|
gst_structure_set (s, "layout", G_TYPE_STRING, "interleaved",
|
|
|
|
"rate", GST_TYPE_INT_RANGE, 1, 655350, NULL);
|
2008-08-03 09:23:14 +00:00
|
|
|
|
|
|
|
ret = gst_caps_new_empty ();
|
2012-01-06 08:40:22 +00:00
|
|
|
for (i = 1; i <= 8; i++) {
|
|
|
|
s2 = gst_structure_copy (s);
|
2008-08-03 09:23:14 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
if (i == 1) {
|
2012-02-22 17:39:16 +00:00
|
|
|
gst_structure_set (s2, "channels", G_TYPE_INT, 1, NULL);
|
2012-01-06 08:40:22 +00:00
|
|
|
} else {
|
|
|
|
guint64 channel_mask;
|
2008-08-03 09:23:14 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
gst_audio_channel_positions_to_mask (channel_positions[i - 1], i,
|
2012-06-08 08:11:12 +00:00
|
|
|
FALSE, &channel_mask);
|
2012-02-22 17:39:16 +00:00
|
|
|
gst_structure_set (s2, "channels", G_TYPE_INT, i, "channel-mask",
|
2012-01-06 08:40:22 +00:00
|
|
|
GST_TYPE_BITMASK, channel_mask, NULL);
|
2008-08-03 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
gst_caps_append_structure (ret, s2);
|
2008-08-03 09:23:14 +00:00
|
|
|
}
|
2012-01-06 08:40:22 +00:00
|
|
|
gst_structure_free (s);
|
2008-08-03 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (pad, "Return caps %" GST_PTR_FORMAT, ret);
|
|
|
|
|
2012-07-25 12:57:13 +00:00
|
|
|
caps = gst_audio_encoder_proxy_getcaps (enc, ret, filter);
|
2011-09-28 14:09:58 +00:00
|
|
|
gst_caps_unref (ret);
|
|
|
|
|
|
|
|
return caps;
|
2008-08-03 09:23:14 +00:00
|
|
|
}
|
|
|
|
|
2008-08-03 12:23:49 +00:00
|
|
|
static guint64
|
2011-11-15 17:01:16 +00:00
|
|
|
gst_flac_enc_peer_query_total_samples (GstFlacEnc * flacenc, GstPad * pad)
|
2008-08-03 12:23:49 +00:00
|
|
|
{
|
|
|
|
gint64 duration;
|
2012-01-06 08:40:22 +00:00
|
|
|
GstAudioInfo *info =
|
|
|
|
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (flacenc));
|
2008-08-03 12:23:49 +00:00
|
|
|
|
2009-06-01 20:33:02 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "querying peer for DEFAULT format duration");
|
2011-11-15 17:01:16 +00:00
|
|
|
if (gst_pad_peer_query_duration (pad, GST_FORMAT_DEFAULT, &duration)
|
2011-09-28 15:39:12 +00:00
|
|
|
&& duration != GST_CLOCK_TIME_NONE)
|
2008-08-03 12:23:49 +00:00
|
|
|
goto done;
|
|
|
|
|
2009-06-01 20:33:02 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "querying peer for TIME format duration");
|
2008-08-03 12:23:49 +00:00
|
|
|
|
2011-11-15 17:01:16 +00:00
|
|
|
if (gst_pad_peer_query_duration (pad, GST_FORMAT_TIME, &duration)
|
2011-09-28 15:39:12 +00:00
|
|
|
&& duration != GST_CLOCK_TIME_NONE) {
|
2009-06-01 20:33:02 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "peer reported duration %" GST_TIME_FORMAT,
|
|
|
|
GST_TIME_ARGS (duration));
|
2012-01-06 08:40:22 +00:00
|
|
|
duration = GST_CLOCK_TIME_TO_FRAMES (duration, GST_AUDIO_INFO_RATE (info));
|
2008-08-03 12:23:49 +00:00
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (flacenc, "Upstream reported no total samples");
|
|
|
|
return GST_CLOCK_TIME_NONE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
GST_DEBUG_OBJECT (flacenc,
|
|
|
|
"Upstream reported %" G_GUINT64_FORMAT " total samples", duration);
|
|
|
|
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static gboolean
|
2011-09-28 14:09:58 +00:00
|
|
|
gst_flac_enc_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
|
2005-10-02 15:33:14 +00:00
|
|
|
{
|
|
|
|
GstFlacEnc *flacenc;
|
2008-08-03 12:23:49 +00:00
|
|
|
guint64 total_samples = GST_CLOCK_TIME_NONE;
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__StreamEncoderInitStatus init_status;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
flacenc = GST_FLAC_ENC (enc);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
/* if configured again, means something changed, can't handle that */
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
if (FLAC__stream_encoder_get_state (flacenc->encoder) !=
|
|
|
|
FLAC__STREAM_ENCODER_UNINITIALIZED)
|
2005-10-02 15:33:14 +00:00
|
|
|
goto encoder_already_initialized;
|
|
|
|
|
2012-07-25 14:02:34 +00:00
|
|
|
/* delay setting output caps/format until we have all headers */
|
2003-07-06 20:49:52 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
gst_audio_get_channel_reorder_map (GST_AUDIO_INFO_CHANNELS (info),
|
|
|
|
channel_positions[GST_AUDIO_INFO_CHANNELS (info) - 1], info->position,
|
|
|
|
flacenc->channel_reorder_map);
|
|
|
|
|
2011-11-15 17:01:16 +00:00
|
|
|
total_samples = gst_flac_enc_peer_query_total_samples (flacenc,
|
2011-09-28 14:09:58 +00:00
|
|
|
GST_AUDIO_ENCODER_SINK_PAD (enc));
|
2008-08-03 12:23:49 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
FLAC__stream_encoder_set_bits_per_sample (flacenc->encoder,
|
2012-07-25 13:28:14 +00:00
|
|
|
GST_AUDIO_INFO_DEPTH (info));
|
2012-01-06 08:40:22 +00:00
|
|
|
FLAC__stream_encoder_set_sample_rate (flacenc->encoder,
|
|
|
|
GST_AUDIO_INFO_RATE (info));
|
|
|
|
FLAC__stream_encoder_set_channels (flacenc->encoder,
|
|
|
|
GST_AUDIO_INFO_CHANNELS (info));
|
2008-08-03 12:23:49 +00:00
|
|
|
|
|
|
|
if (total_samples != GST_CLOCK_TIME_NONE)
|
|
|
|
FLAC__stream_encoder_set_total_samples_estimate (flacenc->encoder,
|
2009-06-01 23:37:15 +00:00
|
|
|
MIN (total_samples, G_GUINT64_CONSTANT (0x0FFFFFFFFF)));
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2012-07-26 13:19:57 +00:00
|
|
|
gst_flac_enc_set_metadata (flacenc, info, total_samples);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
/* callbacks clear to go now;
|
|
|
|
* write callbacks receives headers during init */
|
|
|
|
flacenc->stopped = FALSE;
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
init_status = FLAC__stream_encoder_init_stream (flacenc->encoder,
|
|
|
|
gst_flac_enc_write_callback, gst_flac_enc_seek_callback,
|
|
|
|
gst_flac_enc_tell_callback, NULL, flacenc);
|
|
|
|
if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
|
|
|
goto failed_to_initialize;
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
/* no special feedback to base class; should provide all available samples */
|
2005-10-02 15:33:14 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
encoder_already_initialized:
|
|
|
|
{
|
|
|
|
g_warning ("flac already initialized -- fixme allow this");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
failed_to_initialize:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (flacenc, LIBRARY, INIT, (NULL),
|
2012-03-13 11:40:37 +00:00
|
|
|
("could not initialize encoder (wrong parameters?) %d", init_status));
|
2005-10-02 15:33:14 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
static gboolean
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_update_quality (GstFlacEnc * flacenc, gint quality)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2012-01-06 08:40:22 +00:00
|
|
|
GstAudioInfo *info =
|
|
|
|
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (flacenc));
|
|
|
|
|
2002-09-15 22:26:33 +00:00
|
|
|
flacenc->quality = quality;
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
#define DO_UPDATE(name, val, str) \
|
|
|
|
G_STMT_START { \
|
|
|
|
if (FLAC__stream_encoder_get_##name (flacenc->encoder) != \
|
|
|
|
flacenc_params[quality].val) { \
|
|
|
|
FLAC__stream_encoder_set_##name (flacenc->encoder, \
|
|
|
|
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));
|
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
if (GST_AUDIO_INFO_CHANNELS (info) == 2
|
|
|
|
|| GST_AUDIO_INFO_CHANNELS (info) == 0) {
|
2004-08-17 12:38:33 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
static FLAC__StreamEncoderSeekStatus
|
|
|
|
gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
FLAC__uint64 absolute_byte_offset, void *client_data)
|
2003-05-11 17:18:17 +00:00
|
|
|
{
|
2005-10-02 15:33:14 +00:00
|
|
|
GstFlacEnc *flacenc;
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
GstPad *peerpad;
|
2011-09-28 15:39:12 +00:00
|
|
|
GstSegment seg;
|
2003-05-11 17:18:17 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacenc = GST_FLAC_ENC (client_data);
|
2003-05-11 17:18:17 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flacenc->stopped)
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
|
2009-03-27 21:17:05 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
if ((peerpad = gst_pad_get_peer (GST_AUDIO_ENCODER_SRC_PAD (flacenc)))) {
|
2012-02-10 15:23:14 +00:00
|
|
|
GstEvent *event;
|
|
|
|
gboolean ret;
|
2012-03-28 12:48:46 +00:00
|
|
|
GstQuery *query;
|
|
|
|
gboolean seekable = FALSE;
|
|
|
|
|
|
|
|
/* try to seek to the beginning of the output */
|
|
|
|
query = gst_query_new_seeking (GST_FORMAT_BYTES);
|
|
|
|
if (gst_pad_query (peerpad, query)) {
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
gst_query_parse_seeking (query, &format, &seekable, NULL, NULL);
|
|
|
|
if (format != GST_FORMAT_BYTES)
|
|
|
|
seekable = FALSE;
|
|
|
|
} else {
|
|
|
|
GST_LOG_OBJECT (flacenc, "SEEKING query not handled");
|
|
|
|
}
|
|
|
|
gst_query_unref (query);
|
|
|
|
|
|
|
|
if (!seekable) {
|
|
|
|
GST_DEBUG_OBJECT (flacenc, "downstream not seekable; not rewriting");
|
2012-03-29 15:21:53 +00:00
|
|
|
gst_object_unref (peerpad);
|
2012-03-28 12:48:46 +00:00
|
|
|
return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
|
|
|
|
}
|
2012-02-10 15:23:14 +00:00
|
|
|
|
|
|
|
gst_segment_init (&seg, GST_FORMAT_BYTES);
|
|
|
|
seg.start = absolute_byte_offset;
|
|
|
|
seg.stop = GST_BUFFER_OFFSET_NONE;
|
|
|
|
seg.time = 0;
|
|
|
|
event = gst_event_new_segment (&seg);
|
2005-10-02 15:33:14 +00:00
|
|
|
|
2012-02-10 15:23:14 +00:00
|
|
|
ret = gst_pad_send_event (peerpad, event);
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
gst_object_unref (peerpad);
|
2003-05-11 17:18:17 +00:00
|
|
|
|
2006-02-03 20:05:20 +00:00
|
|
|
if (ret) {
|
2009-10-09 10:25:19 +00:00
|
|
|
GST_DEBUG ("Seek to %" G_GUINT64_FORMAT " %s",
|
|
|
|
(guint64) absolute_byte_offset, "succeeded");
|
2006-02-03 20:05:20 +00:00
|
|
|
} else {
|
2009-10-09 10:25:19 +00:00
|
|
|
GST_DEBUG ("Seek to %" G_GUINT64_FORMAT " %s",
|
|
|
|
(guint64) absolute_byte_offset, "failed");
|
2008-08-07 16:13:41 +00:00
|
|
|
return FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
|
2006-02-03 20:05:20 +00:00
|
|
|
}
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Seek to %" G_GUINT64_FORMAT " failed (no peer pad)",
|
2009-10-09 10:25:19 +00:00
|
|
|
(guint64) absolute_byte_offset);
|
2005-01-09 20:01:59 +00:00
|
|
|
}
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
|
|
|
flacenc->offset = absolute_byte_offset;
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
|
2003-05-11 17:18:17 +00:00
|
|
|
}
|
|
|
|
|
2007-05-25 16:02:51 +00:00
|
|
|
static void
|
|
|
|
notgst_value_array_append_buffer (GValue * array_val, GstBuffer * buf)
|
|
|
|
{
|
|
|
|
GValue value = { 0, };
|
|
|
|
|
|
|
|
g_value_init (&value, GST_TYPE_BUFFER);
|
|
|
|
/* copy buffer to avoid problems with circular refcounts */
|
|
|
|
buf = gst_buffer_copy (buf);
|
|
|
|
/* again, for good measure */
|
2012-01-30 16:16:51 +00:00
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER);
|
2007-05-25 16:02:51 +00:00
|
|
|
gst_value_set_buffer (&value, buf);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
gst_value_array_append_value (array_val, &value);
|
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define HDR_TYPE_STREAMINFO 0
|
|
|
|
#define HDR_TYPE_VORBISCOMMENT 4
|
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
static GstFlowReturn
|
2007-05-25 16:02:51 +00:00
|
|
|
gst_flac_enc_process_stream_headers (GstFlacEnc * enc)
|
|
|
|
{
|
|
|
|
GstBuffer *vorbiscomment = NULL;
|
|
|
|
GstBuffer *streaminfo = NULL;
|
|
|
|
GstBuffer *marker = NULL;
|
|
|
|
GValue array = { 0, };
|
|
|
|
GstCaps *caps;
|
|
|
|
GList *l;
|
2011-09-28 14:09:58 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-01-06 08:40:22 +00:00
|
|
|
GstAudioInfo *info =
|
|
|
|
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
|
2007-05-25 16:02:51 +00:00
|
|
|
|
|
|
|
caps = gst_caps_new_simple ("audio/x-flac",
|
2012-01-06 08:40:22 +00:00
|
|
|
"channels", G_TYPE_INT, GST_AUDIO_INFO_CHANNELS (info),
|
|
|
|
"rate", G_TYPE_INT, GST_AUDIO_INFO_RATE (info), NULL);
|
2007-05-25 16:02:51 +00:00
|
|
|
|
|
|
|
for (l = enc->headers; l != NULL; l = l->next) {
|
2011-04-19 16:55:31 +00:00
|
|
|
GstBuffer *buf;
|
2012-01-24 13:38:58 +00:00
|
|
|
GstMapInfo map;
|
2011-04-19 16:55:31 +00:00
|
|
|
guint8 *data;
|
|
|
|
gsize size;
|
2007-05-25 16:02:51 +00:00
|
|
|
|
|
|
|
/* mark buffers so oggmux will ignore them if it already muxed the
|
|
|
|
* header buffers from the streamheaders field in the caps */
|
2011-04-19 16:55:31 +00:00
|
|
|
l->data = gst_buffer_make_writable (GST_BUFFER_CAST (l->data));
|
2007-05-25 16:02:51 +00:00
|
|
|
|
2011-04-19 16:55:31 +00:00
|
|
|
buf = GST_BUFFER_CAST (l->data);
|
2012-01-30 16:16:51 +00:00
|
|
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_HEADER);
|
2011-04-19 16:55:31 +00:00
|
|
|
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
data = map.data;
|
|
|
|
size = map.size;
|
2007-05-25 16:02:51 +00:00
|
|
|
|
|
|
|
/* find initial 4-byte marker which we need to skip later on */
|
|
|
|
if (size == 4 && memcmp (data, "fLaC", 4) == 0) {
|
2011-04-19 16:55:31 +00:00
|
|
|
marker = buf;
|
2007-05-25 16:02:51 +00:00
|
|
|
} else if (size > 1 && (data[0] & 0x7f) == HDR_TYPE_STREAMINFO) {
|
2011-04-19 16:55:31 +00:00
|
|
|
streaminfo = buf;
|
2007-05-25 16:02:51 +00:00
|
|
|
} else if (size > 1 && (data[0] & 0x7f) == HDR_TYPE_VORBISCOMMENT) {
|
2011-04-19 16:55:31 +00:00
|
|
|
vorbiscomment = buf;
|
2007-05-25 16:02:51 +00:00
|
|
|
}
|
2011-04-19 16:55:31 +00:00
|
|
|
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2007-05-25 16:02:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (marker == NULL || streaminfo == NULL || vorbiscomment == NULL) {
|
|
|
|
GST_WARNING_OBJECT (enc, "missing header %p %p %p, muxing into container "
|
|
|
|
"formats may be broken", marker, streaminfo, vorbiscomment);
|
|
|
|
goto push_headers;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&array, GST_TYPE_ARRAY);
|
|
|
|
|
|
|
|
/* add marker including STREAMINFO header */
|
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
guint16 num;
|
2012-01-24 13:38:58 +00:00
|
|
|
GstMapInfo map;
|
2011-04-19 16:55:31 +00:00
|
|
|
guint8 *bdata;
|
2012-01-24 13:38:58 +00:00
|
|
|
gsize slen;
|
2007-05-25 16:02:51 +00:00
|
|
|
|
|
|
|
/* minus one for the marker that is merged with streaminfo here */
|
|
|
|
num = g_list_length (enc->headers) - 1;
|
|
|
|
|
2011-04-19 16:55:31 +00:00
|
|
|
slen = gst_buffer_get_size (streaminfo);
|
|
|
|
buf = gst_buffer_new_and_alloc (13 + slen);
|
|
|
|
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_WRITE);
|
|
|
|
bdata = map.data;
|
2011-04-19 16:55:31 +00:00
|
|
|
bdata[0] = 0x7f;
|
|
|
|
memcpy (bdata + 1, "FLAC", 4);
|
|
|
|
bdata[5] = 0x01; /* mapping version major */
|
|
|
|
bdata[6] = 0x00; /* mapping version minor */
|
|
|
|
bdata[7] = (num & 0xFF00) >> 8;
|
|
|
|
bdata[8] = (num & 0x00FF) >> 0;
|
|
|
|
memcpy (bdata + 9, "fLaC", 4);
|
|
|
|
gst_buffer_extract (streaminfo, 0, bdata + 13, slen);
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2011-04-19 16:55:31 +00:00
|
|
|
|
2007-05-25 16:02:51 +00:00
|
|
|
notgst_value_array_append_buffer (&array, buf);
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add VORBISCOMMENT header */
|
|
|
|
notgst_value_array_append_buffer (&array, vorbiscomment);
|
|
|
|
|
|
|
|
/* add other headers, if there are any */
|
|
|
|
for (l = enc->headers; l != NULL; l = l->next) {
|
2011-04-19 16:55:31 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER_CAST (l->data);
|
|
|
|
|
|
|
|
if (buf != marker && buf != streaminfo && buf != vorbiscomment) {
|
|
|
|
notgst_value_array_append_buffer (&array, buf);
|
2007-05-25 16:02:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_structure_set_value (gst_caps_get_structure (caps, 0),
|
|
|
|
"streamheader", &array);
|
|
|
|
g_value_unset (&array);
|
|
|
|
|
|
|
|
push_headers:
|
2012-03-13 11:40:37 +00:00
|
|
|
gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (enc), caps);
|
2007-05-25 16:02:51 +00:00
|
|
|
|
2013-08-16 11:26:28 +00:00
|
|
|
gst_audio_encoder_set_headers (GST_AUDIO_ENCODER (enc), enc->headers);
|
2007-05-25 16:02:51 +00:00
|
|
|
enc->headers = NULL;
|
|
|
|
|
|
|
|
gst_caps_unref (caps);
|
2011-09-28 14:09:58 +00:00
|
|
|
|
|
|
|
return ret;
|
2007-05-25 16:02:51 +00:00
|
|
|
}
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
static FLAC__StreamEncoderWriteStatus
|
|
|
|
gst_flac_enc_write_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
const FLAC__byte buffer[], size_t bytes,
|
|
|
|
unsigned samples, unsigned current_frame, void *client_data)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2007-05-25 16:02:51 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2005-10-02 15:33:14 +00:00
|
|
|
GstFlacEnc *flacenc;
|
2001-12-23 13:56:23 +00:00
|
|
|
GstBuffer *outbuf;
|
2014-06-10 09:59:13 +00:00
|
|
|
GstSegment *segment;
|
|
|
|
GstClockTime duration;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-12-09 19:51:03 +00:00
|
|
|
flacenc = GST_FLAC_ENC (client_data);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (flacenc->stopped)
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2007-05-25 16:02:51 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (bytes);
|
2011-04-19 16:55:31 +00:00
|
|
|
gst_buffer_fill (outbuf, 0, buffer, bytes);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2007-05-25 16:02:51 +00:00
|
|
|
/* we assume libflac passes us stuff neatly framed */
|
|
|
|
if (!flacenc->got_headers) {
|
|
|
|
if (samples == 0) {
|
2008-10-10 12:28:34 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "Got header, queueing (%u bytes)",
|
|
|
|
(guint) bytes);
|
2007-05-25 16:02:51 +00:00
|
|
|
flacenc->headers = g_list_append (flacenc->headers, outbuf);
|
|
|
|
/* note: it's important that we increase our byte offset */
|
|
|
|
goto out;
|
|
|
|
} else {
|
|
|
|
GST_INFO_OBJECT (flacenc, "Non-header packet, we have all headers now");
|
2011-09-28 14:09:58 +00:00
|
|
|
ret = gst_flac_enc_process_stream_headers (flacenc);
|
2007-05-25 16:02:51 +00:00
|
|
|
flacenc->got_headers = TRUE;
|
|
|
|
}
|
2012-01-12 10:30:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flacenc->got_headers && samples == 0) {
|
2011-09-28 14:09:58 +00:00
|
|
|
/* header fixup, push downstream directly */
|
2009-06-01 23:48:00 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "Fixing up headers at pos=%" G_GUINT64_FORMAT
|
|
|
|
", size=%u", flacenc->offset, (guint) bytes);
|
2011-04-19 16:55:31 +00:00
|
|
|
#if 0
|
2009-06-01 23:48:00 +00:00
|
|
|
GST_MEMDUMP_OBJECT (flacenc, "Presumed header fragment",
|
|
|
|
GST_BUFFER_DATA (outbuf), GST_BUFFER_SIZE (outbuf));
|
2011-04-19 16:55:31 +00:00
|
|
|
#endif
|
2011-09-28 14:09:58 +00:00
|
|
|
ret = gst_pad_push (GST_AUDIO_ENCODER_SRC_PAD (flacenc), outbuf);
|
2009-06-01 23:48:00 +00:00
|
|
|
} else {
|
2011-09-28 14:09:58 +00:00
|
|
|
/* regular frame data, pass to base class */
|
2014-06-10 09:59:13 +00:00
|
|
|
if (flacenc->eos && flacenc->samples_in == flacenc->samples_out + samples) {
|
|
|
|
/* If encoding part of a frame, and we have no set stop time on
|
|
|
|
* the output segment, we update the segment stop time to reflect
|
|
|
|
* the last sample. This will let oggmux set the last page's
|
|
|
|
* granpos to tell a decoder the dummy samples should be clipped.
|
|
|
|
*/
|
|
|
|
segment = &GST_AUDIO_ENCODER_OUTPUT_SEGMENT (flacenc);
|
|
|
|
if (!GST_CLOCK_TIME_IS_VALID (segment->stop)) {
|
|
|
|
GST_DEBUG_OBJECT (flacenc,
|
|
|
|
"No stop time and partial frame, updating segment");
|
|
|
|
duration =
|
|
|
|
gst_util_uint64_scale (flacenc->samples_out + samples,
|
|
|
|
GST_SECOND,
|
|
|
|
FLAC__stream_encoder_get_sample_rate (flacenc->encoder));
|
|
|
|
segment->stop = segment->start + duration;
|
|
|
|
GST_DEBUG_OBJECT (flacenc, "new output segment %" GST_SEGMENT_FORMAT,
|
|
|
|
segment);
|
|
|
|
gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (flacenc),
|
|
|
|
gst_event_new_segment (segment));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-19 07:23:25 +00:00
|
|
|
GST_LOG ("Pushing buffer: samples=%u, size=%u, pos=%" G_GUINT64_FORMAT,
|
2009-06-01 23:48:00 +00:00
|
|
|
samples, (guint) bytes, flacenc->offset);
|
2011-09-28 14:09:58 +00:00
|
|
|
ret = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (flacenc),
|
|
|
|
outbuf, samples);
|
2007-05-25 16:02:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 13:19:17 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
|
|
|
GST_DEBUG_OBJECT (flacenc, "flow: %s", gst_flow_get_name (ret));
|
|
|
|
|
|
|
|
flacenc->last_flow = ret;
|
|
|
|
|
2007-05-25 16:02:51 +00:00
|
|
|
out:
|
2005-01-09 20:01:59 +00:00
|
|
|
flacenc->offset += bytes;
|
|
|
|
|
2010-08-27 16:02:57 +00:00
|
|
|
if (ret != GST_FLOW_OK)
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
|
|
|
|
|
|
|
|
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
2005-01-09 20:01:59 +00:00
|
|
|
}
|
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
static FLAC__StreamEncoderTellStatus
|
|
|
|
gst_flac_enc_tell_callback (const FLAC__StreamEncoder * encoder,
|
|
|
|
FLAC__uint64 * absolute_byte_offset, void *client_data)
|
2005-01-09 20:01:59 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacEnc *flacenc = GST_FLAC_ENC (client_data);
|
2005-01-09 20:01:59 +00:00
|
|
|
|
|
|
|
*absolute_byte_offset = flacenc->offset;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static gboolean
|
2011-09-28 14:09:58 +00:00
|
|
|
gst_flac_enc_sink_event (GstAudioEncoder * enc, GstEvent * event)
|
2003-11-28 13:04:21 +00:00
|
|
|
{
|
2005-10-02 15:33:14 +00:00
|
|
|
GstFlacEnc *flacenc;
|
|
|
|
GstTagList *taglist;
|
2012-07-26 13:19:57 +00:00
|
|
|
GstToc *toc;
|
2011-09-28 14:09:58 +00:00
|
|
|
gboolean ret = FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
flacenc = GST_FLAC_ENC (enc);
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2013-04-17 05:50:27 +00:00
|
|
|
GST_DEBUG ("Received %s event on sinkpad, %" GST_PTR_FORMAT,
|
|
|
|
GST_EVENT_TYPE_NAME (event), event);
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_EOS:
|
2011-09-28 14:09:58 +00:00
|
|
|
flacenc->eos = TRUE;
|
2012-03-30 10:18:45 +00:00
|
|
|
ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
2005-10-02 15:33:14 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_TAG:
|
|
|
|
if (flacenc->tags) {
|
|
|
|
gst_event_parse_tag (event, &taglist);
|
2009-04-29 09:12:36 +00:00
|
|
|
gst_tag_list_insert (flacenc->tags, taglist,
|
|
|
|
gst_tag_setter_get_tag_merge_mode (GST_TAG_SETTER (flacenc)));
|
2005-10-02 15:33:14 +00:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2012-03-30 10:18:45 +00:00
|
|
|
ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
2005-10-02 15:33:14 +00:00
|
|
|
break;
|
2012-07-26 13:19:57 +00:00
|
|
|
case GST_EVENT_TOC:
|
|
|
|
gst_event_parse_toc (event, &toc, NULL);
|
|
|
|
if (toc) {
|
|
|
|
if (flacenc->toc != toc) {
|
|
|
|
if (flacenc->toc)
|
|
|
|
gst_toc_unref (flacenc->toc);
|
|
|
|
flacenc->toc = toc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
|
|
|
break;
|
2014-06-10 09:59:13 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
|
|
|
flacenc->samples_in = 0;
|
|
|
|
flacenc->samples_out = 0;
|
|
|
|
ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
default:
|
2012-03-30 10:18:45 +00:00
|
|
|
ret = GST_AUDIO_ENCODER_CLASS (parent_class)->sink_event (enc, event);
|
2005-10-02 15:33:14 +00:00
|
|
|
break;
|
2003-11-28 13:04:21 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
return ret;
|
2003-05-11 17:18:17 +00:00
|
|
|
}
|
2002-06-07 20:09:05 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
#define READ_INT24 GST_READ_UINT24_LE
|
|
|
|
#else
|
|
|
|
#define READ_INT24 GST_READ_UINT24_BE
|
|
|
|
#endif
|
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
static GstFlowReturn
|
2011-09-28 14:09:58 +00:00
|
|
|
gst_flac_enc_handle_frame (GstAudioEncoder * enc, GstBuffer * buffer)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2005-10-02 15:33:14 +00:00
|
|
|
GstFlacEnc *flacenc;
|
2002-09-15 22:26:33 +00:00
|
|
|
FLAC__int32 *data;
|
2012-01-06 08:40:22 +00:00
|
|
|
gint samples, width, channels;
|
2002-09-15 22:26:33 +00:00
|
|
|
gulong i;
|
2012-01-06 08:40:22 +00:00
|
|
|
gint j;
|
2002-09-15 22:26:33 +00:00
|
|
|
FLAC__bool res;
|
2012-01-24 13:38:58 +00:00
|
|
|
GstMapInfo map;
|
2012-01-06 08:40:22 +00:00
|
|
|
GstAudioInfo *info =
|
|
|
|
gst_audio_encoder_get_audio_info (GST_AUDIO_ENCODER (enc));
|
|
|
|
gint *reorder_map;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
flacenc = GST_FLAC_ENC (enc);
|
2007-05-24 17:00:21 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
/* base class ensures configuration */
|
2012-01-06 08:40:22 +00:00
|
|
|
g_return_val_if_fail (GST_AUDIO_INFO_WIDTH (info) != 0,
|
|
|
|
GST_FLOW_NOT_NEGOTIATED);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
width = GST_AUDIO_INFO_WIDTH (info);
|
|
|
|
channels = GST_AUDIO_INFO_CHANNELS (info);
|
|
|
|
reorder_map = flacenc->channel_reorder_map;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2011-09-28 14:09:58 +00:00
|
|
|
if (G_UNLIKELY (!buffer)) {
|
|
|
|
if (flacenc->eos) {
|
2013-03-19 07:23:25 +00:00
|
|
|
GST_DEBUG_OBJECT (flacenc, "finish encoding");
|
2011-09-28 14:09:58 +00:00
|
|
|
FLAC__stream_encoder_finish (flacenc->encoder);
|
2008-08-08 15:20:24 +00:00
|
|
|
} else {
|
2011-09-28 14:09:58 +00:00
|
|
|
/* can't handle intermittent draining/resyncing */
|
|
|
|
GST_ELEMENT_WARNING (flacenc, STREAM, FORMAT, (NULL),
|
|
|
|
("Stream discontinuity detected. "
|
|
|
|
"The output may have wrong timestamps, "
|
|
|
|
"consider using audiorate to handle discontinuities"));
|
2008-08-08 15:20:24 +00:00
|
|
|
}
|
2011-09-28 14:09:58 +00:00
|
|
|
return flacenc->last_flow;
|
2008-08-08 15:20:24 +00:00
|
|
|
}
|
|
|
|
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
samples = map.size / (width >> 3);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
data = g_malloc (samples * sizeof (FLAC__int32));
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2012-01-06 08:40:22 +00:00
|
|
|
samples /= channels;
|
2013-03-19 07:23:25 +00:00
|
|
|
GST_LOG_OBJECT (flacenc, "processing %d samples, %d channels", samples,
|
|
|
|
channels);
|
2008-08-03 11:38:22 +00:00
|
|
|
if (width == 8) {
|
2012-01-24 13:38:58 +00:00
|
|
|
gint8 *indata = (gint8 *) map.data;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
for (i = 0; i < samples; i++)
|
2012-01-06 08:40:22 +00:00
|
|
|
for (j = 0; j < channels; j++)
|
|
|
|
data[i * channels + reorder_map[j]] =
|
|
|
|
(FLAC__int32) indata[i * channels + j];
|
2008-08-03 11:38:22 +00:00
|
|
|
} else if (width == 16) {
|
2012-01-24 13:38:58 +00:00
|
|
|
gint16 *indata = (gint16 *) map.data;
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2008-08-03 11:38:22 +00:00
|
|
|
for (i = 0; i < samples; i++)
|
2012-01-06 08:40:22 +00:00
|
|
|
for (j = 0; j < channels; j++)
|
|
|
|
data[i * channels + reorder_map[j]] =
|
|
|
|
(FLAC__int32) indata[i * channels + j];
|
|
|
|
} else if (width == 24) {
|
2012-01-24 13:38:58 +00:00
|
|
|
guint8 *indata = (guint8 *) map.data;
|
2012-01-06 08:40:22 +00:00
|
|
|
guint32 val;
|
|
|
|
|
|
|
|
for (i = 0; i < samples; i++)
|
|
|
|
for (j = 0; j < channels; j++) {
|
|
|
|
val = READ_INT24 (&indata[3 * (i * channels + j)]);
|
|
|
|
if (val & 0x00800000)
|
|
|
|
val |= 0xff000000;
|
|
|
|
data[i * channels + reorder_map[j]] = (FLAC__int32) val;
|
|
|
|
}
|
2008-08-03 11:38:22 +00:00
|
|
|
} else if (width == 32) {
|
2012-01-24 13:38:58 +00:00
|
|
|
gint32 *indata = (gint32 *) map.data;
|
2008-08-03 11:38:22 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
for (i = 0; i < samples; i++)
|
2012-01-06 08:40:22 +00:00
|
|
|
for (j = 0; j < channels; j++)
|
|
|
|
data[i * channels + reorder_map[j]] =
|
|
|
|
(FLAC__int32) indata[i * channels + j];
|
2005-10-02 15:33:14 +00:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
2012-01-24 13:38:58 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
2001-12-23 13:56:23 +00:00
|
|
|
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
|
2012-07-25 13:28:14 +00:00
|
|
|
(const FLAC__int32 *) data, samples);
|
2014-06-10 09:59:13 +00:00
|
|
|
flacenc->samples_in += samples;
|
2001-12-23 13:56:23 +00:00
|
|
|
|
2005-10-02 15:33:14 +00:00
|
|
|
g_free (data);
|
2002-09-15 22:26:33 +00:00
|
|
|
|
2007-09-26 13:19:17 +00:00
|
|
|
if (!res) {
|
|
|
|
if (flacenc->last_flow == GST_FLOW_OK)
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
else
|
|
|
|
return flacenc->last_flow;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_set_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:33 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacEnc *this = GST_FLAC_ENC (object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (this);
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
switch (prop_id) {
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QUALITY:
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_update_quality (this, g_value_get_enum (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_STREAMABLE_SUBSET:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_streamable_subset (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MID_SIDE_STEREO:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_do_mid_side_stereo (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_LOOSE_MID_SIDE_STEREO:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_loose_mid_side_stereo (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_BLOCKSIZE:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_blocksize (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MAX_LPC_ORDER:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_max_lpc_order (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QLP_COEFF_PRECISION:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_qlp_coeff_precision (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QLP_COEFF_PREC_SEARCH:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_do_qlp_coeff_prec_search (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_ESCAPE_CODING:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
FLAC__stream_encoder_set_do_escape_coding (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_EXHAUSTIVE_MODEL_SEARCH:
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_set_do_exhaustive_model_search (this->encoder,
|
|
|
|
g_value_get_boolean (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MIN_RESIDUAL_PARTITION_ORDER:
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_set_min_residual_partition_order (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MAX_RESIDUAL_PARTITION_ORDER:
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_set_max_residual_partition_order (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_RICE_PARAMETER_SEARCH_DIST:
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_set_rice_parameter_search_dist (this->encoder,
|
|
|
|
g_value_get_uint (value));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2009-07-16 18:44:40 +00:00
|
|
|
case PROP_PADDING:
|
|
|
|
this->padding = g_value_get_uint (value);
|
|
|
|
break;
|
2010-01-06 16:06:53 +00:00
|
|
|
case PROP_SEEKPOINTS:
|
|
|
|
this->seekpoints = g_value_get_int (value);
|
|
|
|
break;
|
2002-09-15 22:26:33 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
break;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (this);
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-09 19:51:03 +00:00
|
|
|
gst_flac_enc_get_property (GObject * object, guint prop_id,
|
2004-03-14 22:34:33 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
2001-12-23 13:56:23 +00:00
|
|
|
{
|
2005-12-09 19:51:03 +00:00
|
|
|
GstFlacEnc *this = GST_FLAC_ENC (object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_LOCK (this);
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
2001-12-23 13:56:23 +00:00
|
|
|
switch (prop_id) {
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QUALITY:
|
2002-09-15 22:26:33 +00:00
|
|
|
g_value_set_enum (value, this->quality);
|
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_STREAMABLE_SUBSET:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_streamable_subset (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MID_SIDE_STEREO:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_do_mid_side_stereo (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_LOOSE_MID_SIDE_STEREO:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_loose_mid_side_stereo (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_BLOCKSIZE:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
|
|
|
FLAC__stream_encoder_get_blocksize (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MAX_LPC_ORDER:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
|
|
|
FLAC__stream_encoder_get_max_lpc_order (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QLP_COEFF_PRECISION:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
|
|
|
FLAC__stream_encoder_get_qlp_coeff_precision (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_QLP_COEFF_PREC_SEARCH:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_do_qlp_coeff_prec_search (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_ESCAPE_CODING:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_do_escape_coding (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_EXHAUSTIVE_MODEL_SEARCH:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_boolean (value,
|
|
|
|
FLAC__stream_encoder_get_do_exhaustive_model_search (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MIN_RESIDUAL_PARTITION_ORDER:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_get_min_residual_partition_order
|
|
|
|
(this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_MAX_RESIDUAL_PARTITION_ORDER:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
2008-08-03 09:23:14 +00:00
|
|
|
FLAC__stream_encoder_get_max_residual_partition_order
|
|
|
|
(this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2005-10-02 15:33:14 +00:00
|
|
|
case PROP_RICE_PARAMETER_SEARCH_DIST:
|
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
Original commit message from CVS:
Patch by: Josh Coalson <xflac at yahoo dot com>,
updated by Alexis Ballier <aballier at gentoo dot org>:
* configure.ac:
* ext/flac/gstflacdec.c: (gst_flac_dec_reset_decoders),
(gst_flac_dec_setup_seekable_decoder),
(gst_flac_dec_setup_stream_decoder), (gst_flac_dec_seek),
(gst_flac_dec_tell), (gst_flac_dec_length), (gst_flac_dec_eof),
(gst_flac_dec_read_seekable), (gst_flac_dec_read_stream):
* ext/flac/gstflacdec.h:
* ext/flac/gstflacenc.c: (gst_flac_enc_init),
(gst_flac_enc_finalize), (gst_flac_enc_set_metadata),
(gst_flac_enc_sink_setcaps), (gst_flac_enc_update_quality),
(gst_flac_enc_seek_callback), (gst_flac_enc_write_callback),
(gst_flac_enc_tell_callback), (gst_flac_enc_sink_event),
(gst_flac_enc_chain), (gst_flac_enc_set_property),
(gst_flac_enc_get_property), (gst_flac_enc_change_state):
* ext/flac/gstflacenc.h:
Add support for flac >= 1.1.3 which changed the API. Fixes bug #385887.
2007-06-10 10:53:26 +00:00
|
|
|
g_value_set_uint (value,
|
|
|
|
FLAC__stream_encoder_get_rice_parameter_search_dist (this->encoder));
|
2002-09-15 22:26:33 +00:00
|
|
|
break;
|
2009-07-16 18:44:40 +00:00
|
|
|
case PROP_PADDING:
|
|
|
|
g_value_set_uint (value, this->padding);
|
|
|
|
break;
|
2010-01-06 16:06:53 +00:00
|
|
|
case PROP_SEEKPOINTS:
|
|
|
|
g_value_set_int (value, this->seekpoints);
|
|
|
|
break;
|
2002-09-15 22:26:33 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|
ext/flac/gstflacenc.*: Fix seeking, so that flacenc can rewrite the header with the correct duration and amount of sa...
Original commit message from CVS:
* ext/flac/gstflacenc.c: (gst_flacenc_base_init),
(gst_flacenc_init), (gst_flacenc_sink_setcaps),
(gst_flacenc_seek_callback), (gst_flacenc_write_callback),
(gst_flacenc_sink_event), (gst_flacenc_chain),
(gst_flacenc_set_property), (gst_flacenc_get_property),
(gst_flacenc_change_state):
* ext/flac/gstflacenc.h:
Fix seeking, so that flacenc can rewrite the header with the
correct duration and amount of samples and all that at EOS;
also set timestamps and granulepos on outgoing buffers; add
debug category; fix state change function.
2005-10-24 15:50:06 +00:00
|
|
|
|
2005-11-21 16:36:05 +00:00
|
|
|
GST_OBJECT_UNLOCK (this);
|
2001-12-23 13:56:23 +00:00
|
|
|
}
|