mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 21:28:08 +00:00
Add NAT policy JNI wrapper.
This commit is contained in:
parent
69b99e2e4e
commit
94695d4774
7 changed files with 421 additions and 15 deletions
|
|
@ -282,16 +282,19 @@ public:
|
|||
chatRoomClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatRoomImpl"));
|
||||
chatRoomCtrId = env->GetMethodID(chatRoomClass,"<init>", "(J)V");
|
||||
|
||||
friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));;
|
||||
friendClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendImpl"));
|
||||
friendCtrId = env->GetMethodID(friendClass,"<init>", "(J)V");
|
||||
|
||||
friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl"));;
|
||||
friendListClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendListImpl"));
|
||||
friendListCtrId = env->GetMethodID(friendListClass,"<init>", "(J)V");
|
||||
friendListCreatedId = env->GetMethodID(listenerClass, "friendListCreated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V");
|
||||
friendListRemovedId = env->GetMethodID(listenerClass, "friendListRemoved", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriendList;)V");
|
||||
friendListSyncStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneFriendList$State"));
|
||||
friendListSyncStateFromIntId = env->GetStaticMethodID(friendListSyncStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneFriendList$State;");
|
||||
|
||||
natPolicyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneNatPolicyImpl"));
|
||||
natPolicyCtrId = env->GetMethodID(natPolicyClass, "<init>", "(J)V");
|
||||
|
||||
addressClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAddressImpl"));
|
||||
addressCtrId = env->GetMethodID(addressClass,"<init>", "(J)V");
|
||||
|
||||
|
|
@ -412,6 +415,9 @@ public:
|
|||
jclass friendListSyncStateClass;
|
||||
jmethodID friendListSyncStateFromIntId;
|
||||
|
||||
jclass natPolicyClass;
|
||||
jmethodID natPolicyCtrId;
|
||||
|
||||
jclass addressClass;
|
||||
jmethodID addressCtrId;
|
||||
|
||||
|
|
@ -599,6 +605,29 @@ jobject getFriendList(JNIEnv *env, LinphoneFriendList *lfriendList){
|
|||
return jobj;
|
||||
}
|
||||
|
||||
jobject getNatPolicy(JNIEnv *env, LinphoneNatPolicy *lNatPolicy) {
|
||||
jobject jobj = 0;
|
||||
|
||||
if (lNatPolicy != NULL) {
|
||||
LinphoneCore *lc = lNatPolicy->lc;
|
||||
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
|
||||
|
||||
void *up = linphone_nat_policy_get_user_data(lNatPolicy);
|
||||
if (up == NULL) {
|
||||
jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy);
|
||||
linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj));
|
||||
linphone_nat_policy_ref(lNatPolicy);
|
||||
} else {
|
||||
jobj = env->NewLocalRef((jobject)up);
|
||||
if (jobj == NULL) {
|
||||
jobj = env->NewObject(ljb->natPolicyClass, ljb->natPolicyCtrId, (jlong)lNatPolicy);
|
||||
linphone_nat_policy_set_user_data(lNatPolicy, (void *)env->NewWeakGlobalRef(jobj));
|
||||
}
|
||||
}
|
||||
}
|
||||
return jobj;
|
||||
}
|
||||
|
||||
jobject getEvent(JNIEnv *env, LinphoneEvent *lev){
|
||||
if (lev==NULL) return NULL;
|
||||
jobject jev=(jobject)linphone_event_get_user_data(lev);
|
||||
|
|
@ -4340,6 +4369,21 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv
|
|||
return (jint)linphone_core_get_firewall_policy((LinphoneCore*)lc);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createNatPolicy(JNIEnv *env, jobject thiz, jlong lc) {
|
||||
LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy((LinphoneCore *)lc);
|
||||
return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setNatPolicy(JNIEnv *env, jobject thiz, jlong lc, jlong jpolicy) {
|
||||
linphone_core_set_nat_policy((LinphoneCore *)lc, (LinphoneNatPolicy *)jpolicy);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_getNatPolicy(JNIEnv *env, jobject thiz, jlong lc) {
|
||||
LinphoneNatPolicy *nat_policy = linphone_core_get_nat_policy((LinphoneCore *)lc);
|
||||
return (nat_policy != NULL) ? getNatPolicy(env, nat_policy) : NULL;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
|
||||
const char* server = GetStringUTFChars(env, jserver);
|
||||
linphone_core_set_stun_server((LinphoneCore*)lc,server);
|
||||
|
|
@ -7417,3 +7461,81 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_reloadMsPlugins(J
|
|||
linphone_core_reload_ms_plugins((LinphoneCore*)pcore, path);
|
||||
ReleaseStringUTFChars(env, jpath, path);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getCore(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneCore *lc = ((LinphoneNatPolicy *)jNatPolicy)->lc;
|
||||
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
|
||||
return ljb->getCore();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_clear(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
linphone_nat_policy_clear(nat_policy);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_stunEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
return (linphone_nat_policy_stun_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableStun(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
linphone_nat_policy_enable_stun(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_turnEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
return (linphone_nat_policy_turn_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableTurn(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
linphone_nat_policy_enable_turn(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_iceEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
return (linphone_nat_policy_ice_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableIce(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
linphone_nat_policy_enable_ice(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_upnpEnabled(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
return (linphone_nat_policy_upnp_enabled(nat_policy) == FALSE) ? JNI_FALSE : JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_enableUpnp(JNIEnv *env, jobject thiz, jlong jNatPolicy, jboolean jEnable) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
linphone_nat_policy_enable_upnp(nat_policy, (jEnable == JNI_FALSE) ? FALSE : TRUE);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
const char *stun_server = linphone_nat_policy_get_stun_server(nat_policy);
|
||||
return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServer(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServer) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
const char *stun_server = GetStringUTFChars(env, jStunServer);
|
||||
linphone_nat_policy_set_stun_server(nat_policy, stun_server);
|
||||
ReleaseStringUTFChars(env, jStunServer, stun_server);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_getStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
const char *stun_server = linphone_nat_policy_get_stun_server_username(nat_policy);
|
||||
return (stun_server != NULL) ? env->NewStringUTF(stun_server) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneNatPolicyImpl_setStunServerUsername(JNIEnv *env, jobject thiz, jlong jNatPolicy, jstring jStunServerUsername) {
|
||||
LinphoneNatPolicy *nat_policy = (LinphoneNatPolicy *)jNatPolicy;
|
||||
const char *stun_server_username = GetStringUTFChars(env, jStunServerUsername);
|
||||
linphone_nat_policy_set_stun_server_username(nat_policy, stun_server_username);
|
||||
ReleaseStringUTFChars(env, jStunServerUsername, stun_server_username);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *poli
|
|||
LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy);
|
||||
|
||||
/**
|
||||
* Seth the username used to authenticate with the STUN/TURN server.
|
||||
* Set the username used to authenticate with the STUN/TURN server.
|
||||
* The authentication will search for a LinphoneAuthInfo with this username.
|
||||
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
|
||||
* @param[in] policy LinphoneNatPolicy object
|
||||
|
|
|
|||
|
|
@ -24,28 +24,35 @@ if(ANDROID)
|
|||
find_package(Java REQUIRED COMPONENTS Development)
|
||||
|
||||
set(JNI_CLASSES
|
||||
"org.linphone.core.ErrorInfoImpl"
|
||||
"org.linphone.core.LinphoneAddressImpl"
|
||||
"org.linphone.core.LinphoneAuthInfoImpl"
|
||||
"org.linphone.core.LinphoneBufferImpl"
|
||||
"org.linphone.core.LinphoneCallImpl"
|
||||
"org.linphone.core.LinphoneCallLogImpl"
|
||||
"org.linphone.core.LinphoneCallParamsImpl"
|
||||
"org.linphone.core.LinphoneCallStatsImpl"
|
||||
"org.linphone.core.LinphoneChatMessageImpl"
|
||||
"org.linphone.core.LinphoneChatRoomImpl"
|
||||
"org.linphone.core.LinphoneConferenceImpl"
|
||||
"org.linphone.core.LinphoneConferenceParamsImpl"
|
||||
"org.linphone.core.LinphoneContentImpl"
|
||||
"org.linphone.core.LinphoneCoreFactoryImpl"
|
||||
"org.linphone.core.LinphoneCoreImpl"
|
||||
"org.linphone.core.LinphoneFriendImpl"
|
||||
"org.linphone.core.LinphoneProxyConfigImpl"
|
||||
"org.linphone.core.PayloadTypeImpl"
|
||||
"org.linphone.core.LpConfigImpl"
|
||||
"org.linphone.core.LinphoneInfoMessageImpl"
|
||||
"org.linphone.core.LinphoneEventImpl"
|
||||
"org.linphone.core.LinphoneFriendImpl"
|
||||
"org.linphone.core.LinphoneFriendListImpl"
|
||||
"org.linphone.core.LinphoneInfoMessageImpl"
|
||||
"org.linphone.core.LinphoneNatPolicyImpl"
|
||||
"org.linphone.core.LinphonePlayerImpl"
|
||||
"org.linphone.core.LinphoneProxyConfigImpl"
|
||||
"org.linphone.core.LpConfigImpl"
|
||||
"org.linphone.core.PayloadTypeImpl"
|
||||
"org.linphone.core.PresenceActivityImpl"
|
||||
"org.linphone.core.PresenceModelImpl"
|
||||
"org.linphone.core.PresenceNoteImpl"
|
||||
"org.linphone.core.PresencePersonImpl"
|
||||
"org.linphone.core.PresenceServiceImpl"
|
||||
"org.linphone.core.ErrorInfoImpl"
|
||||
"org.linphone.core.TunnelConfigImpl"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ public interface LinphoneCore {
|
|||
}
|
||||
/**
|
||||
* Describes firewall policy.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
static public class FirewallPolicy {
|
||||
|
||||
|
|
@ -1116,6 +1116,7 @@ public interface LinphoneCore {
|
|||
*
|
||||
**/
|
||||
void enableVideo(boolean vcap_enabled, boolean display_enabled);
|
||||
|
||||
/**
|
||||
* Returns TRUE if video is enabled, FALSE otherwise.
|
||||
*
|
||||
|
|
@ -1127,6 +1128,7 @@ public interface LinphoneCore {
|
|||
* @param stun_server Stun server address and port, such as stun.linphone.org or stun.linphone.org:3478
|
||||
*/
|
||||
void setStunServer(String stun_server);
|
||||
|
||||
/**
|
||||
* Get STUN server
|
||||
* @return stun server address if previously set.
|
||||
|
|
@ -1136,24 +1138,49 @@ public interface LinphoneCore {
|
|||
/**
|
||||
* Sets policy regarding workarounding NATs
|
||||
* @param pol one of the FirewallPolicy members.
|
||||
* @deprecated
|
||||
**/
|
||||
void setFirewallPolicy(FirewallPolicy pol);
|
||||
|
||||
/**
|
||||
* @return previously set firewall policy.
|
||||
* @deprecated
|
||||
*/
|
||||
FirewallPolicy getFirewallPolicy();
|
||||
|
||||
/**
|
||||
* Create a new LinphoneNatPolicy object with every policies being disabled.
|
||||
* @return A new LinphoneNatPolicy object.
|
||||
*/
|
||||
LinphoneNatPolicy createNatPolicy();
|
||||
|
||||
/**
|
||||
* Set the policy to use to pass through NATs/firewalls.
|
||||
* It may be overridden by a NAT policy for a specific proxy config.
|
||||
* @param policy LinphoneNatPolicy object
|
||||
*/
|
||||
void setNatPolicy(LinphoneNatPolicy policy);
|
||||
|
||||
/**
|
||||
* Get The policy that is used to pass through NATs/firewalls.
|
||||
* It may be overridden by a NAT policy for a specific proxy config.
|
||||
* @return LinphoneNatPolicy object in use.
|
||||
*/
|
||||
LinphoneNatPolicy getNatPolicy();
|
||||
|
||||
/**
|
||||
* Initiates an outgoing call given a destination LinphoneAddress
|
||||
*
|
||||
* @param addr the destination of the call {@link #LinphoneAddress }.
|
||||
* @param params call parameters {@link #LinphoneCallParams }
|
||||
*
|
||||
*<br>The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}. .
|
||||
*<br>The LinphoneAddress can be constructed directly using {@link LinphoneCoreFactory#createLinphoneAddress} , or created {@link LinphoneCore#interpretUrl(String)}.
|
||||
*
|
||||
* @return a {@link #LinphoneCall LinphoneCall} object
|
||||
* @throws LinphoneCoreException in case of failure
|
||||
**/
|
||||
LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException ;
|
||||
LinphoneCall inviteAddressWithParams(LinphoneAddress destination, LinphoneCallParams params) throws LinphoneCoreException;
|
||||
|
||||
/**
|
||||
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
|
||||
*
|
||||
|
|
|
|||
113
java/common/org/linphone/core/LinphoneNatPolicy.java
Normal file
113
java/common/org/linphone/core/LinphoneNatPolicy.java
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
LinphoneNatPolicy.java
|
||||
Copyright (C) 2016 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.linphone.core;
|
||||
|
||||
/**
|
||||
* Policy to use to pass through NATs/firewalls.
|
||||
*
|
||||
*/
|
||||
public interface LinphoneNatPolicy {
|
||||
/**
|
||||
* Clear a NAT policy (deactivate all protocols and unset the STUN server).
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Tell whether STUN is enabled.
|
||||
* @return Boolean value telling whether STUN is enabled.
|
||||
*/
|
||||
boolean stunEnabled();
|
||||
|
||||
/**
|
||||
* Enable STUN.
|
||||
* If TURN is also enabled, TURN will be used instead of STUN.
|
||||
* @param enable Boolean value telling whether to enable STUN.
|
||||
*/
|
||||
void enableStun(boolean enable);
|
||||
|
||||
/**
|
||||
* Tell whether TURN is enabled.
|
||||
* @return Boolean value telling whether TURN is enabled.
|
||||
*/
|
||||
boolean turnEnabled();
|
||||
|
||||
/**
|
||||
* Enable TURN.
|
||||
* If STUN is also enabled, it is ignored and TURN is used.
|
||||
* @param enable Boolean value telling whether to enable TURN.
|
||||
*/
|
||||
void enableTurn(boolean enable);
|
||||
|
||||
/**
|
||||
* Tell whether ICE is enabled.
|
||||
* @return Boolean value telling whether ICE is enabled.
|
||||
*/
|
||||
boolean iceEnabled();
|
||||
|
||||
/**
|
||||
* Enable ICE.
|
||||
* ICE can be enabled without STUN/TURN, in which case only the local candidates will be used.
|
||||
* @param enable Boolean value telling whether to enable ICE.
|
||||
*/
|
||||
void enableIce(boolean enable);
|
||||
|
||||
/**
|
||||
* Tell whether uPnP is enabled.
|
||||
* @return Boolean value telling whether uPnP is enabled.
|
||||
*/
|
||||
boolean upnpEnabled();
|
||||
|
||||
/**
|
||||
* Enable uPnP.
|
||||
* This has the effect to disable every other policies (ICE, STUN and TURN).
|
||||
* @param enable Boolean value telling whether to enable uPnP.
|
||||
*/
|
||||
void enableUpnp(boolean enable);
|
||||
|
||||
/**
|
||||
* Get the STUN/TURN server to use with this NAT policy.
|
||||
* Used when STUN or TURN are enabled.
|
||||
* @return The STUN server used by this NAT policy.
|
||||
*/
|
||||
String getStunServer();
|
||||
|
||||
/**
|
||||
* Set the STUN/TURN server to use with this NAT policy.
|
||||
* Used when STUN or TURN are enabled.
|
||||
* @param stun_server The STUN server to use with this NAT policy.
|
||||
*/
|
||||
void setStunServer(String stun_server);
|
||||
|
||||
/**
|
||||
* Get the username used to authenticate with the STUN/TURN server.
|
||||
* The authentication will search for a LinphoneAuthInfo with this username.
|
||||
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
|
||||
* @return The username used to authenticate with the STUN/TURN server.
|
||||
*/
|
||||
String getStunServerUsername();
|
||||
|
||||
/**
|
||||
* Set the username used to authenticate with the STUN/TURN server.
|
||||
* The authentication will search for a LinphoneAuthInfo with this username.
|
||||
* If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo.
|
||||
* @param username The username used to authenticate with the STUN/TURN server.
|
||||
*/
|
||||
void setStunServerUsername(String username);
|
||||
}
|
||||
|
|
@ -111,6 +111,9 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private native boolean isVideoSupported(long nativePtr);
|
||||
private native void setFirewallPolicy(long nativePtr, int enum_value);
|
||||
private native int getFirewallPolicy(long nativePtr);
|
||||
private native Object createNatPolicy(long nativePtr);
|
||||
private native void setNatPolicy(long nativePtr, long policyPtr);
|
||||
private native Object getNatPolicy(long nativePtr);
|
||||
private native void setStunServer(long nativePtr, String stun_server);
|
||||
private native String getStunServer(long nativePtr);
|
||||
private native int updateCall(long ptrLc, long ptrCall, long ptrParams);
|
||||
|
|
@ -524,12 +527,21 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public synchronized FirewallPolicy getFirewallPolicy() {
|
||||
return FirewallPolicy.fromInt(getFirewallPolicy(nativePtr));
|
||||
}
|
||||
public synchronized String getStunServer() {
|
||||
return getStunServer(nativePtr);
|
||||
}
|
||||
public synchronized void setFirewallPolicy(FirewallPolicy pol) {
|
||||
setFirewallPolicy(nativePtr,pol.value());
|
||||
}
|
||||
public synchronized LinphoneNatPolicy createNatPolicy() {
|
||||
return (LinphoneNatPolicy)createNatPolicy(nativePtr);
|
||||
}
|
||||
public synchronized void setNatPolicy(LinphoneNatPolicy policy) {
|
||||
setNatPolicy(nativePtr, ((LinphoneNatPolicyImpl)policy).mNativePtr);
|
||||
}
|
||||
public synchronized LinphoneNatPolicy getNatPolicy() {
|
||||
return (LinphoneNatPolicy)getNatPolicy(nativePtr);
|
||||
}
|
||||
public synchronized String getStunServer() {
|
||||
return getStunServer(nativePtr);
|
||||
}
|
||||
public synchronized void setStunServer(String stunServer) {
|
||||
setStunServer(nativePtr, stunServer);
|
||||
}
|
||||
|
|
|
|||
125
java/impl/org/linphone/core/LinphoneNatPolicyImpl.java
Normal file
125
java/impl/org/linphone/core/LinphoneNatPolicyImpl.java
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
LinphoneNatPolicyImpl.java
|
||||
Copyright (C) 2015 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package org.linphone.core;
|
||||
|
||||
public class LinphoneNatPolicyImpl implements LinphoneNatPolicy {
|
||||
protected final long mNativePtr;
|
||||
|
||||
private native Object getCore(long nativePtr);
|
||||
private native void clear(long nativePtr);
|
||||
private native boolean stunEnabled(long nativePtr);
|
||||
private native void enableStun(long nativePtr, boolean enable);
|
||||
private native boolean turnEnabled(long nativePtr);
|
||||
private native void enableTurn(long nativePtr, boolean enable);
|
||||
private native boolean iceEnabled(long nativePtr);
|
||||
private native void enableIce(long nativePtr, boolean enable);
|
||||
private native boolean upnpEnabled(long nativePtr);
|
||||
private native void enableUpnp(long nativePtr, boolean enable);
|
||||
private native String getStunServer(long nativePtr);
|
||||
private native void setStunServer(long nativePtr, String stun_server);
|
||||
private native String getStunServerUsername(long nativePtr);
|
||||
private native void setStunServerUsername(long nativePtr, String username);
|
||||
|
||||
protected LinphoneNatPolicyImpl(long nativePtr) {
|
||||
mNativePtr = nativePtr;
|
||||
}
|
||||
|
||||
private synchronized LinphoneCore getCore() {
|
||||
return (LinphoneCore)getCore(mNativePtr);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
synchronized(getCore()) {
|
||||
clear(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean stunEnabled() {
|
||||
synchronized(getCore()) {
|
||||
return stunEnabled(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableStun(boolean enable) {
|
||||
synchronized(getCore()) {
|
||||
enableStun(mNativePtr, enable);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean turnEnabled() {
|
||||
synchronized(getCore()) {
|
||||
return turnEnabled(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableTurn(boolean enable) {
|
||||
synchronized(getCore()) {
|
||||
enableTurn(mNativePtr, enable);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean iceEnabled() {
|
||||
synchronized(getCore()) {
|
||||
return iceEnabled(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableIce(boolean enable) {
|
||||
synchronized(getCore()) {
|
||||
enableIce(mNativePtr, enable);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean upnpEnabled() {
|
||||
synchronized(getCore()) {
|
||||
return upnpEnabled(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableUpnp(boolean enable) {
|
||||
synchronized(getCore()) {
|
||||
enableUpnp(mNativePtr, enable);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStunServer() {
|
||||
synchronized(getCore()) {
|
||||
return getStunServer(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStunServer(String stun_server) {
|
||||
synchronized(getCore()) {
|
||||
setStunServer(mNativePtr, stun_server);
|
||||
}
|
||||
}
|
||||
|
||||
public String getStunServerUsername() {
|
||||
synchronized(getCore()) {
|
||||
return getStunServerUsername(mNativePtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void setStunServerUsername(String username) {
|
||||
synchronized(getCore()) {
|
||||
setStunServerUsername(mNativePtr, username);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue