From 7a969dbd7a60aff6faf9d268c0eec0c6bac1382b Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 23 Apr 2015 16:45:09 +0200 Subject: [PATCH] linphonecore: add linphone_call_stats_get_rtp_stats API to easily retrieve rtp stats --- coreapi/linphonecall.c | 28 ++++++++++++++++------------ coreapi/linphonecore.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 894d8cd08..4c149b6a2 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -3267,23 +3267,27 @@ float linphone_call_stats_get_receiver_interarrival_jitter(const LinphoneCallSta return (float)report_block_get_interarrival_jitter(rrb) / (float)pt->clock_rate; } +rtp_stats_t linphone_call_stats_get_rtp_stats(const LinphoneCallStats *stats, LinphoneCall *call) { + rtp_stats_t rtp_stats; + memset(&rtp_stats, 0, sizeof(rtp_stats)); + + if (stats && call) { + if (stats->type == LINPHONE_CALL_STATS_AUDIO && call->audiostream != NULL) + audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats); + #ifdef VIDEO_ENABLED + else if (call->videostream != NULL) + video_stream_get_local_rtp_stats(call->videostream, &rtp_stats); + #endif + } + return rtp_stats; +} + /** * Gets the cumulative number of late packets * @return The cumulative number of late packets **/ uint64_t linphone_call_stats_get_late_packets_cumulative_number(const LinphoneCallStats *stats, LinphoneCall *call) { - rtp_stats_t rtp_stats; - - if (!stats || !call) - return 0; - memset(&rtp_stats, 0, sizeof(rtp_stats)); - if (stats->type == LINPHONE_CALL_STATS_AUDIO && call->audiostream != NULL) - audio_stream_get_local_rtp_stats(call->audiostream, &rtp_stats); -#ifdef VIDEO_ENABLED - else if (call->videostream != NULL) - video_stream_get_local_rtp_stats(call->videostream, &rtp_stats); -#endif - return rtp_stats.outoftime; + return linphone_call_stats_get_rtp_stats(stats, call).outoftime; } /** diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 662637bba..c2488a050 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -561,6 +561,7 @@ LINPHONE_PUBLIC float linphone_call_stats_get_sender_loss_rate(const LinphoneCal LINPHONE_PUBLIC float linphone_call_stats_get_receiver_loss_rate(const LinphoneCallStats *stats); LINPHONE_PUBLIC float linphone_call_stats_get_sender_interarrival_jitter(const LinphoneCallStats *stats, LinphoneCall *call); LINPHONE_PUBLIC float linphone_call_stats_get_receiver_interarrival_jitter(const LinphoneCallStats *stats, LinphoneCall *call); +LINPHONE_PUBLIC rtp_stats_t linphone_call_stats_get_rtp_stats(const LinphoneCallStats *statss, LinphoneCall *call); LINPHONE_PUBLIC uint64_t linphone_call_stats_get_late_packets_cumulative_number(const LinphoneCallStats *stats, LinphoneCall *call); LINPHONE_PUBLIC float linphone_call_stats_get_download_bandwidth(const LinphoneCallStats *stats); LINPHONE_PUBLIC float linphone_call_stats_get_upload_bandwidth(const LinphoneCallStats *stats);