static void ng_stats_media(bencode_item_t *list, const struct call_media *m, struct call_stats *totals) { bencode_item_t *dict, *streams = NULL, *flags; GList *l; struct packet_stream *ps; if (!list) goto stats; dict = bencode_list_add_dictionary(list); bencode_dictionary_add_integer(dict, "index", m->index); bencode_dictionary_add_str(dict, "type", &m->type); if (m->protocol) bencode_dictionary_add_string(dict, "protocol", m->protocol->name); streams = bencode_dictionary_add_list(dict, "streams"); flags = bencode_dictionary_add_list(dict, "flags"); BF_M("initialized", INITIALIZED); BF_M("rtcp-mux", RTCP_MUX); BF_M("DTLS-SRTP", DTLS); BF_M("SDES", SDES); BF_M("passthrough", PASSTHRU); BF_M("ICE", ICE); stats: for (l = m->streams.head; l; l = l->next) { ps = l->data; ng_stats_stream(streams, ps, totals); } }
static void ng_stats_stream(bencode_item_t *list, const struct packet_stream *ps, struct call_stats *totals) { bencode_item_t *dict = NULL, *flags; struct stats *s; if (!list) goto stats; dict = bencode_list_add_dictionary(list); if (ps->sfd) bencode_dictionary_add_integer(dict, "local port", ps->sfd->fd.localport); ng_stats_endpoint(bencode_dictionary_add_dictionary(dict, "endpoint"), &ps->endpoint); ng_stats_endpoint(bencode_dictionary_add_dictionary(dict, "advertised endpoint"), &ps->advertised_endpoint); if (ps->crypto.params.crypto_suite) bencode_dictionary_add_string(dict, "crypto suite", ps->crypto.params.crypto_suite->name); bencode_dictionary_add_integer(dict, "last packet", ps->last_packet); flags = bencode_dictionary_add_list(dict, "flags"); BF_PS("RTP", RTP); BF_PS("RTCP", RTCP); BF_PS("fallback RTCP", FALLBACK_RTCP); BF_PS("filled", FILLED); BF_PS("confirmed", CONFIRMED); BF_PS("kernelized", KERNELIZED); BF_PS("no kernel support", NO_KERNEL_SUPPORT); BF_PS("DTLS fingerprint verified", FINGERPRINT_VERIFIED); BF_PS("strict source address", STRICT_SOURCE); BF_PS("media handover", MEDIA_HANDOVER); stats: if (totals->last_packet < ps->last_packet) totals->last_packet = ps->last_packet; /* XXX distinguish between input and output */ s = &totals->totals[0]; if (!PS_ISSET(ps, RTP)) s = &totals->totals[1]; ng_stats(bencode_dictionary_add_dictionary(dict, "stats"), &ps->stats, s); }