rtpsession: Remember the corresponding media SSRC for RTX sources
authorSebastian Dröge <sebastian@centricular.com>
Mon, 3 Oct 2022 16:12:55 +0000 (19:12 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 10 Oct 2022 14:56:17 +0000 (14:56 +0000)
This allows timing out the RTX source and sending BYE for it when the
actual media source belonging to it is timed out.

This change only applies to sending sources from this session.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/360

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3112>

subprojects/gst-plugins-good/gst/rtpmanager/rtpsession.c
subprojects/gst-plugins-good/gst/rtpmanager/rtpsource.c
subprojects/gst-plugins-good/gst/rtpmanager/rtpsource.h

index c9581b0..48ef879 100644 (file)
@@ -4167,7 +4167,8 @@ session_cleanup (const gchar * key, RTPSource * source, ReportData * data)
         /* this is an internal source that is not using our suggested ssrc.
          * since there must be another source using this ssrc, we can remove
          * this one instead of making it a receiver forever */
-        if (source->ssrc != sess->suggested_ssrc) {
+        if (source->ssrc != sess->suggested_ssrc
+            && source->media_ssrc != sess->suggested_ssrc) {
           rtp_source_mark_bye (source, "timed out");
           /* do not schedule bye here, since we are inside the RTCP timeout
            * processing and scheduling bye will interfere with SR/RR sending */
index cb12644..0a0d858 100644 (file)
@@ -825,6 +825,7 @@ rtp_source_update_send_caps (RTPSource * src, GstCaps * caps)
   GstStructure *s;
   guint val;
   gint ival;
+  guint ssrc, rtx_ssrc = -1;
   gboolean rtx;
 
   /* nothing changed, return */
@@ -833,7 +834,17 @@ rtp_source_update_send_caps (RTPSource * src, GstCaps * caps)
 
   s = gst_caps_get_structure (caps, 0);
 
-  rtx = (gst_structure_get_uint (s, "rtx-ssrc", &val) && val == src->ssrc);
+  if (!gst_structure_get_uint (s, "ssrc", &ssrc))
+    return;
+  gst_structure_get_uint (s, "rtx-ssrc", &rtx_ssrc);
+
+  if (src->ssrc != ssrc && src->ssrc != rtx_ssrc) {
+    GST_WARNING ("got ssrc %u/%u that doesn't match with this source's ssrc %u",
+        ssrc, rtx_ssrc, src->ssrc);
+    return;
+  }
+
+  rtx = (rtx_ssrc == src->ssrc);
 
   if (gst_structure_get_int (s, rtx ? "rtx-payload" : "payload", &ival))
     src->payload = ival;
@@ -859,6 +870,12 @@ rtp_source_update_send_caps (RTPSource * src, GstCaps * caps)
       src->seqnum_offset);
 
   gst_caps_replace (&src->send_caps, caps);
+
+  if (rtx) {
+    src->media_ssrc = ssrc;
+  } else {
+    src->media_ssrc = -1;
+  }
 }
 
 /**
index a272305..e23d537 100644 (file)
@@ -137,6 +137,9 @@ struct _RTPSource {
   /*< private >*/
   guint32       ssrc;
 
+  /* If not -1 then this is the SSRC of the corresponding media RTPSource */
+  guint32       media_ssrc;
+
   guint16       generation;
   GHashTable    *reported_in_sr_of;     /* set of SSRCs */