mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-30 17:36:22 +00:00
add Android wifi lock management at LinphoneCall level
This commit is contained in:
parent
5dc7fa8d1a
commit
3e1a1430f4
6 changed files with 61 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
* <br> 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.
|
||||
* <br> 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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ extern "C" {
|
|||
#define ngettext(singular, plural, number) (((number)==1)?(singular):(plural))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <jni.h>
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue