@@ -2286,10 +2286,11 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
22862286 janus_mutex_unlock (& stream -> mutex );
22872287 }
22882288 }
2289- if (video && stream -> rtx_nacked [ vindex ] != NULL ) {
2289+ if (video ) {
22902290 /* Check if this packet is a duplicate: can happen with RFC4588 */
22912291 guint16 seqno = ntohs (header -> seq_number );
2292- int nstate = GPOINTER_TO_INT (g_hash_table_lookup (stream -> rtx_nacked [vindex ], GUINT_TO_POINTER (seqno )));
2292+ int nstate = stream -> rtx_nacked [vindex ] ?
2293+ GPOINTER_TO_INT (g_hash_table_lookup (stream -> rtx_nacked [vindex ], GUINT_TO_POINTER (seqno ))) : 0 ;
22932294 if (nstate == 1 ) {
22942295 /* Packet was NACKed and this is the first time we receive it: change state to received */
22952296 JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Received NACKed packet %" SCNu16 " (SSRC %" SCNu32 ", vindex %d)...\n" ,
@@ -2300,6 +2301,16 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
23002301 JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Detected duplicate packet %" SCNu16 " (SSRC %" SCNu32 ", vindex %d)...\n" ,
23012302 handle -> handle_id , seqno , packet_ssrc , vindex );
23022303 return ;
2304+ } else if (rtx && nstate == 0 ) {
2305+ /* We received a retransmission for a packet we didn't NACK: drop it
2306+ * FIXME This seems to happen with Chrome when RFC4588 is enabled: in that case,
2307+ * Chrome sends the first packet ~8 times as a retransmission, probably to ensure
2308+ * we receive it, since the first packet cannot be NACKed (NACKs are triggered
2309+ * when there's a gap in between two packets, and the first doesn't have a reference)
2310+ * Rather than dropping, we should add a better check in the future */
2311+ JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Got a retransmission for non-NACKed packet %" SCNu16 " (SSRC %" SCNu32 ", vindex %d)...\n" ,
2312+ handle -> handle_id , seqno , packet_ssrc , vindex );
2313+ return ;
23032314 }
23042315 }
23052316 /* Backup the RTP header before passing it to the proper RTP switching context */
@@ -2399,7 +2410,8 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
23992410
24002411 /* Update the RTCP context as well */
24012412 rtcp_context * rtcp_ctx = video ? stream -> video_rtcp_ctx [vindex ] : stream -> audio_rtcp_ctx ;
2402- janus_rtcp_process_incoming_rtp (rtcp_ctx , buf , buflen );
2413+ gboolean count_lost = ((!video && !component -> do_audio_nacks ) || (video && !component -> do_video_nacks )) ? TRUE : FALSE;
2414+ janus_rtcp_process_incoming_rtp (rtcp_ctx , buf , buflen , count_lost );
24032415
24042416 /* Keep track of RTP sequence numbers, in case we need to NACK them */
24052417 /* Note: unsigned int overflow/underflow wraps (defined behavior) */
@@ -2466,6 +2478,7 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
24662478 } else if (cur_seq -> state == SEQ_MISSING && now - cur_seq -> ts > SEQ_MISSING_WAIT ) {
24672479 JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Missed sequence number %" SCNu16 " (%s stream #%d), sending 1st NACK\n" ,
24682480 handle -> handle_id , cur_seq -> seq , video ? "video" : "audio" , vindex );
2481+ rtcp_ctx -> lost ++ ;
24692482 nacks = g_slist_prepend (nacks , GUINT_TO_POINTER (cur_seq -> seq ));
24702483 cur_seq -> state = SEQ_NACKED ;
24712484 if (video && janus_flags_is_set (& handle -> webrtc_flags , JANUS_ICE_HANDLE_WEBRTC_RFC4588_RTX )) {
@@ -3949,7 +3962,8 @@ static gboolean janus_ice_outgoing_traffic_handle(janus_ice_handle *handle, janu
39493962 janus_rtp_header * header = (janus_rtp_header * )pkt -> data ;
39503963 guint32 timestamp = ntohl (header -> timestamp );
39513964 guint16 seq = ntohs (header -> seq_number );
3952- JANUS_LOG (LOG_ERR , "[%" SCNu64 "] ... SRTP protect error... %s (len=%d-->%d, ts=%" SCNu32 ", seq=%" SCNu16 ")...\n" , handle -> handle_id , janus_srtp_error_str (res ), pkt -> length , protected , timestamp , seq );
3965+ JANUS_LOG (LOG_DBG , "[%" SCNu64 "] ... SRTP protect error... %s (len=%d-->%d, ts=%" SCNu32 ", seq=%" SCNu16 ")...\n" ,
3966+ handle -> handle_id , janus_srtp_error_str (res ), pkt -> length , protected , timestamp , seq );
39533967 janus_ice_free_rtp_packet (p );
39543968 } else {
39553969 /* Shoot! */
0 commit comments