Skip to content

Commit

Permalink
Fixed simulcast issue when automaticlly dropping to lower layers
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero committed Oct 11, 2019
1 parent 5bdba78 commit 84e80fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
15 changes: 7 additions & 8 deletions plugins/janus_echotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,13 @@ void janus_echotest_incoming_rtp(janus_plugin_session *handle, int video, char *
/* Process this packet: don't relay if it's not the SSRC/layer we wanted to handle */
gboolean relay = janus_rtp_simulcasting_context_process_rtp(&session->sim_context,
buf, len, session->ssrc, session->rid, session->vcodec, &session->context);
if(session->sim_context.need_pli) {
/* Send a PLI */
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(handle, 1, rtcpbuf, 12);
}
/* Do we need to drop this? */
if(!relay)
return;
Expand All @@ -566,14 +573,6 @@ void janus_echotest_incoming_rtp(janus_plugin_session *handle, int video, char *
gateway->push_event(handle, &janus_echotest_plugin, NULL, event, NULL);
json_decref(event);
}
if(session->sim_context.need_pli) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(handle, 1, rtcpbuf, 12);
}
if(session->sim_context.changed_temporal) {
/* Notify the user about the temporal layer change */
json_t *event = json_object();
Expand Down
6 changes: 3 additions & 3 deletions plugins/janus_recordplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,6 @@ void janus_recordplay_incoming_rtp(janus_plugin_session *handle, int video, char
/* Process this packet: don't save if it's not the SSRC/layer we wanted to handle */
gboolean save = janus_rtp_simulcasting_context_process_rtp(&session->sim_context,
buf, len, session->ssrc, session->rid, session->recording->vcodec, &session->context);
/* Do we need to drop this? */
if(!save)
return;
if(session->sim_context.need_pli) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
Expand All @@ -1204,6 +1201,9 @@ void janus_recordplay_incoming_rtp(janus_plugin_session *handle, int video, char
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(handle, 1, rtcpbuf, 12);
}
/* Do we need to drop this? */
if(!save)
return;
/* If we got here, update the RTP header and save the packet */
janus_rtp_header_update(header, &session->context, TRUE, 0);
if(session->recording->vcodec == JANUS_VIDEOCODEC_VP8) {
Expand Down
16 changes: 8 additions & 8 deletions plugins/janus_videocall.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,14 @@ void janus_videocall_incoming_rtp(janus_plugin_session *handle, int video, char
/* Do we need to drop this? */
if(!relay)
return;
if(peer->sim_context.need_pli) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(session->handle, 1, rtcpbuf, 12);
}
/* Any event we should notify? */
if(peer->sim_context.changed_substream) {
/* Notify the user about the substream change */
Expand All @@ -735,14 +743,6 @@ void janus_videocall_incoming_rtp(janus_plugin_session *handle, int video, char
gateway->push_event(peer->handle, &janus_videocall_plugin, NULL, event, NULL);
json_decref(event);
}
if(peer->sim_context.need_pli) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(session->handle, 1, rtcpbuf, 12);
}
if(peer->sim_context.changed_temporal) {
/* Notify the user about the temporal layer change */
json_t *event = json_object();
Expand Down
18 changes: 9 additions & 9 deletions plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -6519,6 +6519,15 @@ static void janus_videoroom_relay_rtp_packet(gpointer data, gpointer user_data)
/* Process this packet: don't relay if it's not the SSRC/layer we wanted to handle */
gboolean relay = janus_rtp_simulcasting_context_process_rtp(&subscriber->sim_context,
(char *)packet->data, packet->length, packet->ssrc, NULL, subscriber->feed->vcodec, &subscriber->context);
if(subscriber->sim_context.need_pli && subscriber->feed && subscriber->feed->session &&
subscriber->feed->session->handle) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(subscriber->feed->session->handle, 1, rtcpbuf, 12);
}
/* Do we need to drop this? */
if(!relay)
return;
Expand All @@ -6532,15 +6541,6 @@ static void janus_videoroom_relay_rtp_packet(gpointer data, gpointer user_data)
gateway->push_event(subscriber->session->handle, &janus_videoroom_plugin, NULL, event, NULL);
json_decref(event);
}
if(subscriber->sim_context.need_pli && subscriber->feed && subscriber->feed->session &&
subscriber->feed->session->handle) {
/* Send a PLI */
JANUS_LOG(LOG_VERB, "We need a PLI for the simulcast context\n");
char rtcpbuf[12];
memset(rtcpbuf, 0, 12);
janus_rtcp_pli((char *)&rtcpbuf, 12);
gateway->relay_rtcp(subscriber->feed->session->handle, 1, rtcpbuf, 12);
}
if(subscriber->sim_context.changed_temporal) {
/* Notify the user about the temporal layer change */
json_t *event = json_object();
Expand Down
10 changes: 6 additions & 4 deletions rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,12 @@ gboolean janus_rtp_simulcasting_context_process_rtp(janus_rtp_simulcasting_conte
if(substream < 0)
substream = 0;
if(context->substream != substream) {
JANUS_LOG(LOG_WARN, "No packet received on substream %d for a while, falling back to %d\n",
context->substream, substream);
context->substream_target = substream;
/* Notify the caller that we need a PLI */
if(context->substream_target != substream) {
JANUS_LOG(LOG_WARN, "No packet received on substream %d for a while, falling back to %d\n",
context->substream, substream);
context->substream_target = substream;
}
/* Notify the caller that we (still) need a PLI */
context->need_pli = TRUE;
}
}
Expand Down

0 comments on commit 84e80fb

Please sign in to comment.