Commit 80150859 authored by Simon Morlat's avatar Simon Morlat
Browse files

add stun settings from java

parent f95414d0
......@@ -950,3 +950,28 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv*
linphone_core_set_native_video_window_id((LinphoneCore*)lc,(unsigned long)obj);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc, int enum_value){
linphone_core_set_firewall_policy((LinphoneCore*)lc,(LinphoneFirewallPolicy)enum_value);
}
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv *env, jobject thiz, jlong lc){
return linphone_core_get_firewall_policy((LinphoneCore*)lc);
}
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){
const char* server = NULL;
if (jserver) server=env->GetStringUTFChars(jserver, NULL);
linphone_core_set_stun_server((LinphoneCore*)lc,server);
if (server) env->ReleaseStringUTFChars(jserver,server);
}
extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){
const char *ret= linphone_core_get_stun_server((LinphoneCore*)lc);
if (ret==NULL) return NULL;
jstring jvalue =env->NewStringUTF(ret);
return jvalue;
}
......@@ -114,6 +114,48 @@ public interface LinphoneCore {
return mStringValue;
}
}
/**
* Describes proxy registration states.
*
*/
static public class FirewallPolicy {
static private Vector values = new Vector();
/**
* No firewall is assumed.
*/
static public FirewallPolicy NoFirewall = new FirewallPolicy(0,"NoFirewall");
/**
* Use NAT address (discouraged)
*/
static public FirewallPolicy UseNatAddress = new FirewallPolicy(1,"UseNatAddress");
/**
* Use stun server to discover RTP addresses and ports.
*/
static public FirewallPolicy UseStun = new FirewallPolicy(2,"UseStun");
private final int mValue;
private final String mStringValue;
private FirewallPolicy(int value,String stringValue) {
mValue = value;
values.addElement(this);
mStringValue=stringValue;
}
public static FirewallPolicy fromInt(int value) {
for (int i=0; i<values.size();i++) {
FirewallPolicy state = (FirewallPolicy) values.elementAt(i);
if (state.mValue == value) return state;
}
throw new RuntimeException("state not found ["+value+"]");
}
public String toString() {
return mStringValue;
}
public int value(){
return mValue;
}
}
/**
* Signaling transports
*
......@@ -392,4 +434,24 @@ public interface LinphoneCore {
*
***/
boolean isVideoEnabled();
/**
* Specify a STUN server to help firewall traversal.
* @param stun_server Stun server address and port, such as stun.linphone.org or stun.linphone.org:3478
*/
public void setStunServer(String stun_server);
/**
* @return stun server address if previously set.
*/
public String getStunServer();
/**
* Sets policy regarding workarounding NATs
* @param pol one of the FirewallPolicy members.
**/
public void setFirewallPolicy(FirewallPolicy pol);
/**
* @return previously set firewall policy.
*/
public FirewallPolicy getFirewallPolicy();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment