From a2c25ccd099ccaa3e1232f21417ae1733b26e787 Mon Sep 17 00:00:00 2001
From: Havard Graff <havard.graff@gmail.com>
Date: Mon, 1 Feb 2021 16:07:08 +0100
Subject: [PATCH] rtprtxsend: if no rtx is present, don't expose a rtx-ssrc in
 caps

The point here is that rtpsession will create a new rtpsource when
the field "rtx-ssrc" is present, and when not doing rtx, that means
a random ssrc will create a new rtpsource that will be included in RTCP
messages for the current session.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1882>
---
 .../gst-plugins-good/gst/rtpmanager/gstrtprtxsend.c    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtprtxsend.c b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtprtxsend.c
index 57e2a84487..e873d451c9 100644
--- a/subprojects/gst-plugins-good/gst/rtpmanager/gstrtprtxsend.c
+++ b/subprojects/gst-plugins-good/gst/rtpmanager/gstrtprtxsend.c
@@ -661,14 +661,16 @@ gst_rtp_rtx_send_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
 
       gst_structure_get_int (s, "clock-rate", &data->clock_rate);
 
-      /* The session might need to know the RTX ssrc */
       caps = gst_caps_copy (caps);
-      gst_caps_set_simple (caps, "rtx-ssrc", G_TYPE_UINT, data->rtx_ssrc,
-          "rtx-seqnum-offset", G_TYPE_UINT, data->seqnum_base, NULL);
 
-      if (GPOINTER_TO_INT (rtx_payload) != -1)
+      /* The session might need to know the RTX ssrc */
+      if (GPOINTER_TO_INT (rtx_payload) != -1) {
+        gst_caps_set_simple (caps, "rtx-ssrc", G_TYPE_UINT, data->rtx_ssrc,
+            "rtx-seqnum-offset", G_TYPE_UINT, data->seqnum_base, NULL);
+
         gst_caps_set_simple (caps, "rtx-payload", G_TYPE_INT,
             GPOINTER_TO_INT (rtx_payload), NULL);
+      }
 
       GST_DEBUG_OBJECT (rtx, "got clock-rate from caps: %d for ssrc: %u",
           data->clock_rate, ssrc);