Commit cf86a35a authored by Benjamin REIS's avatar Benjamin REIS
Browse files

Merge remote-tracking branch 'origin/master' into dev_conference_info

parents fc029784 7f1414a6
......@@ -115,11 +115,13 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_ortp_CONFIG_DIR}/ORTPConfig.cmake")
set(BcToolbox_FIND_COMPONENTS tester)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
include("${EP_belr_CONFIG_DIR}/BelrConfig.cmake")
else()
find_package(BelleSIP REQUIRED)
find_package(Mediastreamer2 REQUIRED)
find_package(ORTP REQUIRED)
find_package(BcToolbox 0.0.3 REQUIRED OPTIONAL_COMPONENTS tester)
find_package(Belr REQUIRED)
endif()
find_package(XML2 REQUIRED)
find_package(Zlib)
......@@ -208,6 +210,7 @@ set(LINPHONE_INCLUDE_DIRS
${BELLESIP_INCLUDE_DIRS}
${MEDIASTREAMER2_INCLUDE_DIRS}
${BCTOOLBOX_CORE_INCLUDE_DIRS}
${BELR_INCLUDE_DIRS}
)
if (BZRTP_FOUND)
list(APPEND LINPHONE_INCLUDE_DIRS ${BZRTP_INCLUDE_DIRS})
......@@ -243,7 +246,7 @@ if(MSVC)
endif()
add_definitions("-DLINPHONE_EXPORTS")
set(LINPHONE_CPPFLAGS ${BELCARD_CPPFLAGS} ${BELLESIP_CPPFLAGS} ${MEDIASTREAMER2_CPPFLAGS} ${BCTOOLBOX_CPPFLAGS})
set(LINPHONE_CPPFLAGS ${BELCARD_CPPFLAGS} ${BELLESIP_CPPFLAGS} ${MEDIASTREAMER2_CPPFLAGS} ${BCTOOLBOX_CPPFLAGS} ${BELR_CPPFLAGS})
if(ENABLE_STATIC)
list(APPEND LINPHONE_CPPFLAGS "-DLINPHONE_STATIC")
endif()
......
......@@ -35,13 +35,22 @@ endif()
set(LINPHONE_PRIVATE_HEADER_FILES
../src/conference/conference-info.hxx
../src/conference/conference-listener.h
../src/conference/local-conference-event-handler.h
../src/conference/remote-conference-event-handler.h
../src/cpim/cpim.h
../src/cpim/header/cpim-core-headers.h
../src/cpim/header/cpim-generic-header.h
../src/cpim/header/cpim-header-p.h
../src/cpim/header/cpim-header.h
../src/cpim/message/cpim-message.h
../src/cpim/parser/cpim-grammar.h
../src/cpim/parser/cpim-parser.h
../src/object/object.h
../src/object/singleton.h
../src/utils/general.h
../src/conference/conference-listener.h
../src/conference/remote-conference-event-handler.h
../src/conference/local-conference-event-handler.h
../src/conference/conference-info.hxx
../src/utils/utils.h
bellesip_sal/sal_impl.h
carddav.h
conference_private.h
......@@ -128,9 +137,16 @@ set(LINPHONE_SOURCE_FILES_C
)
set(LINPHONE_SOURCE_FILES_CXX
conference.cc
../src/conference/remote-conference-event-handler.cpp
../src/conference/local-conference-event-handler.cpp
../src/conference/conference-info.cxx
../src/conference/local-conference-event-handler.cpp
../src/conference/remote-conference-event-handler.cpp
../src/cpim/header/cpim-core-headers.cpp
../src/cpim/header/cpim-generic-header.cpp
../src/cpim/header/cpim-header.cpp
../src/cpim/message/cpim-message.cpp
../src/cpim/parser/cpim-grammar.cpp
../src/cpim/parser/cpim-parser.cpp
../src/utils/utils.cpp
)
set(LINPHONE_INCLUDE_DIRS ${LINPHONE_INCLUDE_DIRS} /Users/reisbenjamin/xsd-4.0.0-i686-macosx/libxsd /usr/local/Cellar/xerces-c/3.1.4/include)
if(ANDROID)
......@@ -168,7 +184,11 @@ set(LIBS
${MEDIASTREAMER2_LIBRARIES}
${ORTP_LIBRARIES}
${XML2_LIBRARIES}
<<<<<<< HEAD
/usr/local/Cellar/xerces-c/3.1.4/lib/libxerces-c.dylib
=======
${BELR_LIBRARIES}
>>>>>>> origin/master
)
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
list(APPEND LIBS "Ws2_32")
......
......@@ -117,13 +117,14 @@ void linphone_chat_message_cbs_set_file_transfer_progress_indication(
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatMessage);
static void _linphone_chat_room_destroy(LinphoneChatRoom *cr) {
bctbx_list_free_with_data(cr->transient_messages, (void (*)(void *))linphone_chat_message_release);
if (cr->received_rtt_characters) {
cr->received_rtt_characters = bctbx_list_free_with_data(cr->received_rtt_characters, (void (*)(void *))ms_free);
}
linphone_chat_room_delete_composing_idle_timer(cr);
linphone_chat_room_delete_composing_refresh_timer(cr);
linphone_chat_room_delete_remote_composing_refresh_timer(cr);
bctbx_list_free_with_data(cr->transient_messages, (bctbx_list_free_func)linphone_chat_message_release);
if (cr->weak_messages != NULL) bctbx_list_free(cr->weak_messages);
if (cr->received_rtt_characters) {
cr->received_rtt_characters = bctbx_list_free_with_data(cr->received_rtt_characters, (bctbx_list_free_func)ms_free);
}
if (cr->lc != NULL) {
if (bctbx_list_find(cr->lc->chatrooms, cr)) {
ms_error("LinphoneChatRoom[%p] is destroyed while still being used by the LinphoneCore. This is abnormal."
......@@ -138,7 +139,6 @@ static void _linphone_chat_room_destroy(LinphoneChatRoom *cr) {
if (cr->pending_message)
linphone_chat_message_destroy(cr->pending_message);
ms_free(cr->peer);
if (cr->weak_messages != NULL) bctbx_list_free(cr->weak_messages);
}
void linphone_chat_message_set_state(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
......@@ -313,6 +313,7 @@ void linphone_chat_room_release(LinphoneChatRoom *cr) {
linphone_chat_room_delete_composing_refresh_timer(cr);
linphone_chat_room_delete_remote_composing_refresh_timer(cr);
bctbx_list_for_each(cr->weak_messages, (bctbx_list_iterate_func)linphone_chat_message_deactivate);
bctbx_list_for_each(cr->transient_messages, (bctbx_list_iterate_func)linphone_chat_message_deactivate);
cr->lc = NULL;
linphone_chat_room_unref(cr);
}
......@@ -784,8 +785,8 @@ static const char *iscomposing_prefix = "/xsi:isComposing";
static void process_im_is_composing_notification(LinphoneChatRoom *cr, xmlparsing_context_t *xml_ctx) {
char xpath_str[MAX_XPATH_LENGTH];
xmlXPathObjectPtr iscomposing_object;
const char *state_str = NULL;
const char *refresh_str = NULL;
char *state_str = NULL;
char *refresh_str = NULL;
int refresh_duration = lp_config_get_int(cr->lc->config, "sip", "composing_remote_refresh_timeout",
COMPOSING_DEFAULT_REMOTE_REFRESH_TIMEOUT);
int i;
......@@ -860,8 +861,8 @@ static void process_imdn(LinphoneChatRoom *cr, xmlparsing_context_t *xml_ctx) {
xmlXPathObjectPtr imdn_object;
xmlXPathObjectPtr delivery_status_object;
xmlXPathObjectPtr display_status_object;
const char *message_id_str = NULL;
const char *datetime_str = NULL;
char *message_id_str = NULL;
char *datetime_str = NULL;
LinphoneCore *lc = linphone_chat_room_get_core(cr);
LinphoneImNotifPolicy *policy = linphone_core_get_im_notif_policy(lc);
......@@ -1717,11 +1718,11 @@ void linphone_chat_message_unref(LinphoneChatMessage *msg) {
}
static void linphone_chat_message_deactivate(LinphoneChatMessage *msg){
/*mark the chat msg as orphan (it has no chat room anymore)*/
msg->chat_room = NULL;
if (msg->file_transfer_information != NULL) {
linphone_chat_message_cancel_file_transfer(msg);
_linphone_chat_message_cancel_file_transfer(msg, FALSE);
}
/*mark the chat msg as orphan (it has no chat room anymore)*/
msg->chat_room = NULL;
}
static void linphone_chat_message_release(LinphoneChatMessage *msg) {
......
......@@ -335,7 +335,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data,
} else { /* no encryption key, transfer in plain, just copy the msg sent by server */
msg->message = ms_strdup(body);
}
msg->content_type = ms_strdup("application/vnd.gsma.rcs-ft-http+xml");
linphone_chat_message_set_content_type(msg, "application/vnd.gsma.rcs-ft-http+xml");
linphone_chat_message_ref(msg);
linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone);
_release_http_request(msg);
......@@ -613,7 +613,7 @@ void linphone_chat_message_start_file_download(LinphoneChatMessage *msg,
linphone_chat_message_download_file(msg);
}
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
void _linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg, bool_t unref) {
if (msg->http_request) {
if (msg->state == LinphoneChatMessageStateInProgress) {
linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered);
......@@ -625,7 +625,7 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
, msg
, msg->chat_room);
belle_http_provider_cancel_request(msg->chat_room->lc->http_provider, msg->http_request);
if (msg->dir == LinphoneChatMessageOutgoing) {
if ((msg->dir == LinphoneChatMessageOutgoing) && unref) {
// must release it
linphone_chat_message_unref(msg);
}
......@@ -639,6 +639,10 @@ void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
}
}
void linphone_chat_message_cancel_file_transfer(LinphoneChatMessage *msg) {
_linphone_chat_message_cancel_file_transfer(msg, TRUE);
}
void linphone_chat_message_set_file_transfer_filepath(LinphoneChatMessage *msg, const char *filepath) {
if (msg->file_transfer_filepath != NULL) {
ms_free(msg->file_transfer_filepath);
......
......@@ -205,9 +205,9 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
LinphoneFriend *lf;
LinphoneContent *presence_part;
xmlXPathObjectPtr resource_object;
const char *version_str = NULL;
const char *full_state_str = NULL;
const char *uri = NULL;
char *version_str = NULL;
char *full_state_str = NULL;
char *uri = NULL;
bool_t full_state = FALSE;
int version;
int i;
......@@ -249,7 +249,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList
resource_object = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/rlmi:list/rlmi:resource/rlmi:instance[@state=\"active\"]/..");
if ((resource_object != NULL) && (resource_object->nodesetval != NULL)) {
for (i = 1; i <= resource_object->nodesetval->nodeNr; i++) {
const char *cid = NULL;
char *cid = NULL;
linphone_xml_xpath_context_set_node(xml_ctx, xmlXPathNodeSetItem(resource_object->nodesetval, i-1));
cid = linphone_get_xml_text_content(xml_ctx, "./rlmi:instance/@cid");
if (cid != NULL) {
......
......@@ -579,8 +579,8 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
uint8_t selfZid[12]; /* same data but in byte buffer */
char xpath_str[MAX_XPATH_LENGTH];
limeKey_t associatedKey;
const char *peerZidHex = NULL;
const char *sessionIndexHex = NULL;
char *peerZidHex = NULL;
char *sessionIndexHex = NULL;
xmlparsing_context_t *xml_ctx;
xmlXPathObjectPtr msg_object;
uint8_t *encryptedMessage = NULL;
......@@ -635,12 +635,14 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
msg_object = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/doc/msg");
if ((msg_object != NULL) && (msg_object->nodesetval != NULL)) {
for (i = 1; i <= msg_object->nodesetval->nodeNr; i++) {
const char *currentZidHex;
const char *encryptedMessageb64;
const char *encryptedContentTypeb64;
char *currentZidHex;
char *encryptedMessageb64;
char *encryptedContentTypeb64;
snprintf(xpath_str, sizeof(xpath_str), "/doc/msg[%i]/pzid", i);
currentZidHex = linphone_get_xml_text_content(xml_ctx, xpath_str);
if ((currentZidHex != NULL) && (strcmp(currentZidHex, (char *)selfZidHex) == 0)) {
linphone_free_xml_text_content(currentZidHex);
/* We found the msg node we are looking for */
snprintf(xpath_str, sizeof(xpath_str), "/doc/msg[%i]/index", i);
sessionIndexHex = linphone_get_xml_text_content(xml_ctx, xpath_str);
......@@ -665,9 +667,9 @@ int lime_decryptMultipartMessage(void *cachedb, uint8_t *message, const char *se
}
break;
}
if (currentZidHex != NULL) linphone_free_xml_text_content(currentZidHex);
}
}
if (msg_object != NULL) xmlXPathFreeObject(msg_object);
}
/* do we have retrieved correctly all the needed data */
......@@ -766,6 +768,7 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) {
return the list of possible uris and store the selected one in the chatroom ? */
res = (lime_getCachedSndKeysByURI(zrtp_cache_db, &associatedKeys) == 0);
lime_freeKeys(&associatedKeys);
ms_free(peer);
return res;
}
}
......@@ -795,7 +798,10 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
}
peerUri = linphone_address_as_string_uri_only(msg->from);
selfUri = linphone_address_as_string_uri_only(msg->to);
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type, bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0")));
retval = lime_decryptMultipartMessage(zrtp_cache_db, (uint8_t *)msg->message, selfUri, peerUri, &decrypted_body, &decrypted_content_type,
bctbx_time_string_to_sec(lp_config_get_string(lc->config, "sip", "lime_key_validity", "0")));
ms_free(peerUri);
ms_free(selfUri);
if (retval != 0) {
ms_warning("Unable to decrypt message, reason : %s", lime_error_code_to_string(retval));
if (decrypted_body) ms_free(decrypted_body);
......@@ -809,6 +815,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneImEncryptionEn
msg->message = (char *)decrypted_body;
if (decrypted_content_type != NULL) {
linphone_chat_message_set_content_type(msg, decrypted_content_type);
ms_free(decrypted_content_type);
} else {
if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0) {
linphone_chat_message_set_content_type(msg, "application/vnd.gsma.rcs-ft-http+xml");
......@@ -863,7 +870,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneImEncryptionEn
ms_free(msg->message);
}
msg->message = (char *)crypted_body;
msg->content_type = ms_strdup(new_content_type);
linphone_chat_message_set_content_type(msg, new_content_type);
}
ms_free(peerUri);
ms_free(selfUri);
......
......@@ -1721,6 +1721,9 @@ static void linphone_call_set_terminated(LinphoneCall *call){
if (call->chat_room){
call->chat_room->call = NULL;
}
if (lc->calls == NULL){
ms_bandwidth_controller_reset_state(lc->bw_controller);
}
}
/*function to be called at each incoming reINVITE, in order to adjust various local parameters to what is being offered by remote:
......
......@@ -6227,6 +6227,9 @@ static void set_media_network_reachable(LinphoneCore* lc, bool_t is_media_reacha
bctbx_list_for_each(lc->calls, (MSIterateFunc)linphone_call_refresh_sockets);
}
linphone_core_repair_calls(lc);
if (lc->bw_controller){
ms_bandwidth_controller_reset_state(lc->bw_controller);
}
}
}
......@@ -6623,8 +6626,7 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
int ret;
const char *errmsg;
const char *backupExtension = "_backup";
char *backupName = reinterpret_cast<char *>(malloc(snprintf(NULL, 0, "%s%s", fileName, backupExtension) + 1));
sprintf(backupName, "%s%s", fileName, backupExtension);
char *backupName = bctbx_strdup_printf("%s%s", fileName, backupExtension);
sqlite3 *db;
linphone_core_zrtp_cache_close(lc);
......@@ -6637,7 +6639,7 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
unlink(backupName);
rename(fileName, backupName);
lc->zrtp_cache_db=NULL;
return;
goto end;
}
ret = ms_zrtp_initCache((void *)db); /* this may perform an update, check return value */
......@@ -6652,11 +6654,13 @@ void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName) {
unlink(backupName);
rename(fileName, backupName);
lc->zrtp_cache_db = NULL;
return;
goto end;
}
/* everything ok, set the db pointer into core */
lc->zrtp_cache_db = db;
end:
if (backupName) bctbx_free(backupName);
#endif /* SQLITE_STORAGE_ENABLED */
}
......@@ -7011,9 +7015,9 @@ const char * linphone_core_get_video_preset(const LinphoneCore *lc) {
static int linphone_core_call_void_method(jobject obj, jmethodID id) {
JNIEnv *env=ms_get_jni_env();
if (env && obj) {
(*env)->CallVoidMethod(env,obj,id);
if ((*env)->ExceptionCheck(env)) {
(*env)->ExceptionClear(env);
env->CallVoidMethod(obj,id);
if (env->ExceptionCheck()) {
env->ExceptionClear();
return -1;
} else
return 0;
......
......@@ -3512,6 +3512,107 @@ extern "C" jint Java_org_linphone_core_PayloadTypeImpl_getRate(JNIEnv* env,jobj
return (jint)payload_type_get_rate(pt);
}
/* Linphone Player */
struct LinphonePlayerData {
LinphonePlayerData(JNIEnv *env, jobject listener, jobject window) :
mListener(env->NewGlobalRef(listener)),
mWindow(env->NewGlobalRef(window))
{
mListenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass(listener));
mEndOfFileMethodID = env->GetMethodID(mListenerClass, "endOfFile", "(Lorg/linphone/core/LinphonePlayer;)V");
if(mEndOfFileMethodID == NULL) {
ms_error("Could not get endOfFile method ID");
env->ExceptionClear();
}
}
~LinphonePlayerData() {
JNIEnv *env;
jvm->AttachCurrentThread(&env, NULL);
env->DeleteGlobalRef(mListener);
env->DeleteGlobalRef(mListenerClass);
if (mWindow) env->DeleteGlobalRef(mWindow);
}
void setPlayer(jobject player) { mJLinphonePlayer = player; }
jobject mListener;
jclass mListenerClass;
jobject mJLinphonePlayer;
jobject mWindow;
jmethodID mEndOfFileMethodID;
};
static void _eof_callback(LinphonePlayer *player) {
JNIEnv *env;
LinphonePlayerData *player_data = (LinphonePlayerData *)linphone_player_get_user_data(player);
jvm->AttachCurrentThread(&env, NULL);
env->CallVoidMethod(player_data->mListener, player_data->mEndOfFileMethodID, player_data->mJLinphonePlayer);
}
extern "C" void Java_org_linphone_core_LinphonePlayerImpl_init(JNIEnv *env, jobject jPlayer, jlong ptr) {
LinphonePlayer *player = (LinphonePlayer *)ptr;
LinphonePlayerData *data = (LinphonePlayerData *)linphone_player_get_user_data(player);
data->setPlayer(jPlayer);
linphone_player_cbs_set_eof_reached(linphone_player_get_callbacks(player), _eof_callback);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename) {
const char *cfilename = GetStringUTFChars(env, filename);
if(linphone_player_open((LinphonePlayer *)ptr, cfilename) == -1) {
ReleaseStringUTFChars(env, filename, cfilename);
return -1;
}
ReleaseStringUTFChars(env, filename, cfilename);
return 0;
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_start(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_start((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_pause(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_pause((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_seek(JNIEnv *env, jobject jobj, jlong ptr, jint timeMs) {
return (jint)linphone_player_seek((LinphonePlayer *)ptr, timeMs);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getState(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_state((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getDuration(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_duration((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getCurrentPosition(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_current_position((LinphonePlayer *)ptr);
}
extern "C" void Java_org_linphone_core_LinphonePlayerImpl_close(JNIEnv *env, jobject playerPtr, jlong ptr) {
LinphonePlayer *player = (LinphonePlayer *)ptr;
if(player->user_data) {
LinphonePlayerData *data = (LinphonePlayerData *)player->user_data;
if(data) delete data;
player->user_data = NULL;
}
linphone_player_close(player);
}
extern "C" void Java_org_linphone_core_LinphonePlayerImpl_destroy(JNIEnv *env, jobject jobj, jlong playerPtr) {
LinphonePlayer *player = (LinphonePlayer *)playerPtr;
if(player == NULL) {
ms_error("Cannot destroy the LinphonePlayerImpl object. Native pointer is NULL");
return;
}
if(linphone_player_get_user_data(player)) {
delete (LinphonePlayerData *)linphone_player_get_user_data(player);
}
linphone_player_unref(player);
}
//LinphoneCall
extern "C" void Java_org_linphone_core_LinphoneCallImpl_finalize(JNIEnv* env
,jobject thiz
......@@ -3702,7 +3803,10 @@ extern "C" jfloat Java_org_linphone_core_LinphoneCallImpl_getAverageQuality( JNI
}
extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getPlayer(JNIEnv *env, jobject thiz, jlong callPtr) {
return (jlong)linphone_call_get_player((LinphoneCall *)callPtr);
LinphonePlayer *player = linphone_call_get_player((LinphoneCall *)callPtr);
LinphonePlayerData *data = new LinphonePlayerData(env, thiz, NULL);
linphone_player_set_user_data(player, data);
return (jlong)linphone_player_ref(player);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_mediaInProgress( JNIEnv* env
......@@ -7503,109 +7607,15 @@ JNIEXPORT void JNICALL Java_org_linphone_core_ErrorInfoImpl_unref(JNIEnv *env, j
}
#endif
/* Linphone Player */
struct LinphonePlayerData {
LinphonePlayerData(JNIEnv *env, jobject listener, jobject jLinphonePlayer) :
mListener(env->NewGlobalRef(listener)),
mJLinphonePlayer(env->NewGlobalRef(jLinphonePlayer))
{
mListenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass(listener));
mEndOfFileMethodID = env->GetMethodID(mListenerClass, "endOfFile", "(Lorg/linphone/core/LinphonePlayer;)V");
if(mEndOfFileMethodID == NULL) {
ms_error("Could not get endOfFile method ID");
env->ExceptionClear();
}
}
~LinphonePlayerData() {
JNIEnv *env;
jvm->AttachCurrentThread(&env, NULL);
env->DeleteGlobalRef(mListener);
env->DeleteGlobalRef(mListenerClass);
env->DeleteGlobalRef(mJLinphonePlayer);
}
jobject mListener;
jclass mListenerClass;
jobject mJLinphonePlayer;
jmethodID mEndOfFileMethodID;
};
static void _eof_callback(LinphonePlayer *player, void *user_data) {
JNIEnv *env;
LinphonePlayerData *player_data = (LinphonePlayerData *)user_data;
jvm->AttachCurrentThread(&env, NULL);
env->CallVoidMethod(player_data->mListener, player_data->mEndOfFileMethodID, player_data->mJLinphonePlayer);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename) {
const char *cfilename = GetStringUTFChars(env, filename);
if(linphone_player_open((LinphonePlayer *)ptr, cfilename) == -1) {
ReleaseStringUTFChars(env, filename, cfilename);
return -1;
}
ReleaseStringUTFChars(env, filename, cfilename);
return 0;
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_start(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_start((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_pause(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_pause((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_seek(JNIEnv *env, jobject jobj, jlong ptr, jint timeMs) {
return (jint)linphone_player_seek((LinphonePlayer *)ptr, timeMs);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getState(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_state((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getDuration(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_duration((LinphonePlayer *)ptr);
}
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_getCurrentPosition(JNIEnv *env, jobject jobj, jlong ptr) {
return (jint)linphone_player_get_current_position((LinphonePlayer *)ptr);
}
extern "C" void Java_org_linphone_core_LinphonePlayerImpl_close(JNIEnv *env, jobject playerPtr, jlong ptr) {
LinphonePlayer *player = (LinphonePlayer *)ptr;
if(player->user_data) {
LinphonePlayerData *data = (LinphonePlayerData *)player->user_data;
if(data) delete data;
player->user_data = NULL;
}
linphone_player_close(player);
}
extern "C" void Java_org_linphone_core_LinphonePlayerImpl_destroy(JNIEnv *env, jobject jobj, jlong playerPtr) {
LinphonePlayer *player = (LinphonePlayer *)playerPtr;
if(player == NULL) {
ms_error("Cannot destroy the LinphonePlayerImpl object. Native pointer is NULL");
return;
}
if(player->user_data) {
delete (LinphonePlayerData *)player->user_data;
}
jobject window_id = (jobject)ms_media_player_get_window_id((MSMediaPlayer *)player->impl);
if(window_id) env->DeleteGlobalRef(window_id);
_linphone_player_destroy(player);
}
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createLocalPlayer(JNIEnv *env, jobject jobj, jlong ptr, jobject window) {
jobject window_ref = NULL;
window_ref = env->NewGlobalRef(window);
LinphonePlayer *player = linphone_core_create_local_player((LinphoneCore *)ptr, NULL, "MSAndroidDisplay", (void *)window_ref);
LinphonePlayer *player = linphone_core_create_local_player((LinphoneCore *)ptr, NULL, "MSAndroidDisplay", (void *)window);
LinphonePlayerData *data = new LinphonePlayerData(env, jobj, window);
linphone_player_set_user_data(player, data);
if(player == NULL) {
ms_error("Fails to create a player");
if(window_ref) env->DeleteGlobalRef(window_ref);
return 0;
} else {
return (jlong)player;
return (jlong)linphone_player_ref(player);
}
}