1 /*
2 call_stats.h
3 Copyright (C) 2010-2016 Belledonne Communications SARL
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 */
19 
20 #ifndef LINPHONE_CALL_STATS_H
21 #define LINPHONE_CALL_STATS_H
22 
23 #include "linphone/types.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /**
30  * @addtogroup call_misc
31  * @{
32  */
33 
34 #define LINPHONE_CALL_STATS_AUDIO ((int)LinphoneStreamTypeAudio)
35 #define LINPHONE_CALL_STATS_VIDEO ((int)LinphoneStreamTypeVideo)
36 #define LINPHONE_CALL_STATS_TEXT  ((int)LinphoneStreamTypeText)
37 
38 #define LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE (1 << 0) /**< received_rtcp field of LinphoneCallStats object has been updated */
39 #define LINPHONE_CALL_STATS_SENT_RTCP_UPDATE (1 << 1) /**< sent_rtcp field of LinphoneCallStats object has been updated */
40 #define LINPHONE_CALL_STATS_PERIODICAL_UPDATE (1 << 2) /**< Every seconds LinphoneCallStats object has been updated */
41 
42 /**
43  * Increment refcount.
44  * @param[in] stats LinphoneCallStats object
45  * @ingroup misc
46 **/
47 LINPHONE_PUBLIC LinphoneCallStats *linphone_call_stats_ref(LinphoneCallStats *stats);
48 
49 /**
50  * Decrement refcount and possibly free the object.
51  * @param[in] stats LinphoneCallStats object
52  * @ingroup misc
53 **/
54 LINPHONE_PUBLIC void linphone_call_stats_unref(LinphoneCallStats *stats);
55 
56 /**
57  * Gets the user data in the LinphoneCallStats object
58  * @param[in] stats the LinphoneCallStats
59  * @return the user data
60  * @ingroup misc
61 */
62 LINPHONE_PUBLIC void *linphone_call_stats_get_user_data(const LinphoneCallStats *stats);
63 
64 /**
65  * Sets the user data in the LinphoneCallStats object
66  * @param[in] stats the LinphoneCallStats object
67  * @param[in] data the user data
68  * @ingroup misc
69 */
70 LINPHONE_PUBLIC void linphone_call_stats_set_user_data(LinphoneCallStats *stats, void *data);
71 
72 /**
73  * Get the type of the stream the stats refer to.
74  * @param[in] stats LinphoneCallStats object
75  * @return The type of the stream the stats refer to
76  */
77 LINPHONE_PUBLIC LinphoneStreamType linphone_call_stats_get_type(const LinphoneCallStats *stats);
78 
79 /**
80  * Get the local loss rate since last report
81  * @return The sender loss rate
82 **/
83 LINPHONE_PUBLIC float linphone_call_stats_get_sender_loss_rate(const LinphoneCallStats *stats);
84 
85 /**
86  * Gets the remote reported loss rate since last report
87  * @return The receiver loss rate
88 **/
89 LINPHONE_PUBLIC float linphone_call_stats_get_receiver_loss_rate(const LinphoneCallStats *stats);
90 
91 /**
92  * Get the local loss rate since last report
93  * @return The local loss rate
94 **/
95 LINPHONE_PUBLIC float linphone_call_stats_get_local_loss_rate(const LinphoneCallStats *stats);
96 
97 /**
98  * Gets the local late rate since last report
99  * @return The local late rate
100 **/
101 LINPHONE_PUBLIC float linphone_call_stats_get_local_late_rate(const LinphoneCallStats *stats);
102 
103 /**
104  * Gets the local interarrival jitter
105  * @param[in] stats LinphoneCallStats object
106  * @return The interarrival jitter at last emitted sender report
107 **/
108 LINPHONE_PUBLIC float linphone_call_stats_get_sender_interarrival_jitter(const LinphoneCallStats *stats);
109 
110 /**
111  * Gets the remote reported interarrival jitter
112  * @param[in] stats LinphoneCallStats object
113  * @return The interarrival jitter at last received receiver report
114 **/
115 LINPHONE_PUBLIC float linphone_call_stats_get_receiver_interarrival_jitter(const LinphoneCallStats *stats);
116 
117 LINPHONE_PUBLIC const rtp_stats_t *linphone_call_stats_get_rtp_stats(const LinphoneCallStats *stats);
118 
119 /**
120  * Gets the cumulative number of late packets
121  * @param[in] stats LinphoneCallStats object
122  * @return The cumulative number of late packets
123 **/
124 LINPHONE_PUBLIC uint64_t linphone_call_stats_get_late_packets_cumulative_number(const LinphoneCallStats *stats);
125 
126 /**
127  * Get the bandwidth measurement of the received stream, expressed in kbit/s, including IP/UDP/RTP headers.
128  * @param[in] stats LinphoneCallStats object
129  * @return The bandwidth measurement of the received stream in kbit/s.
130  */
131 LINPHONE_PUBLIC float linphone_call_stats_get_download_bandwidth(const LinphoneCallStats *stats);
132 
133 /**
134  * Get the bandwidth measurement of the sent stream, expressed in kbit/s, including IP/UDP/RTP headers.
135  * @param[in] stats LinphoneCallStats object
136  * @return The bandwidth measurement of the sent stream in kbit/s.
137  */
138 LINPHONE_PUBLIC float linphone_call_stats_get_upload_bandwidth(const LinphoneCallStats *stats);
139 
140 /**
141  * Get the state of ICE processing.
142  * @param[in] stats LinphoneCallStats object
143  * @return The state of ICE processing.
144  */
145 LINPHONE_PUBLIC LinphoneIceState linphone_call_stats_get_ice_state(const LinphoneCallStats *stats);
146 
147 /**
148  * Get the state of uPnP processing.
149  * @param[in] stats LinphoneCallStats object
150  * @return The state of uPnP processing.
151  */
152 LINPHONE_PUBLIC LinphoneUpnpState linphone_call_stats_get_upnp_state(const LinphoneCallStats *stats);
153 
154 /**
155  * Get the IP address family of the remote peer.
156  * @param[in] stats LinphoneCallStats object
157  * @return The IP address family of the remote peer.
158  */
159 LINPHONE_PUBLIC LinphoneAddressFamily linphone_call_stats_get_ip_family_of_remote(const LinphoneCallStats *stats);
160 
161 /**
162  * Get the jitter buffer size in ms.
163  * @param[in] stats LinphoneCallStats object
164  * @return The jitter buffer size in ms.
165  */
166 LINPHONE_PUBLIC float linphone_call_stats_get_jitter_buffer_size_ms(const LinphoneCallStats *stats);
167 
168 /**
169  * Get the round trip delay in s.
170  * @param[in] stats LinphoneCallStats object
171  * @return The round trip delay in s.
172  */
173 LINPHONE_PUBLIC float linphone_call_stats_get_round_trip_delay(const LinphoneCallStats *stats);
174 
175 /**
176  * @}
177  */
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif /* LINPHONE_ADDRESS_H */
184