Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
faa60922
Commit
faa60922
authored
Nov 03, 2015
by
Simon Morlat
Browse files
fix crashes in android when doing things with LinphoneCore within the globalStateChanged callbacks.
Add wrappers for the http proxy api.
parent
eb172d10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
0 deletions
+96
-0
coreapi/linphonecore_jni.cc
coreapi/linphonecore_jni.cc
+55
-0
java/common/org/linphone/core/LinphoneCore.java
java/common/org/linphone/core/LinphoneCore.java
+18
-0
java/impl/org/linphone/core/LinphoneCoreImpl.java
java/impl/org/linphone/core/LinphoneCoreImpl.java
+23
-0
No files found.
coreapi/linphonecore_jni.cc
View file @
faa60922
...
...
@@ -659,6 +659,15 @@ public:
env
->
DeleteLocalRef
(
d
);
}
}
static
void
setCoreIfNotDone
(
JNIEnv
*
env
,
jobject
jcore
,
LinphoneCore
*
lc
){
jclass
objClass
=
env
->
GetObjectClass
(
jcore
);
jfieldID
myFieldID
=
env
->
GetFieldID
(
objClass
,
"nativePtr"
,
"J"
);
jlong
fieldVal
=
env
->
GetLongField
(
jcore
,
myFieldID
);
if
(
fieldVal
==
0
){
env
->
SetLongField
(
jcore
,
myFieldID
,
(
jlong
)
lc
);
}
}
static
void
globalStateChange
(
LinphoneCore
*
lc
,
LinphoneGlobalState
gstate
,
const
char
*
message
)
{
JNIEnv
*
env
=
0
;
jint
result
=
jvm
->
AttachCurrentThread
(
&
env
,
NULL
);
...
...
@@ -668,6 +677,11 @@ public:
}
LinphoneCoreVTable
*
table
=
linphone_core_get_current_vtable
(
lc
);
LinphoneCoreData
*
lcData
=
(
LinphoneCoreData
*
)
linphone_core_v_table_get_user_data
(
table
);
jobject
jcore
=
lcData
->
core
;
/*at this stage, the java object may not be aware of its C object, because linphone_core_new() hasn't returned yet.*/
setCoreIfNotDone
(
env
,
jcore
,
lc
);
jstring
msg
=
message
?
env
->
NewStringUTF
(
message
)
:
NULL
;
env
->
CallVoidMethod
(
lcData
->
listener
,
lcData
->
globalStateId
...
...
@@ -6475,3 +6489,44 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallLogImpl_getCallId(J
return
str
?
env
->
NewStringUTF
(
str
)
:
NULL
;
}
/*
* Class: org_linphone_core_LinphoneCoreImpl
* Method: setHttpProxyHost
* Signature: (JLjava/lang/String;)V
*/
JNIEXPORT
void
JNICALL
Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyHost
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
core
,
jstring
jhost
){
const
char
*
host
=
jhost
?
env
->
GetStringUTFChars
(
jhost
,
NULL
)
:
NULL
;
linphone_core_set_http_proxy_host
((
LinphoneCore
*
)
core
,
host
);
if
(
host
)
env
->
ReleaseStringUTFChars
(
jhost
,
host
);
}
/*
* Class: org_linphone_core_LinphoneCoreImpl
* Method: setHttpProxyPort
* Signature: (JI)V
*/
JNIEXPORT
void
JNICALL
Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyPort
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
core
,
jint
port
){
linphone_core_set_http_proxy_port
((
LinphoneCore
*
)
core
,
port
);
}
/*
* Class: org_linphone_core_LinphoneCoreImpl
* Method: getHttpProxyHost
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_org_linphone_core_LinphoneCoreImpl_getHttpProxyHost
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
core
){
const
char
*
host
=
linphone_core_get_http_proxy_host
((
LinphoneCore
*
)
core
);
return
host
?
env
->
NewStringUTF
(
host
)
:
NULL
;
}
/*
* Class: org_linphone_core_LinphoneCoreImpl
* Method: getHttpProxyPort
* Signature: (J)I
*/
JNIEXPORT
jint
JNICALL
Java_org_linphone_core_LinphoneCoreImpl_getHttpProxyPort
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
core
){
return
linphone_core_get_http_proxy_port
((
LinphoneCore
*
)
core
);
}
java/common/org/linphone/core/LinphoneCore.java
View file @
faa60922
...
...
@@ -2179,4 +2179,22 @@ public interface LinphoneCore {
* Get the provisioning URI previously set.
**/
public
String
getProvisioningUri
();
/**
* Set an http proxy hostname or IP address to use for SIP connection.
*/
public
void
setHttpProxyHost
(
String
host
);
/**
* Set an http proxy port to use for SIP connection.
*/
public
void
setHttpProxyPort
(
int
port
);
/**
* Get the http proxy host previously set.
**/
public
String
getHttpProxyHost
();
/**
* Get the http proxy port previously set.
**/
public
int
getHttpProxyPort
();
}
java/impl/org/linphone/core/LinphoneCoreImpl.java
View file @
faa60922
...
...
@@ -1535,4 +1535,27 @@ class LinphoneCoreImpl implements LinphoneCore {
public
GlobalState
getGlobalState
(){
return
GlobalState
.
fromInt
(
getGlobalState
(
nativePtr
));
}
private
native
void
setHttpProxyHost
(
long
nativePtr
,
String
host
);
@Override
public
void
setHttpProxyHost
(
String
host
){
setHttpProxyHost
(
nativePtr
,
host
);
}
private
native
void
setHttpProxyPort
(
long
nativePtr
,
int
port
);
@Override
public
void
setHttpProxyPort
(
int
port
){
setHttpProxyPort
(
nativePtr
,
port
);
}
private
native
String
getHttpProxyHost
(
long
nativePtr
);
@Override
public
String
getHttpProxyHost
(){
return
getHttpProxyHost
(
nativePtr
);
}
private
native
int
getHttpProxyPort
(
long
nativePtr
);
@Override
public
int
getHttpProxyPort
(){
return
getHttpProxyPort
(
nativePtr
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment