rtpsession: Call on-new-ssrc earlier
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 24 Apr 2019 17:47:54 +0000 (13:47 -0400)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 7 Aug 2019 10:05:19 +0000 (10:05 +0000)
Right now, we may call on-new-ssrc after we have processed the first
RTP packet. This prevents properly configuring the source as some
property like "probation" are copied internally for use as a
decreasing counter. For this specific property, it prevents the
application from disabling probation on auxiliary sparse stream.

Probation is harmful on sparse streams since the probation algorithm
assume frequent and contiguous RTP packets.

gst/rtpmanager/rtpsession.c
tests/check/elements/rtpsession.c

index bc952c2..fefa259 100644 (file)
@@ -2240,6 +2240,9 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
   prevactive = RTP_SOURCE_IS_ACTIVE (source);
   oldrate = source->bitrate;
 
+  if (created)
+    on_new_ssrc (sess, source);
+
   /* let source process the packet */
   result = rtp_source_process_rtp (source, &pinfo);
 
@@ -2252,8 +2255,6 @@ rtp_session_process_rtp (RTPSession * sess, GstBuffer * buffer,
   if (oldrate != source->bitrate)
     sess->recalc_bandwidth = TRUE;
 
-  if (created)
-    on_new_ssrc (sess, source);
 
   if (source->validated) {
     gboolean created;
index a00766f..60bd167 100644 (file)
@@ -1861,6 +1861,32 @@ GST_START_TEST (test_on_sending_nacks)
 
 GST_END_TEST;
 
+static void
+disable_probation_on_new_ssrc (GObject * session, GObject * source)
+{
+  g_object_set (source, "probation", 0, NULL);
+}
+
+GST_START_TEST (test_disable_probation)
+{
+  SessionHarness *h = session_harness_new ();
+
+  g_object_set (h->internal_session, "internal-ssrc", 0xDEADBEEF, NULL);
+  g_signal_connect (h->internal_session, "on-new-ssrc",
+      G_CALLBACK (disable_probation_on_new_ssrc), NULL);
+
+  /* Receive a RTP buffer from the wire */
+  fail_unless_equals_int (GST_FLOW_OK,
+      session_harness_recv_rtp (h, generate_test_buffer (0, 0x12345678)));
+
+  /* When probation is disable, the packet should be produced immediatly */
+  fail_unless_equals_int (1, gst_harness_buffers_in_queue (h->recv_rtp_h));
+
+  session_harness_free (h);
+}
+
+GST_END_TEST;
+
 static Suite *
 rtpsession_suite (void)
 {
@@ -1890,6 +1916,7 @@ rtpsession_suite (void)
   tcase_add_test (tc_chain, test_change_sent_sdes);
   tcase_add_test (tc_chain, test_disable_sr_timestamp);
   tcase_add_test (tc_chain, test_on_sending_nacks);
+  tcase_add_test (tc_chain, test_disable_probation);
   return s;
 }