From 7ac6a838d4fb2f0e16850a265ad5392923f71488 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 11 Jun 2015 15:21:02 +0200 Subject: [PATCH] Add linphone_core_get_video_preset() + Add JNI wrapper for some core functions. --- coreapi/linphonecore.c | 6 +++++- coreapi/linphonecore.h | 7 +++++++ coreapi/linphonecore_jni.cc | 13 +++++++++++++ .../common/org/linphone/core/LinphoneCore.java | 18 ++++++++++++++++++ .../org/linphone/core/LinphoneCoreImpl.java | 17 +++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6f79635c8..f83365bb3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7371,7 +7371,11 @@ bool_t linphone_core_video_multicast_enabled(const LinphoneCore *lc) { } void linphone_core_set_video_preset(LinphoneCore *lc, const char *preset) { - lp_config_set_string(lc->config, "video", "preset", NULL); + lp_config_set_string(lc->config, "video", "preset", preset); +} + +const char * linphone_core_get_video_preset(const LinphoneCore *lc) { + return lp_config_get_string(lc->config, "video", "preset", NULL); } #ifdef ANDROID diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 2c6a52276..2467d859e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -3528,6 +3528,13 @@ LINPHONE_PUBLIC const OrtpNetworkSimulatorParams *linphone_core_get_network_simu */ LINPHONE_PUBLIC void linphone_core_set_video_preset(LinphoneCore *lc, const char *preset); +/** + * Get the video preset used for video calls. + * @param[in] lc LinphoneCore object + * @return The name of the video preset used for video calls (can be NULL if the default video preset is used). + */ +LINPHONE_PUBLIC const char * linphone_core_get_video_preset(const LinphoneCore *lc); + #ifdef __cplusplus } #endif diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index c916ea4d2..ad985aa01 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3805,10 +3805,18 @@ extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSi return arr; } +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc) { + return (jint) linphone_core_get_download_bandwidth((LinphoneCore *)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDownloadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){ linphone_core_set_download_bandwidth((LinphoneCore *)lc, (int) bw); } +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc) { + return (jint) linphone_core_get_upload_bandwidth((LinphoneCore *)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUploadBandwidth(JNIEnv *env, jobject thiz, jlong lc, jint bw){ linphone_core_set_upload_bandwidth((LinphoneCore *)lc, (int) bw); } @@ -6221,3 +6229,8 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoPreset(JN linphone_core_set_video_preset((LinphoneCore *)lc, char_preset); if (char_preset) env->ReleaseStringUTFChars(preset, char_preset); } + +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getVideoPreset(JNIEnv *env, jobject thiz, jlong lc) { + const char *tmp = linphone_core_get_video_preset((LinphoneCore *)lc); + return tmp ? env->NewStringUTF(tmp) : NULL; +} diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 9af7b1309..410c8930e 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1064,7 +1064,18 @@ public interface LinphoneCore { */ void setRingback(String path); + /** + * Retrieve the maximum available upload bandwidth. + **/ + int getUploadBandwidth(); + void setUploadBandwidth(int bw); + + /** + * Retrieve the maximum available download bandwidth. + **/ + int getDownloadBandwidth(); + /** * Sets maximum available download bandwidth * @@ -2041,4 +2052,11 @@ public interface LinphoneCore { * @param preset The name of the video preset to be used (can be null to use the default video preset). */ public void setVideoPreset(String preset); + + /** + * Get the video preset used for video calls. + * @param lc LinphoneCore object + * @return The name of the video preset used for video calls (can be null if the default video preset is used). + */ + public String getVideoPreset(); } diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 84b7915cc..e0f3882bb 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -107,7 +107,9 @@ class LinphoneCoreImpl implements LinphoneCore { private native String getStunServer(long nativePtr); private native long createDefaultCallParams(long nativePtr); private native int updateCall(long ptrLc, long ptrCall, long ptrParams); + private native int getUploadBandwidth(long nativePtr); private native void setUploadBandwidth(long nativePtr, int bw); + private native int getDownloadBandwidth(long nativePtr); private native void setDownloadBandwidth(long nativePtr, int bw); private native void setPreferredVideoSize(long nativePtr, int width, int heigth); private native void setPreferredVideoSizeByName(long nativePtr, String name); @@ -512,10 +514,19 @@ class LinphoneCoreImpl implements LinphoneCore { return updateCall(nativePtr, ptrCall, ptrParams); } + + public synchronized int getUploadBandwidth() { + return getUploadBandwidth(nativePtr); + } + public synchronized void setUploadBandwidth(int bw) { setUploadBandwidth(nativePtr, bw); } + public synchronized int getDownloadBandwidth() { + return getDownloadBandwidth(nativePtr); + } + public synchronized void setDownloadBandwidth(int bw) { setDownloadBandwidth(nativePtr, bw); } @@ -1485,4 +1496,10 @@ class LinphoneCoreImpl implements LinphoneCore { public void setVideoPreset(String preset) { setVideoPreset(nativePtr, preset); } + + private native String getVideoPreset(long nativePtr); + @Override + public String getVideoPreset() { + return getVideoPreset(nativePtr); + } }