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 752694 - rtpmux: allow the ssrc-property to decide ssrc on outgoing buffers
rtpmux: allow the ssrc-property to decide ssrc on outgoing buffers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other All
: Normal critical
: 1.7.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-22 07:54 UTC by Håvard Graff (hgr)
Modified: 2015-10-02 21:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstrtpmux: allow the ssrc-property to decide ssrc on outgoing buffers (21.70 KB, patch)
2015-09-01 01:14 UTC, Olivier Crête
committed Details | Review
rtpmux: As 0xFFFFFFFF is a valid ssrc, check if it has been set (2.72 KB, patch)
2015-09-01 01:14 UTC, Olivier Crête
committed Details | Review
rtpmux: Use default upstream event handling (1.79 KB, patch)
2015-09-01 01:14 UTC, Olivier Crête
committed Details | Review

Comment 1 Olivier Crête 2015-07-22 21:42:06 UTC
On a reconfigure, it should do a downstream getcaps to get the ssrc again if it ignores the ssrc from upstream. so that ... ! payloader ! rtpmux ! capsfilter ! ... works if you change the ssrc on the capsfilter?  It shoudl also react to the collision custom event just like rtpbasepayload.
Comment 2 Håvard Graff (hgr) 2015-07-23 09:11:40 UTC
(In reply to Olivier Crête from comment #1)
> On a reconfigure, it should do a downstream getcaps to get the ssrc again if
> it ignores the ssrc from upstream. so that ... ! payloader ! rtpmux !
> capsfilter ! ... works if you change the ssrc on the capsfilter?  It shoudl
> also react to the collision custom event just like rtpbasepayload.

Sure, but my patch does not change any of that, and I don't think this is/was working either. I can add another patch to fix this as well, but I think the first patch should be applied first :)
Comment 3 Håvard Graff (hgr) 2015-07-23 11:23:47 UTC
Here is a patch to respect downstream ssrc as well as a disabled test for the downstream ssrc changing dynamically. (not implemented)

https://github.com/pexip/gst-plugins-good/commit/d709198fe691d8be85248efe504603b5c74951ff.patch
Comment 5 Håvard Graff (hgr) 2015-07-25 12:55:56 UTC
I should probably also mention that without these patches, rtpmux does not actually use the same ssrc on the srcpad at all, meaning two different inputs with different ssrc will have different ssrc on the output as well, making the whole point of a muxer void.
Comment 6 Olivier Crête 2015-07-29 23:16:45 UTC
Setting something in getcaps is wrong. And the current code breaks the Farstream unit tests.

I think what you want to do is, in setcaps, get the downstream caps, if they are set, then take the ssrc from there, is not, try the property and as a last resort, generate a random one. I'd also drop everything that is not ssrc/timestamp-offset/seqnum-offset/clock-rate/media-type from the caps. In any subsequent setcaps, if the clock-rate/media-type match the current ones, just return TRUE without pushing a different event. This will reduce the amount of churn. Also, we need to support the GstRTPCollision event to deal with SSRC collisions correctly.
Comment 7 Håvard Graff (hgr) 2015-07-30 05:28:53 UTC
Yeah, as I mentioned, when trying to make the dynamic caps test pass I quickly realized this would need a bigger refactoring. As long as you agree that the tests in the patch should pass, I don't really care how it is inplemented, but currently the rtpmux outouts different ssrcs which is very bad.
Comment 8 Sebastian Dröge (slomo) 2015-08-13 14:50:26 UTC
Olivier, so is farstream just depending on completely broken behaviour or does it make sense in some way? Do you agree that hgr's tests are making sense, or are there bugs in them? If his tests make sense, let's fix rtpmux to make them pass ;)
Comment 9 Olivier Crête 2015-08-13 15:12:02 UTC
I agree with hgr's tests, and Farstraem should work with them.

