[Pkg-voip-commits] [janus] 66/163: Only do NACKs for a specific medium if they were negotiated

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.5-1
in repository janus.

commit 90fa6b67385657a9ea6135fe178d9d44a0434846
Author: Lorenzo Miniero <lminiero at gmail.com>
Date:   Wed Aug 2 20:10:02 2017 +0200

    Only do NACKs for a specific medium if they were negotiated
---
 ice.c | 25 ++++++++++++++++++++++++-
 ice.h |  4 ++++
 sdp.c | 10 ++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/ice.c b/ice.c
index f6d68c4..a100cf5 100644
--- a/ice.c
+++ b/ice.c
@@ -2115,6 +2115,10 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
 
 				/* Keep track of RTP sequence numbers, in case we need to NACK them */
 				/* 	Note: unsigned int overflow/underflow wraps (defined behavior) */
+				if((!video && !component->do_audio_nacks) || (video && !component->do_video_nacks)) {
+					/* ... unless NACKs are disabled for this medium */
+					return;
+				}
 				guint16 new_seqn = ntohs(header->seq_number);
 				guint16 cur_seqn;
 				int last_seqs_len = 0;
@@ -2295,7 +2299,7 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
 				gint64 now = janus_get_monotonic_time();
 				GSList *nacks = janus_rtcp_get_nacks(buf, buflen);
 				guint nacks_count = g_slist_length(nacks);
-				if(nacks_count) {
+				if(nacks_count && ((!video && component->do_audio_nacks) || (video && component->do_video_nacks))) {
 					/* Handle NACK */
 					JANUS_LOG(LOG_HUGE, "[%"SCNu64"]     Just got some NACKS (%d) we should handle...\n", handle->handle_id, nacks_count);
 					GSList *list = nacks;
@@ -3006,6 +3010,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
 		audio_rtp->icefailed_detected = 0;
 		audio_rtp->dtlsrt_source = NULL;
 		audio_rtp->dtls = NULL;
+		audio_rtp->do_audio_nacks = FALSE;
+		audio_rtp->do_video_nacks = FALSE;
 		audio_rtp->retransmit_buffer = NULL;
 		audio_rtp->retransmit_log_ts = 0;
 		audio_rtp->retransmit_recent_cnt = 0;
@@ -3070,6 +3076,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
 			audio_rtcp->icefailed_detected = 0;
 			audio_rtcp->dtlsrt_source = NULL;
 			audio_rtcp->dtls = NULL;
+			audio_rtcp->do_audio_nacks = FALSE;
+			audio_rtcp->do_video_nacks = FALSE;
 			audio_rtcp->retransmit_buffer = NULL;
 			audio_rtcp->retransmit_log_ts = 0;
 			audio_rtcp->retransmit_recent_cnt = 0;
@@ -3165,6 +3173,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
 		video_rtp->icefailed_detected = 0;
 		video_rtp->dtlsrt_source = NULL;
 		video_rtp->dtls = NULL;
+		video_rtp->do_audio_nacks = FALSE;
+		video_rtp->do_video_nacks = FALSE;
 		video_rtp->retransmit_buffer = NULL;
 		video_rtp->retransmit_log_ts = 0;
 		video_rtp->retransmit_recent_cnt = 0;
@@ -3229,6 +3239,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
 			video_rtcp->icefailed_detected = 0;
 			video_rtcp->dtlsrt_source = NULL;
 			video_rtcp->dtls = NULL;
+			video_rtcp->do_audio_nacks = FALSE;
+			video_rtcp->do_video_nacks = FALSE;
 			video_rtcp->retransmit_buffer = NULL;
 			video_rtcp->retransmit_log_ts = 0;
 			video_rtcp->retransmit_recent_cnt = 0;
@@ -3319,6 +3331,8 @@ int janus_ice_setup_local(janus_ice_handle *handle, int offer, int audio, int vi
 		data_component->icefailed_detected = 0;
 		data_component->dtlsrt_source = NULL;
 		data_component->dtls = NULL;
+		data_component->do_audio_nacks = FALSE;
+		data_component->do_video_nacks = FALSE;
 		data_component->retransmit_buffer = NULL;
 		data_component->retransmit_log_ts = 0;
 		data_component->retransmit_recent_cnt = 0;
@@ -3883,6 +3897,15 @@ void *janus_ice_send_thread(void *data) {
 						}
 						if(max_nack_queue > 0) {
 							/* Save the packet for retransmissions that may be needed later */
+							if((pkt->type == JANUS_ICE_PACKET_AUDIO && !component->do_audio_nacks) ||
+									(pkt->type == JANUS_ICE_PACKET_VIDEO && !component->do_video_nacks)) {
+								/* ... unless NACKs are disabled for this medium */
+								g_free(pkt->data);
+								pkt->data = NULL;
+								g_free(pkt);
+								pkt = NULL;
+								continue;
+							}
 							janus_rtp_packet *p = (janus_rtp_packet *)g_malloc0(sizeof(janus_rtp_packet));
 							p->data = (char *)g_malloc0(protected);
 							memcpy(p->data, sbuf, protected);
diff --git a/ice.h b/ice.h
index 7222ede..4a00a92 100644
--- a/ice.h
+++ b/ice.h
@@ -440,6 +440,10 @@ struct janus_ice_component {
 	GSource *dtlsrt_source;
 	/*! \brief DTLS-SRTP stack */
 	janus_dtls_srtp *dtls;
+	/*! \brief Whether we should do NACKs (in or out) for audio */
+	gboolean do_audio_nacks;
+	/*! \brief Whether we should do NACKs (in or out) for video */
+	gboolean do_video_nacks;
 	/*! \brief List of previously sent janus_rtp_packet RTP packets, in case we receive NACKs */
 	GList *retransmit_buffer;
 	/*! \brief Last time a log message about sending retransmits was printed */
diff --git a/sdp.c b/sdp.c
index 2e6624a..c72366c 100644
--- a/sdp.c
+++ b/sdp.c
@@ -324,6 +324,16 @@ int janus_sdp_process(void *ice_handle, janus_sdp *remote_sdp) {
 					if(res != 0) {
 						JANUS_LOG(LOG_ERR, "[%"SCNu64"] Failed to parse SSRC attribute... (%d)\n", handle->handle_id, res);
 					}
+				} else if(!strcasecmp(a->name, "rtcp-fb")) {
+					if(a->value && strstr(a->value, "nack") && stream->rtp_component) {
+						if(m->type == JANUS_SDP_AUDIO) {
+							/* Enable NACKs for audio */
+							stream->rtp_component->do_audio_nacks = TRUE;
+						} else if(m->type == JANUS_SDP_VIDEO) {
+							/* Enable NACKs for video */
+							stream->rtp_component->do_video_nacks = TRUE;
+						}
+					}
 				}
 #ifdef HAVE_SCTP
 				else if(!strcasecmp(a->name, "sctpmap")) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list