@@ -4204,11 +4204,9 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
4204
4204
if (janus_ice_event_stats_period > 0 && handle -> last_event_stats >= janus_ice_event_stats_period ) {
4205
4205
handle -> last_event_stats = 0 ;
4206
4206
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 */
4212
4210
if (stream && stream -> audio_rtcp_ctx ) {
4213
4211
json_t * info = json_object ();
4214
4212
json_object_set_new (info , "media" , json_string ("audio" ));
@@ -4233,16 +4231,17 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
4233
4231
json_object_set_new (info , "nacks-sent" , json_integer (stream -> component -> out_stats .audio .nacks ));
4234
4232
json_object_set_new (info , "retransmissions-received" , json_integer (stream -> audio_rtcp_ctx -> retransmitted ));
4235
4233
}
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 ();
4237
4238
json_array_append_new (combined_event , info );
4238
4239
} else {
4239
4240
janus_events_notify_handlers (JANUS_EVENT_TYPE_MEDIA , JANUS_EVENT_SUBTYPE_MEDIA_STATS ,
4240
4241
session -> session_id , handle -> handle_id , handle -> opaque_id , info );
4241
4242
}
4242
4243
}
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 */
4246
4245
int vindex = 0 ;
4247
4246
for (vindex = 0 ; vindex < 3 ; vindex ++ ) {
4248
4247
if (stream && stream -> video_rtcp_ctx [vindex ]) {
@@ -4277,7 +4276,10 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
4277
4276
json_object_set_new (info , "nacks-sent" , json_integer (stream -> component -> out_stats .video [vindex ].nacks ));
4278
4277
json_object_set_new (info , "retransmissions-received" , json_integer (stream -> video_rtcp_ctx [vindex ]-> retransmitted ));
4279
4278
}
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 ();
4281
4283
json_array_append_new (combined_event , info );
4282
4284
} else {
4283
4285
janus_events_notify_handlers (JANUS_EVENT_TYPE_MEDIA , JANUS_EVENT_SUBTYPE_MEDIA_STATS ,
0 commit comments