]> sjero.net Git - linphone/commitdiff
add jni and java accessors for realtime late and loss rates
authorSimon Morlat <simon.morlat@linphone.org>
Tue, 9 Apr 2013 13:52:30 +0000 (15:52 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Tue, 9 Apr 2013 13:52:30 +0000 (15:52 +0200)
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneCallStats.java
java/impl/org/linphone/core/LinphoneCallImpl.java
java/impl/org/linphone/core/LinphoneCallStatsImpl.java
mediastreamer2

index 6b6c3f5ce8c640bdf4c2e1cdddb4996a300bd16a..ddc26f657146565bb40605b052a63e85650b41fe 100644 (file)
@@ -1578,6 +1578,23 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getJitterBufferSi
        return (jfloat)((LinphoneCallStats *)stats_ptr)->jitter_stats.jitter_buffer_size_ms;
 }
 
+extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLossRate(JNIEnv *env, jobject thiz,jlong stats_ptr) {
+       const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
+       return stats->local_loss_rate;
+}
+
+extern "C" jfloat Java_org_linphone_core_LinphoneCallStatsImpl_getLocalLateRate(JNIEnv *env, jobject thiz, jlong stats_ptr) {
+       const LinphoneCallStats *stats = (LinphoneCallStats *)stats_ptr;
+       return stats->local_late_rate;
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCallStatsImpl_updateStats(JNIEnv *env, jobject thiz, jlong call_ptr, jint mediatype) {
+       if (mediatype==LINPHONE_CALL_STATS_AUDIO)
+               linphone_call_get_audio_stats((LinphoneCall*)call_ptr);
+       else 
+               linphone_call_get_video_stats((LinphoneCall*)call_ptr);
+}
+
 /*payloadType*/
 extern "C" jstring Java_org_linphone_core_PayloadTypeImpl_toString(JNIEnv*  env,jobject  thiz,jlong ptr) {
        PayloadType* pt = (PayloadType*)ptr;
@@ -1702,7 +1719,6 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality(      JNI
        return (jfloat)linphone_call_get_average_quality((LinphoneCall*)ptr);
 }
 
-
 //LinphoneFriend
 extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
                                                                                                                                                ,jobject  thiz
index f1248c445540e0ae070ef99ce153a7e5a9dd7ba1..295c99484105b96e51e76dd5ad2618ac3938c03f 100644 (file)
@@ -121,25 +121,25 @@ public interface LinphoneCallStats {
        public float getUploadBandwidth();
 
        /**
-        * Get the sender loss rate since last report
+        * Get the local loss rate since last report
         * @return The sender loss rate
         */
        public float getSenderLossRate();
 
        /**
-        * Get the receiver loss rate since last report
+        * Get the remote reported loss rate since last report
         * @return The receiver loss rate
         */
        public float getReceiverLossRate();
 
        /**
-        * Get the sender interarrival jitter
+        * Get the local interarrival jitter
         * @return The interarrival jitter at last emitted sender report
         */
        public float getSenderInterarrivalJitter();
 
        /**
-        * Get the receiver interarrival jitter
+        * Get the remote reported interarrival jitter
         * @return The interarrival jitter at last received receiver report
         */
        public float getReceiverInterarrivalJitter();
@@ -161,4 +161,16 @@ public interface LinphoneCallStats {
         * @return The jitter buffer size in milliseconds
         */
        public float getJitterBufferSize();
+
+       /**
+        * Get the local loss rate. Unlike getSenderLossRate() that returns this loss rate "since last emitted RTCP report", the value returned here is updated every second.
+        * @return The local loss rate percentage.
+       **/
+       public float getLocalLossRate();
+
+       /**
+        * Get the local late packets rate. The value returned here is updated every second.
+        * @return The local late rate percentage.
+       **/
+       public float getLocalLateRate();
 }
index 30bcd528fce17e94ec46bd94c393513cc7962d50..041acaef226a79ff7efcbba7974f3e4addd6126d 100644 (file)
@@ -68,9 +68,11 @@ class LinphoneCallImpl implements LinphoneCall {
                videoStats = stats;
        }
        public LinphoneCallStats getAudioStats() {
+               if (audioStats!=null) ((LinphoneCallStatsImpl)audioStats).updateRealTimeStats(this);
                return audioStats;
        }
        public LinphoneCallStats getVideoStats() {
+               if (videoStats!=null) ((LinphoneCallStatsImpl)videoStats).updateRealTimeStats(this);
                return videoStats;
        }
        public CallDirection getDirection() {
index 53fcb5ffd5fe701d54b0802e9d5a34e57cb35dee..4657ba01aefe773118a4364bb68925d00aa170b9 100644 (file)
@@ -31,6 +31,9 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
        private float roundTripDelay;
        private long latePacketsCumulativeNumber;
        private float jitterBufferSize;
+       private float localLossRate;
+       private float localLateRate;
+       private long nativePtr;
 
        private native int getMediaType(long nativeStatsPtr);
        private native int getIceState(long nativeStatsPtr);
@@ -43,8 +46,12 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
        private native float getRoundTripDelay(long nativeStatsPtr);
        private native long getLatePacketsCumulativeNumber(long nativeStatsPtr, long nativeCallPtr);
        private native float getJitterBufferSize(long nativeStatsPtr);
+       private native float getLocalLossRate(long nativeStatsPtr);
+       private native float getLocalLateRate(long nativeStatsPtr);
+       private native void updateStats(long nativeCallPtr, int mediaType);
 
        protected LinphoneCallStatsImpl(long nativeCallPtr, long nativeStatsPtr) {
+               nativePtr=nativeStatsPtr;
                mediaType = getMediaType(nativeStatsPtr);
                iceState = getIceState(nativeStatsPtr);
                downloadBandwidth = getDownloadBandwidth(nativeStatsPtr);
@@ -56,6 +63,13 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
                roundTripDelay = getRoundTripDelay(nativeStatsPtr);
                latePacketsCumulativeNumber = getLatePacketsCumulativeNumber(nativeStatsPtr, nativeCallPtr);
                jitterBufferSize = getJitterBufferSize(nativeStatsPtr);
+               
+       }
+
+       protected void updateRealTimeStats(LinphoneCall call){
+               updateStats( ((LinphoneCallImpl)call).nativePtr, mediaType);
+               localLossRate=getLocalLossRate(nativePtr);
+               localLateRate=getLocalLateRate(nativePtr);
        }
 
        public MediaType getMediaType() {
@@ -101,4 +115,12 @@ class LinphoneCallStatsImpl implements LinphoneCallStats {
        public float getJitterBufferSize() {
                return jitterBufferSize;
        }
+
+       public float getLocalLossRate(){
+               return localLossRate;
+       }
+
+       public float getLocalLateRate(){
+               return localLateRate;
+       }
 }
index abf2a7ec461ac411703233e3554e985d62fa0b9c..4f93003c1eade1442fdedd8dee10f18c98ec47c3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit abf2a7ec461ac411703233e3554e985d62fa0b9c
+Subproject commit 4f93003c1eade1442fdedd8dee10f18c98ec47c3