Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transport-wide CC feedback when simulcast SSRCs are missing #2908

Merged
merged 3 commits into from
Mar 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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