Skip to content

Commit

Permalink
Fix transport-wide CC feedback when simulcast SSRCs are missing (#2908)
Browse files Browse the repository at this point in the history
  • Loading branch information
OxleyS committed Mar 2, 2022
1 parent ba03156 commit f62c80f
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -3979,6 +3979,7 @@ static gboolean janus_ice_outgoing_transport_wide_cc_feedback(gpointer user_data
janus_ice_handle *handle = (janus_ice_handle *)user_data;
janus_ice_peerconnection *pc = handle->pc;

guint32 ssrc_peer = 0;
janus_ice_peerconnection_medium *medium = NULL;
if(pc) {
/* Find inbound video medium */
Expand All @@ -3989,14 +3990,31 @@ static gboolean janus_ice_outgoing_transport_wide_cc_feedback(gpointer user_data
while (g_hash_table_iter_next(&iter, NULL, &value)) {
janus_ice_peerconnection_medium *m = value;
if(m && m->type == JANUS_MEDIA_VIDEO && m->recv) {
medium = m;
break;
/* If a medium (or simulcast layer, if applicable) has not received data, its SSRC may be unknown. */
/* Pick the first valid SSRC we find across all considered mediums */
int i = 0;
for(i = 0; i < 3; i++) {
if(m->ssrc_peer[i] != 0) {
ssrc_peer = m->ssrc_peer[i];
medium = m;
break;
}
}

/* Stop if we found a valid SSRC/medium to use */
if(medium && ssrc_peer)
break;
}
}
janus_mutex_unlock(&handle->mutex);
}

if(pc && pc->do_transport_wide_cc && medium) {
if(medium == NULL) {
JANUS_LOG(LOG_HUGE, "No medium with a valid peer SSRC found for transport-wide CC feedback\n");
return G_SOURCE_CONTINUE;
}

if(pc && pc->do_transport_wide_cc) {
/* Create a transport wide feedback message */
size_t size = 1300;
char rtcpbuf[1300];
Expand Down Expand Up @@ -4065,7 +4083,7 @@ static gboolean janus_ice_outgoing_transport_wide_cc_feedback(gpointer user_data
guint8 feedback_packet_count = pc->transport_wide_cc_feedback_count++;
/* Create RTCP packet */
int len = janus_rtcp_transport_wide_cc_feedback(rtcpbuf, size,
medium->ssrc, medium->ssrc_peer[0], feedback_packet_count, packets_to_process);
medium->ssrc, ssrc_peer, feedback_packet_count, packets_to_process);
/* Enqueue it, we'll send it later */
if(len > 0) {
janus_plugin_rtcp rtcp = { .mindex = medium->mindex, .video = TRUE, .buffer = rtcpbuf, .length = len };
Expand Down

0 comments on commit f62c80f

Please sign in to comment.