GNOME Bugzilla – Bug 793763
rtpopuspay does not honour 'stereo' prop
Last modified: 2018-11-03 15:26:41 UTC
GST_DEBUG=3 GST_DEBUG_DUMP_DOT_DIR=/tmp gst-launch-1.0 pulsesrc ! opusenc ! rtpopuspay ! "application/x-rtp,media=audio,encoding-name=OPUS,stereo=(string)1" ! filesink location=/dev/null Look at resulting graph; the opusenc is actually taking 1-channel audio. This makes it "work": --- a/gst/rtp/gstrtpopuspay.c +++ b/gst/rtp/gstrtpopuspay.c @@ -254,14 +254,14 @@ gst_rtp_opus_pay_getcaps (GstRTPBasePayload * payload, GstCaps *caps2 = gst_caps_copy (caps); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 2, NULL); - gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 1, NULL); - caps = gst_caps_merge (caps, caps2); +// gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 1, NULL); +// caps = gst_caps_merge (caps, caps2); } else if (!strcmp (stereo, "0")) { GstCaps *caps2 = gst_caps_copy (caps); gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL); - gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 2, NULL); - caps = gst_caps_merge (caps, caps2); +// gst_caps_set_simple (caps2, "channels", G_TYPE_INT, 2, NULL); +// caps = gst_caps_merge (caps, caps2); } } gst_caps_unref (peercaps); However that isn't quite right because 'stereo=1' is supposed to be a *hint*. It's supposed to *allow* mono audio if it really has to, but I'd like it to make *some* attempt to do as it's asked. It looks like reordering the channels=[1,2] vs. channels=[2,1] options is expected to do that? It doesn't seem to work. FWIW I saw this in a Farstream conference the other way round: I was setting 'stereo=0' and still actually getting stereo because the "hint" wasn't honoured.
This also needs some negotiation code where rtpopusdepay is currently setting the srcpad caps. it would have to check what downstream supports with regards to the number of channels and then select something appropriate. If downstream supports mono and stereo, stereo should have preference if stereo=1.
Note that following the discussion in bug 793765 it looks like I'm going to keep using my own special cut-and-paste of rtpopuspay for ever, so I can also just hard-code it to mono and my interest in this bug is somewhat diminished. It should still be fixed though, ideally...
Judging by the output of GST_DEBUG=*pay*:6 gst-launch-1.0 audiotestsrc ! opusenc ! rtpopuspay ! 'application/x-rtp,media=audio,encoding-name=OPUS,stereo=(string)1' ! fakesink -v 2>&1 | grep gst_rtp_opus_pay_getcaps vs. GST_DEBUG=*pay*:6 gst-launch-1.0 audiotestsrc ! opusenc ! rtpopuspay ! 'application/x-rtp,media=audio,encoding-name=OPUS,stereo=(string)0' ! fakesink -v 2>&1 | grep gst_rtp_opus_pay_getcaps if does do the right thing somewhere, that is it should return: audio/x-opus,channels=2; audio/x-opus,channels=1 for stereo=1 and audio/x-opus,channels=1; audio/x-opus,channels=2 for stereo=0 Unclear to me for now if there's more stuff needed in rtpopuspay or if it goes wrong somewhere upstream (e.g. opusenc).
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/444.