]> sjero.net Git - linphone/blob - java/impl/org/linphone/core/LinphoneCallStatsImpl.java
add jni and java accessors for realtime late and loss rates
[linphone] / java / impl / org / linphone / core / LinphoneCallStatsImpl.java
1 /*
2 LinPhoneCallStatsImpl.java
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19 package org.linphone.core;
20
21
22 class LinphoneCallStatsImpl implements LinphoneCallStats {
23         private int mediaType;
24         private int iceState;
25         private float downloadBandwidth;
26         private float uploadBandwidth;
27         private float senderLossRate;
28         private float receiverLossRate;
29         private float senderInterarrivalJitter;
30         private float receiverInterarrivalJitter;
31         private float roundTripDelay;
32         private long latePacketsCumulativeNumber;
33         private float jitterBufferSize;
34         private float localLossRate;
35         private float localLateRate;
36         private long nativePtr;
37
38         private native int getMediaType(long nativeStatsPtr);
39         private native int getIceState(long nativeStatsPtr);
40         private native float getDownloadBandwidth(long nativeStatsPtr);
41         private native float getUploadBandwidth(long nativeStatsPtr);
42         private native float getSenderLossRate(long nativeStatsPtr);
43         private native float getReceiverLossRate(long nativeStatsPtr);
44         private native float getSenderInterarrivalJitter(long nativeStatsPtr, long nativeCallPtr);
45         private native float getReceiverInterarrivalJitter(long nativeStatsPtr, long nativeCallPtr);
46         private native float getRoundTripDelay(long nativeStatsPtr);
47         private native long getLatePacketsCumulativeNumber(long nativeStatsPtr, long nativeCallPtr);
48         private native float getJitterBufferSize(long nativeStatsPtr);
49         private native float getLocalLossRate(long nativeStatsPtr);
50         private native float getLocalLateRate(long nativeStatsPtr);
51         private native void updateStats(long nativeCallPtr, int mediaType);
52
53         protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) {
54                 nativePtr=nativeStatsPtr;
55                 mediaType = getMediaType(nativeStatsPtr);
56                 iceState = getIceState(nativeStatsPtr);
57                 downloadBandwidth = getDownloadBandwidth(nativeStatsPtr);
58                 uploadBandwidth = getUploadBandwidth(nativeStatsPtr);
59                 senderLossRate = getSenderLossRate(nativeStatsPtr);
60                 receiverLossRate = getReceiverLossRate(nativeStatsPtr);
61                 senderInterarrivalJitter = getSenderInterarrivalJitter(nativeStatsPtr, nativeCallPtr);
62                 receiverInterarrivalJitter = getReceiverInterarrivalJitter(nativeStatsPtr, nativeCallPtr);
63                 roundTripDelay = getRoundTripDelay(nativeStatsPtr);
64                 latePacketsCumulativeNumber = getLatePacketsCumulativeNumber(nativeStatsPtr, nativeCallPtr);
65                 jitterBufferSize = getJitterBufferSize(nativeStatsPtr);
66                 
67         }
68
69         protected void updateRealTimeStats(LinphoneCall call){
70                 updateStats( ((LinphoneCallImpl)call).nativePtr, mediaType);
71                 localLossRate=getLocalLossRate(nativePtr);
72                 localLateRate=getLocalLateRate(nativePtr);
73         }
74
75         public MediaType getMediaType() {
76                 return MediaType.fromInt(mediaType);
77         }
78
79         public IceState getIceState() {
80                 return IceState.fromInt(iceState);
81         }
82
83         public float getDownloadBandwidth() {
84                 return downloadBandwidth;
85         }
86
87         public float getUploadBandwidth() {
88                 return uploadBandwidth;
89         }
90
91         public float getSenderLossRate() {
92                 return senderLossRate;
93         }
94
95         public float getReceiverLossRate() {
96                 return receiverLossRate;
97         }
98
99         public float getSenderInterarrivalJitter() {
100                 return senderInterarrivalJitter;
101         }
102
103         public float getReceiverInterarrivalJitter() {
104                 return receiverInterarrivalJitter;
105         }
106
107         public float getRoundTripDelay() {
108                 return roundTripDelay;
109         }
110
111         public long getLatePacketsCumulativeNumber() {
112                 return latePacketsCumulativeNumber;
113         }
114
115         public float getJitterBufferSize() {
116                 return jitterBufferSize;
117         }
118
119         public float getLocalLossRate(){
120                 return localLossRate;
121         }
122
123         public float getLocalLateRate(){
124                 return localLateRate;
125         }
126 }