After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766265 - opusdec with FEC breaks when packet sizes change
opusdec with FEC breaks when packet sizes change
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
1.8.0
Other Linux
: Normal normal
: 1.8.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-11 10:29 UTC by dyudaken
Modified: 2016-05-20 14:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
preconstructed rtp packets that break decoder (53.21 KB, application/x-bzip)
2016-05-11 10:29 UTC, dyudaken
  Details
opusdec: Use GST_AUDIO_DECODER_ERROR (1.16 KB, patch)
2016-05-14 12:50 UTC, Olivier Crête
none Details | Review
opusdec: Use GST_AUDIO_DECODER_ERROR (1.16 KB, patch)
2016-05-19 16:28 UTC, Olivier Crête
committed Details | Review
opus: Post error message on GST_FLOW_ERROR (2.85 KB, patch)
2016-05-19 16:28 UTC, Olivier Crête
committed Details | Review

Description dyudaken 2016-05-11 10:29:07 UTC
Created attachment 327633 [details]
preconstructed rtp packets that break decoder

when frame sizes fluctuate, the gstreamer opus decoder breaks. I think it fails to handle the buffer too small error in FEC mode:

running the following breaks the stream:
gst-launch-1.0 multifilesrc do-timestamp=true location=./c%04d.rtp caps=application/x-rtp ! identity datarate=10000 ! rtpjitterbuffer do-lost=true ! rtpopusdepay ! opusparse ! opusdec plc=true use-inband-fec=true ! autoaudiosink

while this works (FEC off):
gst-launch-1.0 multifilesrc do-timestamp=true location=./c%04d.rtp caps=application/x-rtp ! identity datarate=10000 ! rtpjitterbuffer do-lost=true ! rtpopusdepay ! opusparse ! opusdec ! autoaudiosink

Also works for reference: 
gst-launch-1.0 multifilesrc do-timestamp=true location=./c%04d.rtp caps=application/x-rtp ! identity datarate=10000 ! rtpjitterbuffer do-lost=true ! rtpopusdepay ! matroskamux ! filesink location=out.mkv

ffplay out.mkv
Comment 1 Olivier Crête 2016-05-14 12:46:09 UTC
This kind of usecase makes it really hard for the packet loss concealer to guess the size of the next packet.. You should really avoid fluctuating the number of frames per packet like that. But there seems to indeed be some kind of actual bug.

I've been testing with the rtpjitterbuffer patch from bug #:
gst-launch-1.0 multifilesrc location=./c%04d.rtp caps='application/x-rtp, payload=111, clock-rate=48000' ! rtpjitterbuffer do-lost=false ! udpsink port=8888 sync=1

gst-launch-1.0 udpsrc port=8888 ! application/x-rtp, payload=111, media-type=audio, encoding-name=OPUS, clock-rate=48000 ! rtpjitterbuffer do-lost=true ! rtpopusdepay ! opusparse ! opusdec plc=true use-inband-fec=1 ! pulsesink

The patch I'm attaching here just prevents it from stopping, the jitterbuffer seems to still produce lost packet events with odd durations.
Comment 2 Olivier Crête 2016-05-14 12:50:02 UTC
You need the rtpjitterbuffer patch from bug #9835479 to run the sender test pipoeline.
Comment 3 Olivier Crête 2016-05-14 12:50:42 UTC
Created attachment 327879 [details] [review]
opusdec: Use GST_AUDIO_DECODER_ERROR

This way, the first invalid stream won't break all decoding.
Comment 4 Sebastian Dröge (slomo) 2016-05-15 07:50:25 UTC
Review of attachment 327879 [details] [review]:

Makes sense

::: ext/opus/gstopusdec.c
@@ +559,3 @@
     gst_buffer_unref (outbuf);
+    GST_AUDIO_DECODER_ERROR (dec, 1, STREAM, DECODE, ("Error decoding stream"),
+        ("Decoding error (%d): %s", n, opus_strerror (n)), hret);

hret? You probably mean ret :)
Comment 5 Olivier Crête 2016-05-19 16:28:00 UTC
Created attachment 328215 [details] [review]
opusdec: Use GST_AUDIO_DECODER_ERROR

This way, the first invalid stream won't break all decoding.
Comment 6 Olivier Crête 2016-05-19 16:28:03 UTC
Created attachment 328216 [details] [review]
opus: Post error message on GST_FLOW_ERROR
Comment 7 Olivier Crête 2016-05-20 14:59:36 UTC
Merged into master:

commit 0bfed26f5685560f33c7e1a8759619e53d27a330
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Thu May 19 12:26:05 2016 -0400

    opus: Post error message on GST_FLOW_ERROR
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766265

commit 1a700c3ae671694c206bed7939b8462db652a9b1
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sat May 14 14:41:28 2016 +0200

    opusdec: Use GST_AUDIO_DECODER_ERROR
    
    This way, the first invalid stream won't break all decoding.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766265

And into 1.8:

commit ac8ed8746d683d2d1696baacdc2ac6d7b21af31e
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Sat May 14 14:41:28 2016 +0200

    opusdec: Use GST_AUDIO_DECODER_ERROR
    
    This way, the first invalid stream won't break all decoding.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766265