@@ -2596,11 +2596,12 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
25962596 video = 0 ;
25972597 } else if (rtcp_ssrc == stream -> video_ssrc ) {
25982598 video = 1 ;
2599- } else {
2599+ } else if ( janus_rtcp_has_fir ( buf , len ) || janus_rtcp_has_pli ( buf , len ) || janus_rtcp_get_remb ( buf , len )) {
26002600 /* Mh, no SR or RR? Try checking if there's any FIR, PLI or REMB */
2601- if (janus_rtcp_has_fir (buf , len ) || janus_rtcp_has_pli (buf , len ) || janus_rtcp_get_remb (buf , len )) {
2602- video = 1 ;
2603- }
2601+ video = 1 ;
2602+ } else {
2603+ JANUS_LOG (LOG_WARN ,"[%" SCNu64 "] Dropping RTCP packet with unknown SSRC (%" SCNu32 ")\n" , handle -> handle_id , rtcp_ssrc );
2604+ return ;
26042605 }
26052606 JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Incoming RTCP, bundling: this is %s (local SSRC: video=%" SCNu32 ", audio=%" SCNu32 ", got %" SCNu32 ")\n" ,
26062607 handle -> handle_id , video ? "video" : "audio" , stream -> video_ssrc , stream -> audio_ssrc , rtcp_ssrc );
@@ -2618,6 +2619,9 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
26182619 } else if (stream -> video_ssrc_peer [2 ] && rtcp_ssrc == stream -> video_ssrc_peer [2 ]) {
26192620 video = 1 ;
26202621 vindex = 2 ;
2622+ } else {
2623+ JANUS_LOG (LOG_WARN ,"[%" SCNu64 "] Dropping RTCP packet with unknown SSRC (%" SCNu32 ")\n" , handle -> handle_id , rtcp_ssrc );
2624+ return ;
26212625 }
26222626 JANUS_LOG (LOG_HUGE , "[%" SCNu64 "] Incoming RTCP, bundling: this is %s (remote SSRC: video=%" SCNu32 " #%d, audio=%" SCNu32 ", got %" SCNu32 ")\n" ,
26232627 handle -> handle_id , video ? "video" : "audio" , stream -> video_ssrc_peer [vindex ], vindex , stream -> audio_ssrc_peer , rtcp_ssrc );
@@ -2715,6 +2719,18 @@ static void janus_ice_cb_nice_recv(NiceAgent *agent, guint stream_id, guint comp
27152719 component -> retransmit_log_ts = now ;
27162720 }
27172721
2722+ /* Fix packet data for RTCP SR and RTCP RR */
2723+ janus_rtp_switching_context * rtp_ctx = video ? & stream -> rtp_ctx [vindex ] : & stream -> rtp_ctx [0 ];
2724+ uint32_t ssrc_peer = video ? stream -> video_ssrc_peer_orig [vindex ] : stream -> audio_ssrc_peer_orig ;
2725+ uint32_t ssrc_local = video ? stream -> video_ssrc : stream -> audio_ssrc ;
2726+ uint32_t ssrc_expected = video ? rtp_ctx -> v_last_ssrc : rtp_ctx -> a_last_ssrc ;
2727+ if (janus_rtcp_fix_report_data (buf , buflen , rtp_ctx , ssrc_peer , ssrc_local , ssrc_expected , video ) < 0 ) {
2728+ /* Drop packet in case of parsing error or SSRC different from the one expected. */
2729+ /* This might happen at the very beginning of the communication or early after */
2730+ /* a re-negotation has been concluded. */
2731+ return ;
2732+ }
2733+
27182734 janus_plugin * plugin = (janus_plugin * )handle -> app ;
27192735 if (plugin && plugin -> incoming_rtcp && handle -> app_handle &&
27202736 !g_atomic_int_get (& handle -> app_handle -> stopped ) &&
0 commit comments