Skip to content

Commit 72dc3a6

Browse files
committed
Send data stats when using event handlers (see #3126)
1 parent d08ee9f commit 72dc3a6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ice.c

+22
Original file line numberDiff line numberDiff line change
@@ -4602,6 +4602,28 @@ static gboolean janus_ice_outgoing_stats_handle(gpointer user_data) {
46024602
}
46034603
}
46044604
}
4605+
#ifdef HAVE_SCTP
4606+
/* Finally, send data stats */
4607+
if(janus_flags_is_set(&handle->webrtc_flags, JANUS_ICE_HANDLE_WEBRTC_DATA_CHANNELS)) {
4608+
json_t *info = json_object();
4609+
json_object_set_new(info, "media", json_string("data"));
4610+
if(stream->component) {
4611+
json_object_set_new(info, "packets-received", json_integer(stream->component->in_stats.data.packets));
4612+
json_object_set_new(info, "packets-sent", json_integer(stream->component->out_stats.data.packets));
4613+
json_object_set_new(info, "bytes-received", json_integer(stream->component->in_stats.data.bytes));
4614+
json_object_set_new(info, "bytes-sent", json_integer(stream->component->out_stats.data.bytes));
4615+
}
4616+
/* Shall we send dedicated events per media or one per PeerConnection? */
4617+
if(combine) {
4618+
if(combined_event == NULL)
4619+
combined_event = json_array();
4620+
json_array_append_new(combined_event, info);
4621+
} else {
4622+
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,
4623+
session->session_id, handle->handle_id, handle->opaque_id, info);
4624+
}
4625+
}
4626+
#endif
46054627
if(combined_event) {
46064628
janus_events_notify_handlers(JANUS_EVENT_TYPE_MEDIA, JANUS_EVENT_SUBTYPE_MEDIA_STATS,
46074629
session->session_id, handle->handle_id, handle->opaque_id, combined_event);

0 commit comments

Comments
 (0)