Skip to content

Commit 7c83c09

Browse files
authored
Fix last stats before closing PeerConnection not being sent to handlers (replaces #2873) (#2874)
1 parent ed17a64 commit 7c83c09

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

ice.c

+12-10
Original file line numberDiff line numberDiff line change
@@ -4204,11 +4204,9 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
42044204
if(janus_ice_event_stats_period > 0 && handle->last_event_stats >= janus_ice_event_stats_period) {
42054205
handle->last_event_stats = 0;
42064206
json_t *combined_event = NULL;
4207-
/* Shall janus send dedicated events per media or one per peerConnection */
4208-
if(janus_events_is_enabled() && janus_ice_event_get_combine_media_stats())
4209-
combined_event = json_array();
4210-
/* Audio */
4211-
if(janus_events_is_enabled() && janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_HAS_AUDIO)) {
4207+
gboolean combine = janus_ice_event_get_combine_media_stats();
4208+
if(janus_events_is_enabled()) {
4209+
/* Audio */
42124210
if(stream && stream->audio_rtcp_ctx) {
42134211
json_t *info = json_object();
42144212
json_object_set_new(info, "media", json_string("audio"));
@@ -4233,16 +4231,17 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
42334231
json_object_set_new(info, "nacks-sent", json_integer(stream->component->out_stats.audio.nacks));
42344232
json_object_set_new(info, "retransmissions-received", json_integer(stream->audio_rtcp_ctx->retransmitted));
42354233
}
4236-
if(combined_event != NULL) {
4234+
/* Shall we send dedicated events per media or one per PeerConnection? */
4235+
if(combine) {
4236+
if(combined_event == NULL)
4237+
combined_event = json_array();
42374238
json_array_append_new(combined_event, info);
42384239
} else {
42394240
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,
42404241
session->session_id, handle->handle_id, handle->opaque_id, info);
42414242
}
42424243
}
4243-
}
4244-
/* Do the same for video */
4245-
if(janus_events_is_enabled() && janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_HAS_VIDEO)) {
4244+
/* Do the same for video */
42464245
int vindex=0;
42474246
for(vindex=0; vindex<3; vindex++) {
42484247
if(stream && stream->video_rtcp_ctx[vindex]) {
@@ -4277,7 +4276,10 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
42774276
json_object_set_new(info, "nacks-sent", json_integer(stream->component->out_stats.video[vindex].nacks));
42784277
json_object_set_new(info, "retransmissions-received", json_integer(stream->video_rtcp_ctx[vindex]->retransmitted));
42794278
}
4280-
if(combined_event) {
4279+
/* Shall we send dedicated events per media or one per PeerConnection? */
4280+
if(combine) {
4281+
if(combined_event == NULL)
4282+
combined_event = json_array();
42814283
json_array_append_new(combined_event, info);
42824284
} else {
42834285
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,

0 commit comments

Comments
 (0)