From 84c102b6fe567116319b6f4006dac8872df5fffc Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 24 Apr 2019 13:47:54 -0400 Subject: [PATCH] rtpsession: Call on-new-ssrc earlier 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 | 5 +++-- tests/check/elements/rtpsession.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index bc952c2131..fefa259d4f 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -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; diff --git a/tests/check/elements/rtpsession.c b/tests/check/elements/rtpsession.c index a00766fb23..60bd167975 100644 --- a/tests/check/elements/rtpsession.c +++ b/tests/check/elements/rtpsession.c @@ -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; }