mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +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.
This commit is contained in:
parent
f2fa0a91a6
commit
68fd0eca8b
6 changed files with 485 additions and 6 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2007-06-10 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
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-09 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_sink_set_caps):
|
||||
|
|
22
configure.ac
22
configure.ac
|
@ -652,11 +652,16 @@ AG_GST_CHECK_FEATURE(ESD, [ESounD sound daemon], esdsink, [
|
|||
|
||||
dnl *** FLAC ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_FLAC, true)
|
||||
AC_TRY_RUN([
|
||||
#include <FLAC/export.h>
|
||||
int main () { return FLAC_API_VERSION_CURRENT<8; }
|
||||
],legacy_flac=no,legacy_flac=yes,legacy_flac=no)
|
||||
|
||||
if test "x$legacy_flac" = "xyes"; then
|
||||
AG_GST_CHECK_FEATURE(FLAC, [FLAC lossless audio], flac, [
|
||||
AG_GST_CHECK_LIBHEADER(FLAC, FLAC, FLAC__seekable_stream_encoder_new, -lm, FLAC/all.h, FLAC_LIBS="-lFLAC -lm")
|
||||
dnl API change in FLAC 1.1.1, so require that...
|
||||
dnl (this check will also fail with FLAC 1.1.3 which changed API again
|
||||
dnl and with which our plugin does not compile or work yet)
|
||||
dnl (this check will also fail with FLAC 1.1.3 which changed API again)
|
||||
if test x$HAVE_FLAC = xyes; then
|
||||
AC_CHECK_DECL(FLAC__SEEKABLE_STREAM_ENCODER_TELL_ERROR,
|
||||
HAVE_FLAC="yes", HAVE_FLAC="no", [
|
||||
|
@ -665,6 +670,19 @@ AG_GST_CHECK_FEATURE(FLAC, [FLAC lossless audio], flac, [
|
|||
fi
|
||||
AC_SUBST(FLAC_LIBS)
|
||||
])
|
||||
else
|
||||
AG_GST_CHECK_FEATURE(FLAC, [FLAC lossless audio], flac, [
|
||||
AG_GST_CHECK_LIBHEADER(FLAC, FLAC, FLAC__stream_encoder_new, -lm, FLAC/all.h, FLAC_LIBS="-lFLAC -lm")
|
||||
dnl API change in FLAC 1.1.3, so require that...
|
||||
if test x$HAVE_FLAC = xyes; then
|
||||
AC_CHECK_DECL(FLAC__STREAM_ENCODER_TELL_STATUS_ERROR,
|
||||
HAVE_FLAC="yes", HAVE_FLAC="no", [
|
||||
#include <FLAC/stream_encoder.h>
|
||||
])
|
||||
fi
|
||||
AC_SUBST(FLAC_LIBS)
|
||||
])
|
||||
fi
|
||||
|
||||
dnl *** GConf ***
|
||||
translit(dnm, m, l) AM_CONDITIONAL(USE_GCONF, true)
|
||||
|
|
|
@ -94,6 +94,7 @@ static void gst_flac_dec_reset_decoders (GstFlacDec * flacdec);
|
|||
static void gst_flac_dec_setup_seekable_decoder (GstFlacDec * flacdec);
|
||||
static void gst_flac_dec_setup_stream_decoder (GstFlacDec * flacdec);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamDecoderReadStatus
|
||||
gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
||||
FLAC__byte buffer[], unsigned *bytes, void *client_data);
|
||||
|
@ -131,6 +132,33 @@ static void gst_flac_dec_error_callback_seekable (const
|
|||
FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
static void gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder *
|
||||
decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
#else
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__byte buffer[], size_t * bytes, void *client_data);
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__byte buffer[], size_t * bytes, void *client_data);
|
||||
static FLAC__StreamDecoderSeekStatus
|
||||
gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 position, void *client_data);
|
||||
static FLAC__StreamDecoderTellStatus
|
||||
gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 * position, void *client_data);
|
||||
static FLAC__StreamDecoderLengthStatus
|
||||
gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 * length, void *client_data);
|
||||
static FLAC__bool gst_flac_dec_eof (const FLAC__StreamDecoder * decoder,
|
||||
void *client_data);
|
||||
static FLAC__StreamDecoderWriteStatus
|
||||
gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
|
||||
const FLAC__Frame * frame,
|
||||
const FLAC__int32 * const buffer[], void *client_data);
|
||||
static void gst_flac_dec_metadata_callback_stream (const FLAC__StreamDecoder *
|
||||
decoder, const FLAC__StreamMetadata * metadata, void *client_data);
|
||||
static void gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder *
|
||||
decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
|
||||
#endif
|
||||
|
||||
GST_BOILERPLATE (GstFlacDec, gst_flac_dec, GstElement, GST_TYPE_ELEMENT);
|
||||
#define GST_FLAC_DEC_SRC_CAPS \
|
||||
|
@ -213,7 +241,11 @@ static void
|
|||
gst_flac_dec_reset_decoders (GstFlacDec * flacdec)
|
||||
{
|
||||
if (flacdec->seekable_decoder) {
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_decoder_delete (flacdec->seekable_decoder);
|
||||
#else
|
||||
FLAC__stream_decoder_delete (flacdec->seekable_decoder);
|
||||
#endif
|
||||
flacdec->seekable_decoder = NULL;
|
||||
}
|
||||
|
||||
|
@ -239,6 +271,7 @@ gst_flac_dec_setup_seekable_decoder (GstFlacDec * dec)
|
|||
{
|
||||
gst_flac_dec_reset_decoders (dec);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
dec->seekable_decoder = FLAC__seekable_stream_decoder_new ();
|
||||
|
||||
FLAC__seekable_stream_decoder_set_read_callback (dec->seekable_decoder,
|
||||
|
@ -260,6 +293,12 @@ gst_flac_dec_setup_seekable_decoder (GstFlacDec * dec)
|
|||
FLAC__seekable_stream_decoder_set_error_callback (dec->seekable_decoder,
|
||||
gst_flac_dec_error_callback_seekable);
|
||||
FLAC__seekable_stream_decoder_set_client_data (dec->seekable_decoder, dec);
|
||||
#else
|
||||
dec->seekable_decoder = FLAC__stream_decoder_new ();
|
||||
FLAC__stream_decoder_set_metadata_respond (dec->seekable_decoder,
|
||||
FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
||||
FLAC__stream_decoder_set_md5_checking (dec->seekable_decoder, false); /* no point calculating since it's never checked here */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -271,6 +310,7 @@ gst_flac_dec_setup_stream_decoder (GstFlacDec * dec)
|
|||
|
||||
dec->stream_decoder = FLAC__stream_decoder_new ();
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__stream_decoder_set_read_callback (dec->stream_decoder,
|
||||
gst_flac_dec_read_stream);
|
||||
FLAC__stream_decoder_set_write_callback (dec->stream_decoder,
|
||||
|
@ -282,6 +322,11 @@ gst_flac_dec_setup_stream_decoder (GstFlacDec * dec)
|
|||
FLAC__stream_decoder_set_error_callback (dec->stream_decoder,
|
||||
gst_flac_dec_error_callback_stream);
|
||||
FLAC__stream_decoder_set_client_data (dec->stream_decoder, dec);
|
||||
#else
|
||||
FLAC__stream_decoder_set_md5_checking (dec->stream_decoder, false); /* no point calculating since it's never checked here */
|
||||
FLAC__stream_decoder_set_metadata_respond (dec->stream_decoder,
|
||||
FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -545,6 +590,7 @@ gst_flac_dec_metadata_callback (GstFlacDec * flacdec,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static void
|
||||
gst_flac_dec_metadata_callback_seekable (const FLAC__SeekableStreamDecoder * d,
|
||||
const FLAC__StreamMetadata * metadata, void *client_data)
|
||||
|
@ -553,6 +599,7 @@ gst_flac_dec_metadata_callback_seekable (const FLAC__SeekableStreamDecoder * d,
|
|||
|
||||
gst_flac_dec_metadata_callback (dec, metadata);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_flac_dec_metadata_callback_stream (const FLAC__StreamDecoder * decoder,
|
||||
|
@ -588,12 +635,14 @@ gst_flac_dec_error_callback (GstFlacDec * dec,
|
|||
dec->last_flow = GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static void
|
||||
gst_flac_dec_error_callback_seekable (const FLAC__SeekableStreamDecoder * d,
|
||||
FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
gst_flac_dec_error_callback (GST_FLAC_DEC (client_data), status);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder * d,
|
||||
|
@ -602,9 +651,15 @@ gst_flac_dec_error_callback_stream (const FLAC__StreamDecoder * d,
|
|||
gst_flac_dec_error_callback (GST_FLAC_DEC (client_data), status);
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamDecoderSeekStatus
|
||||
gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
||||
FLAC__uint64 position, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamDecoderSeekStatus
|
||||
gst_flac_dec_seek (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 position, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
|
||||
|
@ -613,12 +668,22 @@ gst_flac_dec_seek (const FLAC__SeekableStreamDecoder * decoder,
|
|||
GST_DEBUG ("seek %" G_GINT64_FORMAT, position);
|
||||
flacdec->offset = position;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamDecoderTellStatus
|
||||
gst_flac_dec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
||||
FLAC__uint64 * position, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamDecoderTellStatus
|
||||
gst_flac_dec_tell (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 * position, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
|
||||
|
@ -628,12 +693,22 @@ gst_flac_dec_tell (const FLAC__SeekableStreamDecoder * decoder,
|
|||
|
||||
GST_DEBUG ("tell %" G_GINT64_FORMAT, *position);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamDecoderLengthStatus
|
||||
gst_flac_dec_length (const FLAC__SeekableStreamDecoder * decoder,
|
||||
FLAC__uint64 * length, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamDecoderLengthStatus
|
||||
gst_flac_dec_length (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__uint64 * length, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
GstFormat fmt = GST_FORMAT_BYTES;
|
||||
|
@ -643,22 +718,39 @@ gst_flac_dec_length (const FLAC__SeekableStreamDecoder * decoder,
|
|||
flacdec = GST_FLAC_DEC (client_data);
|
||||
|
||||
if (!(peer = gst_pad_get_peer (flacdec->sinkpad)))
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
#endif
|
||||
gst_pad_query_duration (peer, &fmt, &len);
|
||||
gst_object_unref (peer);
|
||||
if (fmt != GST_FORMAT_BYTES || len == -1)
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
|
||||
#endif
|
||||
|
||||
*length = len;
|
||||
|
||||
GST_DEBUG ("length %" G_GINT64_FORMAT, *length);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__bool
|
||||
gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
|
||||
void *client_data)
|
||||
#else
|
||||
static FLAC__bool
|
||||
gst_flac_dec_eof (const FLAC__StreamDecoder * decoder, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
GstFormat fmt;
|
||||
|
@ -686,9 +778,15 @@ gst_flac_dec_eof (const FLAC__SeekableStreamDecoder * decoder,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamDecoderReadStatus
|
||||
gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
||||
FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
gst_flac_dec_read_seekable (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__byte buffer[], size_t * bytes, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
GstBuffer *buf;
|
||||
|
@ -697,7 +795,11 @@ gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
|||
|
||||
if (gst_pad_pull_range (flacdec->sinkpad, flacdec->offset, *bytes,
|
||||
&buf) != GST_FLOW_OK)
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
#endif
|
||||
|
||||
GST_DEBUG ("Read %d bytes at %" G_GUINT64_FORMAT,
|
||||
GST_BUFFER_SIZE (buf), flacdec->offset);
|
||||
|
@ -706,12 +808,22 @@ gst_flac_dec_read_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
|||
gst_buffer_unref (buf);
|
||||
flacdec->offset += *bytes;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
gst_flac_dec_read_stream (const FLAC__StreamDecoder * decoder,
|
||||
FLAC__byte buffer[], size_t * bytes, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacDec *dec = GST_FLAC_DEC (client_data);
|
||||
guint len;
|
||||
|
@ -881,6 +993,7 @@ done:
|
|||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__StreamDecoderWriteStatus
|
||||
gst_flac_dec_write_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
||||
const FLAC__Frame * frame,
|
||||
|
@ -888,6 +1001,7 @@ gst_flac_dec_write_seekable (const FLAC__SeekableStreamDecoder * decoder,
|
|||
{
|
||||
return gst_flac_dec_write (GST_FLAC_DEC (client_data), frame, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
static FLAC__StreamDecoderWriteStatus
|
||||
gst_flac_dec_write_stream (const FLAC__StreamDecoder * decoder,
|
||||
|
@ -901,7 +1015,13 @@ static void
|
|||
gst_flac_dec_loop (GstPad * sinkpad)
|
||||
{
|
||||
GstFlacDec *flacdec;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__SeekableStreamDecoderState s;
|
||||
#else
|
||||
FLAC__StreamDecoderState s;
|
||||
FLAC__StreamDecoderInitStatus is;
|
||||
#endif
|
||||
|
||||
flacdec = GST_FLAC_DEC (GST_OBJECT_PARENT (sinkpad));
|
||||
|
||||
|
@ -909,9 +1029,19 @@ gst_flac_dec_loop (GstPad * sinkpad)
|
|||
|
||||
if (flacdec->init) {
|
||||
GST_DEBUG_OBJECT (flacdec, "initializing decoder");
|
||||
#ifdef LEGACY_FLAC
|
||||
s = FLAC__seekable_stream_decoder_init (flacdec->seekable_decoder);
|
||||
if (s != FLAC__SEEKABLE_STREAM_DECODER_OK)
|
||||
goto analyze_state;
|
||||
#else
|
||||
is = FLAC__stream_decoder_init_stream (flacdec->seekable_decoder,
|
||||
gst_flac_dec_read_seekable, gst_flac_dec_seek, gst_flac_dec_tell,
|
||||
gst_flac_dec_length, gst_flac_dec_eof, gst_flac_dec_write_stream,
|
||||
gst_flac_dec_metadata_callback_stream,
|
||||
gst_flac_dec_error_callback_stream, flacdec);
|
||||
if (is != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
goto analyze_state;
|
||||
#endif
|
||||
/* FLAC__seekable_stream_decoder_process_metadata (flacdec->seekable_decoder); */
|
||||
flacdec->init = FALSE;
|
||||
}
|
||||
|
@ -921,15 +1051,30 @@ gst_flac_dec_loop (GstPad * sinkpad)
|
|||
flacdec->last_flow = GST_FLOW_OK;
|
||||
|
||||
GST_LOG_OBJECT (flacdec, "processing single");
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_decoder_process_single (flacdec->seekable_decoder);
|
||||
|
||||
#else
|
||||
FLAC__stream_decoder_process_single (flacdec->seekable_decoder);
|
||||
#endif
|
||||
analyze_state:
|
||||
|
||||
GST_LOG_OBJECT (flacdec, "done processing, checking encoder state");
|
||||
#ifdef LEGACY_FLAC
|
||||
s = FLAC__seekable_stream_decoder_get_state (flacdec->seekable_decoder);
|
||||
#else
|
||||
s = FLAC__stream_decoder_get_state (flacdec->seekable_decoder);
|
||||
#endif
|
||||
switch (s) {
|
||||
#ifdef LEGACY_FLAC
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_OK:
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:{
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
|
||||
#else
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
case FLAC__STREAM_DECODER_READ_FRAME:
|
||||
#endif
|
||||
{
|
||||
GST_DEBUG_OBJECT (flacdec, "everything ok");
|
||||
|
||||
if (GST_FLOW_IS_FATAL (flacdec->last_flow) ||
|
||||
|
@ -961,9 +1106,17 @@ analyze_state:
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:{
|
||||
#else
|
||||
case FLAC__STREAM_DECODER_END_OF_STREAM:{
|
||||
#endif
|
||||
GST_DEBUG_OBJECT (flacdec, "EOS");
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_decoder_reset (flacdec->seekable_decoder);
|
||||
#else
|
||||
FLAC__stream_decoder_reset (flacdec->seekable_decoder);
|
||||
#endif
|
||||
|
||||
if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) != 0) {
|
||||
if (flacdec->segment.duration > 0) {
|
||||
|
@ -977,6 +1130,7 @@ analyze_state:
|
|||
goto eos_and_pause;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
|
||||
|
@ -984,11 +1138,23 @@ analyze_state:
|
|||
case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
|
||||
case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
|
||||
#else
|
||||
case FLAC__STREAM_DECODER_OGG_ERROR:
|
||||
case FLAC__STREAM_DECODER_SEEK_ERROR:
|
||||
case FLAC__STREAM_DECODER_ABORTED:
|
||||
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
|
||||
case FLAC__STREAM_DECODER_UNINITIALIZED:
|
||||
#endif
|
||||
default:{
|
||||
/* fixme: this error sucks -- should try to figure out when/if an more
|
||||
specific error was already sent via the callback */
|
||||
#ifdef LEGACY_FLAC
|
||||
GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
|
||||
("%s", FLAC__SeekableStreamDecoderStateString[s]));
|
||||
#else
|
||||
GST_ELEMENT_ERROR (flacdec, STREAM, DECODE, (NULL),
|
||||
("%s", FLAC__StreamDecoderStateString[s]));
|
||||
#endif
|
||||
goto eos_and_pause;
|
||||
}
|
||||
}
|
||||
|
@ -1106,7 +1272,11 @@ gst_flac_dec_sink_event (GstPad * pad, GstEvent * event)
|
|||
static GstFlowReturn
|
||||
gst_flac_dec_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__StreamDecoderState s;
|
||||
#else
|
||||
FLAC__StreamDecoderInitStatus s;
|
||||
#endif
|
||||
GstFlacDec *dec;
|
||||
gboolean got_audio_frame;
|
||||
|
||||
|
@ -1118,11 +1288,22 @@ gst_flac_dec_chain (GstPad * pad, GstBuffer * buf)
|
|||
|
||||
if (dec->init) {
|
||||
GST_DEBUG_OBJECT (dec, "initializing decoder");
|
||||
#ifdef LEGACY_FLAC
|
||||
s = FLAC__stream_decoder_init (dec->stream_decoder);
|
||||
if (s != FLAC__STREAM_DECODER_SEARCH_FOR_METADATA) {
|
||||
GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
#else
|
||||
s = FLAC__stream_decoder_init_stream (dec->stream_decoder,
|
||||
gst_flac_dec_read_stream, NULL, NULL, NULL, NULL,
|
||||
gst_flac_dec_write_stream, gst_flac_dec_metadata_callback_stream,
|
||||
gst_flac_dec_error_callback_stream, dec);
|
||||
if (s != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
|
||||
GST_ELEMENT_ERROR (GST_ELEMENT (dec), LIBRARY, INIT, (NULL), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
#endif
|
||||
GST_DEBUG_OBJECT (dec, "initialized (framed=%d)", dec->framed);
|
||||
dec->init = FALSE;
|
||||
}
|
||||
|
@ -1603,8 +1784,13 @@ gst_flac_dec_handle_seek_event (GstFlacDec * flacdec, GstEvent * event)
|
|||
flacdec->seeking = TRUE;
|
||||
|
||||
seek_ok =
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_decoder_seek_absolute (flacdec->seekable_decoder,
|
||||
segment.start);
|
||||
#else
|
||||
FLAC__stream_decoder_seek_absolute (flacdec->seekable_decoder,
|
||||
segment.start);
|
||||
#endif
|
||||
|
||||
flacdec->seeking = FALSE;
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
|
||||
#include <FLAC/all.h>
|
||||
|
||||
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
|
||||
#define LEGACY_FLAC
|
||||
#else
|
||||
#undef LEGACY_FLAC
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_FLAC_DEC gst_flac_dec_get_type()
|
||||
|
@ -41,7 +47,11 @@ typedef struct _GstFlacDecClass GstFlacDecClass;
|
|||
struct _GstFlacDec {
|
||||
GstElement element;
|
||||
|
||||
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
|
||||
FLAC__SeekableStreamDecoder *seekable_decoder; /* for pull-based operation */
|
||||
#else
|
||||
FLAC__StreamDecoder *seekable_decoder; /* for pull-based operation */
|
||||
#endif
|
||||
|
||||
FLAC__StreamDecoder *stream_decoder; /* for chain-based operation */
|
||||
GstAdapter *adapter;
|
||||
|
|
|
@ -113,6 +113,7 @@ static void gst_flac_enc_get_property (GObject * object, guint prop_id,
|
|||
static GstStateChangeReturn gst_flac_enc_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__StreamEncoderWriteStatus
|
||||
gst_flac_enc_write_callback (const FLAC__SeekableStreamEncoder * encoder,
|
||||
const FLAC__byte buffer[], unsigned bytes,
|
||||
|
@ -123,6 +124,18 @@ gst_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|||
static FLAC__SeekableStreamEncoderTellStatus
|
||||
gst_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder * encoder,
|
||||
FLAC__uint64 * absolute_byte_offset, void *client_data);
|
||||
#else
|
||||
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);
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -307,7 +320,11 @@ gst_flac_enc_init (GstFlacEnc * flacenc, GstFlacEncClass * klass)
|
|||
gst_pad_use_fixed_caps (flacenc->srcpad);
|
||||
gst_element_add_pad (GST_ELEMENT (flacenc), flacenc->srcpad);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
flacenc->encoder = FLAC__seekable_stream_encoder_new ();
|
||||
#else
|
||||
flacenc->encoder = FLAC__stream_encoder_new ();
|
||||
#endif
|
||||
|
||||
flacenc->offset = 0;
|
||||
flacenc->samples_written = 0;
|
||||
|
@ -323,7 +340,11 @@ gst_flac_enc_finalize (GObject * object)
|
|||
GstFlacEnc *flacenc = GST_FLAC_ENC (object);
|
||||
|
||||
gst_tag_list_free (flacenc->tags);
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_delete (flacenc->encoder);
|
||||
#else
|
||||
FLAC__stream_encoder_delete (flacenc->encoder);
|
||||
#endif
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -368,8 +389,13 @@ gst_flac_enc_set_metadata (GstFlacEnc * flacenc)
|
|||
FLAC__metadata_object_new (FLAC__METADATA_TYPE_VORBIS_COMMENT);
|
||||
gst_tag_list_foreach (copy, add_one_tag, flacenc);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
if (FLAC__seekable_stream_encoder_set_metadata (flacenc->encoder,
|
||||
flacenc->meta, 1) != true)
|
||||
#else
|
||||
if (FLAC__stream_encoder_set_metadata (flacenc->encoder,
|
||||
flacenc->meta, 1) != true)
|
||||
#endif
|
||||
g_warning ("Dude, i'm already initialized!");
|
||||
gst_tag_list_free (copy);
|
||||
}
|
||||
|
@ -379,13 +405,24 @@ gst_flac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|||
{
|
||||
GstFlacEnc *flacenc;
|
||||
GstStructure *structure;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__SeekableStreamEncoderState state;
|
||||
#else
|
||||
FLAC__StreamEncoderInitStatus init_status;
|
||||
#endif
|
||||
gint depth, chans, rate, width;
|
||||
|
||||
flacenc = GST_FLAC_ENC (gst_pad_get_parent (pad));
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) !=
|
||||
FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED)
|
||||
#else
|
||||
if (FLAC__stream_encoder_get_state (flacenc->encoder) !=
|
||||
FLAC__STREAM_ENCODER_UNINITIALIZED)
|
||||
#endif
|
||||
|
||||
goto encoder_already_initialized;
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
@ -411,6 +448,7 @@ gst_flac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|||
|
||||
gst_caps_unref (caps);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_bits_per_sample (flacenc->encoder,
|
||||
flacenc->depth);
|
||||
FLAC__seekable_stream_encoder_set_sample_rate (flacenc->encoder,
|
||||
|
@ -426,12 +464,25 @@ gst_flac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|||
gst_flac_enc_tell_callback);
|
||||
|
||||
FLAC__seekable_stream_encoder_set_client_data (flacenc->encoder, flacenc);
|
||||
#else
|
||||
FLAC__stream_encoder_set_bits_per_sample (flacenc->encoder, flacenc->depth);
|
||||
FLAC__stream_encoder_set_sample_rate (flacenc->encoder, flacenc->sample_rate);
|
||||
FLAC__stream_encoder_set_channels (flacenc->encoder, flacenc->channels);
|
||||
#endif
|
||||
|
||||
gst_flac_enc_set_metadata (flacenc);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
state = FLAC__seekable_stream_encoder_init (flacenc->encoder);
|
||||
if (state != FLAC__STREAM_ENCODER_OK)
|
||||
goto failed_to_initialize;
|
||||
#else
|
||||
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;
|
||||
#endif
|
||||
|
||||
gst_object_unref (flacenc);
|
||||
|
||||
|
@ -465,6 +516,7 @@ gst_flac_enc_update_quality (GstFlacEnc * flacenc, gint quality)
|
|||
{
|
||||
flacenc->quality = quality;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
#define DO_UPDATE(name, val, str) \
|
||||
G_STMT_START { \
|
||||
if (FLAC__seekable_stream_encoder_get_##name (flacenc->encoder) != \
|
||||
|
@ -475,6 +527,19 @@ gst_flac_enc_update_quality (GstFlacEnc * flacenc, gint quality)
|
|||
} \
|
||||
} G_STMT_END
|
||||
|
||||
#else
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (flacenc));
|
||||
|
||||
if (flacenc->channels == 2) {
|
||||
|
@ -504,9 +569,15 @@ gst_flac_enc_update_quality (GstFlacEnc * flacenc, gint quality)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamEncoderSeekStatus
|
||||
gst_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
||||
FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamEncoderSeekStatus
|
||||
gst_flac_enc_seek_callback (const FLAC__StreamEncoder * encoder,
|
||||
FLAC__uint64 absolute_byte_offset, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacEnc *flacenc;
|
||||
GstEvent *event;
|
||||
|
@ -515,8 +586,11 @@ gst_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|||
flacenc = GST_FLAC_ENC (client_data);
|
||||
|
||||
if (flacenc->stopped)
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK;
|
||||
|
||||
#else
|
||||
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
|
||||
#endif
|
||||
event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
|
||||
absolute_byte_offset, GST_BUFFER_OFFSET_NONE, 0);
|
||||
|
||||
|
@ -538,8 +612,11 @@ gst_flac_enc_seek_callback (const FLAC__SeekableStreamEncoder * encoder,
|
|||
}
|
||||
|
||||
flacenc->offset = absolute_byte_offset;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_ENCODER_SEEK_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -664,10 +741,17 @@ push_headers:
|
|||
gst_caps_unref (caps);
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__StreamEncoderWriteStatus
|
||||
gst_flac_enc_write_callback (const FLAC__SeekableStreamEncoder * encoder,
|
||||
const FLAC__byte buffer[], unsigned bytes,
|
||||
unsigned samples, unsigned current_frame, void *client_data)
|
||||
#else
|
||||
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)
|
||||
#endif
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
GstFlacEnc *flacenc;
|
||||
|
@ -733,15 +817,25 @@ out:
|
|||
return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
|
||||
}
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
static FLAC__SeekableStreamEncoderTellStatus
|
||||
gst_flac_enc_tell_callback (const FLAC__SeekableStreamEncoder * encoder,
|
||||
FLAC__uint64 * absolute_byte_offset, void *client_data)
|
||||
#else
|
||||
static FLAC__StreamEncoderTellStatus
|
||||
gst_flac_enc_tell_callback (const FLAC__StreamEncoder * encoder,
|
||||
FLAC__uint64 * absolute_byte_offset, void *client_data)
|
||||
#endif
|
||||
{
|
||||
GstFlacEnc *flacenc = GST_FLAC_ENC (client_data);
|
||||
|
||||
*absolute_byte_offset = flacenc->offset;
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_ENCODER_TELL_STATUS_OK;
|
||||
#else
|
||||
return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -785,7 +879,11 @@ gst_flac_enc_sink_event (GstPad * pad, GstEvent * event)
|
|||
break;
|
||||
}
|
||||
case GST_EVENT_EOS:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_finish (flacenc->encoder);
|
||||
#else
|
||||
FLAC__stream_encoder_finish (flacenc->encoder);
|
||||
#endif
|
||||
ret = gst_pad_event_default (pad, event);
|
||||
break;
|
||||
case GST_EVENT_TAG:
|
||||
|
@ -846,8 +944,13 @@ gst_flac_enc_chain (GstPad * pad, GstBuffer * buffer)
|
|||
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
#ifdef LEGACY_FLAC
|
||||
res = FLAC__seekable_stream_encoder_process_interleaved (flacenc->encoder,
|
||||
(const FLAC__int32 *) data, samples / flacenc->channels);
|
||||
#else
|
||||
res = FLAC__stream_encoder_process_interleaved (flacenc->encoder,
|
||||
(const FLAC__int32 *) data, samples / flacenc->channels);
|
||||
#endif
|
||||
|
||||
g_free (data);
|
||||
|
||||
|
@ -870,52 +973,112 @@ gst_flac_enc_set_property (GObject * object, guint prop_id,
|
|||
gst_flac_enc_update_quality (this, g_value_get_enum (value));
|
||||
break;
|
||||
case PROP_STREAMABLE_SUBSET:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_streamable_subset (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_streamable_subset (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MID_SIDE_STEREO:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_do_mid_side_stereo (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_do_mid_side_stereo (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_LOOSE_MID_SIDE_STEREO:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_loose_mid_side_stereo (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_loose_mid_side_stereo (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_BLOCKSIZE:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_blocksize (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_blocksize (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MAX_LPC_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_max_lpc_order (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_max_lpc_order (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_QLP_COEFF_PRECISION:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_qlp_coeff_precision (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_qlp_coeff_precision (this->encoder,
|
||||
g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_QLP_COEFF_PREC_SEARCH:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_do_qlp_coeff_prec_search (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_do_qlp_coeff_prec_search (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_ESCAPE_CODING:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_do_escape_coding (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_do_escape_coding (this->encoder,
|
||||
g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_EXHAUSTIVE_MODEL_SEARCH:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_do_exhaustive_model_search (this->
|
||||
encoder, g_value_get_boolean (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_do_exhaustive_model_search (this->
|
||||
encoder, g_value_get_boolean (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MIN_RESIDUAL_PARTITION_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_min_residual_partition_order (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_min_residual_partition_order (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MAX_RESIDUAL_PARTITION_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_max_residual_partition_order (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_max_residual_partition_order (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
case PROP_RICE_PARAMETER_SEARCH_DIST:
|
||||
#ifdef LEGACY_FLAC
|
||||
FLAC__seekable_stream_encoder_set_rice_parameter_search_dist (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#else
|
||||
FLAC__stream_encoder_set_rice_parameter_search_dist (this->
|
||||
encoder, g_value_get_uint (value));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -938,59 +1101,121 @@ gst_flac_enc_get_property (GObject * object, guint prop_id,
|
|||
g_value_set_enum (value, this->quality);
|
||||
break;
|
||||
case PROP_STREAMABLE_SUBSET:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_streamable_subset (this->encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_streamable_subset (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MID_SIDE_STEREO:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_do_mid_side_stereo (this->encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_do_mid_side_stereo (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_LOOSE_MID_SIDE_STEREO:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_loose_mid_side_stereo (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_loose_mid_side_stereo (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_BLOCKSIZE:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_blocksize (this->encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_blocksize (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MAX_LPC_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_max_lpc_order (this->encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_max_lpc_order (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_QLP_COEFF_PRECISION:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_qlp_coeff_precision (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_qlp_coeff_precision (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_QLP_COEFF_PREC_SEARCH:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_do_qlp_coeff_prec_search (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_do_qlp_coeff_prec_search (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_ESCAPE_CODING:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_do_escape_coding (this->encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_do_escape_coding (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_EXHAUSTIVE_MODEL_SEARCH:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_boolean (value,
|
||||
FLAC__seekable_stream_encoder_get_do_exhaustive_model_search (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_boolean (value,
|
||||
FLAC__stream_encoder_get_do_exhaustive_model_search (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MIN_RESIDUAL_PARTITION_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_min_residual_partition_order (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_min_residual_partition_order (this->
|
||||
encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_MAX_RESIDUAL_PARTITION_ORDER:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_max_residual_partition_order (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_max_residual_partition_order (this->
|
||||
encoder));
|
||||
#endif
|
||||
break;
|
||||
case PROP_RICE_PARAMETER_SEARCH_DIST:
|
||||
#ifdef LEGACY_FLAC
|
||||
g_value_set_uint (value,
|
||||
FLAC__seekable_stream_encoder_get_rice_parameter_search_dist (this->
|
||||
encoder));
|
||||
#else
|
||||
g_value_set_uint (value,
|
||||
FLAC__stream_encoder_get_rice_parameter_search_dist (this->encoder));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -1022,11 +1247,19 @@ gst_flac_enc_change_state (GstElement * element, GstStateChange transition)
|
|||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
#ifdef LEGACY_FLAC
|
||||
if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) !=
|
||||
FLAC__STREAM_ENCODER_UNINITIALIZED) {
|
||||
flacenc->stopped = TRUE;
|
||||
FLAC__seekable_stream_encoder_finish (flacenc->encoder);
|
||||
}
|
||||
#else
|
||||
if (FLAC__stream_encoder_get_state (flacenc->encoder) !=
|
||||
FLAC__STREAM_ENCODER_UNINITIALIZED) {
|
||||
flacenc->stopped = TRUE;
|
||||
FLAC__stream_encoder_finish (flacenc->encoder);
|
||||
}
|
||||
#endif
|
||||
flacenc->offset = 0;
|
||||
flacenc->samples_written = 0;
|
||||
flacenc->channels = 0;
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
|
||||
#include <FLAC/all.h>
|
||||
|
||||
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
|
||||
#define LEGACY_FLAC
|
||||
#else
|
||||
#undef LEGACY_FLAC
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_FLAC_ENC (gst_flac_enc_get_type())
|
||||
|
@ -55,7 +61,11 @@ struct _GstFlacEnc {
|
|||
gboolean stopped;
|
||||
FLAC__int32 *data;
|
||||
|
||||
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT < 8
|
||||
FLAC__SeekableStreamEncoder *encoder;
|
||||
#else
|
||||
FLAC__StreamEncoder *encoder;
|
||||
#endif
|
||||
FLAC__StreamMetadata **meta;
|
||||
|
||||
GstTagList * tags;
|
||||
|
|
Loading…
Reference in a new issue