diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c
index ea0676b6d..eb6f3ed76 100644
--- a/coreapi/linphonecall.c
+++ b/coreapi/linphonecall.c
@@ -784,6 +784,10 @@ static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from,
/*by default local_audio_ip=local_video_ip=local_ip*/
strncpy(call->local_audio_ip,call->localip,sizeof(call->local_audio_ip));
strncpy(call->local_video_ip,call->localip,sizeof(call->local_video_ip));
+#ifdef ANDROID
+ ms_message("Call [%p] aquires wifi lock");
+ linphone_core_wifi_lock_aquire(call->lc);
+#endif
}
void linphone_call_init_stats(LinphoneCallStats *stats, int type) {
@@ -1328,6 +1332,10 @@ static void linphone_call_destroy(LinphoneCall *obj){
}
sal_error_info_reset(&obj->non_op_error);
+ #ifdef ANDROID
+ ms_message("Call [%p] releases wifi lock");
+ linphone_core_wifi_lock_release(obj->lc);
+ #endif
}
/**
diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index 2a951a18c..59209d868 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -7321,3 +7321,17 @@ void linphone_core_enable_video_multicast(LinphoneCore *lc, bool_t yesno) {
bool_t linphone_core_video_multicast_enabled(const LinphoneCore *lc) {
return lc->rtp_conf.video_multicast_enabled;
}
+#ifdef ANDROID
+void linphone_core_wifi_lock_acquire(LinphoneCore *lc) {
+ JNIEnv *env=ms_get_jni_env();
+ if (env && lc->wifi_lock)
+ env->CallVoidMethod(lc->wifi_lock,lc->wifi_lock_aquire_id);
+}
+void linphone_core_wifi_lock_release(LinphoneCore *lc) {
+ JNIEnv *env=ms_get_jni_env();
+ if (env && lc->wifi_lock)
+ env->CallVoidMethod(lc->wifi_lock,lc->wifi_lock_release_id);
+
+}
+#endif
+
diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h
index 999bf4823..e8ab365c6 100644
--- a/coreapi/linphonecore.h
+++ b/coreapi/linphonecore.h
@@ -3374,6 +3374,8 @@ LINPHONE_PUBLIC int linphone_core_get_video_multicast_ttl(const LinphoneCore *co
/**
* Use to enable multicast rtp for audio stream.
+ * * If enable, outgoing calls put a multicast address from #linphone_core_get_video_multicast_addr into audio cline. In case of outgoing call audio stream is sent to this multicast address.
+ *
For incoming calls behavior is unchanged.
* @param core the core
* @param yesno if yes, subsequent calls propose multicast ip set by #linphone_core_set_audio_multicast_addr
* @return an ipv4/6 multicast address or null
@@ -3391,8 +3393,10 @@ LINPHONE_PUBLIC bool_t linphone_core_audio_multicast_enabled(const LinphoneCore
/**
* Use to enable multicast rtp for video stream.
+ * If enable, outgoing calls put a multicast address from #linphone_core_get_video_multicast_addr into video cline. In case of outgoing call video stream is sent to this a multicast address.
+ *
For incoming calls behavior is unchanged.
* @param core the core
- * @param yesno if yes, subsequent calls propose multicast ip set by #linphone_core_set_video_multicast_addr
+ * @param yesno if yes, subsequent outgoing calls propose multicast ip set by #linphone_core_set_video_multicast_addr
* @ingroup media_parameters
**/
LINPHONE_PUBLIC void linphone_core_enable_video_multicast(LinphoneCore *core, bool_t yesno);
diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc
index b159050f0..80c105b37 100644
--- a/coreapi/linphonecore_jni.cc
+++ b/coreapi/linphonecore_jni.cc
@@ -3979,6 +3979,22 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidPowerManager(J
#endif
}
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAndroidWifiLock(JNIEnv *env, jobject thiz, jlong lc, jobject wifi_lock) {
+#ifdef ANDROID
+ if (lc->wifi_lock)
+ env->DeleteGlobalRef(lc->wifi_lock);
+ if(wm != NULL) {
+ lc->wifi_lock=env->NewGlobalRef(wifi_lock);
+ jclass wifiLockClass = env->FindClass(env, "android/net/wifi/WifiManager/WifiLock");
+ lc->wifi_lock_aquire_id = env->GetMethodID(wifiLockClass, "acquire", "()V");
+ lc->wifi_lock_release_id = env->GetMethodID(wifiLockClass, "release", "()V");
+ } else {
+ lc->wifi_manager=NULL;
+ }
+
+#endif
+}
+
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getAudioDscp(JNIEnv* env,jobject thiz,jlong ptr){
return linphone_core_get_audio_dscp((LinphoneCore*)ptr);
}
diff --git a/coreapi/private.h b/coreapi/private.h
index 18feea39f..83d41ae7f 100644
--- a/coreapi/private.h
+++ b/coreapi/private.h
@@ -78,7 +78,9 @@ extern "C" {
#define ngettext(singular, plural, number) (((number)==1)?(singular):(plural))
#endif
#endif
-
+#ifdef ANDROID
+#include
+#endif
struct _LinphoneCallParams{
belle_sip_object_t base;
@@ -796,6 +798,11 @@ struct _LinphoneCore
const char **supported_formats;
LinphoneContent *log_collection_upload_information;
LinphoneCoreVTable *current_vtable; // the latest vtable to call a callback, see linphone_core_get_current_vtable
+#ifdef ANDROID
+ jobject wifi_lock;
+ jmethodID wifi_lock_acquire_id;
+ jmethodID wifi_lock_release_id;
+#endif
};
@@ -1092,6 +1099,11 @@ void linphone_core_notify_log_collection_upload_progress_indication(LinphoneCore
void set_mic_gain_db(AudioStream *st, float gain);
void set_playback_gain_db(AudioStream *st, float gain);
+#ifdef ANDROID
+void linphone_core_wifi_lock_acquire(LinphoneCore *lc);
+void linphone_core_wifi_lock_release(LinphoneCore *lc);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java
index d69d53ef0..d210be6fa 100644
--- a/java/impl/org/linphone/core/LinphoneCoreImpl.java
+++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java
@@ -157,6 +157,7 @@ public class LinphoneCoreImpl implements LinphoneCore {
private native boolean isSdp200AckEnabled(long nativePtr);
private native void stopRinging(long nativePtr);
private native static void setAndroidPowerManager(Object pm);
+ private native void setAndroidWifiLock(long nativePtr,Object pm);
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig, File factoryConfig, Object userdata) throws IOException {
mListener = listener;
@@ -184,6 +185,10 @@ public class LinphoneCoreImpl implements LinphoneCore {
mContext = (Context)context;
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
setAndroidPowerManager(mContext.getSystemService(Context.POWER_SERVICE));
+ if (Version.sdkAboveOrEqual(Version.API12_HONEYCOMB_MR1_31X)) {
+ WifiManager wifiManager=(WifiManager) getSystemService(Context.WIFI_SERVICE);
+ setAndroidWifiLock(nativePtr,wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, this.getPackageName()+"-"+nativePtr+"-wifi-call-lock"));
+ }
}
public synchronized void addAuthInfo(LinphoneAuthInfo info) {