1 From 6c3e13197ebc81df26d5e01a161a13e8e4b66bf4 Mon Sep 17 00:00:00 2001
2 From: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
3 Date: Mon, 30 Apr 2012 14:40:02 +0100
4 Subject: [PATCH 12/20] opusdec: fix lost packet handling for FEC/PLC
6 The base audio decoder sends zero size packets, not NULL buffers,
7 to signal dropped packets.
9 ext/opus/gstopusdec.c | 20 +++++++++++++-------
10 1 file changed, 13 insertions(+), 7 deletions(-)
12 diff --git a/ext/opus/gstopusdec.c b/ext/opus/gstopusdec.c
13 index 7776f58..cbfc3ac 100644
14 --- a/ext/opus/gstopusdec.c
15 +++ b/ext/opus/gstopusdec.c
16 @@ -382,13 +382,16 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buffer)
17 to potentially wait for next buffer to decode a missing buffer */
18 if (dec->use_inband_fec && !dec->primed) {
19 GST_DEBUG_OBJECT (dec, "First buffer received in FEC mode, early out");
20 + gst_buffer_replace (&dec->last_buffer, buffer);
25 /* That's the buffer we'll be sending to the opus decoder. */
26 - buf = dec->use_inband_fec && dec->last_buffer ? dec->last_buffer : buffer;
27 + buf = (dec->use_inband_fec
28 + && GST_BUFFER_SIZE (dec->last_buffer) > 0) ? dec->last_buffer : buffer;
31 + if (buf && GST_BUFFER_SIZE (buf) > 0) {
32 data = GST_BUFFER_DATA (buf);
33 size = GST_BUFFER_SIZE (buf);
34 GST_DEBUG_OBJECT (dec, "Using buffer of size %u", size);
35 @@ -418,20 +421,24 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buffer)
36 if (dec->use_inband_fec) {
37 if (dec->last_buffer) {
38 /* normal delayed decode */
39 + GST_LOG_OBJECT (dec, "FEC enabled, decoding last delayed buffer");
40 n = opus_multistream_decode (dec->state, data, size, out_data, samples,
43 /* FEC reconstruction decode */
44 + GST_LOG_OBJECT (dec, "FEC enabled, reconstructing last buffer");
45 n = opus_multistream_decode (dec->state, data, size, out_data, samples,
50 + GST_LOG_OBJECT (dec, "FEC disabled, decoding buffer");
51 n = opus_multistream_decode (dec->state, data, size, out_data, samples, 0);
55 GST_ELEMENT_ERROR (dec, STREAM, DECODE, ("Decoding error: %d", n), (NULL));
56 + gst_buffer_unref (outbuf);
57 return GST_FLOW_ERROR;
59 GST_DEBUG_OBJECT (dec, "decoded %d samples", n);
60 @@ -472,17 +479,16 @@ opus_dec_chain_parse_data (GstOpusDec * dec, GstBuffer * buffer)
64 + if (dec->use_inband_fec) {
65 + gst_buffer_replace (&dec->last_buffer, buffer);
68 res = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (dec), outbuf, 1);
70 if (res != GST_FLOW_OK)
71 GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (res));
74 - if (dec->use_inband_fec) {
75 - gst_buffer_replace (&dec->last_buffer, buffer);