diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-03-01 14:29:50 +0400 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2012-03-01 14:29:50 +0400 |
commit | f189f62b139a5d95b6ad9093566fed09093e1879 (patch) | |
tree | cbef8f2507ef138434bce93f44e6c082ec290d12 | |
parent | 9f4fb6feb9635695d3345f6f03319004c7210fe4 (diff) | |
parent | 50cd7c9ac6f2d64d8b43e03f2b248efa02dafe4c (diff) |
Merge branch 'master' into 0.11
Conflicts:
ext/wavpack/gstwavpackenc.c
tests/check/elements/audioiirfilter.c
tests/examples/v4l2/probe.c
29 files changed, 1243 insertions, 499 deletions
diff --git a/ext/annodex/gstannodex.c b/ext/annodex/gstannodex.c index 789091cfe..f4c963109 100644 --- a/ext/annodex/gstannodex.c +++ b/ext/annodex/gstannodex.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/ext/annodex/gstcmmlparser.c b/ext/annodex/gstcmmlparser.c index 0e2f7cd8e..b76cf4a0b 100644 --- a/ext/annodex/gstcmmlparser.c +++ b/ext/annodex/gstcmmlparser.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <stdarg.h> #include <gst/gst.h> diff --git a/ext/annodex/gstcmmltag.c b/ext/annodex/gstcmmltag.c index 2cf5d5fef..8b2a1893e 100644 --- a/ext/annodex/gstcmmltag.c +++ b/ext/annodex/gstcmmltag.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/ext/pulse/pulseprobe.c b/ext/pulse/pulseprobe.c index 55f02005e..06e098622 100644 --- a/ext/pulse/pulseprobe.c +++ b/ext/pulse/pulseprobe.c @@ -21,6 +21,10 @@ * USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/ext/wavpack/gstwavpackdec.c b/ext/wavpack/gstwavpackdec.c index f7c96ba14..8f0778d63 100644 --- a/ext/wavpack/gstwavpackdec.c +++ b/ext/wavpack/gstwavpackdec.c @@ -55,8 +55,6 @@ #include "gstwavpackstreamreader.h" -#define WAVPACK_DEC_MAX_ERRORS 16 - GST_DEBUG_CATEGORY_STATIC (gst_wavpack_dec_debug); #define GST_CAT_DEFAULT gst_wavpack_dec_debug @@ -73,22 +71,34 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, " - "width = (int) 32, " - "depth = (int) [ 1, 32 ], " + "width = (int) 8, depth = (int) 8, " + "channels = (int) [ 1, 8 ], " + "rate = (int) [ 6000, 192000 ], " + "endianness = (int) BYTE_ORDER, " "signed = (boolean) true; " + "audio/x-raw-int, " + "width = (int) 16, depth = (int) 16, " "channels = (int) [ 1, 8 ], " "rate = (int) [ 6000, 192000 ], " - "endianness = (int) BYTE_ORDER, " "signed = (boolean) true") + "endianness = (int) BYTE_ORDER, " "signed = (boolean) true; " + "audio/x-raw-int, " + "width = (int) 32, depth = (int) 32, " + "channels = (int) [ 1, 8 ], " + "rate = (int) [ 6000, 192000 ], " + "endianness = (int) BYTE_ORDER, " "signed = (boolean) true; ") ); -static GstFlowReturn gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buffer); -static gboolean gst_wavpack_dec_sink_set_caps (GstPad * pad, GstCaps * caps); -static gboolean gst_wavpack_dec_sink_event (GstPad * pad, GstEvent * event); +static gboolean gst_wavpack_dec_start (GstAudioDecoder * dec); +static gboolean gst_wavpack_dec_stop (GstAudioDecoder * dec); +static gboolean gst_wavpack_dec_set_format (GstAudioDecoder * dec, + GstCaps * caps); +static GstFlowReturn gst_wavpack_dec_handle_frame (GstAudioDecoder * dec, + GstBuffer * buffer); + static void gst_wavpack_dec_finalize (GObject * object); -static GstStateChangeReturn gst_wavpack_dec_change_state (GstElement * element, - GstStateChange transition); static void gst_wavpack_dec_post_tags (GstWavpackDec * dec); -GST_BOILERPLATE (GstWavpackDec, gst_wavpack_dec, GstElement, GST_TYPE_ELEMENT); +GST_BOILERPLATE (GstWavpackDec, gst_wavpack_dec, GstAudioDecoder, + GST_TYPE_AUDIO_DECODER); static void gst_wavpack_dec_base_init (gpointer klass) @@ -110,11 +120,14 @@ static void gst_wavpack_dec_class_init (GstWavpackDecClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; - GstElementClass *gstelement_class = (GstElementClass *) klass; + GstAudioDecoderClass *base_class = (GstAudioDecoderClass *) (klass); - gstelement_class->change_state = - GST_DEBUG_FUNCPTR (gst_wavpack_dec_change_state); gobject_class->finalize = gst_wavpack_dec_finalize; + + base_class->start = GST_DEBUG_FUNCPTR (gst_wavpack_dec_start); + base_class->stop = GST_DEBUG_FUNCPTR (gst_wavpack_dec_stop); + base_class->set_format = GST_DEBUG_FUNCPTR (gst_wavpack_dec_set_format); + base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_wavpack_dec_handle_frame); } static void @@ -123,33 +136,15 @@ gst_wavpack_dec_reset (GstWavpackDec * dec) dec->wv_id.buffer = NULL; dec->wv_id.position = dec->wv_id.length = 0; - dec->error_count = 0; - dec->channels = 0; dec->channel_mask = 0; dec->sample_rate = 0; dec->depth = 0; - - gst_segment_init (&dec->segment, GST_FORMAT_TIME); - dec->next_block_index = 0; } static void gst_wavpack_dec_init (GstWavpackDec * dec, GstWavpackDecClass * gklass) { - dec->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); - gst_pad_set_chain_function (dec->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_dec_chain)); - gst_pad_set_setcaps_function (dec->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_dec_sink_set_caps)); - gst_pad_set_event_function (dec->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_dec_sink_event)); - gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad); - - dec->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); - gst_pad_use_fixed_caps (dec->srcpad); - gst_element_add_pad (GST_ELEMENT (dec), dec->srcpad); - dec->context = NULL; dec->stream_reader = gst_wavpack_stream_reader_new (); @@ -168,26 +163,79 @@ gst_wavpack_dec_finalize (GObject * object) } static gboolean -gst_wavpack_dec_sink_set_caps (GstPad * pad, GstCaps * caps) +gst_wavpack_dec_start (GstAudioDecoder * dec) { - GstWavpackDec *dec = GST_WAVPACK_DEC (gst_pad_get_parent (pad)); + GST_DEBUG_OBJECT (dec, "start"); + + /* never mind a few errors */ + gst_audio_decoder_set_max_errors (dec, 16); + /* don't bother us with flushing */ + gst_audio_decoder_set_drainable (dec, FALSE); + + return TRUE; +} + +static gboolean +gst_wavpack_dec_stop (GstAudioDecoder * dec) +{ + GstWavpackDec *wpdec = GST_WAVPACK_DEC (dec); + + GST_DEBUG_OBJECT (dec, "stop"); + + if (wpdec->context) { + WavpackCloseFile (wpdec->context); + wpdec->context = NULL; + } + + gst_wavpack_dec_reset (wpdec); + + return TRUE; +} + +static void +gst_wavpack_dec_negotiate (GstWavpackDec * dec) +{ + GstCaps *caps; + + /* arrange for 1, 2 or 4-byte width == depth output */ + if (dec->depth == 24) + dec->width = 32; + else + dec->width = dec->depth; + + caps = gst_caps_new_simple ("audio/x-raw-int", + "rate", G_TYPE_INT, dec->sample_rate, + "channels", G_TYPE_INT, dec->channels, + "depth", G_TYPE_INT, dec->width, + "width", G_TYPE_INT, dec->width, + "endianness", G_TYPE_INT, G_BYTE_ORDER, + "signed", G_TYPE_BOOLEAN, TRUE, NULL); + + /* Only set the channel layout for more than two channels + * otherwise things break unfortunately */ + if (dec->channel_mask != 0 && dec->channels > 2) + if (!gst_wavpack_set_channel_layout (caps, dec->channel_mask)) + GST_WARNING_OBJECT (dec, "Failed to set channel layout"); + + GST_DEBUG_OBJECT (dec, "setting caps %" GST_PTR_FORMAT, caps); + + /* should always succeed */ + gst_pad_set_caps (GST_AUDIO_DECODER_SRC_PAD (dec), caps); + gst_caps_unref (caps); +} + +static gboolean +gst_wavpack_dec_set_format (GstAudioDecoder * bdec, GstCaps * caps) +{ + GstWavpackDec *dec = GST_WAVPACK_DEC (bdec); GstStructure *structure = gst_caps_get_structure (caps, 0); /* Check if we can set the caps here already */ if (gst_structure_get_int (structure, "channels", &dec->channels) && gst_structure_get_int (structure, "rate", &dec->sample_rate) && gst_structure_get_int (structure, "width", &dec->depth)) { - GstCaps *caps; GstAudioChannelPosition *pos; - caps = gst_caps_new_simple ("audio/x-raw-int", - "rate", G_TYPE_INT, dec->sample_rate, - "channels", G_TYPE_INT, dec->channels, - "depth", G_TYPE_INT, dec->depth, - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); - /* If we already have the channel layout set from upstream * take this */ if (gst_structure_has_field (structure, "channel-positions")) { @@ -204,19 +252,13 @@ gst_wavpack_dec_sink_set_caps (GstPad * pad, GstCaps * caps) g_free (pos); } - GST_DEBUG_OBJECT (dec, "setting caps %" GST_PTR_FORMAT, caps); - - /* should always succeed */ - gst_pad_set_caps (dec->srcpad, caps); - gst_caps_unref (caps); + gst_wavpack_dec_negotiate (dec); /* send GST_TAG_AUDIO_CODEC and GST_TAG_BITRATE tags before something * is decoded or after the format has changed */ gst_wavpack_dec_post_tags (dec); } - gst_object_unref (dec); - return TRUE; } @@ -227,28 +269,26 @@ gst_wavpack_dec_post_tags (GstWavpackDec * dec) GstFormat format_time = GST_FORMAT_TIME, format_bytes = GST_FORMAT_BYTES; gint64 duration, size; - list = gst_tag_list_new (); - - gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, - GST_TAG_AUDIO_CODEC, "Wavpack", NULL); - /* try to estimate the average bitrate */ - if (gst_pad_query_peer_duration (dec->sinkpad, &format_bytes, &size) && - gst_pad_query_peer_duration (dec->sinkpad, &format_time, &duration) && - size > 0 && duration > 0) { + if (gst_pad_query_peer_duration (GST_AUDIO_DECODER_SINK_PAD (dec), + &format_bytes, &size) && + gst_pad_query_peer_duration (GST_AUDIO_DECODER_SINK_PAD (dec), + &format_time, &duration) && size > 0 && duration > 0) { guint64 bitrate; + list = gst_tag_list_new (); + bitrate = gst_util_uint64_scale (size, 8 * GST_SECOND, duration); gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_BITRATE, (guint) bitrate, NULL); - } - gst_element_post_message (GST_ELEMENT (dec), - gst_message_new_tag (GST_OBJECT (dec), list)); + gst_element_post_message (GST_ELEMENT (dec), + gst_message_new_tag (GST_OBJECT (dec), list)); + } } static GstFlowReturn -gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) +gst_wavpack_dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buf) { GstWavpackDec *dec; GstBuffer *outbuf = NULL; @@ -256,8 +296,13 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) WavpackHeader wph; int32_t decoded, unpacked_size; gboolean format_changed; + gint width, depth, i, max; + gint32 *dec_data = NULL; + guint8 *out_data; - dec = GST_WAVPACK_DEC (GST_PAD_PARENT (pad)); + dec = GST_WAVPACK_DEC (bdec); + + g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); /* check input, we only accept framed input with complete chunks */ if (GST_BUFFER_SIZE (buf) < sizeof (WavpackHeader)) @@ -285,46 +330,31 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) dec->context = WavpackOpenFileInputEx (dec->stream_reader, &dec->wv_id, NULL, error_msg, OPEN_STREAMING, 0); + /* expect this to work */ if (!dec->context) { - GST_WARNING ("Couldn't decode buffer: %s", error_msg); - dec->error_count++; - if (dec->error_count <= WAVPACK_DEC_MAX_ERRORS) { - goto out; /* just return OK for now */ - } else { - goto decode_error; - } + GST_WARNING_OBJECT (dec, "Couldn't decode buffer: %s", error_msg); + goto context_failed; } } g_assert (dec->context != NULL); - dec->error_count = 0; - format_changed = (dec->sample_rate != WavpackGetSampleRate (dec->context)) || (dec->channels != WavpackGetNumChannels (dec->context)) || - (dec->depth != WavpackGetBitsPerSample (dec->context)) || + (dec->depth != WavpackGetBytesPerSample (dec->context) * 8) || #ifdef WAVPACK_OLD_API (dec->channel_mask != dec->context->config.channel_mask); #else (dec->channel_mask != WavpackGetChannelMask (dec->context)); #endif - if (!GST_PAD_CAPS (dec->srcpad) || format_changed) { - GstCaps *caps; + if (!GST_PAD_CAPS (GST_AUDIO_DECODER_SRC_PAD (dec)) || format_changed) { gint channel_mask; dec->sample_rate = WavpackGetSampleRate (dec->context); dec->channels = WavpackGetNumChannels (dec->context); - dec->depth = WavpackGetBitsPerSample (dec->context); - - caps = gst_caps_new_simple ("audio/x-raw-int", - "rate", G_TYPE_INT, dec->sample_rate, - "channels", G_TYPE_INT, dec->channels, - "depth", G_TYPE_INT, dec->depth, - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BYTE_ORDER, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + dec->depth = WavpackGetBytesPerSample (dec->context) * 8; #ifdef WAVPACK_OLD_API channel_mask = dec->context->config.channel_mask; @@ -336,17 +366,7 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) dec->channel_mask = channel_mask; - /* Only set the channel layout for more than two channels - * otherwise things break unfortunately */ - if (channel_mask != 0 && dec->channels > 2) - if (!gst_wavpack_set_channel_layout (caps, channel_mask)) - GST_WARNING_OBJECT (dec, "Failed to set channel layout"); - - GST_DEBUG_OBJECT (dec, "setting caps %" GST_PTR_FORMAT, caps); - - /* should always succeed */ - gst_pad_set_caps (dec->srcpad, caps); - gst_caps_unref (caps); + gst_wavpack_dec_negotiate (dec); /* send GST_TAG_AUDIO_CODEC and GST_TAG_BITRATE tags before something * is decoded or after the format has changed */ @@ -354,59 +374,82 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) } /* alloc output buffer */ - unpacked_size = 4 * wph.block_samples * dec->channels; - ret = gst_pad_alloc_buffer (dec->srcpad, GST_BUFFER_OFFSET (buf), - unpacked_size, GST_PAD_CAPS (dec->srcpad), &outbuf); + unpacked_size = (dec->width / 8) * wph.block_samples * dec->channels; + ret = gst_pad_alloc_buffer (GST_AUDIO_DECODER_SRC_PAD (dec), + GST_BUFFER_OFFSET (buf), unpacked_size, + GST_PAD_CAPS (GST_AUDIO_DECODER_SRC_PAD (dec)), &outbuf); if (ret != GST_FLOW_OK) goto out; - gst_buffer_copy_metadata (outbuf, buf, GST_BUFFER_COPY_TIMESTAMPS); - - /* If we got a DISCONT buffer forward the flag. Nothing else - * has to be done as libwavpack doesn't store state between - * Wavpack blocks */ - if (GST_BUFFER_IS_DISCONT (buf) || dec->next_block_index != wph.block_index) - GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); - - dec->next_block_index = wph.block_index + wph.block_samples; + dec_data = g_malloc (4 * wph.block_samples * dec->channels); + out_data = GST_BUFFER_DATA (outbuf); /* decode */ - decoded = WavpackUnpackSamples (dec->context, - (int32_t *) GST_BUFFER_DATA (outbuf), wph.block_samples); + decoded = WavpackUnpackSamples (dec->context, dec_data, wph.block_samples); if (decoded != wph.block_samples) goto decode_error; - if ((outbuf = gst_audio_buffer_clip (outbuf, &dec->segment, - dec->sample_rate, 4 * dec->channels))) { - GST_LOG_OBJECT (dec, "pushing buffer with time %" GST_TIME_FORMAT, - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf))); - ret = gst_pad_push (dec->srcpad, outbuf); + width = dec->width; + depth = dec->depth; + max = dec->channels * wph.block_samples; + if (width == 8) { + gint8 *outbuffer = (gint8 *) out_data; + + for (i = 0; i < max; i--) { + *outbuffer++ = (gint8) (dec_data[i]); + } + } else if (width == 16) { + gint16 *outbuffer = (gint16 *) out_data; + + for (i = 0; i < max; i++) { + *outbuffer++ = (gint8) (dec_data[i]); + } + } else if (dec->width == 32) { + gint32 *outbuffer = (gint32 *) out_data; + + if (width != depth) { + for (i = 0; i < max; i++) { + *outbuffer++ = (gint32) (dec_data[i] << (width - depth)); + } + } else { + for (i = 0; i < max; i++) { + *outbuffer++ = (gint32) dec_data[i]; + } + } + } else { + g_assert_not_reached (); } + g_free (dec_data); + + ret = gst_audio_decoder_finish_frame (bdec, outbuf, 1); + out: if (G_UNLIKELY (ret != GST_FLOW_OK)) { GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (ret)); } - gst_buffer_unref (buf); - return ret; /* ERRORS */ input_not_framed: { GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("Expected framed input")); - gst_buffer_unref (buf); return GST_FLOW_ERROR; } invalid_header: { GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("Invalid wavpack header")); - gst_buffer_unref (buf); return GST_FLOW_ERROR; } +context_failed: + { + GST_AUDIO_DECODER_ERROR (bdec, 1, LIBRARY, INIT, (NULL), + ("error creating Wavpack context"), ret); + goto out; + } decode_error: { const gchar *reason = "unknown"; @@ -420,86 +463,15 @@ decode_error: } else { reason = "couldn't create decoder context"; } - GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), - ("Failed to decode wavpack stream: %s", reason)); + GST_AUDIO_DECODER_ERROR (bdec, 1, STREAM, DECODE, (NULL), + ("decoding error: %s", reason), ret); + g_free (dec_data); if (outbuf) gst_buffer_unref (outbuf); - gst_buffer_unref (buf); - return GST_FLOW_ERROR; - } -} - -static gboolean -gst_wavpack_dec_sink_event (GstPad * pad, GstEvent * event) -{ - GstWavpackDec *dec = GST_WAVPACK_DEC (gst_pad_get_parent (pad)); - - GST_LOG_OBJECT (dec, "Received %s event", GST_EVENT_TYPE_NAME (event)); - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_NEWSEGMENT:{ - GstFormat fmt; - gboolean is_update; - gint64 start, end, base; - gdouble rate; - - gst_event_parse_new_segment (event, &is_update, &rate, &fmt, &start, - &end, &base); - if (fmt == GST_FORMAT_TIME) { - GST_DEBUG ("Got NEWSEGMENT event in GST_FORMAT_TIME, passing on (%" - GST_TIME_FORMAT " - %" GST_TIME_FORMAT ")", GST_TIME_ARGS (start), - GST_TIME_ARGS (end)); - gst_segment_set_newsegment (&dec->segment, is_update, rate, fmt, - start, end, base); - } else { - gst_segment_init (&dec->segment, GST_FORMAT_TIME); - } - break; - } - default: - break; - } - - gst_object_unref (dec); - return gst_pad_event_default (pad, event); -} - -static GstStateChangeReturn -gst_wavpack_dec_change_state (GstElement * element, GstStateChange transition) -{ - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; - GstWavpackDec *dec = GST_WAVPACK_DEC (element); - - switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: - break; - case GST_STATE_CHANGE_READY_TO_PAUSED: - break; - case GST_STATE_CHANGE_PAUSED_TO_PLAYING: - break; - default: - break; - } - - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); - - switch (transition) { - case GST_STATE_CHANGE_PLAYING_TO_PAUSED: - break; - case GST_STATE_CHANGE_PAUSED_TO_READY: - if (dec->context) { - WavpackCloseFile (dec->context); - dec->context = NULL; - } - - gst_wavpack_dec_reset (dec); - break; - case GST_STATE_CHANGE_READY_TO_NULL: - break; - default: - break; + if (ret == GST_FLOW_OK) + gst_audio_decoder_finish_frame (bdec, NULL, 1); + return ret; } - - return ret; } gboolean diff --git a/ext/wavpack/gstwavpackdec.h b/ext/wavpack/gstwavpackdec.h index eb6e4c3bb..68e8e3385 100644 --- a/ext/wavpack/gstwavpackdec.h +++ b/ext/wavpack/gstwavpackdec.h @@ -24,6 +24,7 @@ #define __GST_WAVPACK_DEC_H__ #include <gst/gst.h> +#include <gst/audio/gstaudiodecoder.h> #include <wavpack/wavpack.h> @@ -45,31 +46,25 @@ typedef struct _GstWavpackDecClass GstWavpackDecClass; struct _GstWavpackDec { - GstElement element; + GstAudioDecoder element; /*< private > */ - GstPad *sinkpad; - GstPad *srcpad; WavpackContext *context; WavpackStreamReader *stream_reader; read_id wv_id; - GstSegment segment; /* used for clipping, TIME format */ - guint32 next_block_index; - gint sample_rate; gint depth; + gint width; gint channels; gint channel_mask; - - gint error_count; }; struct _GstWavpackDecClass { - GstElementClass parent; + GstAudioDecoderClass parent; }; GType gst_wavpack_dec_get_type (void); diff --git a/ext/wavpack/gstwavpackenc.c b/ext/wavpack/gstwavpackenc.c index c871772e7..0d2515fa5 100644 --- a/ext/wavpack/gstwavpackenc.c +++ b/ext/wavpack/gstwavpackenc.c @@ -55,12 +55,18 @@ #include "gstwavpackenc.h" #include "gstwavpackcommon.h" -static GstFlowReturn gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buffer); -static gboolean gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps); +static gboolean gst_wavpack_enc_start (GstAudioEncoder * enc); +static gboolean gst_wavpack_enc_stop (GstAudioEncoder * enc); +static gboolean gst_wavpack_enc_set_format (GstAudioEncoder * enc, + GstAudioInfo * info); +static GstFlowReturn gst_wavpack_enc_handle_frame (GstAudioEncoder * enc, + GstBuffer * in_buf); +static gboolean gst_wavpack_enc_sink_event (GstAudioEncoder * enc, + GstEvent * event); + static int gst_wavpack_enc_push_block (void *id, void *data, int32_t count); -static gboolean gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event); -static GstStateChangeReturn gst_wavpack_enc_change_state (GstElement * element, - GstStateChange transition); +static GstFlowReturn gst_wavpack_enc_drain (GstWavpackEnc * enc); + static void gst_wavpack_enc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_wavpack_enc_get_property (GObject * object, guint prop_id, @@ -86,7 +92,7 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, " "width = (int) 32, " - "depth = (int) [ 1, 32], " + "depth = (int) { 24, 32 }, " "endianness = (int) BYTE_ORDER, " "channels = (int) [ 1, 8 ], " "rate = (int) [ 6000, 192000 ]," "signed = (boolean) TRUE") @@ -97,7 +103,7 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-wavpack, " "width = (int) [ 1, 32 ], " - "channels = (int) [ 1, 2 ], " + "channels = (int) [ 1, 8 ], " "rate = (int) [ 6000, 192000 ], " "framed = (boolean) TRUE") ); @@ -196,21 +202,8 @@ gst_wavpack_enc_joint_stereo_mode_get_type (void) return qtype; } -static void -_do_init (GType object_type) -{ - const GInterfaceInfo preset_interface_info = { - NULL, /* interface_init */ - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - g_type_add_interface_static (object_type, GST_TYPE_PRESET, - &preset_interface_info); -} - -GST_BOILERPLATE_FULL (GstWavpackEnc, gst_wavpack_enc, GstElement, - GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE (GstWavpackEnc, gst_wavpack_enc, GstAudioEncoder, + GST_TYPE_AUDIO_ENCODER); static void gst_wavpack_enc_base_init (gpointer klass) @@ -232,23 +225,24 @@ gst_wavpack_enc_base_init (gpointer klass) "Sebastian Dröge <slomo@circular-chaos.org>"); } - static void gst_wavpack_enc_class_init (GstWavpackEncClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; - GstElementClass *gstelement_class = (GstElementClass *) klass; + GstAudioEncoderClass *base_class = (GstAudioEncoderClass *) (klass); parent_class = g_type_class_peek_parent (klass); - /* set state change handler */ - gstelement_class->change_state = - GST_DEBUG_FUNCPTR (gst_wavpack_enc_change_state); - /* set property handlers */ gobject_class->set_property = gst_wavpack_enc_set_property; gobject_class->get_property = gst_wavpack_enc_get_property; + base_class->start = GST_DEBUG_FUNCPTR (gst_wavpack_enc_start); + base_class->stop = GST_DEBUG_FUNCPTR (gst_wavpack_enc_stop); + base_class->set_format = GST_DEBUG_FUNCPTR (gst_wavpack_enc_set_format); + base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_wavpack_enc_handle_frame); + base_class->event = GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_event); + /* install all properties */ g_object_class_install_property (gobject_class, ARG_MODE, g_param_spec_enum ("mode", "Encoding mode", @@ -306,6 +300,9 @@ gst_wavpack_enc_reset (GstWavpackEnc * enc) g_checksum_free (enc->md5_context); enc->md5_context = NULL; } + if (enc->pending_segment) + gst_event_unref (enc->pending_segment); + enc->pending_segment = NULL; if (enc->pending_buffer) { gst_buffer_unref (enc->pending_buffer); @@ -332,18 +329,7 @@ gst_wavpack_enc_reset (GstWavpackEnc * enc) static void gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass) { - enc->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); - gst_pad_set_setcaps_function (enc->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_set_caps)); - gst_pad_set_chain_function (enc->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_enc_chain)); - gst_pad_set_event_function (enc->sinkpad, - GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_event)); - gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad); - - /* setup src pad */ - enc->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); - gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad); + GstAudioEncoder *benc = GST_AUDIO_ENCODER (enc); /* initialize object attributes */ enc->wp_config = NULL; @@ -367,37 +353,51 @@ gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass) enc->md5 = FALSE; enc->extra_processing = 0; enc->joint_stereo_mode = GST_WAVPACK_JS_MODE_AUTO; + + /* require perfect ts */ + gst_audio_encoder_set_perfect_timestamp (benc, TRUE); +} + + +static gboolean +gst_wavpack_enc_start (GstAudioEncoder * enc) +{ + GST_DEBUG_OBJECT (enc, "start"); + + return TRUE; +} + +static gboolean +gst_wavpack_enc_stop (GstAudioEncoder * enc) +{ + GstWavpackEnc *wpenc = GST_WAVPACK_ENC (enc); + + GST_DEBUG_OBJECT (enc, "stop"); + gst_wavpack_enc_reset (wpenc); + + return TRUE; } static gboolean -gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps) +gst_wavpack_enc_set_format (GstAudioEncoder * benc, GstAudioInfo * info) { - GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad)); - GstStructure *structure = gst_caps_get_structure (caps, 0); + GstWavpackEnc *enc = GST_WAVPACK_ENC (benc); GstAudioChannelPosition *pos; + GstCaps *caps; - if (!gst_structure_get_int (structure, "channels", &enc->channels) || - !gst_structure_get_int (structure, "rate", &enc->samplerate) || - !gst_structure_get_int (structure, "depth", &enc->depth)) { - GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), - ("got invalid caps: %" GST_PTR_FORMAT, caps)); - gst_object_unref (enc); - return FALSE; - } + /* we may be configured again, but that change should have cleanup context */ + g_assert (enc->wp_context == NULL); - pos = gst_audio_get_channel_positions (structure); - /* If one channel is NONE they'll be all undefined */ - if (pos != NULL && pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE) { - g_free (pos); - pos = NULL; - } + enc->channels = GST_AUDIO_INFO_CHANNELS (info); + enc->depth = GST_AUDIO_INFO_DEPTH (info); + enc->samplerate = GST_AUDIO_INFO_RATE (info); - if (pos == NULL) { - GST_ELEMENT_ERROR (enc, STREAM, FORMAT, (NULL), - ("input has no valid channel layout")); + pos = info->position; + g_assert (pos); - gst_object_unref (enc); - return FALSE; + /* If one channel is NONE they'll be all undefined */ + if (pos != NULL && pos[0] == GST_AUDIO_CHANNEL_POSITION_NONE) { + goto invalid_channels; } enc->channel_mask = @@ -405,7 +405,6 @@ gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps) enc->need_channel_remap = gst_wavpack_set_channel_mapping (pos, enc->channels, enc->channel_mapping); - g_free (pos); /* set fixed src pad caps now that we know what we will get */ caps = gst_caps_new_simple ("audio/x-wavpack", @@ -416,18 +415,28 @@ gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps) if (!gst_wavpack_set_channel_layout (caps, enc->channel_mask)) GST_WARNING_OBJECT (enc, "setting channel layout failed"); - if (!gst_pad_set_caps (enc->srcpad, caps)) { - GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), - ("setting caps failed: %" GST_PTR_FORMAT, caps)); - gst_caps_unref (caps); - gst_object_unref (enc); - return FALSE; - } - gst_pad_use_fixed_caps (enc->srcpad); + if (!gst_pad_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), caps)) + goto setting_src_caps_failed; gst_caps_unref (caps); - gst_object_unref (enc); + + /* no special feedback to base class; should provide all available samples */ + return TRUE; + + /* ERRORS */ +setting_src_caps_failed: + { + GST_DEBUG_OBJECT (enc, + "Couldn't set caps on source pad: %" GST_PTR_FORMAT, caps); + gst_caps_unref (caps); + return FALSE; + } +invalid_channels: + { + GST_DEBUG_OBJECT (enc, "input has invalid channel layout"); + return FALSE; + } } static void @@ -549,21 +558,14 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count) GstBuffer *buffer; GstPad *pad; guchar *block = (guchar *) data; + gint samples = 0; - pad = (wid->correction) ? enc->wvcsrcpad : enc->srcpad; + pad = (wid->correction) ? enc->wvcsrcpad : GST_AUDIO_ENCODER_SRC_PAD (enc); flow = (wid->correction) ? &enc->wvcsrcpad_last_return : &enc-> srcpad_last_return; - *flow = gst_pad_alloc_buffer_and_set_caps (pad, GST_BUFFER_OFFSET_NONE, - count, GST_PAD_CAPS (pad), &buffer); - - if (*flow != GST_FLOW_OK) { - GST_WARNING_OBJECT (enc, "flow on %s:%s = %s", - GST_DEBUG_PAD_NAME (pad), gst_flow_get_name (*flow)); - return FALSE; - } - + buffer = gst_buffer_new_and_alloc (count); g_memmove (GST_BUFFER_DATA (buffer), block, count); if (count > sizeof (WavpackHeader) && memcmp (block, "wvpk", 4) == 0) { @@ -599,12 +601,14 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count) enc->pending_buffer = NULL; enc->pending_offset = 0; - /* if it's the first wavpack block, send a NEW_SEGMENT event */ - if (wph.block_index == 0) { - gst_pad_push_event (pad, - gst_event_new_new_segment (FALSE, - 1.0, GST_FORMAT_TIME, 0, GST_BUFFER_OFFSET_NONE, 0)); + /* only send segment on correction pad, + * regular pad is handled normally by baseclass */ + if (wid->correction && enc->pending_segment) { + gst_pad_push_event (pad, enc->pending_segment); + enc->pending_segment = NULL; + } + if (wph.block_index == 0) { /* save header for later reference, so we can re-send it later on * EOS with fixed up values for total sample count etc. */ if (enc->first_block == NULL && !wid->correction) { @@ -614,29 +618,23 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count) } } } - - /* set buffer timestamp, duration, offset, offset_end from - * the wavpack header */ - GST_BUFFER_TIMESTAMP (buffer) = enc->timestamp_offset + - gst_util_uint64_scale_int (GST_SECOND, wph.block_index, - enc->samplerate); - GST_BUFFER_DURATION (buffer) = - gst_util_uint64_scale_int (GST_SECOND, wph.block_samples, - enc->samplerate); - GST_BUFFER_OFFSET (buffer) = wph.block_index; - GST_BUFFER_OFFSET_END (buffer) = wph.block_index + wph.block_samples; + samples = wph.block_samples; } else { /* if it's something else set no timestamp and duration on the buffer */ GST_DEBUG_OBJECT (enc, "got %d bytes of unknown data", count); - - GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; - GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; } - /* push the buffer and forward errors */ - GST_DEBUG_OBJECT (enc, "pushing buffer with %d bytes", - GST_BUFFER_SIZE (buffer)); - *flow = gst_pad_push (pad, buffer); + if (wid->correction || wid->passthrough) { + /* push the buffer and forward errors */ + GST_DEBUG_OBJECT (enc, "pushing buffer with %d bytes", + GST_BUFFER_SIZE (buffer)); + *flow = gst_pad_push (pad, buffer); + } else { + GST_DEBUG_OBJECT (enc, "handing frame of %d bytes", + GST_BUFFER_SIZE (buffer)); + *flow = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), buffer, + samples); + } if (*flow != GST_FLOW_OK) { GST_WARNING_OBJECT (enc, "flow on %s:%s = %s", @@ -666,18 +664,25 @@ gst_wavpack_enc_fix_channel_order (GstWavpackEnc * enc, gint32 * data, } static GstFlowReturn -gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) +gst_wavpack_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf) { - GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad)); - uint32_t sample_count = GST_BUFFER_SIZE (buf) / 4; + GstWavpackEnc *enc = GST_WAVPACK_ENC (benc); + uint32_t sample_count; GstFlowReturn ret; + /* base class ensures configuration */ + g_return_val_if_fail (enc->depth != 0, GST_FLOW_NOT_NEGOTIATED); + /* reset the last returns to GST_FLOW_OK. This is only set to something else * while WavpackPackSamples() or more specific gst_wavpack_enc_push_block() * so not valid anymore */ enc->srcpad_last_return = enc->wvcsrcpad_last_return = GST_FLOW_OK; - GST_DEBUG ("got %u raw samples", sample_count); + if (G_UNLIKELY (!buf)) + return gst_wavpack_enc_drain (enc); + + sample_count = GST_BUFFER_SIZE (buf) / 4; + GST_DEBUG_OBJECT (enc, "got %u raw samples", sample_count); /* check if we already have a valid WavpackContext, otherwise make one */ if (!enc->wp_context) { @@ -685,13 +690,8 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) enc->wp_context = WavpackOpenFileOutput (gst_wavpack_enc_push_block, &enc->wv_id, (enc->correction_mode > 0) ? &enc->wvc_id : NULL); - if (!enc->wp_context) { - GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), - ("error creating Wavpack context")); - gst_object_unref (enc); - gst_buffer_unref (buf); - return GST_FLOW_ERROR; - } + if (!enc->wp_context) + goto context_failed; /* set the WavpackConfig according to our parameters */ gst_wavpack_enc_set_wp_config (enc); @@ -701,76 +701,12 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) if (!WavpackSetConfiguration (enc->wp_context, enc->wp_config, (uint32_t) (-1)) || !WavpackPackInit (enc->wp_context)) { - GST_ELEMENT_ERROR (enc, LIBRARY, SETTINGS, (NULL), - ("error setting up wavpack encoding context")); WavpackCloseFile (enc->wp_context); - gst_object_unref (enc); - gst_buffer_unref (buf); - return GST_FLOW_ERROR; + goto config_failed; } - GST_DEBUG ("setup of encoding context successfull"); + GST_DEBUG_OBJECT (enc, "setup of encoding context successfull"); } - /* Save the timestamp of the first buffer. This will be later - * used as offset for all following buffers */ - if (enc->timestamp_offset == GST_CLOCK_TIME_NONE) { - if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - enc->timestamp_offset = GST_BUFFER_TIMESTAMP (buf); - enc->next_ts = GST_BUFFER_TIMESTAMP (buf); - } else { - enc->timestamp_offset = 0; - enc->next_ts = 0; - } - } - - /* Check if we have a continous stream, if not drop some samples or the buffer or - * insert some silence samples */ - if (enc->next_ts != GST_CLOCK_TIME_NONE && - GST_BUFFER_TIMESTAMP (buf) < enc->next_ts) { - guint64 diff = enc->next_ts - GST_BUFFER_TIMESTAMP (buf); - guint64 diff_bytes; - - GST_WARNING_OBJECT (enc, "Buffer is older than previous " - "timestamp + duration (%" GST_TIME_FORMAT "< %" GST_TIME_FORMAT - "), cannot handle. Clipping buffer.", - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), - GST_TIME_ARGS (enc->next_ts)); - - diff_bytes = - GST_CLOCK_TIME_TO_FRAMES (diff, enc->samplerate) * enc->channels * 2; - if (diff_bytes >= GST_BUFFER_SIZE (buf)) { - gst_buffer_unref (buf); - return GST_FLOW_OK; - } - buf = gst_buffer_make_metadata_writable (buf); - GST_BUFFER_DATA (buf) += diff_bytes; - GST_BUFFER_SIZE (buf) -= diff_bytes; - - GST_BUFFER_TIMESTAMP (buf) += diff; - if (GST_BUFFER_DURATION_IS_VALID (buf)) - GST_BUFFER_DURATION (buf) -= diff; - } - - /* Allow a diff of at most 5 ms */ - if (enc->next_ts != GST_CLOCK_TIME_NONE - && GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { - if (GST_BUFFER_TIMESTAMP (buf) != enc->next_ts && - GST_BUFFER_TIMESTAMP (buf) - enc->next_ts > 5 * GST_MSECOND) { - GST_WARNING_OBJECT (enc, - "Discontinuity detected: %" G_GUINT64_FORMAT " > %" G_GUINT64_FORMAT, - GST_BUFFER_TIMESTAMP (buf) - enc->next_ts, 5 * GST_MSECOND); - - WavpackFlushSamples (enc->wp_context); - enc->timestamp_offset += (GST_BUFFER_TIMESTAMP (buf) - enc->next_ts); - } - } - - if (GST_BUFFER_TIMESTAMP_IS_VALID (buf) - && GST_BUFFER_DURATION_IS_VALID (buf)) - enc->next_ts = GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf); - else - enc->next_ts = GST_CLOCK_TIME_NONE; - if (enc->need_channel_remap) { buf = gst_buffer_make_writable (buf); gst_wavpack_enc_fix_channel_order (enc, (gint32 *) GST_BUFFER_DATA (buf), @@ -787,7 +723,7 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) /* encode and handle return values from encoding */ if (WavpackPackSamples (enc->wp_context, (int32_t *) GST_BUFFER_DATA (buf), sample_count / enc->channels)) { - GST_DEBUG ("encoding samples successful"); + GST_DEBUG_OBJECT (enc, "encoding samples successful"); ret = GST_FLOW_OK; } else { if ((enc->srcpad_last_return == GST_FLOW_RESEND) || @@ -803,15 +739,35 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) (enc->wvcsrcpad_last_return == GST_FLOW_FLUSHING)) { ret = GST_FLOW_FLUSHING; } else { - GST_ELEMENT_ERROR (enc, LIBRARY, ENCODE, (NULL), - ("encoding samples failed")); - ret = GST_FLOW_ERROR; + goto encoding_failed; } } - gst_buffer_unref (buf); - gst_object_unref (enc); +exit: return ret; + + /* ERRORS */ +encoding_failed: + { + GST_ELEMENT_ERROR (enc, LIBRARY, ENCODE, (NULL), + ("encoding samples failed")); + ret = GST_FLOW_ERROR; + goto exit; + } +config_failed: + { + GST_ELEMENT_ERROR (enc, LIBRARY, SETTINGS, (NULL), + ("error setting up wavpack encoding context")); + ret = GST_FLOW_ERROR; + goto exit; + } +context_failed: + { + GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), + ("error creating Wavpack context")); + ret = GST_FLOW_ERROR; + goto exit; + } } static void @@ -828,7 +784,7 @@ gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * enc) WavpackUpdateNumSamples (enc->wp_context, enc->first_block); /* try to seek to the beginning of the output */ - ret = gst_pad_push_event (enc->srcpad, event); + ret = gst_pad_push_event (GST_AUDIO_ENCODER_SRC_PAD (enc), event); if (ret) { /* try to rewrite the first block */ GST_DEBUG_OBJECT (enc, "rewriting first block ..."); @@ -836,111 +792,84 @@ gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * enc) ret = gst_wavpack_enc_push_block (&enc->wv_id, enc->first_block, enc->first_block_size); enc->wv_id.passthrough = FALSE; + g_free (enc->first_block); + enc->first_block = NULL; } else { GST_WARNING_OBJECT (enc, "rewriting of first block failed. " "Seeking to first block failed!"); } } -static gboolean -gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event) +static GstFlowReturn +gst_wavpack_enc_drain (GstWavpackEnc * enc) { - GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad)); - gboolean ret = TRUE; + if (!enc->wp_context) + return GST_FLOW_OK; - GST_DEBUG ("Received %s event on sinkpad", GST_EVENT_TYPE_NAME (event)); + GST_DEBUG_OBJECT (enc, "draining"); - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS: - /* Encode all remaining samples and flush them to the src pads */ - WavpackFlushSamples (enc->wp_context); - - /* Drop all remaining data, this is no complete block otherwise - * it would've been pushed already */ - if (enc->pending_buffer) { - gst_buffer_unref (enc->pending_buffer); - enc->pending_buffer = NULL; - enc->pending_offset = 0; - } + /* Encode all remaining samples and flush them to the src pads */ + WavpackFlushSamples (enc->wp_context); - /* write the MD5 sum if we have to write one */ - if ((enc->md5) && (enc->md5_context)) { - guint8 md5_digest[16]; - gsize digest_len = sizeof (md5_digest); + /* Drop all remaining data, this is no complete block otherwise + * it would've been pushed already */ + if (enc->pending_buffer) { + gst_buffer_unref (enc->pending_buffer); + enc->pending_buffer = NULL; + enc->pending_offset = 0; + } - g_checksum_get_digest (enc->md5_context, md5_digest, &digest_len); - if (digest_len == sizeof (md5_digest)) - WavpackStoreMD5Sum (enc->wp_context, md5_digest); - else - GST_WARNING_OBJECT (enc, "Calculating MD5 digest failed"); - } + /* write the MD5 sum if we have to write one */ + if ((enc->md5) && (enc->md5_context)) { + guint8 md5_digest[16]; + gsize digest_len = sizeof (md5_digest); - /* Try to rewrite the first frame with the correct sample number */ - if (enc->first_block) - gst_wavpack_enc_rewrite_first_block (enc); + g_checksum_get_digest (enc->md5_context, md5_digest, &digest_len); + if (digest_len == sizeof (md5_digest)) { + WavpackStoreMD5Sum (enc->wp_context, md5_digest); + WavpackFlushSamples (enc->wp_context); + } else + GST_WARNING_OBJECT (enc, "Calculating MD5 digest failed"); + } - /* close the context if not already happened */ - if (enc->wp_context) { - WavpackCloseFile (enc->wp_context); - enc->wp_context = NULL; - } + /* Try to rewrite the first frame with the correct sample number */ + if (enc->first_block) + gst_wavpack_enc_rewrite_first_block (enc); - ret = gst_pad_event_default (pad, event); - break; - case GST_EVENT_NEWSEGMENT: - if (enc->wp_context) { - GST_WARNING_OBJECT (enc, "got NEWSEGMENT after encoding " - "already started"); - } - /* drop NEWSEGMENT events, we create our own when pushing - * the first buffer to the pads */ - gst_event_unref (event); - ret = TRUE; - break; - default: - ret = gst_pad_event_default (pad, event); - break; + /* close the context if not already happened */ + if (enc->wp_context) { + WavpackCloseFile (enc->wp_context); + enc->wp_context = NULL; } - gst_object_unref (enc); - return ret; + return GST_FLOW_OK; } -static GstStateChangeReturn -gst_wavpack_enc_change_state (GstElement * element, GstStateChange transition) +static gboolean +gst_wavpack_enc_sink_event (GstAudioEncoder * benc, GstEvent * event) { - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; - GstWavpackEnc *enc = GST_WAVPACK_ENC (element); - - switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: - /* set the last returned GstFlowReturns of the two pads to GST_FLOW_OK - * as they're only set to something else in WavpackPackSamples() or more - * specific gst_wavpack_enc_push_block() and nothing happened there yet */ - enc->srcpad_last_return = enc->wvcsrcpad_last_return = GST_FLOW_OK; - break; - case GST_STATE_CHANGE_READY_TO_PAUSED: - break; - case GST_STATE_CHANGE_PAUSED_TO_PLAYING: - default: - break; - } + GstWavpackEnc *enc = GST_WAVPACK_ENC (benc); - ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + GST_DEBUG_OBJECT (enc, "Received %s event on sinkpad", + GST_EVENT_TYPE_NAME (event)); - switch (transition) { - case GST_STATE_CHANGE_PLAYING_TO_PAUSED: - break; - case GST_STATE_CHANGE_PAUSED_TO_READY: - gst_wavpack_enc_reset (enc); - break; - case GST_STATE_CHANGE_READY_TO_NULL: + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_NEWSEGMENT: + if (enc->wp_context) { + GST_WARNING_OBJECT (enc, "got NEWSEGMENT after encoding " + "already started"); + } + /* peek and hold NEWSEGMENT events for sending on correction pad */ + if (enc->pending_segment) + gst_event_unref (enc->pending_segment); + enc->pending_segment = gst_event_ref (event); break; default: break; } - return ret; + /* baseclass handles rest */ + return FALSE; } static void diff --git a/ext/wavpack/gstwavpackenc.h b/ext/wavpack/gstwavpackenc.h index d2df844e5..aab4296fb 100644 --- a/ext/wavpack/gstwavpackenc.h +++ b/ext/wavpack/gstwavpackenc.h @@ -23,6 +23,7 @@ #define __GST_WAVPACK_ENC_H__ #include <gst/gst.h> +#include <gst/audio/gstaudioencoder.h> #include <wavpack/wavpack.h> @@ -50,10 +51,9 @@ typedef struct struct _GstWavpackEnc { - GstElement element; + GstAudioEncoder element; /*< private > */ - GstPad *sinkpad, *srcpad; GstPad *wvcsrcpad; GstFlowReturn srcpad_last_return; @@ -86,6 +86,7 @@ struct _GstWavpackEnc GstBuffer *pending_buffer; gint32 pending_offset; + GstEvent *pending_segment; GstClockTime timestamp_offset; GstClockTime next_ts; @@ -93,7 +94,7 @@ struct _GstWavpackEnc struct _GstWavpackEncClass { - GstElementClass parent; + GstAudioEncoderClass parent; }; GType gst_wavpack_enc_get_type (void); diff --git a/gst/audiofx/audiofirfilter.c b/gst/audiofx/audiofirfilter.c index 100df0ce0..8b2f72301 100644 --- a/gst/audiofx/audiofirfilter.c +++ b/gst/audiofx/audiofirfilter.c @@ -45,6 +45,10 @@ * </refsect2> */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/gst/audiofx/audioiirfilter.c b/gst/audiofx/audioiirfilter.c index 5907a161d..86a428ad8 100644 --- a/gst/audiofx/audioiirfilter.c +++ b/gst/audiofx/audioiirfilter.c @@ -41,6 +41,10 @@ * </refsect2> */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/gst/audioparsers/Makefile.am b/gst/audioparsers/Makefile.am index 22bc81fa0..4d4d53ed2 100644 --- a/gst/audioparsers/Makefile.am +++ b/gst/audioparsers/Makefile.am @@ -3,7 +3,7 @@ plugin_LTLIBRARIES = libgstaudioparsers.la libgstaudioparsers_la_SOURCES = \ gstaacparse.c gstamrparse.c gstac3parse.c \ gstdcaparse.c gstflacparse.c gstmpegaudioparse.c \ - plugin.c + gstwavpackparse.c plugin.c libgstaudioparsers_la_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) @@ -15,4 +15,4 @@ libgstaudioparsers_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstaudioparsers_la_LIBTOOLFLAGS = --tag=disable-static noinst_HEADERS = gstaacparse.h gstamrparse.h gstac3parse.h \ - gstdcaparse.h gstflacparse.h gstmpegaudioparse.h + gstdcaparse.h gstflacparse.h gstmpegaudioparse.h gstwavpackparse.h diff --git a/gst/audioparsers/gstwavpackparse.c b/gst/audioparsers/gstwavpackparse.c new file mode 100644 index 000000000..61b0eb46b --- /dev/null +++ b/gst/audioparsers/gstwavpackparse.c @@ -0,0 +1,648 @@ +/* GStreamer Wavpack parser + * Copyright (C) 2012 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> + * Copyright (C) 2012 Nokia Corporation. All rights reserved. + * Contact: Stefan Kost <stefan.kost@nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +/** + * SECTION:element-wavpackparse + * @short_description: Wavpack parser + * @see_also: #GstAmrParse, #GstAACParse + * + * This is an Wavpack parser. + * + * <refsect2> + * <title>Example launch line</title> + * |[ + * gst-launch filesrc location=abc.wavpack ! wavpackparse ! wavpackdec ! audioresample ! audioconvert ! autoaudiosink + * ]| + * </refsect2> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> + +#include "gstwavpackparse.h" + +#include <gst/base/gstbytereader.h> +#include <gst/audio/multichannel.h> + +GST_DEBUG_CATEGORY_STATIC (wavpack_parse_debug); +#define GST_CAT_DEFAULT wavpack_parse_debug + +static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-wavpack, " + "width = (int) [ 1, 32 ], " + "channels = (int) [ 1, 8 ], " + "rate = (int) [ 6000, 192000 ], " "framed = (boolean) TRUE; " + "audio/x-wavpack-correction, " "framed = (boolean) TRUE") + ); + +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-wavpack")); + +static void gst_wavpack_parse_finalize (GObject * object); + +static gboolean gst_wavpack_parse_start (GstBaseParse * parse); +static gboolean gst_wavpack_parse_stop (GstBaseParse * parse); +static gboolean gst_wavpack_parse_check_valid_frame (GstBaseParse * parse, + GstBaseParseFrame * frame, guint * size, gint * skipsize); +static GstFlowReturn gst_wavpack_parse_parse_frame (GstBaseParse * parse, + GstBaseParseFrame * frame); +static GstCaps *gst_wavpack_parse_get_sink_caps (GstBaseParse * parse); + +/* FIXME remove when all properly renamed */ +typedef GstWavpackParse GstWavpackParse2; +typedef GstWavpackParseClass GstWavpackParse2Class; + +GST_BOILERPLATE (GstWavpackParse2, gst_wavpack_parse, GstBaseParse, + GST_TYPE_BASE_PARSE); + +static void +gst_wavpack_parse_base_init (gpointer klass) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (klass); + + gst_element_class_add_static_pad_template (element_class, &sink_template); + gst_element_class_add_static_pad_template (element_class, &src_template); + + gst_element_class_set_details_simple (element_class, + "Wavpack audio stream parser", "Codec/Parser/Audio", + "Wavpack parser", "Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>"); +} + +static void +gst_wavpack_parse_class_init (GstWavpackParseClass * klass) +{ + GstBaseParseClass *parse_class = GST_BASE_PARSE_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + GST_DEBUG_CATEGORY_INIT (wavpack_parse_debug, "wavpackparse", 0, + "Wavpack audio stream parser"); + + object_class->finalize = gst_wavpack_parse_finalize; + + parse_class->start = GST_DEBUG_FUNCPTR (gst_wavpack_parse_start); + parse_class->stop = GST_DEBUG_FUNCPTR (gst_wavpack_parse_stop); + parse_class->check_valid_frame = + GST_DEBUG_FUNCPTR (gst_wavpack_parse_check_valid_frame); + parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_wavpack_parse_parse_frame); + parse_class->get_sink_caps = + GST_DEBUG_FUNCPTR (gst_wavpack_parse_get_sink_caps); +} + +static void +gst_wavpack_parse_reset (GstWavpackParse * wvparse) +{ + wvparse->channels = -1; + wvparse->channel_mask = 0; + wvparse->sample_rate = -1; + wvparse->width = -1; + wvparse->total_samples = 0; +} + +static void +gst_wavpack_parse_init (GstWavpackParse * wvparse, GstWavpackParseClass * klass) +{ + gst_wavpack_parse_reset (wvparse); +} + +static void +gst_wavpack_parse_finalize (GObject * object) +{ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static gboolean +gst_wavpack_parse_start (GstBaseParse * parse) +{ + GstWavpackParse *wvparse = GST_WAVPACK_PARSE (parse); + + GST_DEBUG_OBJECT (parse, "starting"); + + gst_wavpack_parse_reset (wvparse); + + /* need header at least */ + gst_base_parse_set_min_frame_size (GST_BASE_PARSE (wvparse), + sizeof (WavpackHeader)); + + /* inform baseclass we can come up with ts, based on counters in packets */ + gst_base_parse_set_has_timing_info (GST_BASE_PARSE_CAST (wvparse), TRUE); + gst_base_parse_set_syncable (GST_BASE_PARSE_CAST (wvparse), TRUE); + + return TRUE; +} + +static gboolean +gst_wavpack_parse_stop (GstBaseParse * parse) +{ + GST_DEBUG_OBJECT (parse, "stopping"); + + return TRUE; +} + +static gint +gst_wavpack_get_default_channel_mask (gint nchannels) +{ + gint channel_mask = 0; + + /* Set the default channel mask for the given number of channels. + * It's the same as for WAVE_FORMAT_EXTENDED: + * http://www.microsoft.com/whdc/device/audio/multichaud.mspx + */ + switch (nchannels) { + case 11: + channel_mask |= 0x00400; + channel_mask |= 0x00200; + case 9: + channel_mask |= 0x00100; + case 8: + channel_mask |= 0x00080; + channel_mask |= 0x00040; + case 6: + channel_mask |= 0x00020; + channel_mask |= 0x00010; + case 4: + channel_mask |= 0x00008; + case 3: + channel_mask |= 0x00004; + case 2: + channel_mask |= 0x00002; + channel_mask |= 0x00001; + break; + case 1: + /* For mono use front center */ + channel_mask |= 0x00004; + break; + } + + return channel_mask; +} + +static const struct +{ + const guint32 ms_mask; + const GstAudioChannelPosition gst_pos; +} layout_mapping[] = { + { + 0x00001, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT}, { + 0x00002, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}, { + 0x00004, GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER}, { + 0x00008, GST_AUDIO_CHANNEL_POSITION_LFE}, { + 0x00010, GST_AUDIO_CHANNEL_POSITION_REAR_LEFT}, { + 0x00020, GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}, { + 0x00040, GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER}, { + 0x00080, GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER}, { + 0x00100, GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}, { + 0x00200, GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT}, { + 0x00400, GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}, { + 0x00800, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_CENTER */ + { + 0x01000, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_FRONT_LEFT */ + { + 0x02000, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_FRONT_CENTER */ + { + 0x04000, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_FRONT_RIGHT */ + { + 0x08000, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_BACK_LEFT */ + { + 0x10000, GST_AUDIO_CHANNEL_POSITION_INVALID}, /* TOP_BACK_CENTER */ + { + 0x20000, GST_AUDIO_CHANNEL_POSITION_INVALID} /* TOP_BACK_RIGHT */ +}; + +#define MAX_CHANNEL_POSITIONS G_N_ELEMENTS (layout_mapping) + +static gboolean +gst_wavpack_set_channel_layout (GstCaps * caps, gint layout) +{ + GstAudioChannelPosition pos[MAX_CHANNEL_POSITIONS]; + GstStructure *s; + gint num_channels, i, p; + + s = gst_caps_get_structure (caps, 0); + if (!gst_structure_get_int (s, "channels", &num_channels)) + g_return_val_if_reached (FALSE); + + if (num_channels == 1 && layout == 0x00004) { + pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_MONO; + gst_audio_set_channel_positions (s, pos); + return TRUE; + } + + p = 0; + for (i = 0; i < MAX_CHANNEL_POSITIONS; ++i) { + if ((layout & layout_mapping[i].ms_mask) != 0) { + if (p >= num_channels) { + GST_WARNING ("More bits set in the channel layout map than there " + "are channels! Broken file"); + return FALSE; + } + if (layout_mapping[i].gst_pos == GST_AUDIO_CHANNEL_POSITION_INVALID) { + GST_WARNING ("Unsupported channel position (mask 0x%08x) in channel " + "layout map - ignoring those channels", layout_mapping[i].ms_mask); + /* what to do? just ignore it and let downstream deal with a channel + * layout that has INVALID positions in it for now ... */ + } + pos[p] = layout_mapping[i].gst_pos; + ++p; + } + } + + if (p != num_channels) { + GST_WARNING ("Only %d bits set in the channel layout map, but there are " + "supposed to be %d channels! Broken file", p, num_channels); + return FALSE; + } + + gst_audio_set_channel_positions (s, pos); + return TRUE; +} + +static const guint32 sample_rates[] = { + 6000, 8000, 9600, 11025, 12000, 16000, 22050, + 24000, 32000, 44100, 48000, 64000, 88200, 96000, 192000 +}; + +#define CHECK(call) { \ + if (!call) \ + goto read_failed; \ +} + +/* caller ensures properly sync'ed with enough data */ +static gboolean +gst_wavpack_parse_frame_metadata (GstWavpackParse * parse, GstBuffer * buf, + gint skip, WavpackHeader * wph, WavpackInfo * wpi) +{ + GstByteReader br; + gint i; + + g_return_val_if_fail (wph != NULL || wpi != NULL, FALSE); + g_return_val_if_fail (GST_BUFFER_SIZE (buf) >= skip + sizeof (WavpackHeader), + FALSE); + + gst_byte_reader_init (&br, GST_BUFFER_DATA (buf) + skip, wph->ckSize + 8); + /* skip past header */ + gst_byte_reader_skip_unchecked (&br, sizeof (WavpackHeader)); + + /* get some basics from header */ + i = (wph->flags >> 23) & 0xF; + if (!wpi->rate) + wpi->rate = (i < G_N_ELEMENTS (sample_rates)) ? sample_rates[i] : 44100; + wpi->width = ((wph->flags & 0x3) + 1) * 8; + if (!wpi->channels) + wpi->channels = (wph->flags & 0x4) ? 1 : 2; + if (!wpi->channel_mask) + wpi->channel_mask = 5 - wpi->channels; + + /* need to dig metadata blocks for some more */ + while (gst_byte_reader_get_remaining (&br)) { + gint size = 0; + guint16 size2 = 0; + guint8 c, id; + const guint8 *data; + GstByteReader mbr; + + CHECK (gst_byte_reader_get_uint8 (&br, &id)); + CHECK (gst_byte_reader_get_uint8 (&br, &c)); + if (id & ID_LARGE) + CHECK (gst_byte_reader_get_uint16_le (&br, &size2)); + size = size2; + size <<= 8; + size += c; + size <<= 1; + if (id & ID_ODD_SIZE) + size--; + + CHECK (gst_byte_reader_get_data (&br, size + (size & 1), &data)); + gst_byte_reader_init (&mbr, data, size); + + switch (id) { + case ID_WVC_BITSTREAM: + GST_LOG_OBJECT (parse, "correction bitstream"); + wpi->correction = TRUE; + break; + case ID_WV_BITSTREAM: + case ID_WVX_BITSTREAM: + break; + case ID_SAMPLE_RATE: + if (size == 3) { + CHECK (gst_byte_reader_get_uint24_le (&mbr, &wpi->rate)); + GST_LOG_OBJECT (parse, "updated with custom rate %d", wpi->rate); + } else { + GST_DEBUG_OBJECT (parse, "unexpected size for SAMPLE_RATE metadata"); + } + break; + case ID_CHANNEL_INFO: + { + guint16 channels; + guint32 mask = 0; + + if (size == 6) { + CHECK (gst_byte_reader_get_uint16_le (&mbr, &channels)); + channels = channels & 0xFFF; + CHECK (gst_byte_reader_get_uint24_le (&mbr, &mask)); + } else if (size) { + CHECK (gst_byte_reader_get_uint8 (&mbr, &c)); + channels = c; + while (gst_byte_reader_get_uint8 (&mbr, &c)) + mask |= (((guint32) c) << 8); + } else { + GST_DEBUG_OBJECT (parse, "unexpected size for CHANNEL_INFO metadata"); + break; + } + wpi->channels = channels; + wpi->channel_mask = mask; + break; + } + default: + GST_LOG_OBJECT (parse, "unparsed ID 0x%x", id); + break; + } + } + + return TRUE; + + /* ERRORS */ +read_failed: + { + GST_DEBUG_OBJECT (parse, "short read while parsing metadata"); + /* let's look the other way anyway */ + return TRUE; + } +} + +/* caller ensures properly sync'ed with enough data */ +static gboolean +gst_wavpack_parse_frame_header (GstWavpackParse * parse, GstBuffer * buf, + gint skip, WavpackHeader * _wph) +{ + GstByteReader br = GST_BYTE_READER_INIT_FROM_BUFFER (buf); + WavpackHeader wph; + + g_return_val_if_fail (GST_BUFFER_SIZE (buf) >= skip + sizeof (WavpackHeader), + FALSE); + + /* marker */ + gst_byte_reader_skip_unchecked (&br, skip + 4); + + /* read */ + gst_byte_reader_get_uint32_le (&br, &wph.ckSize); + gst_byte_reader_get_uint16_le (&br, &wph.version); + gst_byte_reader_get_uint8 (&br, &wph.track_no); + gst_byte_reader_get_uint8 (&br, &wph.index_no); + gst_byte_reader_get_uint32_le (&br, &wph.total_samples); + gst_byte_reader_get_uint32_le (&br, &wph.block_index); + gst_byte_reader_get_uint32_le (&br, &wph.block_samples); + gst_byte_reader_get_uint32_le (&br, &wph.flags); + gst_byte_reader_get_uint32_le (&br, &wph.crc); + + /* dump */ + GST_LOG_OBJECT (parse, "size %d", wph.ckSize); + GST_LOG_OBJECT (parse, "version 0x%x", wph.version); + GST_LOG_OBJECT (parse, "total samples %d", wph.total_samples); + GST_LOG_OBJECT (parse, "block index %d", wph.block_index); + GST_LOG_OBJECT (parse, "block samples %d", wph.block_samples); + GST_LOG_OBJECT (parse, "flags 0x%x", wph.flags); + GST_LOG_OBJECT (parse, "crc 0x%x", wph.flags); + + if (!parse->total_samples && wph.block_index == 0 && wph.total_samples != -1) { + GST_DEBUG_OBJECT (parse, "determined duration of %u samples", + wph.total_samples); + parse->total_samples = wph.total_samples; + } + + if (_wph) + *_wph = wph; + + return TRUE; +} + +static gboolean +gst_wavpack_parse_check_valid_frame (GstBaseParse * parse, + GstBaseParseFrame * frame, guint * framesize, gint * skipsize) +{ + GstWavpackParse *wvparse = GST_WAVPACK_PARSE (parse); + GstBuffer *buf = frame->buffer; + GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf); + gint off; + gboolean lost_sync, draining, final; + guint frmsize = 0; + WavpackHeader wph; + WavpackInfo wpi = { 0, }; + + if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < sizeof (WavpackHeader))) + return FALSE; + + /* scan for 'wvpk' marker */ + off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffffffff, 0x7776706b, + 0, GST_BUFFER_SIZE (buf)); + + GST_LOG_OBJECT (parse, "possible sync at buffer offset %d", off); + + /* didn't find anything that looks like a sync word, skip */ + if (off < 0) { + *skipsize = GST_BUFFER_SIZE (buf) - 3; + goto skip; + } + + /* possible frame header, but not at offset 0? skip bytes before sync */ + if (off > 0) { + *skipsize = off; + goto skip; + } + + /* make sure the values in the frame header look sane */ + gst_wavpack_parse_frame_header (wvparse, buf, 0, &wph); + frmsize = wph.ckSize + 8; + + /* need the entire frame for parsing */ + if (gst_byte_reader_get_remaining (&reader) < frmsize) + goto more; + + /* got a frame, now we can dig for some more metadata */ + GST_LOG_OBJECT (parse, "got frame"); + gst_wavpack_parse_frame_metadata (wvparse, buf, 0, &wph, &wpi); + + lost_sync = GST_BASE_PARSE_LOST_SYNC (parse); + draining = GST_BASE_PARSE_DRAINING (parse); + + while (!(final = (wph.flags & FLAG_FINAL_BLOCK)) || (lost_sync && !draining)) { + guint32 word = 0; + + GST_LOG_OBJECT (wvparse, "checking next frame syncword; " + "lost_sync: %d, draining: %d, final: %d", lost_sync, draining, final); + + if (!gst_byte_reader_skip (&reader, wph.ckSize + 8) || + !gst_byte_reader_peek_uint32_be (&reader, &word)) { + GST_DEBUG_OBJECT (wvparse, "... but not sufficient data"); + frmsize += 4; + goto more; + } else { + if (word != 0x7776706b) { + GST_DEBUG_OBJECT (wvparse, "0x%x not OK", word); + *skipsize = off + 2; + goto skip; + } + /* need to parse each frame/block for metadata if several ones */ + if (!final) { + gint av; + + GST_LOG_OBJECT (wvparse, "checking frame at offset %d (0x%x)", + frmsize, frmsize); + av = gst_byte_reader_get_remaining (&reader); + if (av < sizeof (WavpackHeader)) { + frmsize += sizeof (WavpackHeader); + goto more; + } + gst_wavpack_parse_frame_header (wvparse, buf, frmsize, &wph); + off = frmsize; + frmsize += wph.ckSize + 8; + if (av < wph.ckSize + 8) + goto more; + gst_wavpack_parse_frame_metadata (wvparse, buf, off, &wph, &wpi); + /* could also check for matching block_index and block_samples ?? */ + } + } + + /* resynced if we make it here */ + lost_sync = FALSE; + } + + /* found frame (up to final), record gathered metadata */ + wvparse->wpi = wpi; + wvparse->wph = wph; + + *framesize = frmsize; + gst_base_parse_set_min_frame_size (parse, sizeof (WavpackHeader)); + + return TRUE; + +skip: + GST_LOG_OBJECT (wvparse, "skipping %d", *skipsize); + return FALSE; + +more: + GST_LOG_OBJECT (wvparse, "need at least %u", frmsize); + gst_base_parse_set_min_frame_size (parse, frmsize); + *skipsize = 0; + return FALSE; +} + +static GstFlowReturn +gst_wavpack_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame) +{ + GstWavpackParse *wvparse = GST_WAVPACK_PARSE (parse); + GstBuffer *buf = frame->buffer; + guint rate, chans, width, mask; + + /* re-use previously parsed data */ + rate = wvparse->wpi.rate; + width = wvparse->wpi.width; + chans = wvparse->wpi.channels; + mask = wvparse->wpi.channel_mask; + + GST_LOG_OBJECT (parse, "rate: %u, width: %u, chans: %u", rate, width, chans); + + GST_BUFFER_TIMESTAMP (buf) = + gst_util_uint64_scale_int (wvparse->wph.block_index, GST_SECOND, rate); + GST_BUFFER_DURATION (buf) = + gst_util_uint64_scale_int (wvparse->wph.block_index + + wvparse->wph.block_samples, GST_SECOND, rate) - + GST_BUFFER_TIMESTAMP (buf); + + if (G_UNLIKELY (wvparse->sample_rate != rate || wvparse->channels != chans + || wvparse->width != width || wvparse->channel_mask != mask)) { + GstCaps *caps; + + if (wvparse->wpi.correction) { + caps = gst_caps_new_simple ("audio/x-wavpack-correction", + "framed", G_TYPE_BOOLEAN, TRUE, NULL); + } else { + caps = gst_caps_new_simple ("audio/x-wavpack", + "channels", G_TYPE_INT, chans, + "rate", G_TYPE_INT, rate, + "width", G_TYPE_INT, width, "framed", G_TYPE_BOOLEAN, TRUE, NULL); + + if (!mask) + mask = gst_wavpack_get_default_channel_mask (wvparse->channels); + if (mask != 0) { + if (!gst_wavpack_set_channel_layout (caps, mask)) { + GST_WARNING_OBJECT (wvparse, "Failed to set channel layout"); + } + } + } + + gst_buffer_set_caps (buf, caps); + gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps); + gst_caps_unref (caps); + + wvparse->sample_rate = rate; + wvparse->channels = chans; + wvparse->width = width; + wvparse->channel_mask = mask; + + if (wvparse->total_samples) { + GST_DEBUG_OBJECT (wvparse, "setting duration"); + gst_base_parse_set_duration (GST_BASE_PARSE (wvparse), + GST_FORMAT_TIME, gst_util_uint64_scale_int (wvparse->total_samples, + GST_SECOND, wvparse->sample_rate), 0); + } + } + + return GST_FLOW_OK; +} + +static GstCaps * +gst_wavpack_parse_get_sink_caps (GstBaseParse * parse) +{ + GstCaps *peercaps; + GstCaps *res; + + peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { + guint i, n; + + /* Remove the framed field */ + peercaps = gst_caps_make_writable (peercaps); + n = gst_caps_get_size (peercaps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (peercaps, i); + + gst_structure_remove_field (s, "framed"); + } + + res = + gst_caps_intersect_full (peercaps, + gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse)), + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (peercaps); + } else { + res = + gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD + (parse))); + } + + return res; +} diff --git a/gst/audioparsers/gstwavpackparse.h b/gst/audioparsers/gstwavpackparse.h new file mode 100644 index 000000000..7fc246eea --- /dev/null +++ b/gst/audioparsers/gstwavpackparse.h @@ -0,0 +1,134 @@ +/* GStreamer Wavpack parser + * Copyright (C) 2012 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> + * Copyright (C) 2012 Nokia Corporation. All rights reserved. + * Contact: Stefan Kost <stefan.kost@nokia.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_WAVPACK_PARSE_H__ +#define __GST_WAVPACK_PARSE_H__ + +#include <gst/gst.h> +#include <gst/base/gstbaseparse.h> + +G_BEGIN_DECLS + +#define GST_TYPE_WAVPACK_PARSE \ + (gst_wavpack_parse_get_type()) +#define GST_WAVPACK_PARSE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_WAVPACK_PARSE, GstWavpackParse)) +#define GST_WAVPACK_PARSE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_WAVPACK_PARSE, GstWavpackParseClass)) +#define GST_IS_WAVPACK_PARSE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_WAVPACK_PARSE)) +#define GST_IS_WAVPACK_PARSE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_WAVPACK_PARSE)) + + +#define ID_UNIQUE 0x3f +#define ID_OPTIONAL_DATA 0x20 +#define ID_ODD_SIZE 0x40 +#define ID_LARGE 0x80 + +#define ID_DUMMY 0x0 +#define ID_ENCODER_INFO 0x1 +#define ID_DECORR_TERMS 0x2 +#define ID_DECORR_WEIGHTS 0x3 +#define ID_DECORR_SAMPLES 0x4 +#define ID_ENTROPY_VARS 0x5 +#define ID_HYBRID_PROFILE 0x6 +#define ID_SHAPING_WEIGHTS 0x7 +#define ID_FLOAT_INFO 0x8 +#define ID_INT32_INFO 0x9 +#define ID_WV_BITSTREAM 0xa +#define ID_WVC_BITSTREAM 0xb +#define ID_WVX_BITSTREAM 0xc +#define ID_CHANNEL_INFO 0xd + +#define ID_RIFF_HEADER (ID_OPTIONAL_DATA | 0x1) +#define ID_RIFF_TRAILER (ID_OPTIONAL_DATA | 0x2) +#define ID_REPLAY_GAIN (ID_OPTIONAL_DATA | 0x3) +#define ID_CUESHEET (ID_OPTIONAL_DATA | 0x4) +#define ID_CONFIG_BLOCK (ID_OPTIONAL_DATA | 0x5) +#define ID_MD5_CHECKSUM (ID_OPTIONAL_DATA | 0x6) +#define ID_SAMPLE_RATE (ID_OPTIONAL_DATA | 0x7) + +#define FLAG_FINAL_BLOCK (1 << 12) + +typedef struct { + char ckID [4]; /* "wvpk" */ + guint32 ckSize; /* size of entire block (minus 8, of course) */ + guint16 version; /* 0x402 to 0x410 are currently valid for decode */ + guchar track_no; /* track number (0 if not used, like now) */ + guchar index_no; /* track sub-index (0 if not used, like now) */ + guint32 total_samples; /* total samples for entire file, but this is + * only valid if block_index == 0 and a value of + * -1 indicates unknown length */ + guint32 block_index; /* index of first sample in block relative to + * beginning of file (normally this would start + * at 0 for the first block) */ + guint32 block_samples; /* number of samples in this block (0 = no audio) */ + guint32 flags; /* various flags for id and decoding */ + guint32 crc; /* crc for actual decoded data */ +} WavpackHeader; + +typedef struct { + gboolean correction; + guint rate; + guint width; + guint channels; + guint channel_mask; +} WavpackInfo; + +typedef struct _GstWavpackParse GstWavpackParse; +typedef struct _GstWavpackParseClass GstWavpackParseClass; + +/** + * GstWavpackParse: + * + * The opaque GstWavpackParse object + */ +struct _GstWavpackParse { + GstBaseParse baseparse; + + /*< private >*/ + gint sample_rate; + gint channels; + gint width; + gint channel_mask; + + guint total_samples; + + WavpackHeader wph; + WavpackInfo wpi; +}; + +/** + * GstWavpackParseClass: + * @parent_class: Element parent class. + * + * The opaque GstWavpackParseClass data structure. + */ +struct _GstWavpackParseClass { + GstBaseParseClass baseparse_class; +}; + +GType gst_wavpack_parse_get_type (void); + +G_END_DECLS + +#endif /* __GST_WAVPACK_PARSE_H__ */ diff --git a/gst/audioparsers/plugin.c b/gst/audioparsers/plugin.c index ae8332d3f..16f98ff6c 100644 --- a/gst/audioparsers/plugin.c +++ b/gst/audioparsers/plugin.c @@ -27,6 +27,7 @@ #include "gstdcaparse.h" #include "gstflacparse.h" #include "gstmpegaudioparse.h" +#include "gstwavpackparse.h" static gboolean plugin_init (GstPlugin * plugin) @@ -45,6 +46,8 @@ plugin_init (GstPlugin * plugin) GST_RANK_PRIMARY + 1, GST_TYPE_FLAC_PARSE); ret &= gst_element_register (plugin, "mpegaudioparse", GST_RANK_PRIMARY + 2, GST_TYPE_MPEG_AUDIO_PARSE); + ret &= gst_element_register (plugin, "wavpackparse2", + GST_RANK_SECONDARY, GST_TYPE_WAVPACK_PARSE); return ret; } diff --git a/gst/interleave/interleave.c b/gst/interleave/interleave.c index 6a0758d70..e09b37fbe 100644 --- a/gst/interleave/interleave.c +++ b/gst/interleave/interleave.c @@ -57,6 +57,10 @@ * </refsect2> */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 6b9061977..95378403c 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <gst/rtp/gstrtpbuffer.h> diff --git a/gst/udp/gstdynudpsink.c b/gst/udp/gstdynudpsink.c index 476847591..2f689c249 100644 --- a/gst/udp/gstdynudpsink.c +++ b/gst/udp/gstdynudpsink.c @@ -21,6 +21,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index 278189255..e4d8fbb6b 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -29,6 +29,10 @@ * It can be combined with rtp payload encoders to implement RTP streaming. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/sys/oss4/oss4-audio.c b/sys/oss4/oss4-audio.c index 09f849596..6317400dc 100644 --- a/sys/oss4/oss4-audio.c +++ b/sys/oss4/oss4-audio.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/sys/oss4/oss4-property-probe.c b/sys/oss4/oss4-property-probe.c index a99410ea2..5674da50a 100644 --- a/sys/oss4/oss4-property-probe.c +++ b/sys/oss4/oss4-property-probe.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 8924ea1fb..43a03df73 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -18,6 +18,10 @@ * USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/tests/check/elements/interleave.c b/tests/check/elements/interleave.c index e456a3e25..6f2d51f40 100644 --- a/tests/check/elements/interleave.c +++ b/tests/check/elements/interleave.c @@ -18,6 +18,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/tests/check/elements/wavpackdec.c b/tests/check/elements/wavpackdec.c index 0d1732333..b1498e166 100644 --- a/tests/check/elements/wavpackdec.c +++ b/tests/check/elements/wavpackdec.c @@ -52,7 +52,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, " - "width = (int) 32, " + "width = (int) 16, " "depth = (int) 16, " "channels = (int) 1, " "rate = (int) 44100, " @@ -112,23 +112,20 @@ GST_START_TEST (test_decode_frame) memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame)); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); GST_BUFFER_TIMESTAMP (inbuffer) = 0; - gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus); /* should decode the buffer without problems */ fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_buffer_unref (inbuffer); outbuffer = GST_BUFFER (buffers->data); fail_if (outbuffer == NULL); /* uncompressed data should be 102400 bytes */ - fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), 102400); + fail_unless_equals_int (GST_BUFFER_SIZE (outbuffer), 51200); - /* and all 102400 bytes must be 0, i.e. silence */ - for (i = 0; i < 102400; i++) + /* and all bytes must be 0, i.e. silence */ + for (i = 0; i < 51200; i++) fail_unless_equals_int (GST_BUFFER_DATA (outbuffer)[i], 0); ASSERT_BUFFER_REFCOUNT (outbuffer, "outbuffer", 1); @@ -166,14 +163,11 @@ GST_START_TEST (test_decode_frame_with_broken_header) GST_BUFFER_DATA (inbuffer)[2] = 'e'; ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); GST_BUFFER_TIMESTAMP (inbuffer) = 0; - gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus); /* should fail gracefully */ fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_ERROR); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_buffer_unref (inbuffer); fail_if ((message = gst_bus_pop (bus)) == NULL); fail_unless_message_error (message, STREAM, DECODE); @@ -204,14 +198,11 @@ GST_START_TEST (test_decode_frame_with_incomplete_frame) memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame) - 2); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); GST_BUFFER_TIMESTAMP (inbuffer) = 0; - gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus); /* should fail gracefully */ fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_ERROR); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_buffer_unref (inbuffer); fail_if ((message = gst_bus_pop (bus)) == NULL); fail_unless_message_error (message, STREAM, DECODE); diff --git a/tests/check/elements/wavpackenc.c b/tests/check/elements/wavpackenc.c index 153668a9d..af852aaa2 100644 --- a/tests/check/elements/wavpackenc.c +++ b/tests/check/elements/wavpackenc.c @@ -32,14 +32,14 @@ static GstBus *bus; #define RAW_CAPS_STRING "audio/x-raw-int, " \ "width = (int) 32, " \ - "depth = (int) 16, " \ + "depth = (int) 32, " \ "channels = (int) 1, " \ "rate = (int) 44100, " \ "endianness = (int) BYTE_ORDER, " \ "signed = (boolean) true" #define WAVPACK_CAPS_STRING "audio/x-wavpack, " \ - "width = (int) 16, " \ + "width = (int) 32, " \ "channels = (int) 1, " \ "rate = (int) 44100, " \ "framed = (boolean) true" @@ -48,7 +48,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-wavpack, " - "width = (int) 16, " + "width = (int) 32, " "channels = (int) 1, " "rate = (int) 44100, " "framed = (boolean) true")); @@ -57,7 +57,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_ALWAYS, GST_STATIC_CAPS ("audio/x-raw-int, " "width = (int) 32, " - "depth = (int) 16, " + "depth = (int) 32, " "channels = (int) 1, " "rate = (int) 44100, " "endianness = (int) BYTE_ORDER, " "signed = (boolean) true")); @@ -118,13 +118,10 @@ GST_START_TEST (test_encode_silence) gst_caps_unref (caps); GST_BUFFER_TIMESTAMP (inbuffer) = 0; ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackenc, bus); fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer), GST_FLOW_OK); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - gst_buffer_unref (inbuffer); fail_if (gst_pad_push_event (mysrcpad, eos) != TRUE); @@ -134,9 +131,7 @@ GST_START_TEST (test_encode_silence) fail_if (outbuffer == NULL); fail_unless_equals_int (GST_BUFFER_TIMESTAMP (outbuffer), 0); - fail_unless_equals_int (GST_BUFFER_OFFSET (outbuffer), 0); fail_unless_equals_int (GST_BUFFER_DURATION (outbuffer), 5668934); - fail_unless_equals_int (GST_BUFFER_OFFSET_END (outbuffer), 250); fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), "wvpk", 4) == 0, "Failed to encode to valid Wavpack frames"); diff --git a/tests/examples/audiofx/firfilter-example.c b/tests/examples/audiofx/firfilter-example.c index b344e74e6..e2fa2dc25 100644 --- a/tests/examples/audiofx/firfilter-example.c +++ b/tests/examples/audiofx/firfilter-example.c @@ -21,6 +21,10 @@ * by transforming the frequency response to the filter kernel. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <math.h> diff --git a/tests/examples/audiofx/iirfilter-example.c b/tests/examples/audiofx/iirfilter-example.c index 7fac2ac92..708bde1e1 100644 --- a/tests/examples/audiofx/iirfilter-example.c +++ b/tests/examples/audiofx/iirfilter-example.c @@ -23,6 +23,10 @@ * of the IIR filter that is used. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <math.h> diff --git a/tests/examples/pulse/pulse.c b/tests/examples/pulse/pulse.c index c82316349..f1d5b26ea 100644 --- a/tests/examples/pulse/pulse.c +++ b/tests/examples/pulse/pulse.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <gst/gst.h> #if 0 diff --git a/tests/examples/rtp/server-alsasrc-PCMA.c b/tests/examples/rtp/server-alsasrc-PCMA.c index 85647993e..625a6ba9f 100644 --- a/tests/examples/rtp/server-alsasrc-PCMA.c +++ b/tests/examples/rtp/server-alsasrc-PCMA.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include <string.h> #include <math.h> diff --git a/tests/icles/test-oss4.c b/tests/icles/test-oss4.c index ad8f46cd0..67e08e914 100644 --- a/tests/icles/test-oss4.c +++ b/tests/icles/test-oss4.c @@ -17,6 +17,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include <config.h> #endif |