The underlying problem is that around 1.2-1.4, wtay changed how ssrc are specified, before (in 0.10 and 1.0), you specified it inside rtpbin and it would propagate out, now wtay changed it so that you specify it at the payloader. I had tried to cheat out by just having the muxer just be a passthrough and let the rtpbin and payloaders talk to each other, but it seems that it's not enough. So we need rtpmux to implement the same logic as the payloader to prefer downstream suggestions, but fallback on internal choice. hgr's patch are in the right direction, but are not complete.

If no one else has time to fix it, I'll get to it.
Comment 10 Olivier Crête 2015-09-01 01:14:07 UTC
Created attachment 310389 [details] [review]
gstrtpmux: allow the ssrc-property to decide ssrc on outgoing buffers

By not doing this, the muxer is not effectively a rtpmuxer, rather a
funnel, since it should be a single stream that exists the muxer.

If not specified, take the first ssrc seen on a sinkpad, allowing upstream
to decide ssrc in "passthrough" with only one sinkpad.

Also, let downstream ssrc overrule internal configured one

We hence has the following order for determining the ssrc used by
rtpmux:

0. Suggestion from GstRTPCollision event
1. Downstream caps
2. ssrc-Property
3. (First) upstream caps containing ssrc
4. Randomly generated
Comment 11 Olivier Crête 2015-09-01 01:14:12 UTC
Created attachment 310390 [details] [review]
rtpmux: As 0xFFFFFFFF is a valid ssrc, check if it has been set
Comment 12 Olivier Crête 2015-09-01 01:14:16 UTC
Created attachment 310391 [details] [review]
rtpmux: Use default upstream event handling
Comment 13 Olivier Crête 2015-09-01 01:16:53 UTC
@hgr: Let me know if these patches fix your problem.
Comment 14 Håvard Graff (hgr) 2015-09-01 06:32:47 UTC
@(In reply to Olivier Crête from comment #13)
> @hgr: Let me know if these patches fix your problem.

If they pass the added tests (including the dynamic one) I am very happy, thanks!
Comment 15 Sebastian Dröge (slomo) 2015-09-01 07:33:12 UTC
Review of attachment 310389 [details] [review]:

Looks mostly good and the approach makes sense IMHO

::: gst/rtpmanager/gstrtpmux.c
@@ +231,3 @@
+
+          while (ssrc == rtp_mux->current_ssrc)
+            rtp_mux->current_ssrc = g_random_int ();

This can probably use a mutex somewhere. The upstream event is not necessarily coming from our streaming thread, and we might put some transient ssrc on some buffers that is not the same as the one in the caps.
Comment 16 Sebastian Dröge (slomo) 2015-10-02 14:34:46 UTC
Olivier?
Comment 17 Olivier Crête 2015-10-02 21:43:15 UTC
Thanks for finding this, added a couple more GST_OBJECT_LOCKs and pushed the patches:

commit 58073eaa7ae5d7c7b93da89faea05e7f01ee58cd
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Mon Aug 31 21:10:16 2015 -0400

    rtpmux: Use default upstream event handling
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752694

commit 43c213fc5db75dcf570ef1c224122307a0899911
Author: Olivier Crête <olivier.crete@collabora.com>
Date:   Mon Aug 31 21:05:03 2015 -0400

    rtpmux: As 0xFFFFFFFF is a valid ssrc, check if it has been set
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752694

commit d5e26ab9099e5a46eda7e9b59f01c1efe463344d
Author: Havard Graff <havard.graff@gmail.com>
Date:   Wed Jul 22 09:47:22 2015 +0200

    gstrtpmux: allow the ssrc-property to decide ssrc on outgoing buffers
    
    By not doing this, the muxer is not effectively a rtpmuxer, rather a
    funnel, since it should be a single stream that exists the muxer.
    
    If not specified, take the first ssrc seen on a sinkpad, allowing upstream
    to decide ssrc in "passthrough" with only one sinkpad.
    
    Also, let downstream ssrc overrule internal configured one
    
    We hence has the following order for determining the ssrc used by
    rtpmux:
    
    0. Suggestion from GstRTPCollision event
    1. Downstream caps
    2. ssrc-Property
    3. (First) upstream caps containing ssrc
    4. Randomly generated
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752694