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
1d055b91
Commit
1d055b91
authored
Mar 02, 2020
by
Sylvain Berfini
🐮
Browse files
feature: Android push, activity monitor and iterate scheduler in SDK
parent
a0f31dfe
Changes
48
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1497 additions
and
700 deletions
+1497
-700
coreapi/linphonecore.c
coreapi/linphonecore.c
+136
-0
coreapi/linphonecore_jni.cc
coreapi/linphonecore_jni.cc
+8
-0
coreapi/private_functions.h
coreapi/private_functions.h
+4
-0
coreapi/private_structs.h
coreapi/private_structs.h
+5
-1
coreapi/proxy.c
coreapi/proxy.c
+16
-0
coreapi/vtables.c
coreapi/vtables.c
+10
-0
include/linphone/callbacks.h
include/linphone/callbacks.h
+12
-0
include/linphone/core.h
include/linphone/core.h
+67
-1
src/call/call.cpp
src/call/call.cpp
+10
-1
src/core/platform-helpers/android-platform-helpers.cpp
src/core/platform-helpers/android-platform-helpers.cpp
+70
-5
tester/call_multi_tester.c
tester/call_multi_tester.c
+25
-0
tester/call_single_tester.c
tester/call_single_tester.c
+14
-0
tester/liblinphone_tester.h
tester/liblinphone_tester.h
+5
-1
tester/proxy_config_tester.c
tester/proxy_config_tester.c
+407
-1
tester/rcfiles/marie_dual_proxy_rc
tester/rcfiles/marie_dual_proxy_rc
+3
-0
tester/rcfiles/marie_rc
tester/rcfiles/marie_rc
+3
-0
tester/tester.c
tester/tester.c
+13
-2
wrappers/java/classes/org/linphone/core/CoreException.java
wrappers/java/classes/org/linphone/core/CoreException.java
+11
-11
wrappers/java/classes/org/linphone/core/Utils.java
wrappers/java/classes/org/linphone/core/Utils.java
+10
-10
wrappers/java/classes/org/linphone/core/tools/AndroidPlatformHelper.java
...lasses/org/linphone/core/tools/AndroidPlatformHelper.java
+668
-667
No files found.
coreapi/linphonecore.c
View file @
1d055b91
...
...
@@ -516,6 +516,22 @@ void linphone_core_cbs_set_qrcode_found(LinphoneCoreCbs *cbs, LinphoneCoreCbsQrc
cbs
->
vtable
->
qrcode_found
=
cb
;
}
LinphoneCoreCbsFirstCallStartedCb
linphone_core_cbs_get_first_call_started
(
LinphoneCoreCbs
*
cbs
)
{
return
cbs
->
vtable
->
first_call_started
;
}
void
linphone_core_cbs_set_first_call_started
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsFirstCallStartedCb
cb
)
{
cbs
->
vtable
->
first_call_started
=
cb
;
}
LinphoneCoreCbsLastCallEndedCb
linphone_core_cbs_get_last_call_ended
(
LinphoneCoreCbs
*
cbs
)
{
return
cbs
->
vtable
->
last_call_ended
;
}
void
linphone_core_cbs_set_last_call_ended
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsLastCallEndedCb
cb
)
{
cbs
->
vtable
->
last_call_ended
=
cb
;
}
void
linphone_core_cbs_set_ec_calibration_result
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsEcCalibrationResultCb
cb
)
{
cbs
->
vtable
->
ec_calibration_result
=
cb
;
}
...
...
@@ -2475,6 +2491,117 @@ static void _linphone_core_init_account_creator_service(LinphoneCore *lc) {
linphone_core_set_account_creator_service
(
lc
,
service
);
}
static
void
update_proxy_config_push_params
(
LinphoneCore
*
core
)
{
char
*
computedPushParams
=
NULL
;
if
(
core
->
push_notification_enabled
)
{
computedPushParams
=
linphone_core_get_push_notification_contact_uri_parameters
(
core
);
}
bctbx_list_t
*
proxies
=
(
bctbx_list_t
*
)
linphone_core_get_proxy_config_list
(
core
);
for
(;
proxies
!=
NULL
;
proxies
=
proxies
->
next
)
{
LinphoneProxyConfig
*
proxy
=
(
LinphoneProxyConfig
*
)
proxies
->
data
;
bool_t
pushAllowed
=
linphone_proxy_config_is_push_notification_allowed
(
proxy
);
const
char
*
contactUriParams
=
linphone_proxy_config_get_contact_uri_parameters
(
proxy
);
if
(
pushAllowed
)
{
// Do not alter contact uri params for proxy config without push notification allowed
if
(
computedPushParams
&&
core
->
push_notification_enabled
)
{
if
(
!
contactUriParams
||
strcmp
(
contactUriParams
,
computedPushParams
)
!=
0
)
{
linphone_proxy_config_edit
(
proxy
);
linphone_proxy_config_set_contact_uri_parameters
(
proxy
,
computedPushParams
);
linphone_proxy_config_done
(
proxy
);
ms_message
(
"Push notification information [%s] added to proxy config [%p]"
,
computedPushParams
,
proxy
);
}
}
else
{
if
(
contactUriParams
)
{
linphone_proxy_config_edit
(
proxy
);
linphone_proxy_config_set_contact_uri_parameters
(
proxy
,
NULL
);
linphone_proxy_config_done
(
proxy
);
ms_message
(
"Push notification information removed from proxy config [%p]"
,
proxy
);
}
}
}
}
if
(
computedPushParams
)
{
ms_free
(
computedPushParams
);
}
}
void
linphone_core_update_push_notification_information
(
LinphoneCore
*
core
,
const
char
*
param
,
const
char
*
prid
)
{
if
(
core
->
push_notification_param
)
{
ms_free
(
core
->
push_notification_param
);
core
->
push_notification_param
=
NULL
;
}
if
(
core
->
push_notification_prid
)
{
ms_free
(
core
->
push_notification_prid
);
core
->
push_notification_prid
=
NULL
;
}
if
(
param
&&
prid
)
{
core
->
push_notification_param
=
ms_strdup
(
param
);
core
->
push_notification_prid
=
ms_strdup
(
prid
);
ms_message
(
"Push notification information updated: param [%s], prid [%s]"
,
param
,
prid
);
}
update_proxy_config_push_params
(
core
);
}
char
*
linphone_core_get_push_notification_contact_uri_parameters
(
LinphoneCore
*
core
)
{
if
(
!
core
->
push_notification_enabled
)
return
NULL
;
if
(
!
core
->
push_notification_param
||
!
core
->
push_notification_prid
)
return
NULL
;
bool_t
use_legacy_params
=
!!
lp_config_get_int
(
core
->
config
,
"net"
,
"use_legacy_push_notification_params"
,
FALSE
);
const
char
*
format
=
"pn-provider=%s;pn-params=%s;pn-prid=%s;pn-timeout=0;pn-silent=1"
;
if
(
use_legacy_params
)
{
format
=
"pn-type=%s;app-id=%s;pn-tok=%s;pn-timeout=0;pn-silent=1"
;
}
const
char
*
provider
=
NULL
;
// Can this be improved ?
bool_t
tester_env
=
!!
lp_config_get_int
(
core
->
config
,
"tester"
,
"test_env"
,
FALSE
);
if
(
tester_env
)
provider
=
"liblinphone_tester"
;
// End of improvement zone
const
char
*
params
=
core
->
push_notification_param
;
const
char
*
prid
=
core
->
push_notification_prid
;
#ifdef __ANDROID__
if
(
use_legacy_params
)
provider
=
"firebase"
;
else
provider
=
"fcm"
;
#elif TARGET_OS_IPHONE
provider
=
"apple"
;
#endif
if
(
provider
==
NULL
)
return
NULL
;
char
contactUriParams
[
512
];
memset
(
contactUriParams
,
0
,
sizeof
(
contactUriParams
));
snprintf
(
contactUriParams
,
sizeof
(
contactUriParams
),
format
,
provider
,
params
,
prid
);
return
ms_strdup
(
contactUriParams
);
}
void
linphone_core_set_push_notification_enabled
(
LinphoneCore
*
core
,
bool_t
enable
)
{
lp_config_set_int
(
core
->
config
,
"net"
,
"push_notification"
,
enable
);
core
->
push_notification_enabled
=
enable
;
update_proxy_config_push_params
(
core
);
}
bool_t
linphone_core_is_push_notification_enabled
(
LinphoneCore
*
core
)
{
return
core
->
push_notification_enabled
;
}
void
linphone_core_set_auto_iterate_enabled
(
LinphoneCore
*
core
,
bool_t
enable
)
{
lp_config_set_int
(
core
->
config
,
"misc"
,
"auto_iterate"
,
enable
);
core
->
auto_iterate_enabled
=
enable
;
}
bool_t
linphone_core_is_auto_iterate_enabled
(
LinphoneCore
*
core
)
{
return
core
->
auto_iterate_enabled
;
}
static
void
linphone_core_init
(
LinphoneCore
*
lc
,
LinphoneCoreCbs
*
cbs
,
LpConfig
*
config
,
void
*
userdata
,
void
*
system_context
,
bool_t
automatically_start
)
{
LinphoneFactory
*
lfactory
=
linphone_factory_get
();
LinphoneCoreCbs
*
internal_cbs
=
_linphone_core_cbs_new
();
...
...
@@ -2500,6 +2627,15 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
lc
->
sal
->
setUserPointer
(
lc
);
lc
->
sal
->
setCallbacks
(
&
linphone_sal_callbacks
);
bool_t
push_notification_default
=
FALSE
;
bool_t
auto_iterate_default
=
FALSE
;
#if defined(__ANDROID__) || defined(TARGET_OS_IPHONE)
push_notification_default
=
TRUE
;
auto_iterate_default
=
TRUE
;
#endif
lc
->
push_notification_enabled
=
!!
lp_config_get_int
(
lc
->
config
,
"net"
,
"push_notification"
,
push_notification_default
);
lc
->
auto_iterate_enabled
=
!!
lp_config_get_int
(
lc
->
config
,
"misc"
,
"auto_iterate"
,
auto_iterate_default
);
#ifdef __ANDROID__
if
(
system_context
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
...
...
coreapi/linphonecore_jni.cc
View file @
1d055b91
...
...
@@ -1719,6 +1719,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env, jobj
}
}
extern
"C"
jobject
getCore
(
JNIEnv
*
env
,
LinphoneCore
*
cptr
,
bool_t
takeref
)
{
LinphoneJavaBindings
*
ljb
=
(
LinphoneJavaBindings
*
)
linphone_core_get_user_data
(
cptr
);
if
(
ljb
)
{
return
ljb
->
getCore
();
}
return
NULL
;
}
extern
"C"
void
Java_org_linphone_core_LinphoneCoreImpl_addListener
(
JNIEnv
*
env
,
jobject
thiz
,
jlong
lc
,
jobject
jlistener
)
{
LinphoneJavaBindings
*
ljb
=
(
LinphoneJavaBindings
*
)
linphone_core_get_user_data
((
LinphoneCore
*
)
lc
);
LinphoneCoreVTable
*
vTable
=
linphone_core_v_table_new
();
...
...
coreapi/private_functions.h
View file @
1d055b91
...
...
@@ -517,6 +517,8 @@ LinphonePayloadType *linphone_payload_type_new(LinphoneCore *lc, OrtpPayloadType
bool_t
_linphone_core_check_payload_type_usability
(
const
LinphoneCore
*
lc
,
const
OrtpPayloadType
*
pt
);
OrtpPayloadType
*
linphone_payload_type_get_ortp_pt
(
const
LinphonePayloadType
*
pt
);
LINPHONE_PUBLIC
void
linphone_core_update_push_notification_information
(
LinphoneCore
*
core
,
const
char
*
param
,
const
char
*
prid
);
char
*
linphone_core_get_push_notification_contact_uri_parameters
(
LinphoneCore
*
core
);
const
MSCryptoSuite
*
linphone_core_get_srtp_crypto_suites
(
LinphoneCore
*
lc
);
MsZrtpCryptoTypesCount
linphone_core_get_zrtp_key_agreement_suites
(
LinphoneCore
*
lc
,
MSZrtpKeyAgreement
keyAgreements
[
MS_MAX_ZRTP_CRYPTO_TYPES
]);
...
...
@@ -551,6 +553,8 @@ void linphone_core_notify_file_transfer_send(LinphoneCore *lc, LinphoneChatMessa
void
linphone_core_notify_file_transfer_progress_indication
(
LinphoneCore
*
lc
,
LinphoneChatMessage
*
message
,
LinphoneContent
*
content
,
size_t
offset
,
size_t
total
);
void
linphone_core_notify_is_composing_received
(
LinphoneCore
*
lc
,
LinphoneChatRoom
*
room
);
void
linphone_core_notify_dtmf_received
(
LinphoneCore
*
lc
,
LinphoneCall
*
call
,
int
dtmf
);
void
linphone_core_notify_first_call_started
(
LinphoneCore
*
lc
);
void
linphone_core_notify_last_call_ended
(
LinphoneCore
*
lc
);
/*
* return true if at least a registered vtable has a cb for dtmf received*/
bool_t
linphone_core_dtmf_received_has_listener
(
const
LinphoneCore
*
lc
);
...
...
coreapi/private_structs.h
View file @
1d055b91
...
...
@@ -850,6 +850,10 @@ namespace LinphonePrivate {
sqlite3 *friends_db; \
bool_t debug_storage; \
void *system_context; \
bool_t is_unreffing;
bool_t is_unreffing; \
bool_t push_notification_enabled; \
char * push_notification_param; \
char * push_notification_prid; \
bool_t auto_iterate_enabled;
#endif
/* _PRIVATE_STRUCTS_H_ */
coreapi/proxy.c
View file @
1d055b91
...
...
@@ -1846,6 +1846,22 @@ bool_t linphone_proxy_config_is_push_notification_allowed(const LinphoneProxyCon
void
linphone_proxy_config_set_push_notification_allowed
(
LinphoneProxyConfig
*
cfg
,
bool_t
is_allowed
)
{
cfg
->
push_notification_allowed
=
is_allowed
;
if
(
is_allowed
)
{
char
*
computedPushParams
=
linphone_core_get_push_notification_contact_uri_parameters
(
cfg
->
lc
);
if
(
computedPushParams
)
{
linphone_proxy_config_edit
(
cfg
);
linphone_proxy_config_set_contact_uri_parameters
(
cfg
,
computedPushParams
);
linphone_proxy_config_done
(
cfg
);
ms_message
(
"Push notification information [%s] added to proxy config [%p]"
,
computedPushParams
,
cfg
);
ms_free
(
computedPushParams
);
}
}
else
{
linphone_proxy_config_edit
(
cfg
);
linphone_proxy_config_set_contact_uri_parameters
(
cfg
,
NULL
);
linphone_proxy_config_done
(
cfg
);
ms_message
(
"Push notification information removed from proxy config [%p]"
,
cfg
);
}
}
int
linphone_proxy_config_get_unread_chat_message_count
(
const
LinphoneProxyConfig
*
cfg
)
{
...
...
coreapi/vtables.c
View file @
1d055b91
...
...
@@ -99,6 +99,16 @@ void linphone_core_notify_call_state_changed(LinphoneCore *lc, LinphoneCall *cal
cleanup_dead_vtable_refs
(
lc
);
}
void
linphone_core_notify_first_call_started
(
LinphoneCore
*
lc
)
{
NOTIFY_IF_EXIST
(
first_call_started
,
lc
);
cleanup_dead_vtable_refs
(
lc
);
}
void
linphone_core_notify_last_call_ended
(
LinphoneCore
*
lc
)
{
NOTIFY_IF_EXIST
(
last_call_ended
,
lc
);
cleanup_dead_vtable_refs
(
lc
);
}
void
linphone_core_notify_call_encryption_changed
(
LinphoneCore
*
lc
,
LinphoneCall
*
call
,
bool_t
on
,
const
char
*
authentication_token
)
{
NOTIFY_IF_EXIST
(
call_encryption_changed
,
lc
,
call
,
on
,
authentication_token
);
cleanup_dead_vtable_refs
(
lc
);
...
...
include/linphone/callbacks.h
View file @
1d055b91
...
...
@@ -443,6 +443,18 @@ typedef void (*LinphoneCoreCbsChatRoomEphemeralMessageDeleteCb) (LinphoneCore *l
*/
typedef
void
(
*
LinphoneCoreCbsQrcodeFoundCb
)(
LinphoneCore
*
lc
,
const
char
*
result
);
/**
* Callback prototype telling a call has started (incoming or outgoing) while there was no other call.
* @param[in] lc LinphoneCore object
*/
typedef
void
(
*
LinphoneCoreCbsFirstCallStartedCb
)(
LinphoneCore
*
lc
);
/**
* Callback prototype telling the last call has ended (#LinphoneCore.get_calls_nb() returns 0)
* @param[in] lc LinphoneCore object
*/
typedef
void
(
*
LinphoneCoreCbsLastCallEndedCb
)(
LinphoneCore
*
lc
);
/**
* @}
**/
...
...
include/linphone/core.h
View file @
1d055b91
...
...
@@ -233,6 +233,8 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreCbsChatRoomReadCb
chat_room_read
;
LinphoneCoreCbsChatRoomSubjectChangedCb
chat_room_subject_changed
;
LinphoneCoreCbsChatRoomEphemeralMessageDeleteCb
chat_room_ephemeral_message_deleted
;
LinphoneCoreCbsFirstCallStartedCb
first_call_started
;
LinphoneCoreCbsLastCallEndedCb
last_call_ended
;
void
*
user_data
;
/**<User data associated with the above callbacks */
}
LinphoneCoreVTable
;
...
...
@@ -807,6 +809,34 @@ LINPHONE_PUBLIC LinphoneCoreCbsQrcodeFoundCb linphone_core_cbs_get_qrcode_found(
**/
LINPHONE_PUBLIC
void
linphone_core_cbs_set_qrcode_found
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsQrcodeFoundCb
cb
);
/**
* Gets the first call started callback.
* @param[in] cbs LinphoneCoreCbs object
* @return The current callback
*/
LINPHONE_PUBLIC
LinphoneCoreCbsFirstCallStartedCb
linphone_core_cbs_get_first_call_started
(
LinphoneCoreCbs
*
cbs
);
/**
* Sets the first call started callback.
* @param[in] cbs LinphoneCoreCbs object
* @param[in] cb The callback to use
**/
LINPHONE_PUBLIC
void
linphone_core_cbs_set_first_call_started
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsFirstCallStartedCb
cb
);
/**
* Gets the last call ended callback.
* @param[in] cbs LinphoneCoreCbs object
* @return The current callback
*/
LINPHONE_PUBLIC
LinphoneCoreCbsLastCallEndedCb
linphone_core_cbs_get_last_call_ended
(
LinphoneCoreCbs
*
cbs
);
/**
* Sets the last call ended callback.
* @param[in] cbs LinphoneCoreCbs object
* @param[in] cb The callback to use
**/
LINPHONE_PUBLIC
void
linphone_core_cbs_set_last_call_ended
(
LinphoneCoreCbs
*
cbs
,
LinphoneCoreCbsLastCallEndedCb
cb
);
/**
* @brief Sets a callback to call each time the echo-canceler calibration is completed.
*/
...
...
@@ -6207,7 +6237,7 @@ LINPHONE_PUBLIC LinphoneXmlRpcSession * linphone_core_create_xml_rpc_session(Lin
LINPHONE_PUBLIC
void
linphone_core_load_config_from_xml
(
LinphoneCore
*
lc
,
const
char
*
xml_uri
);
/**
* Call this method when you receive a push notification.
* Call this method when you receive a push notification
(if you handle push notifications manually)
.
* It will ensure the proxy configs are correctly registered to the proxy server,
* so the call or the message will be correctly delivered.
* @param[in] lc The #LinphoneCore
...
...
@@ -6237,6 +6267,42 @@ LINPHONE_PUBLIC LinphonePushNotificationMessage * linphone_core_get_new_message_
**/
LINPHONE_PUBLIC
LinphoneChatRoom
*
linphone_core_get_new_chat_room_from_conf_addr
(
LinphoneCore
*
lc
,
const
char
*
chat_room_addr
);
/**
* Enable or disable push notifications on Android & iOS.
* If enabled, it will try to get the push token add configure each proxy config with push_notification_allowed
* set to true with push parameters.
* @param[in] core The #LinphoneCore
* @param[in] enable TRUE to enable push notifications, FALSE to disable
* @ingroup misc
*/
LINPHONE_PUBLIC
void
linphone_core_set_push_notification_enabled
(
LinphoneCore
*
core
,
bool_t
enable
);
/**
* Gets whether push notifications are enabled or not (Android & iOS only).
* @param[in] core The #LinphoneCore
* @return TRUE if push notifications are enabled, FALSE otherwise
* @ingroup misc
*/
LINPHONE_PUBLIC
bool_t
linphone_core_is_push_notification_enabled
(
LinphoneCore
*
core
);
/**
* Enable or disable the automatic schedule of #linphone_core_iterate() method on Android & iOS.
* If enabled, #linphone_core_iterate() will be called on the main thread every 20ms automatically.
* If disabled, it is the application that must do this job.
* @param[in] core The #LinphoneCore
* @param[in] enable TRUE to enable auto iterate, FALSE to disable
* @ingroup misc
*/
LINPHONE_PUBLIC
void
linphone_core_set_auto_iterate_enabled
(
LinphoneCore
*
core
,
bool_t
enable
);
/**
* Gets whether auto iterate is enabled or not (Android & iOS only).
* @param[in] core The #LinphoneCore
* @return TRUE if #linphone_core_iterate() is scheduled automatically, FALSE otherwise
* @ingroup misc
*/
LINPHONE_PUBLIC
bool_t
linphone_core_is_auto_iterate_enabled
(
LinphoneCore
*
core
);
#ifdef __cplusplus
}
#endif
...
...
src/call/call.cpp
View file @
1d055b91
...
...
@@ -310,18 +310,27 @@ void CallPrivate::onCallSessionStateChanged (const shared_ptr<CallSession> &sess
L_Q
();
q
->
getCore
()
->
getPrivate
()
->
getToneManager
()
->
update
(
session
);
switch
(
state
){
LinphoneCore
*
lc
=
q
->
getCore
()
->
getCCore
();
switch
(
state
)
{
case
CallSession
::
State
::
OutgoingInit
:
case
CallSession
::
State
::
IncomingReceived
:
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
acquireWifiLock
();
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
acquireMcastLock
();
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
acquireCpuLock
();
if
(
linphone_core_get_calls_nb
(
lc
)
==
1
)
{
linphone_core_notify_first_call_started
(
lc
);
}
break
;
case
CallSession
::
State
::
Released
:
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
releaseWifiLock
();
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
releaseMcastLock
();
getPlatformHelpers
(
q
->
getCore
()
->
getCCore
())
->
releaseCpuLock
();
break
;
case
CallSession
::
State
::
End
:
case
CallSession
::
State
::
Error
:
if
(
linphone_core_get_calls_nb
(
lc
)
==
0
)
{
linphone_core_notify_last_call_ended
(
lc
);
}
default:
break
;
}
...
...
src/core/platform-helpers/android-platform-helpers.cpp
View file @
1d055b91
...
...
@@ -73,10 +73,13 @@ public:
private:
int
callVoidMethod
(
jmethodID
id
);
static
jmethodID
getMethodId
(
JNIEnv
*
env
,
jclass
klass
,
const
char
*
method
,
const
char
*
signature
);
string
getNativeLibraryDir
();
string
getNativeLibraryDir
();
void
createCoreManager
(
std
::
shared_ptr
<
LinphonePrivate
::
Core
>
core
,
void
*
systemContext
);
void
destroyCoreManager
();
jobject
mJavaHelper
=
nullptr
;
jobject
mSystemContext
=
nullptr
;
jobject
mJavaCoreManager
=
nullptr
;
jmethodID
mWifiLockAcquireId
=
nullptr
;
jmethodID
mWifiLockReleaseId
=
nullptr
;
jmethodID
mMcastLockAcquireId
=
nullptr
;
...
...
@@ -91,6 +94,8 @@ private:
jmethodID
mResizeVideoPreview
=
nullptr
;
jmethodID
mOnLinphoneCoreStartId
=
nullptr
;
jmethodID
mOnLinphoneCoreStopId
=
nullptr
;
jmethodID
mCoreManagerOnLinphoneCoreStartId
=
nullptr
;
jmethodID
mCoreManagerOnLinphoneCoreStopId
=
nullptr
;
jmethodID
mOnWifiOnlyEnabledId
=
nullptr
;
jobject
mPreviewVideoWindow
=
nullptr
;
jobject
mVideoWindow
=
nullptr
;
...
...
@@ -114,7 +119,47 @@ jmethodID AndroidPlatformHelpers::getMethodId (JNIEnv *env, jclass klass, const
return
id
;
}
// -----------------------------------------------------------------------------
extern
"C"
jobject
getCore
(
JNIEnv
*
env
,
LinphoneCore
*
cptr
,
bool_t
takeref
);
void
AndroidPlatformHelpers
::
createCoreManager
(
std
::
shared_ptr
<
LinphonePrivate
::
Core
>
core
,
void
*
systemContext
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
jclass
klass
=
env
->
FindClass
(
"org/linphone/core/tools/service/CoreManager"
);
if
(
!
klass
)
{
lError
()
<<
"Could not find java CoreManager class."
;
return
;
}
jmethodID
ctor
=
env
->
GetMethodID
(
klass
,
"<init>"
,
"(Ljava/lang/Object;Lorg/linphone/core/Core;)V"
);
LinphoneCore
*
lc
=
L_GET_C_BACK_PTR
(
core
);
jobject
javaCore
=
::
LinphonePrivate
::
getCore
(
env
,
lc
,
FALSE
);
mJavaCoreManager
=
env
->
NewObject
(
klass
,
ctor
,
(
jobject
)
systemContext
,
(
jobject
)
javaCore
);
if
(
!
mJavaCoreManager
)
{
lError
()
<<
"Could not instanciate CoreManager object."
;
return
;
}
mJavaCoreManager
=
(
jobject
)
env
->
NewGlobalRef
(
mJavaCoreManager
);
mCoreManagerOnLinphoneCoreStartId
=
getMethodId
(
env
,
klass
,
"onLinphoneCoreStart"
,
"()V"
);
mCoreManagerOnLinphoneCoreStopId
=
getMethodId
(
env
,
klass
,
"onLinphoneCoreStop"
,
"()V"
);
lInfo
()
<<
"CoreManager is fully initialised."
;
}
void
AndroidPlatformHelpers
::
destroyCoreManager
()
{
if
(
mJavaCoreManager
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
env
->
DeleteGlobalRef
(
mJavaCoreManager
);
mJavaCoreManager
=
nullptr
;
lInfo
()
<<
"AndroidCoreManager has been destroyed."
;
}
}
// -----------------------------------------------------------------------------
AndroidPlatformHelpers
::
AndroidPlatformHelpers
(
std
::
shared_ptr
<
LinphonePrivate
::
Core
>
core
,
void
*
systemContext
)
:
GenericPlatformHelpers
(
core
)
{
createCoreManager
(
core
,
systemContext
);
JNIEnv
*
env
=
ms_get_jni_env
();
jclass
klass
=
env
->
FindClass
(
"org/linphone/core/tools/AndroidPlatformHelper"
);
if
(
!
klass
)
...
...
@@ -158,6 +203,7 @@ AndroidPlatformHelpers::AndroidPlatformHelpers (std::shared_ptr<LinphonePrivate:
}
AndroidPlatformHelpers
::~
AndroidPlatformHelpers
()
{
destroyCoreManager
();
if
(
mJavaHelper
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
belle_sip_wake_lock_uninit
(
env
);
...
...
@@ -338,15 +384,25 @@ void AndroidPlatformHelpers::setNetworkReachable(bool reachable) {
void
AndroidPlatformHelpers
::
onLinphoneCoreStart
(
bool
monitoringEnabled
)
{
JNIEnv
*
env
=
ms_get_jni_env
();
if
(
env
&&
mJavaHelper
)
{
env
->
CallVoidMethod
(
mJavaHelper
,
mOnLinphoneCoreStartId
,
(
jboolean
)
monitoringEnabled
);
if
(
env
)
{
if
(
mJavaCoreManager
)
{
env
->
CallVoidMethod
(
mJavaCoreManager
,
mCoreManagerOnLinphoneCoreStartId
);
}
if
(
mJavaHelper
)
{
env
->
CallVoidMethod
(
mJavaHelper
,
mOnLinphoneCoreStartId
,
(
jboolean
)
monitoringEnabled
);
}
}
}
void
AndroidPlatformHelpers
::
onLinphoneCoreStop
()
{
JNIEnv
*
env
=
ms_get_jni_env
();
if
(
env
&&
mJavaHelper
)
{
env
->
CallVoidMethod
(
mJavaHelper
,
mOnLinphoneCoreStopId
);
if
(
env
)
{
if
(
mJavaCoreManager
)
{
env
->
CallVoidMethod
(
mJavaCoreManager
,
mCoreManagerOnLinphoneCoreStopId
);
}
if
(
mJavaHelper
)
{
env
->
CallVoidMethod
(
mJavaHelper
,
mOnLinphoneCoreStopId
);
}
}
}
...
...
@@ -460,4 +516,13 @@ extern "C" JNIEXPORT void JNICALL Java_org_linphone_core_tools_AndroidPlatformHe
linphone_core_enable_keep_alive
(
androidPlatformHelper
->
getCore
()
->
getCCore
(),
enable
?
TRUE
:
FALSE
);
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_org_linphone_core_tools_service_CoreManager_updatePushNotificationInformation
(
JNIEnv
*
env
,
jobject
thiz
,
jlong
ptr
,
jstring
param
,
jstring
prid
)
{
LinphoneCore
*
core
=
static_cast
<
LinphoneCore
*>
((
void
*
)
ptr
);
const
char
*
paramC
=
GetStringUTFChars
(
env
,
param
);
const
char
*
pridC
=
GetStringUTFChars
(
env
,
prid
);
linphone_core_update_push_notification_information
(
core
,
paramC
,
pridC
);
ReleaseStringUTFChars
(
env
,
prid
,
pridC
);
ReleaseStringUTFChars
(
env
,
param
,
paramC
);
}
LINPHONE_END_NAMESPACE
tester/call_multi_tester.c
View file @
1d055b91
...
...
@@ -294,13 +294,35 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag
is_remote_conf
=
(
strcmp
(
lp_config_get_string
(
linphone_core_get_config
(
marie
->
lc
),
"misc"
,
"conference_type"
,
"local"
),
"remote"
)
==
0
);
if
(
is_remote_conf
)
BC_ASSERT_PTR_NOT_NULL
(
focus
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
if
(
!
BC_ASSERT_TRUE
(
call
(
marie
,
pauline
)))
goto
end
;
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
marie_call_pauline
=
linphone_core_get_current_call
(
marie
->
lc
);
pauline_called_by_marie
=
linphone_core_get_current_call
(
pauline
->
lc
);
BC_ASSERT_TRUE
(
pause_call_1
(
marie
,
marie_call_pauline
,
pauline
,
pauline_called_by_marie
));
if
(
!
BC_ASSERT_TRUE
(
call
(
marie
,
laure
)))
goto
end
;
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
initial_marie_stat
=
marie
->
stat
;
initial_pauline_stat
=
pauline
->
stat
;
initial_laure_stat
=
laure
->
stat
;
...
...
@@ -400,6 +422,9 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag
if
(
is_remote_conf
)
BC_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
focus
->
stat
.
number_of_LinphoneCallReleased
,
3
,
10000
));
end:
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
laure
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
bctbx_list_free
(
lcs
);
}
...
...
tester/call_single_tester.c
View file @
1d055b91
...
...
@@ -188,6 +188,11 @@ void simple_call_base(bool_t enable_multicast_recv_side, bool_t disable_soundcar
linphone_core_enable_audio_multicast
(
pauline
->
lc
,
enable_multicast_recv_side
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
if
(
use_multipart_invite_body
)
{
LinphoneCallParams
*
params
=
linphone_core_create_call_params
(
marie
->
lc
,
NULL
);
...
...
@@ -205,6 +210,11 @@ void simple_call_base(bool_t enable_multicast_recv_side, bool_t disable_soundcar
BC_ASSERT_TRUE
(
call
(
marie
,
pauline
));
}
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreFirstCallStarted
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
BC_ASSERT_NOT_EQUAL
(
pauline
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);
pauline_call
=
linphone_core_get_current_call
(
pauline
->
lc
);
BC_ASSERT_PTR_NOT_NULL
(
pauline_call
);
/*check that display name is correctly propagated in From */
...
...
@@ -241,6 +251,10 @@ void simple_call_base(bool_t enable_multicast_recv_side, bool_t disable_soundcar
liblinphone_tester_check_rtcp
(
marie
,
pauline
);
end_call
(
marie
,
pauline
);
BC_ASSERT_EQUAL
(
marie
->
stat
.
number_of_LinphoneCoreLastCallEnded
,
1
,
int
,
"%d"
);