Merge branch 'dev_refactor_cpp' into dev_refactor_cpp_qrcode

This commit is contained in:
Erwan Croze 2018-04-05 13:59:04 +02:00
commit 9234ac3d72
38 changed files with 2894 additions and 267 deletions

View file

@ -84,6 +84,7 @@ set(LINPHONE_SOURCE_FILES_C
linphonecore.c
linphone_tunnel_config.c
localplayer.c
logging.c
lpc2xml.c
lpconfig.c
lsd.c

View file

@ -167,6 +167,7 @@ static LinphoneCore *_linphone_factory_create_core (
LpConfig *config = lp_config_new_with_factory(config_path, factory_config_path);
LinphoneCore *lc = _linphone_core_new_with_config(cbs, config, user_data, system_context, automatically_start);
lp_config_unref(config);
bctbx_uninit_logger();
return lc;
}

View file

@ -39,7 +39,6 @@ if (ENABLE_DOC OR ENABLE_CXX_WRAPPER OR ENABLE_CSHARP_WRAPPER OR ENABLE_JAVA_WRA
set(XML_DIR "${CMAKE_CURRENT_BINARY_DIR}/xml")
set(LINPHONE_DOXYGEN_XML_DIR ${XML_DIR} PARENT_SCOPE)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html/index.html" "${XML_DIR}/index.xml"
COMMAND ${CMAKE_COMMAND} -E remove -f html/* xml/*
COMMAND ${CMAKE_COMMAND} -E remove -f html/* xml/*
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
DEPENDS ${DOC_INPUT_FILES}

View file

@ -21,7 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "linphone/core.h"
#include "linphone/sipsetup.h"
#include "linphone/lpconfig.h"
#include "linphone/logging.h"
#include "private.h"
#include "logging-private.h"
#include "quality_reporting.h"
#include "lime.h"
#include "conference_private.h"
@ -509,40 +511,17 @@ void linphone_core_set_log_file(FILE *file) {
}
void linphone_core_set_log_level(OrtpLogLevel loglevel) {
unsigned int mask = loglevel;
switch (loglevel) {
case ORTP_TRACE:
case ORTP_DEBUG:
mask |= ORTP_DEBUG;
BCTBX_NO_BREAK;
case ORTP_MESSAGE:
mask |= ORTP_MESSAGE;
BCTBX_NO_BREAK;
case ORTP_WARNING:
mask |= ORTP_WARNING;
BCTBX_NO_BREAK;
case ORTP_ERROR:
mask |= ORTP_ERROR;
BCTBX_NO_BREAK;
case ORTP_FATAL:
mask |= ORTP_FATAL;
break;
case ORTP_LOGLEV_END:
break;
}
linphone_core_set_log_level_mask(mask);
LinphoneLoggingService *log_service = linphone_logging_service_get();
linphone_logging_service_set_log_level(log_service, _bctbx_log_level_to_linphone_log_level(loglevel));
}
void linphone_core_set_log_level_mask(unsigned int loglevel) {
bctbx_set_log_level_mask("bctbx", (int)loglevel);
bctbx_set_log_level_mask("ortp", (int)loglevel);
bctbx_set_log_level_mask("mediastreamer", (int)loglevel);
bctbx_set_log_level_mask("bzrtp", (int)loglevel); /*need something to set log level for all domains*/
bctbx_set_log_level_mask("linphone", (int)loglevel);
sal_set_log_level((OrtpLogLevel)loglevel);
void linphone_core_set_log_level_mask(unsigned int mask) {
LinphoneLoggingService *log_service = linphone_logging_service_get();
linphone_logging_service_set_log_level_mask(log_service, _bctbx_log_mask_to_linphone_log_mask(mask));
}
unsigned int linphone_core_get_log_level_mask(void) {
return bctbx_get_log_level_mask(ORTP_LOG_DOMAIN);
LinphoneLoggingService *log_service = linphone_logging_service_get();
return linphone_logging_service_get_log_level_mask(log_service);
}
static int _open_log_collection_file_with_idx(int idx) {
struct stat statbuf;

View file

@ -4462,7 +4462,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIE
,jlong ptr) {
return (jlong) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
}
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jmessage) {
@ -4470,29 +4470,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatM
LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message);
ReleaseStringUTFChars(env, jmessage, message);
return (jlong) chatMessage;
return getChatMessage(env, chatMessage);
}
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatMessage2(JNIEnv* env
,jobject thiz
,jlong ptr
,jstring jmessage
,jstring jurl
,jint state
,jlong time
,jboolean read
,jboolean incoming) {
const char* message = GetStringUTFChars(env, jmessage);
const char* url = GetStringUTFChars(env, jurl);
LinphoneChatMessage *chatMessage = linphone_chat_room_create_message_2(
(LinphoneChatRoom *)ptr, message, url, (LinphoneChatMessageState)state,
(time_t)time, read, incoming);
ReleaseStringUTFChars(env, jmessage, message);
ReleaseStringUTFChars(env, jurl, url);
return (jlong) chatMessage;
}
extern "C" jint Java_org_linphone_core_LinphoneChatRoomImpl_getHistorySize (JNIEnv* env
,jobject thiz
,jlong ptr) {
@ -4527,7 +4508,7 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_markAsRead(JNIEnv*
}
extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferMessage(JNIEnv* env, jobject thiz, jlong ptr, jstring jname, jstring jtype, jstring jsubtype, jint data_size) {
extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferMessage(JNIEnv* env, jobject thiz, jlong ptr, jstring jname, jstring jtype, jstring jsubtype, jint data_size) {
LinphoneCore *lc = linphone_chat_room_get_core((LinphoneChatRoom*) ptr);
LinphoneContent * content = linphone_core_create_content(lc);
LinphoneChatMessage *message = NULL;
@ -4548,7 +4529,7 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferM
linphone_content_unref(content);
return (jlong) message;
return getChatMessage(env, message);
}
extern "C" jboolean Java_org_linphone_core_LinphoneChatRoomImpl_islimeAvailable(JNIEnv *env, jobject thiz, jlong ptr) {
@ -4726,6 +4707,22 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_reSend(JNIEnv* e
linphone_chat_message_resend_2((LinphoneChatMessage*)ptr);
}
static jobject getMessageListener(JNIEnv *env, LinphoneChatMessage *msg){
jobject listener = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data(msg);
if (listener == NULL) {
ms_error("message_state_changed() notification without listener");
return NULL;
}
listener = env->NewLocalRef(listener); //promote the weak ref into a local ref*/
if (listener == NULL){
ms_error("message_state_changed() listener is no longer valid");
linphone_chat_message_set_message_state_changed_cb_user_data(msg, NULL);
return NULL;
}
return listener;
}
static void message_state_changed(LinphoneChatMessage* msg, LinphoneChatMessageState state) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
@ -4734,12 +4731,9 @@ static void message_state_changed(LinphoneChatMessage* msg, LinphoneChatMessageS
return;
}
jobject listener = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data(msg);
jobject listener = getMessageListener(env, msg);
if (!listener) return;
if (listener == NULL) {
ms_error("message_state_changed() notification without listener");
return ;
}
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
jobject jmessage = getChatMessage(env, msg);
@ -4749,14 +4743,7 @@ static void message_state_changed(LinphoneChatMessage* msg, LinphoneChatMessageS
LinphoneCore *lc = linphone_chat_room_get_core(room);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
env->CallVoidMethod(listener, method, jmessage, env->CallStaticObjectMethod(ljb->chatMessageStateClass, ljb->chatMessageStateFromIntId, (jint)state));
if (state == LinphoneChatMessageStateDisplayed) {
env->DeleteGlobalRef(listener);
linphone_chat_message_set_message_state_changed_cb_user_data(msg, NULL);
}
if (jmessage) {
env->DeleteLocalRef(jmessage);
}
env->DeleteLocalRef(listener);
}
static void file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t total) {
@ -4767,7 +4754,8 @@ static void file_transfer_progress_indication(LinphoneChatMessage *msg, const Li
return;
}
jobject listener = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data(msg);
jobject listener = getMessageListener(env, msg);
if (!listener) return;
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageFileTransferProgressChanged", "(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;II)V");
env->DeleteLocalRef(clazz);
@ -4790,7 +4778,8 @@ static void file_transfer_recv(LinphoneChatMessage *msg, const LinphoneContent*
return;
}
jobject listener = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data(msg);
jobject listener = getMessageListener(env, msg);
if (!listener) return;
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageFileTransferReceived", "(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;Lorg/linphone/core/LinphoneBuffer;)V");
env->DeleteLocalRef(clazz);
@ -4819,7 +4808,8 @@ static LinphoneBuffer* file_transfer_send(LinphoneChatMessage *msg, const Linph
return buffer;
}
jobject listener = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data(msg);
jobject listener = getMessageListener(env, msg);
if (!listener) return NULL;
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageFileTransferSent","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneContent;IILorg/linphone/core/LinphoneBuffer;)V");
env->DeleteLocalRef(clazz);
@ -4840,12 +4830,15 @@ static LinphoneBuffer* file_transfer_send(LinphoneChatMessage *msg, const Linph
return buffer;
}
/*
* When the listener is set, we must take a global reference to the listener and the message, so that
* we are able to notify the state changes of the message, until it reaches its final state
*/
extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setListener(JNIEnv* env, jobject thiz, jlong ptr, jobject jlistener) {
jobject listener = env->NewGlobalRef(jlistener);
LinphoneChatMessage *message = (LinphoneChatMessage *)ptr;
LinphoneChatMessageCbs *cbs;
linphone_chat_message_set_message_state_changed_cb_user_data(message, listener);
linphone_chat_message_set_message_state_changed_cb_user_data(message, env->NewWeakGlobalRef(jlistener));
cbs = linphone_chat_message_get_callbacks(message);
linphone_chat_message_cbs_set_msg_state_changed(cbs, message_state_changed);
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
@ -4857,10 +4850,15 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_unref(JNIEnv* en
,jobject thiz
,jlong ptr) {
jobject wref = (jobject)linphone_chat_message_get_user_data((LinphoneChatMessage*)ptr);
jobject listener_wref = (jobject) linphone_chat_message_get_message_state_changed_cb_user_data((LinphoneChatMessage*)ptr);
linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr, NULL);
if (wref){
env->DeleteWeakGlobalRef(wref);
}
if (listener_wref){
linphone_chat_message_set_message_state_changed_cb_user_data((LinphoneChatMessage*)ptr, NULL);
env->DeleteWeakGlobalRef(listener_wref);
}
linphone_chat_message_unref((LinphoneChatMessage*)ptr);
}
@ -4895,34 +4893,6 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*
ReleaseStringUTFChars(env, jmessage, message);
}
static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
if (result != 0) {
ms_error("cannot attach VM\n");
return;
}
jobject listener = (jobject) ud;
jclass clazz = (jclass) env->GetObjectClass(listener);
jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V");
jobject jmessage=(jobject)linphone_chat_message_get_user_data(msg);
LinphoneChatRoom *room = linphone_chat_message_get_chat_room(msg);
LinphoneCore *lc = linphone_chat_room_get_core(room);
LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
env->CallVoidMethod(
listener,
method,
jmessage,
env->CallStaticObjectMethod(ljb->chatMessageStateClass,ljb->chatMessageStateFromIntId,(jint)state));
if (state == LinphoneChatMessageStateDisplayed ) {
env->DeleteGlobalRef(listener);
env->DeleteGlobalRef(jmessage);
linphone_chat_message_set_user_data(msg,NULL);
}
}
extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_getCore(JNIEnv* env
,jobject thiz
@ -4933,36 +4903,13 @@ extern "C" jobject Java_org_linphone_core_LinphoneChatRoomImpl_getCore(JNIEnv*
return core;
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env
,jobject thiz
,jlong chatroom_ptr
,jobject message
,jlong messagePtr
,jobject jlistener) {
jobject listener = env->NewGlobalRef(jlistener);
LinphoneChatMessage *msg = (LinphoneChatMessage *)messagePtr;
message = env->NewGlobalRef(message);
linphone_chat_message_ref(msg);
linphone_chat_message_set_user_data(msg, message);
LinphoneChatMessageCbs *cbs;
cbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_user_data(cbs, (void *)listener);
linphone_chat_message_cbs_set_msg_state_changed(cbs, message_state_changed);
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_recv);
linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send);
linphone_chat_room_send_chat_message_2((LinphoneChatRoom*)chatroom_ptr, msg);
}
extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendChatMessage(JNIEnv* env
,jobject thiz
,jlong chatroom_ptr
,jobject message
,jlong messagePtr) {
message = env->NewGlobalRef(message);
linphone_chat_message_set_user_data((LinphoneChatMessage*)messagePtr, message);
linphone_chat_room_send_chat_message_2((LinphoneChatRoom*)chatroom_ptr, (LinphoneChatMessage*)messagePtr);
}

61
coreapi/logging-private.h Normal file
View file

@ -0,0 +1,61 @@
/*
logging-private.h
Copyright (C) 2017 Belledonne Communications SARL
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LOGGING_PRIVATE_H_
#define _LOGGING_PRIVATE_H_
#include <bctoolbox/logging.h>
#include "linphone/logging.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Converts a #BctbxLogLevel into #LinphoneLogLevel.
*/
LinphoneLogLevel _bctbx_log_level_to_linphone_log_level(BctbxLogLevel level);
/**
* @brief Converts a mask of #BctbxLogLevel into a mask of #LinphoneLogLevel.
*/
unsigned int _bctbx_log_mask_to_linphone_log_mask(unsigned int mask);
/**
* @brief Converts a #LinphoneLogLevel into #BctbxLogLevel.
*/
BctbxLogLevel _linphone_log_level_to_bctbx_log_level(LinphoneLogLevel level);
/**
* @brief Converts a mask of #LinphoneLogLevel into a mask of #BctbxLogLevel.
*/
unsigned int _linphone_log_mask_to_bctbx_log_mask(unsigned int mask);
/**
* @brief Releases the instance pointer of the singleton.
* @note You should not need to call this function since it is automatically done
* at process ending.
*/
void _linphone_logging_service_clean(void);
#ifdef __cplusplus
}
#endif
#endif // _LOGGING_PRIVATE_H_

256
coreapi/logging.c Normal file
View file

@ -0,0 +1,256 @@
/*
log.c
Copyright (C) 2017 Belledonne Communications SARL
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <algorithm>
#include <map>
#include <bctoolbox/logging.h>
#include <belle-sip/object.h>
#include <mediastreamer2/mscommon.h>
#include "linphone/logging.h"
#include "c-wrapper/c-wrapper.h"
#include "logging-private.h"
struct _LinphoneLoggingService {
belle_sip_object_t base;
LinphoneLoggingServiceCbs *cbs;
bctbx_log_handler_t *log_handler;
};
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneLoggingService);
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneLoggingService);
struct _LinphoneLoggingServiceCbs {
belle_sip_object_t base;
void *user_data;
LinphoneLoggingServiceCbsLogMessageWrittenCb message_event_cb;
};
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneLoggingServiceCbs);
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneLoggingServiceCbs);
static LinphoneLoggingServiceCbs *_linphone_logging_service_cbs_new(void);
static LinphoneLoggingService *_linphone_logging_service_instance = NULL;
static std::map<LinphoneLogLevel, BctbxLogLevel> _linphone_log_level_to_bctbx_log_level_map = {
{ LinphoneLogLevelDebug , BCTBX_LOG_DEBUG },
{ LinphoneLogLevelTrace , BCTBX_LOG_TRACE },
{ LinphoneLogLevelMessage , BCTBX_LOG_MESSAGE },
{ LinphoneLogLevelWarning , BCTBX_LOG_WARNING },
{ LinphoneLogLevelError , BCTBX_LOG_ERROR },
{ LinphoneLogLevelFatal , BCTBX_LOG_FATAL }
};
LinphoneLogLevel _bctbx_log_level_to_linphone_log_level(BctbxLogLevel level) {
auto &tmap = _linphone_log_level_to_bctbx_log_level_map;
auto predicate = [level](const std::pair<LinphoneLogLevel, BctbxLogLevel> &tuple)->bool{return tuple.second==level;};
auto response = std::find_if(tmap.cbegin(), tmap.cend(), predicate);
if (response != tmap.cend()) {
return response->first;
} else {
ms_fatal("%s(): invalid argurement [%d]", __FUNCTION__, level);
return LinphoneLogLevelDebug;
}
}
unsigned int _bctbx_log_mask_to_linphone_log_mask(unsigned int mask) {
unsigned int res = 0;
auto &tmap = _linphone_log_level_to_bctbx_log_level_map;
for (auto it=tmap.cbegin(); it!=tmap.cend(); it++) {
if (mask & it->second) {
mask&=~it->second;
res|=it->first;
}
}
if (mask != 0) {
ms_fatal("%s(): invalid flag set in mask [%x]", __FUNCTION__, mask);
}
return res;
}
BctbxLogLevel _linphone_log_level_to_bctbx_log_level(LinphoneLogLevel level) {
try {
return _linphone_log_level_to_bctbx_log_level_map.at(level);
} catch (const std::out_of_range &e) {
ms_fatal("%s(): invalid argument [%d]", __FUNCTION__, level);
return BCTBX_LOG_LOGLEV_END;
}
}
unsigned int _linphone_log_mask_to_bctbx_log_mask(unsigned int mask) {
unsigned int res = 0;
auto &tmap = _linphone_log_level_to_bctbx_log_level_map;
for (auto it=tmap.cbegin(); it!=tmap.cend(); it++) {
if (mask & it->first) {
mask&=~it->first;
res|=it->second;
}
}
if (mask != 0) {
ms_fatal("%s(): invalid flag set in mask [%x]", __FUNCTION__, mask);
}
return res;
}
static void _log_handler_on_message_written_cb(void *info,const char *domain, BctbxLogLevel lev, const char *fmt, va_list args) {
LinphoneLoggingService *service = (LinphoneLoggingService *)info;
if (service->cbs->message_event_cb) {
char *message = bctbx_strdup_vprintf(fmt, args);
service->cbs->message_event_cb(service, domain, _bctbx_log_level_to_linphone_log_level(lev), message);
bctbx_free(message);
}
}
static void _log_handler_destroy_cb(bctbx_log_handler_t *handler) {
LinphoneLoggingService *service = (LinphoneLoggingService *)bctbx_log_handler_get_user_data(handler);
service->log_handler = NULL;
}
static LinphoneLoggingService *_linphone_logging_service_new(void) {
LinphoneLoggingService *service = belle_sip_object_new(LinphoneLoggingService);
service->log_handler = bctbx_create_log_handler(_log_handler_on_message_written_cb, _log_handler_destroy_cb, service);
service->cbs = _linphone_logging_service_cbs_new();
bctbx_add_log_handler(service->log_handler);
return service;
}
LinphoneLoggingService *linphone_logging_service_get(void) {
if (_linphone_logging_service_instance == NULL) {
_linphone_logging_service_instance = _linphone_logging_service_new();
atexit(_linphone_logging_service_clean);
}
return _linphone_logging_service_instance;
}
void _linphone_logging_service_clean(void) {
if (_linphone_logging_service_instance) {
linphone_logging_service_unref(_linphone_logging_service_instance);
_linphone_logging_service_instance = NULL;
}
}
LinphoneLoggingService *linphone_logging_service_ref(LinphoneLoggingService *service) {
return (LinphoneLoggingService *)belle_sip_object_ref(service);
}
void linphone_logging_service_unref(LinphoneLoggingService *service) {
belle_sip_object_ref(service);
}
static void _linphone_logging_service_uninit(LinphoneLoggingService *log_service) {
if (log_service->log_handler) bctbx_remove_log_handler(log_service->log_handler);
linphone_logging_service_cbs_unref(log_service->cbs);
}
void linphone_logging_service_release_instance(void) {
if (_linphone_logging_service_instance) {
belle_sip_object_unref(BELLE_SIP_OBJECT(_linphone_logging_service_instance));
}
_linphone_logging_service_instance = NULL;
}
LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const LinphoneLoggingService *log_service) {
return log_service->cbs;
}
static const char *_linphone_logging_service_log_domains[] = {
"bctbx",
"ortp",
"mediastreamer",
"bzrtp",
"linphone",
NULL
};
void linphone_logging_service_set_log_level(LinphoneLoggingService *log_service, LinphoneLogLevel loglevel) {
const char **domain;
for (domain=_linphone_logging_service_log_domains; *domain; domain++) {
bctbx_set_log_level(*domain, _linphone_log_level_to_bctbx_log_level(loglevel));
}
}
void linphone_logging_service_set_log_level_mask(LinphoneLoggingService *log_service, unsigned int mask) {
const char **domain;
for (domain=_linphone_logging_service_log_domains; *domain; domain++) {
bctbx_set_log_level_mask(*domain, (int)_linphone_log_mask_to_bctbx_log_mask(mask));
}
}
unsigned int linphone_logging_service_get_log_level_mask(const LinphoneLoggingService *log_service) {
return _bctbx_log_mask_to_linphone_log_mask(bctbx_get_log_level_mask(ORTP_LOG_DOMAIN));
}
void linphone_logging_service_set_log_file(const LinphoneLoggingService *service, const char *dir, const char *filename, size_t max_size) {
bctbx_log_handler_t *log_handler = bctbx_create_file_log_handler((uint64_t)max_size, dir, filename, NULL);
bctbx_add_log_handler(log_handler);
}
BELLE_SIP_INSTANCIATE_VPTR(LinphoneLoggingService, belle_sip_object_t,
_linphone_logging_service_uninit, // uninit
NULL, // clone
NULL, // marshal
FALSE // unown
);
static LinphoneLoggingServiceCbs *_linphone_logging_service_cbs_new(void) {
return belle_sip_object_new(LinphoneLoggingServiceCbs);
}
LinphoneLoggingServiceCbs *linphone_logging_service_cbs_ref(LinphoneLoggingServiceCbs *cbs) {
return (LinphoneLoggingServiceCbs *)belle_sip_object_ref(cbs);
}
void linphone_logging_service_cbs_unref(LinphoneLoggingServiceCbs *cbs) {
belle_sip_object_unref(cbs);
}
void linphone_logging_service_cbs_set_log_message_written(LinphoneLoggingServiceCbs *cbs, LinphoneLoggingServiceCbsLogMessageWrittenCb cb) {
cbs->message_event_cb = cb;
}
LinphoneLoggingServiceCbsLogMessageWrittenCb linphone_logging_service_cbs_get_log_message_written(const LinphoneLoggingServiceCbs *cbs) {
return cbs->message_event_cb;
}
void linphone_logging_service_cbs_set_user_data(LinphoneLoggingServiceCbs *cbs, void *user_data) {
cbs->user_data = user_data;
}
BELLE_SIP_INSTANCIATE_VPTR(LinphoneLoggingServiceCbs, belle_sip_object_t,
NULL, // uninit
NULL, // clone
NULL, // marshal
FALSE // unown
);

View file

@ -48,6 +48,7 @@ set(ROOT_HEADER_FILES
im_notif_policy.h
info_message.h
ldapprovider.h
logging.h
lpconfig.h
misc.h
nat_policy.h

View file

@ -338,6 +338,7 @@ LINPHONE_PUBLIC LinphoneConference *linphone_call_get_conference (const Linphone
* Change the playback output device (currently only used for blackberry)
* @param call
* @param route the wanted audio route (earpiece, speaker, ...)
* @donotwrap
**/
LINPHONE_PUBLIC void linphone_call_set_audio_route (LinphoneCall *call, LinphoneAudioRoute route);

View file

@ -369,6 +369,8 @@ LINPHONE_PUBLIC const char* linphone_chat_message_get_text_content(const Linphon
*/
LINPHONE_PUBLIC bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *msg);
LINPHONE_PUBLIC bctbx_list_t *linphone_chat_message_get_participants_in_state (const LinphoneChatMessage *msg, const LinphoneChatMessageState state);
/**
* @}
*/

View file

@ -227,6 +227,12 @@ LINPHONE_PUBLIC int linphone_chat_room_get_history_events_size(LinphoneChatRoom
*/
LINPHONE_PUBLIC LinphoneChatMessage *linphone_chat_room_get_last_message_in_history(LinphoneChatRoom *cr);
/**
* Gets the chat message sent or received in this chat room that matches the message_id
* @param[in] cr The #LinphoneChatRoom object corresponding to the conversation for which the message should be retrieved
* @param[in] message_id The id of the message to find
* @return the #LinphoneChatMessage
*/
LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_room_find_message(LinphoneChatRoom *cr, const char *message_id);
/**

View file

@ -165,7 +165,8 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreNotifyPresenceReceivedCb notify_presence_received; /**< Notify received presence events*/
LinphoneCoreNotifyPresenceReceivedForUriOrTelCb notify_presence_received_for_uri_or_tel; /**< Notify received presence events*/
LinphoneCoreNewSubscriptionRequestedCb new_subscription_requested; /**< Notify about pending presence subscription request */
LINPHONE_DEPRECATED LinphoneCoreAuthInfoRequestedCb auth_info_requested; /**< @deprecated Use authentication_requested instead. Ask the application some authentication information */
LINPHONE_DEPRECATED LinphoneCoreAuthInfoRequestedCb auth_info_requested; /** @brief Ask the application some authentication information.
@deprecated Use authentication_requested instead. Deprecated since 2016-09-21 */
LinphoneCoreAuthenticationRequestedCb authentication_requested; /**< Ask the application some authentication information */
LinphoneCoreCallLogUpdatedCb call_log_updated; /**< Notifies that call log list has been updated */
LinphoneCoreMessageReceivedCb message_received; /**< a message is received, can be text or external body*/
@ -181,11 +182,16 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreSubscriptionStateChangedCb subscription_state_changed; /**<Notifies subscription state change */
LinphoneCoreNotifyReceivedCb notify_received; /**< Notifies a an event notification, see linphone_core_subscribe() */
LinphoneCorePublishStateChangedCb publish_state_changed;/**Notifies publish state change (only from #LinphoneEvent api)*/
LinphoneCoreConfiguringStatusCb configuring_status; /** Notifies configuring status changes */
LINPHONE_DEPRECATED LinphoneCoreTextMessageReceivedCb text_received; /**< @deprecated, use #message_received instead <br> A text message has been received */
LINPHONE_DEPRECATED LinphoneCoreFileTransferRecvCb file_transfer_recv; /**< @deprecated Callback to store file received attached to a #LinphoneChatMessage */
LINPHONE_DEPRECATED LinphoneCoreFileTransferSendCb file_transfer_send; /**< @deprecated Callback to collect file chunk to be sent for a #LinphoneChatMessage */
LINPHONE_DEPRECATED LinphoneCoreFileTransferProgressIndicationCb file_transfer_progress_indication; /**< @deprecated Callback to indicate file transfer progress */
LinphoneCoreConfiguringStatusCb configuring_status; /**< Notifies configuring status changes
@deprecated Deprecated since 2015-11-19. */
LINPHONE_DEPRECATED LinphoneCoreTextMessageReceivedCb text_received; /**< @brief A text message has been received.
@deprecated Use #message_received instead. Deprecated since 2015-11-19. */
LINPHONE_DEPRECATED LinphoneCoreFileTransferRecvCb file_transfer_recv; /**< @brief Callback to store file received attached to a #LinphoneChatMessage.
@deprecated Deprecated since 2015-11-19. */
LINPHONE_DEPRECATED LinphoneCoreFileTransferSendCb file_transfer_send; /**< @brief Callback to collect file chunk to be sent for a #LinphoneChatMessage.
@deprecated Deprecated since 2015-11-19. */
LINPHONE_DEPRECATED LinphoneCoreFileTransferProgressIndicationCb file_transfer_progress_indication; /**< @brief Callback to indicate file transfer progress.
@deprecated Deprecated since 2015-11-19. */
LinphoneCoreNetworkReachableCb network_reachable; /**< Callback to report IP network status (I.E up/down )*/
LinphoneCoreLogCollectionUploadStateChangedCb log_collection_upload_state_changed; /**< Callback to upload collected logs */
LinphoneCoreLogCollectionUploadProgressIndicationCb log_collection_upload_progress_indication; /**< Callback to indicate log collection upload progress */
@ -815,25 +821,28 @@ LINPHONE_PUBLIC void linphone_core_reset_log_collection(void);
/**
* @bref Define a log handler.
* @param logfunc The function pointer of the log handler.
* @deprecated Use #linphone_log_service_set_log_handler() instead. Deprecated since 2017-10-10.
* @donotwrap
*/
LINPHONE_PUBLIC void linphone_core_set_log_handler(OrtpLogFunc logfunc);
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_handler(OrtpLogFunc logfunc);
/**
* @brief Define a log file.
*
* If the file pointer passed as an argument is NULL, stdout is used instead.
* @param file A pointer to the FILE structure of the file to write to.
* @deprecated Use #linphone_log_service_set_file() instead. Deprecated since 2017-10-10.
* @donotwrap
*/
LINPHONE_PUBLIC void linphone_core_set_log_file(FILE *file);
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_file(FILE *file);
/**
* @brief Define the minimum level for logging.
* @param loglevel Minimum level for logging messages.
* @deprecated Use #linphone_logging_service_set_log_level() instead. Deprecated since 2017-10-10.
* @donotwrap
**/
LINPHONE_PUBLIC void linphone_core_set_log_level(OrtpLogLevel loglevel);
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_level(OrtpLogLevel loglevel);
/**
* Define the log level using mask.
@ -841,22 +850,25 @@ LINPHONE_PUBLIC void linphone_core_set_log_level(OrtpLogLevel loglevel);
* The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
* messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
*
* @param loglevel A bitmask of the log levels to set.
* @param mask A bitmask of the log levels to set.
* @deprecated Use #linphone_logging_service_set_log_level() instead. Deprecated since 2017-10-10.
*/
LINPHONE_PUBLIC void linphone_core_set_log_level_mask(unsigned int loglevel);
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_level_mask(unsigned int mask);
/**
* Get defined log level mask.
*
* @return The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
* messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
* @deprecated Use #linphone_logging_service_get_log_level_mask() instead. Deprecated since 2017-10-10.
*/
LINPHONE_PUBLIC unsigned int linphone_core_get_log_level_mask(void);
LINPHONE_PUBLIC LINPHONE_DEPRECATED unsigned int linphone_core_get_log_level_mask(void);
/**
* Enable logs in supplied FILE*.
* @param file a C FILE* where to fprintf logs. If null stdout is used.
* @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead.
* @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level() instead.
* Deprecated since 2017-01-12.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file);
@ -866,13 +878,14 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file);
* @param logfunc The address of a OrtpLogFunc callback whose protoype is
* typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
* @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead.
* Deprecated since 2017-01-12.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc);
/**
* Entirely disable logging.
* @deprecated Use #linphone_core_set_log_level instead.
* @deprecated Use #linphone_core_set_log_level() instead. Deprecated since 2017-01-12.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_disable_logs(void);
@ -894,13 +907,15 @@ LINPHONE_PUBLIC const char *linphone_core_get_version(void);
LINPHONE_PUBLIC const char *linphone_core_get_user_agent(LinphoneCore *lc);
/**
* @deprecated 2016-12-20: Use #linphone_core_get_user_agent instead.
* @deprecated Use #linphone_core_get_user_agent() instead.
* Deprecated since 2015-11-19.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_name(void);
/**
* @deprecated 2016-12-20: Use #linphone_core_get_user_agent instead.
* @deprecated Use #linphone_core_get_user_agent instead.
* Deprecated since 2015-11-19.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_version(void);
@ -918,8 +933,8 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_ver
* @param vtable a LinphoneCoreVTable structure holding your application callbacks
* @param config_path a path to a config file. If it does not exists it will be created.
* The config file is used to store all settings, call logs, friends, proxies... so that all these settings
* become persistent over the life of the LinphoneCore object.
* It is allowed to set a NULL config file. In that case LinphoneCore will not store any settings.
* become persistent over the life of the LinphoneCore object.
* It is allowed to set a NULL config file. In that case LinphoneCore will not store any settings.
* @param factory_config_path a path to a read-only config file that can be used to
* to store hard-coded preference such as proxy settings or internal preferences.
* The settings in this factory file always override the one in the normal config file.
@ -927,7 +942,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_ver
* @param userdata an opaque user pointer that can be retrieved at any time (for example in
* callbacks) using linphone_core_get_user_data().
* @see linphone_core_new_with_config
* @deprecated 2017-01-12: Use linphone_factory_create_core() instead.
* @deprecated Use #linphone_factory_create_core() instead. Deprecated since 2017-01-12.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
@ -944,7 +959,7 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const Linpho
* @param userdata an opaque user pointer that can be retrieved at any time (for example in
* callbacks) using linphone_core_get_user_data().
* @see linphone_core_new
* @deprecated 2017-01-12: Use linphone_factory_create_core_with_config() instead.
* @deprecated Use #linphone_factory_create_core_with_config() instead. Deprecated since 2017-01-12.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, LpConfig *config, void *userdata);
@ -995,7 +1010,7 @@ LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc);
* add a listener to be notified of linphone core events. Once events are received, registered vtable are invoked in order.
* @param vtable a LinphoneCoreVTable structure holding your application callbacks. Object is owned by linphone core until linphone_core_remove_listener.
* @param lc object
* @deprecated Use linphone_core_add_callbacks() instead.
* @deprecated Use linphone_core_add_callbacks() instead. Deprecated since 2017-01-12.
* @donotwrap
*/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable);
@ -1014,7 +1029,7 @@ LINPHONE_PUBLIC void linphone_core_add_callbacks(LinphoneCore *lc, LinphoneCoreC
* remove a listener registred by linphone_core_add_listener.
* @param lc object
* @param vtable a LinphoneCoreVTable structure holding your application callbacks.
* @deprecated Use linphone_core_remove_callbacks() instead.
* @deprecated Use linphone_core_remove_callbacks() instead. Deprecated since 2017-01-12.
* @donotwrap
*/
LINPHONE_DEPRECATED LINPHONE_PUBLIC void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable);
@ -1094,7 +1109,8 @@ LINPHONE_PUBLIC LinphoneCall * linphone_core_invite_with_params(LinphoneCore *lc
LINPHONE_PUBLIC LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params);
/**
* Performs a simple call transfer to the specified destination.
* @brief Performs a simple call transfer to the specified destination.
*
* The remote endpoint is expected to issue a new call to the specified destination.
* The current call remains active and thus can be later paused or terminated.
* It is possible to follow the progress of the transfer provided that transferee sends notification about it.
@ -1105,12 +1121,13 @@ LINPHONE_PUBLIC LinphoneCall * linphone_core_invite_address_with_params(Linphone
* @param[in] refer_to The destination the call is to be refered to
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_transfer() instead
* @deprecated Use #linphone_call_transfer() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to);
/**
* Transfers a call to destination of another running call. This is used for "attended transfer" scenarios.
* @brief Transfers a call to destination of another running call. This is used for "attended transfer" scenarios.
*
* The transfered call is supposed to be in paused state, so that it is able to accept the transfer immediately.
* The destination call is a call previously established to introduce the transfered person.
* This method will send a transfer request to the transfered person. The phone of the transfered is then
@ -1124,12 +1141,13 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_transfer_call(L
* @param[in] dest A running call whose remote person will receive the transfer
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_transfer_to_another() instead
* @deprecated Use #linphone_call_transfer_to_another() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest);
/**
* Start a new call as a consequence of a transfer request received from a call.
* @brief Start a new call as a consequence of a transfer request received from a call.
*
* This function is for advanced usage: the execution of transfers is automatically managed by the LinphoneCore. However if an application
* wants to have control over the call parameters for the new call, it should call this function immediately during the LinphoneCallRefered notification.
* @see LinphoneCoreVTable::call_state_changed
@ -1144,7 +1162,8 @@ LINPHONE_PUBLIC LinphoneCall * linphone_core_start_refered_call(LinphoneCore *lc
#define linphone_core_inc_invite_pending(lc) linphone_core_is_incoming_invite_pending(lc)
/**
* Tells whether there is an incoming invite pending.
* @brief Tells whether there is an incoming invite pending.
*
* @ingroup call_control
* @param[in] lc LinphoneCore object
* @return A boolean telling whether an incoming invite is pending or not.
@ -1168,7 +1187,7 @@ LINPHONE_PUBLIC bool_t linphone_core_in_call(const LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc);
/**
* Accept an incoming call.
* @brief Accept an incoming call.
*
* Basically the application is notified of incoming calls within the
* call_state_changed callback of the #LinphoneCoreVTable structure, where it will receive
@ -1178,12 +1197,12 @@ LINPHONE_PUBLIC LinphoneCall *linphone_core_get_current_call(const LinphoneCore
* @param[in] call The LinphoneCall object representing the call to be answered
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_accept() instead
* @deprecated Use #linphone_call_accept() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);
/**
* Accept an incoming call, with parameters.
* @brief Accept an incoming call, with parameters.
*
* Basically the application is notified of incoming calls within the
* call_state_changed callback of the #LinphoneCoreVTable structure, where it will receive
@ -1195,12 +1214,13 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_call(Lin
* @param[in] params The specific parameters for this call, for example whether video is accepted or not. Use NULL to use default parameters
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_accept_with_params() instead
* @deprecated Use #linphone_call_accept_with_params() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params);
/**
* When receiving an incoming, accept to start a media session as early-media.
* @brief When receiving an incoming, accept to start a media session as early-media.
*
* This means the call is not accepted but audio & video streams can be established if the remote party supports early media.
* However, unlike after call acceptance, mic and camera input are not sent during early-media, though received audio & video are played normally.
* The call can then later be fully accepted using linphone_core_accept_call() or linphone_core_accept_call_with_params().
@ -1209,29 +1229,31 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_call_wit
* @param[in] params The call parameters to use (can be NULL)
* @return 0 if successful, -1 otherwise
* @ingroup call_control
* @deprecated Use linphone_call_accept_early_media_with_params() instead
* @deprecated Use linphone_call_accept_early_media_with_params() instead.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_early_media_with_params(LinphoneCore* lc, LinphoneCall* call, const LinphoneCallParams* params);
/**
* Accept an early media session for an incoming call.
* @brief Accept an early media session for an incoming call.
*
* This is identical as calling linphone_core_accept_early_media_with_params() with NULL call parameters.
* @param[in] lc LinphoneCore object
* @param[in] call The incoming call to accept
* @return 0 if successful, -1 otherwise
* @ingroup call_control
* @see linphone_core_accept_early_media_with_params()
* @deprecated Use linphone_call_accept_early_media() instead
* @deprecated Use #linphone_call_accept_early_media() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_early_media(LinphoneCore* lc, LinphoneCall* call);
/**
* Terminates a call.
* @brief Terminates a call.
*
* @param[in] lc LinphoneCore object
* @param[in] call The LinphoneCall object representing the call to be terminated
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_terminate() instead
* @deprecated Use #linphone_call_terminate() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
@ -1242,18 +1264,18 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_terminate_call(
* @param[in] redirect_uri The URI to redirect the call to
* @return 0 if successful, -1 on error.
* @ingroup call_control
* @deprecated Use linphone_call_redirect() instead
* @deprecated Use #linphone_call_redirect() instead. Deprecated since 2017-02-13.
*/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri);
/**
* Decline a pending incoming call, with a reason.
* @param[in] lc LinphoneCore object
* @param[in] call The LinphoneCall to decline, must be in the IncomingReceived state
* @param[in] reason The reason for rejecting the call: LinphoneReasonDeclined or LinphoneReasonBusy
* @brief Decline a pending incoming call, with a reason.
* @param[in] lc #LinphoneCore object
* @param[in] call The #LinphoneCall to decline, must be in the IncomingReceived state
* @param[in] reason The reason for rejecting the call: #LinphoneReasonDeclined or #LinphoneReasonBusy
* @return 0 on success, -1 on failure
* @ingroup call_control
* @deprecated Use linphone_call_decline() instead
* @deprecated Use #linphone_call_decline() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason);
@ -1266,15 +1288,16 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_decline_call(Li
LINPHONE_PUBLIC LinphoneStatus linphone_core_terminate_all_calls(LinphoneCore *lc);
/**
* Pauses the call. If a music file has been setup using linphone_core_set_play_file(),
* @biref Pauses the call. If a music file has been setup using linphone_core_set_play_file(),
* this file will be played to the remote user.
*
* The only way to resume a paused call is to call linphone_core_resume_call().
* @param[in] lc LinphoneCore object
* @param[in] call The call to pause
* @return 0 on success, -1 on failure
* @ingroup call_control
* @see linphone_core_resume_call()
* @deprecated Use linphone_call_pause() instead
* @deprecated Use #linphone_call_pause() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);
@ -1287,19 +1310,21 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_pause_call(Linp
LINPHONE_PUBLIC LinphoneStatus linphone_core_pause_all_calls(LinphoneCore *lc);
/**
* Resumes a call.
* @brief Resumes a call.
*
* The call needs to have been paused previously with linphone_core_pause_call().
* @param[in] lc LinphoneCore object
* @param[in] call The call to resume
* @return 0 on success, -1 on failure
* @ingroup call_control
* @see linphone_core_pause_call()
* @deprecated Use linphone_call_resume() instead
* @deprecated Use #linphone_call_resume() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call);
/**
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
* @brief Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
*
* In this version this is limited to the following use cases:
* - setting up/down the video stream according to the video parameter of the LinphoneCallParams (see linphone_call_params_enable_video() ).
* - changing the size of the transmitted video after calling linphone_core_set_preferred_video_size()
@ -1312,7 +1337,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_resume_call(Lin
* @param[in] params The new call parameters to use (may be NULL)
* @return 0 if successful, -1 otherwise.
* @ingroup call_control
* @deprecated Use linphone_call_update() instead
* @deprecated Use #linphone_call_update() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params);
@ -1341,7 +1366,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_update_call(Lin
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_defer_call_update(LinphoneCore *lc, LinphoneCall *call);
/**
* Accept call modifications initiated by other end.
* @brief Accept call modifications initiated by other end.
*
* This call may be performed in response to a #LinphoneCallUpdatedByRemote state notification.
* When such notification arrives, the application can decide to call linphone_core_defer_update_call() so that it can
@ -1358,7 +1383,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_defer_call_upda
* @param[in] params A LinphoneCallParams object describing the call parameters to accept
* @return 0 if successful, -1 otherwise (actually when this function call is performed outside ot #LinphoneCallUpdatedByRemote state)
* @ingroup call_control
* @deprecated Use linphone_call_accept_update() instead
* @deprecated Use #linphone_call_accept_update() instead. Deprecated since 2017-02-13.
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneStatus linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params);
@ -1394,13 +1419,13 @@ LINPHONE_PUBLIC LinphoneCall *linphone_core_get_call_by_remote_address2(const Li
/**
* Send the specified dtmf.
* @brief Send the specified dtmf.
*
* @ingroup media_parameters
* @deprecated Use #linphone_call_send_dtmf instead.
* This function only works during calls. The dtmf is automatically played to the user.
* @param lc The LinphoneCore object
* @param dtmf The dtmf name specified as a char, such as '0', '#' etc...
* @deprecated Use #linphone_call_send_dtmf instead. Deprecated since 2015-11-23.
* @ingroup media_parameters
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf);

178
include/linphone/logging.h Normal file
View file

@ -0,0 +1,178 @@
/*
logging.h
Copyright (C) 2017 Belledonne Communications SARL
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _LINPHONE_LOG_H_
#define _LINPHONE_LOG_H_
#include "types.h"
#include "defs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup logging
* @{
*/
/**
* @brief Singleton class giving access to logging features.
*/
typedef struct _LinphoneLoggingService LinphoneLoggingService;
/**
* @brief Listener for #LinphoneLoggingService.
*/
typedef struct _LinphoneLoggingServiceCbs LinphoneLoggingServiceCbs;
/**
* @brief Verbosity levels of log messages.
*/
typedef enum _LinphoneLogLevel {
LinphoneLogLevelDebug = 1, /**< @brief Level for debug messages. */
LinphoneLogLevelTrace = 1<<1, /**< @brief Level for traces. */
LinphoneLogLevelMessage = 1<<2, /**< @brief Level for information messages. */
LinphoneLogLevelWarning = 1<<3, /**< @brief Level for warning messages. */
LinphoneLogLevelError = 1<<4, /**< @brief Level for error messages. */
LinphoneLogLevelFatal = 1<<5 /**< @brief Level for fatal error messages. */
} LinphoneLogLevel;
/**
* @brief Type of callbacks called each time liblinphone write a log message.
*
* @param log_service A pointer on the logging service singleton.
* @param domain A string describing which sub-library of liblinphone the message is coming from.
* @param lev Verbosity level of the message.
* @param message Content of the message.
*/
typedef void (*LinphoneLoggingServiceCbsLogMessageWrittenCb)(LinphoneLoggingService *log_service, const char *domain, LinphoneLogLevel lev, const char *message);
/**
* @brief Gets the singleton logging service object.
*
* The singleton is automatically instantiated if it hasn't
* been done yet.
*
* @return A pointer on the singleton.
*/
LINPHONE_PUBLIC LinphoneLoggingService *linphone_logging_service_get(void);
/**
* @brief Increases the reference counter.
*/
LINPHONE_PUBLIC LinphoneLoggingService *linphone_logging_service_ref(LinphoneLoggingService *service);
/**
* @brief Decreases the reference counter and destroy the object
* if the counter reaches 0.
*/
LINPHONE_PUBLIC void linphone_logging_service_unref(LinphoneLoggingService *service);
/**
* @brief Gets the logging service listener.
*/
LINPHONE_PUBLIC LinphoneLoggingServiceCbs *linphone_logging_service_get_callbacks(const LinphoneLoggingService *log_service);
/**
* @brief Set the verbosity of the log.
*
* For instance, a level of #LinphoneLogLevelMessage will let pass fatal, error, warning and message-typed messages
* whereas trace and debug messages will be dumped out.
*/
LINPHONE_PUBLIC void linphone_logging_service_set_log_level(LinphoneLoggingService *log_service, LinphoneLogLevel level);
/**
* @brief Sets the types of messages that will be authorized to be written in the log.
* @param log_service The logging service singleton.
* @param mask Example: #LinphoneLogLevelMessage|#LinphoneLogLevelError will ONLY let pass message-typed and error messages.
* @note Calling that function reset the log level that has been specified by #linphone_logging_service_set_log_level().
*/
LINPHONE_PUBLIC void linphone_logging_service_set_log_level_mask(LinphoneLoggingService *log_service, unsigned int mask);
/**
* @brief Gets the log level mask.
*/
LINPHONE_PUBLIC unsigned int linphone_logging_service_get_log_level_mask(const LinphoneLoggingService *log_service);
/**
* @brief Enables logging in a file.
*
* That function enables an internal log handler that writes log messages in
* log-rotated files.
*
* @param dir Directory where to create the distinct parts of the log.
* @param filename Name of the log file.
* @param max_size The maximal size of each part of the log. The log rotating is triggered
* each time the currently opened log part reach that limit.
*/
LINPHONE_PUBLIC void linphone_logging_service_set_log_file(const LinphoneLoggingService *service, const char *dir, const char *filename, size_t max_size);
/**
* @brief Increases the reference counter.
*/
LINPHONE_PUBLIC LinphoneLoggingServiceCbs *linphone_logging_service_cbs_ref(LinphoneLoggingServiceCbs *cbs);
/**
* @brief Decreases the reference counter.
*
* The object is automatically destroyed once the counter reach 0.
*/
LINPHONE_PUBLIC void linphone_logging_service_cbs_unref(LinphoneLoggingServiceCbs *cbs);
/**
* @brief Sets the callback to call each time liblinphone writes a log message.
*/
LINPHONE_PUBLIC void linphone_logging_service_cbs_set_log_message_written(LinphoneLoggingServiceCbs *cbs, LinphoneLoggingServiceCbsLogMessageWrittenCb cb);
/**
* @brief Gets the value of the message event callback.
*/
LINPHONE_PUBLIC LinphoneLoggingServiceCbsLogMessageWrittenCb linphone_logging_service_cbs_get_log_message_written(const LinphoneLoggingServiceCbs *cbs);
/**
* @brief Pass a pointer on a custom object.
*
* That pointer can be get back by callbacks by using #linphone_logging_service_get_cbs() and #linphone_logging_service_cbs_get_user_data().
*/
LINPHONE_PUBLIC void linphone_logging_service_cbs_set_user_data(LinphoneLoggingServiceCbs *cbs, void *user_data);
/**
* @brief Gets the user_data pointer back.
*/
LINPHONE_PUBLIC void *linphone_logging_service_cbs_get_user_data(const LinphoneLoggingServiceCbs *cbs);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif // _LINPHONE_LOG_H_

View file

@ -115,11 +115,6 @@ public interface LinphoneChatRoom {
*/
void deleteMessage(LinphoneChatMessage message);
/**
* Create a LinphoneChatMessage
* @return LinphoneChatMessage object
*/
LinphoneChatMessage createLinphoneChatMessage(String message, String url, State state, long timestamp, boolean isRead, boolean isIncoming);
/**
* Returns a back pointer to the core managing the chat room.

View file

@ -25,7 +25,7 @@ import org.linphone.core.LinphoneCall;
@SuppressWarnings("deprecation")
class LinphoneChatRoomImpl implements LinphoneChatRoom {
protected final long nativePtr;
private native long createLinphoneChatMessage(long ptr, String message);
private native Object createLinphoneChatMessage(long ptr, String message);
private native long getPeerAddress(long ptr);
private native void sendMessage(long ptr, String message);
private native void sendMessage2(long ptr, Object msg, long messagePtr, StateListener listener);
@ -39,9 +39,6 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
private native boolean isRemoteComposing(long ptr);
private native void markAsRead(long ptr);
private native void deleteMessage(long room, long message);
private native long createLinphoneChatMessage2(long ptr, String message,
String url, int state, long timestamp, boolean isRead,
boolean isIncoming);
private native void sendChatMessage(long ptr, Object message, long messagePtr);
private native void finalize(long nativePtr);
private native boolean islimeAvailable(long nativePtr);
@ -77,7 +74,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
@Override
public LinphoneChatMessage createLinphoneChatMessage(String message) {
synchronized(getCore()){
return new LinphoneChatMessageImpl(createLinphoneChatMessage(nativePtr, message));
return (LinphoneChatMessage)createLinphoneChatMessage(nativePtr, message);
}
}
@ -144,15 +141,6 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
}
}
@Override
public LinphoneChatMessage createLinphoneChatMessage(String message,
String url, State state, long timestamp, boolean isRead,
boolean isIncoming) {
synchronized(getCore()){
return new LinphoneChatMessageImpl(createLinphoneChatMessage2(
nativePtr, message, url, state.value(), timestamp / 1000, isRead, isIncoming));
}
}
private native Object getCore(long nativePtr);
@Override
public synchronized LinphoneCore getCore() {
@ -162,11 +150,11 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom {
return (LinphoneChatMessage[]) typesPtr;
}
private native long createFileTransferMessage(long ptr, String name, String type, String subtype, int size);
private native Object createFileTransferMessage(long ptr, String name, String type, String subtype, int size);
@Override
public LinphoneChatMessage createFileTransferMessage(LinphoneContent content) {
synchronized(getCore()) {
return new LinphoneChatMessageImpl(createFileTransferMessage(nativePtr, content.getName(), content.getType(), content.getSubtype(), content.getRealSize()));
return (LinphoneChatMessage)createFileTransferMessage(nativePtr, content.getName(), content.getType(), content.getSubtype(), content.getRealSize());
}
}
@Override

View file

@ -31,6 +31,7 @@
#include "chat/notification/imdn.h"
#include "content/content-type.h"
#include "content/content.h"
#include "conference/participant.h"
// =============================================================================
@ -246,6 +247,10 @@ bool_t linphone_chat_message_is_file_transfer_in_progress(LinphoneChatMessage *m
return L_GET_CPP_PTR_FROM_C_OBJECT(msg)->isFileTransferInProgress();
}
bctbx_list_t *linphone_chat_message_get_participants_in_state (const LinphoneChatMessage *msg, const LinphoneChatMessageState state) {
return L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_PRIVATE_FROM_C_OBJECT(msg)->getParticipantsInState((LinphonePrivate::ChatMessage::State) state));
}
// =============================================================================
// Old listener
// =============================================================================

View file

@ -100,6 +100,8 @@ BELLE_SIP_TYPE_ID(LinphoneImNotifPolicy),
BELLE_SIP_TYPE_ID(LinphoneInfoMessage),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider),
BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch),
BELLE_SIP_TYPE_ID(LinphoneLoggingService),
BELLE_SIP_TYPE_ID(LinphoneLoggingServiceCbs),
BELLE_SIP_TYPE_ID(LinphoneNatPolicy),
BELLE_SIP_TYPE_ID(LinphonePayloadType),
BELLE_SIP_TYPE_ID(LinphonePlayer),

View file

@ -59,6 +59,7 @@ public:
void setDirection (ChatMessage::Direction dir);
void setParticipantState (const IdentityAddress &participantAddress, ChatMessage::State newState);
std::list<std::shared_ptr<Participant>> getParticipantsInState (const ChatMessage::State state) const;
void setState (ChatMessage::State newState, bool force = false);
void setTime (time_t time);

View file

@ -34,6 +34,7 @@
#include "chat/modifier/encryption-chat-message-modifier.h"
#include "chat/modifier/file-transfer-chat-message-modifier.h"
#include "chat/modifier/multipart-chat-message-modifier.h"
#include "conference/participant.h"
#include "content/file-content.h"
#include "content/content.h"
#include "core/core.h"
@ -122,6 +123,29 @@ void ChatMessagePrivate::setParticipantState (const IdentityAddress &participant
setState(ChatMessage::State::DeliveredToUser);
}
list<shared_ptr<Participant>> ChatMessagePrivate::getParticipantsInState (const ChatMessage::State state) const {
L_Q();
list<shared_ptr<Participant>> participantsInState;
if (!(q->getChatRoom()->getCapabilities() & AbstractChatRoom::Capabilities::Conference) || !dbKey.isValid()) {
return participantsInState;
}
unique_ptr<MainDb> &mainDb = q->getChatRoom()->getCore()->getPrivate()->mainDb;
shared_ptr<EventLog> eventLog = mainDb->getEventFromKey(dbKey);
list<IdentityAddress> addressesInState = mainDb->getChatMessageParticipantsInState(eventLog, state);
const list<shared_ptr<Participant>> &participants = q->getChatRoom()->getParticipants();
for (IdentityAddress addr : addressesInState) {
for (const auto &participant : participants) {
if (participant->getAddress() == addr) {
participantsInState.push_back(participant);
}
}
}
return participantsInState;
}
void ChatMessagePrivate::setState (ChatMessage::State newState, bool force) {
L_Q();

View file

@ -39,6 +39,7 @@ class AbstractChatRoom;
class Content;
class FileTransferContent;
class ChatMessagePrivate;
class Participant;
class LINPHONE_PUBLIC ChatMessage : public Object, public CoreAccessor {
friend class BasicToClientGroupChatRoom;

View file

@ -92,7 +92,8 @@ void CallSessionPrivate::setState (CallSession::State newState, const string &me
case CallSession::State::Error:
switch (linphone_error_info_get_reason(q->getErrorInfo())) {
case LinphoneReasonDeclined:
log->status = LinphoneCallDeclined;
if (log->status != LinphoneCallMissed) // Do not re-change the status of a call if it's already set
log->status = LinphoneCallDeclined;
break;
case LinphoneReasonNotAnswered:
if (log->dir == LinphoneCallIncoming)
@ -470,7 +471,7 @@ void CallSessionPrivate::updatedByRemote () {
if (deferUpdate || deferUpdateInternal) {
if (state == CallSession::State::UpdatedByRemote && !deferUpdateInternal){
lInfo() << "CallSession [" << q << "]: UpdatedByRemoted was signaled but defered. LinphoneCore expects the application to call linphone_call_accept_update() later";
}
}
} else {
if (state == CallSession::State::UpdatedByRemote)
q->acceptUpdate(nullptr);

View file

@ -1920,8 +1920,7 @@ int MediaSessionPrivate::getVideoBandwidth (const SalMediaDescription *md, const
else if (md->bandwidth > 0) {
/* Case where b=AS is given globally, not per stream */
remoteBandwidth = PayloadTypeHandler::getRemainingBandwidthForVideo(md->bandwidth, audioBandwidth);
} else
remoteBandwidth = lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "net", "default_max_bandwidth", 1500);
}
return PayloadTypeHandler::getMinBandwidth(PayloadTypeHandler::getRemainingBandwidthForVideo(linphone_core_get_upload_bandwidth(q->getCore()->getCCore()), audioBandwidth), remoteBandwidth);
}

View file

@ -1970,6 +1970,30 @@ list<ChatMessage::State> MainDb::getChatMessageParticipantStates (const shared_p
};
}
list<IdentityAddress> MainDb::getChatMessageParticipantsInState (const shared_ptr<EventLog> &eventLog, const ChatMessage::State state) const {
return L_DB_TRANSACTION {
L_D();
const EventLogPrivate *dEventLog = eventLog->getPrivate();
MainDbKeyPrivate *dEventKey = static_cast<MainDbKey &>(dEventLog->dbKey).getPrivate();
const long long &eventId = dEventKey->storageId;
int stateInt = static_cast<int>(state);
list<IdentityAddress> participantsAddresses;
static const string query = "SELECT sip_address.value"
" FROM sip_address, chat_message_participant"
" WHERE event_id = :eventId AND state = :state"
" AND sip_address.id = chat_message_participant.participant_sip_address_id";
soci::rowset<soci::row> rows = (d->dbSession.getBackendSession()->prepare << query, soci::use(eventId), soci::use(stateInt));
for (const auto &row : rows) {
participantsAddresses.push_back(IdentityAddress(row.get<string>(0)));
}
return participantsAddresses;
};
}
ChatMessage::State MainDb::getChatMessageParticipantState (
const shared_ptr<EventLog> &eventLog,
const IdentityAddress &participantAddress

View file

@ -91,6 +91,7 @@ public:
std::list<std::shared_ptr<ChatMessage>> getUnreadChatMessages (const ChatRoomId &chatRoomId) const;
std::list<ChatMessage::State> getChatMessageParticipantStates (const std::shared_ptr<EventLog> &eventLog) const;
std::list<IdentityAddress> getChatMessageParticipantsInState (const std::shared_ptr<EventLog> &eventLog, const ChatMessage::State state) const;
ChatMessage::State getChatMessageParticipantState (
const std::shared_ptr<EventLog> &eventLog,
const IdentityAddress &participantAddress

View file

@ -317,10 +317,12 @@ void IceAgent::updateLocalMediaDescriptionFromIce (SalMediaDescription *desc) {
}
if (firstCl)
result = !!ice_check_list_selected_valid_local_candidate(firstCl, &rtpCandidate, nullptr);
if (result)
if (result) {
strncpy(desc->addr, rtpCandidate->taddr.ip, sizeof(desc->addr));
else
} else {
lWarning() << "If ICE has completed successfully, rtp_candidate should be set!";
ice_dump_valid_list(firstCl);
}
}
strncpy(desc->ice_pwd, ice_session_local_pwd(iceSession), sizeof(desc->ice_pwd));

View file

@ -1037,7 +1037,7 @@ int SalCallOp::decline(SalReason reason, const char *redirection /*optional*/){
}
belle_sip_header_reason_t *SalCallOp::make_reason_header( const SalErrorInfo *info){
if (info != NULL){
if (info && info->reason != SalReasonNone) {
belle_sip_header_reason_t* reason = BELLE_SIP_HEADER_REASON(belle_sip_header_reason_new());
belle_sip_header_reason_set_text(reason, info->status_string);
belle_sip_header_reason_set_protocol(reason,info->protocol);
@ -1123,25 +1123,25 @@ int SalCallOp::update(const char *subject, bool_t no_user_consent) {
int SalCallOp::cancel_invite_with_info(const SalErrorInfo *info) {
belle_sip_request_t* cancel;
ms_message("Cancelling INVITE request from [%s] to [%s] ",get_from(), get_to());
if (this->pending_client_trans == NULL){
if (this->pending_client_trans == NULL) {
ms_warning("There is no transaction to cancel.");
return -1;
}
cancel = belle_sip_client_transaction_create_cancel(this->pending_client_trans);
if (cancel){
if (info != NULL){
if (cancel) {
if (info && info->reason != SalReasonNone) {
belle_sip_header_reason_t* reason = make_reason_header(info);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(cancel),BELLE_SIP_HEADER(reason));
}
send_request(cancel);
return 0;
}else if (this->dialog){
} else if (this->dialog) {
belle_sip_dialog_state_t state = belle_sip_dialog_get_state(this->dialog);;
/*case where the response received is invalid (could not establish a dialog), but the transaction is not cancellable
* because already terminated*/
switch(state){
switch(state) {
case BELLE_SIP_DIALOG_EARLY:
case BELLE_SIP_DIALOG_NULL:
/*force kill the dialog*/
@ -1303,7 +1303,7 @@ int SalCallOp::terminate_with_error(const SalErrorInfo *info) {
int ret = 0;
memset(&sei, 0, sizeof(sei));
if (info == NULL && dialog_state != BELLE_SIP_DIALOG_CONFIRMED && this->dir == Dir::Incoming){
if (info == NULL && dialog_state != BELLE_SIP_DIALOG_CONFIRMED && this->dir == Dir::Incoming) {
/*the purpose of this line is to set a default SalErrorInfo for declining an incoming call (not yet established of course) */
sal_error_info_set(&sei,SalReasonDeclined, "SIP", 0, NULL, NULL);
p_sei = &sei;
@ -1318,7 +1318,7 @@ int SalCallOp::terminate_with_error(const SalErrorInfo *info) {
switch(dialog_state) {
case BELLE_SIP_DIALOG_CONFIRMED: {
belle_sip_request_t * req = belle_sip_dialog_create_request(this->dialog,"BYE");
if (info != NULL){
if (info && info->reason != SalReasonNone) {
belle_sip_header_reason_t* reason = make_reason_header(info);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(reason));
}
@ -1334,7 +1334,7 @@ int SalCallOp::terminate_with_error(const SalErrorInfo *info) {
} else if (this->pending_client_trans){
if (belle_sip_transaction_get_state(BELLE_SIP_TRANSACTION(this->pending_client_trans)) == BELLE_SIP_TRANSACTION_PROCEEDING){
cancelling_invite(p_sei);
}else{
} else {
/* Case where the CANCEL cannot be sent because no provisional response was received so far.
* The Op must be kept for the time of the transaction in case a response is received later.
* The state is passed to Terminating to remember to terminate later.
@ -1351,7 +1351,7 @@ int SalCallOp::terminate_with_error(const SalErrorInfo *info) {
if (this->dir == Dir::Incoming) {
decline_with_error_info(p_sei,NULL);
this->state=State::Terminated;
} else {
} else {
cancelling_invite(p_sei);
}
break;

View file

@ -821,11 +821,11 @@ static void multiple_answers_call_with_media_relay(void) {
linphone_core_remove_supported_tag(pauline->lc,"gruu");
linphone_core_remove_supported_tag(marie1->lc,"gruu");
linphone_core_remove_supported_tag(marie2->lc,"gruu");
linphone_core_manager_start(pauline, TRUE);
linphone_core_manager_start(marie1, TRUE);
linphone_core_manager_start(marie2, TRUE);
LinphoneCall* call1, *call2;
bctbx_list_t* lcs = bctbx_list_append(NULL,pauline->lc);
@ -1038,7 +1038,7 @@ static void terminate_call_with_error(void) {
linphone_call_ref(out_call);
ei = linphone_error_info_new();
linphone_error_info_set(ei, NULL, LinphoneReasonNone, 200, "Call refused for security reason", NULL);
linphone_error_info_set(ei, NULL, LinphoneReasonUnknown, 200, "Call refused for security reason", NULL);
BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
@ -1093,7 +1093,7 @@ static void cancel_call_with_error(void) {
linphone_call_ref(out_call);
ei = linphone_error_info_new();
linphone_error_info_set(ei, NULL, LinphoneReasonNone, 600, "Call has been cancelled", NULL);
linphone_error_info_set(ei, NULL, LinphoneReasonUnknown, 600, "Call has been cancelled", NULL);
BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallOutgoingInit,1));
BC_ASSERT_TRUE(wait_for(caller_mgr->lc, callee_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1));
@ -1421,8 +1421,8 @@ static void call_declined_with_error(void) {
LinphoneErrorInfo *ei = linphone_factory_create_error_info(factory);
LinphoneErrorInfo *reason_ei = linphone_factory_create_error_info(factory);
linphone_error_info_set(ei, "SIP", LinphoneReasonUnknown, 603, "Decline", NULL); //ordre des arguments à vérifier
linphone_error_info_set(reason_ei, "hardware", LinphoneReasonUnknown, 66, "J'ai plus de batterie", NULL);
linphone_error_info_set(ei, "SIP", LinphoneReasonDeclined, 603, "Decline", NULL); //ordre des arguments à vérifier
linphone_error_info_set(reason_ei, "hardware", LinphoneReasonDeclined, 66, "J'ai plus de batterie", NULL);
linphone_error_info_set_sub_error_info(ei, reason_ei);
@ -3153,22 +3153,25 @@ static void early_media_call_with_ringing_base(bool_t network_change){
_linphone_call_add_local_desc_changed_flag(marie_call, SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED);
}
linphone_call_accept(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
connected_time=ms_get_cur_time_ms();
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
BC_ASSERT_PTR_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
BC_ASSERT_FALSE(linphone_call_get_all_muted(marie_call));
liblinphone_tester_check_rtcp(marie, pauline);
/*just to have a call duration !=0*/
wait_for_list(lcs,&dummy,1,2000);
end_call(pauline, marie);
ended_time=ms_get_cur_time_ms();
BC_ASSERT_LOWER( labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld");
if (linphone_core_get_current_call(pauline->lc)
&& linphone_call_get_state(linphone_core_get_current_call(pauline->lc)) == LinphoneCallIncomingEarlyMedia) {
linphone_call_accept(linphone_core_get_current_call(pauline->lc));
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallConnected, 1,1000));
connected_time=ms_get_cur_time_ms();
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning, 1,1000));
BC_ASSERT_PTR_EQUAL(marie_call, linphone_core_get_current_call(marie->lc));
BC_ASSERT_FALSE(linphone_call_get_all_muted(marie_call));
liblinphone_tester_check_rtcp(marie, pauline);
/*just to have a call duration !=0*/
wait_for_list(lcs,&dummy,1,2000);
end_call(pauline, marie);
ended_time=ms_get_cur_time_ms();
BC_ASSERT_LOWER( labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld");
}
bctbx_list_free(lcs);
}
@ -5908,7 +5911,7 @@ static void call_with_ice_without_stun2(void){
static void call_with_ice_stun_not_responding(void){
LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
/*set dummy stun servers*/
linphone_core_set_stun_server(marie->lc, "belledonne-communications.com:443");
linphone_core_set_stun_server(pauline->lc, "belledonne-communications.com:443");

View file

@ -2072,6 +2072,97 @@ static void video_call_with_high_bandwidth_available(void) {
linphone_core_manager_destroy(pauline);
}
static void video_call_expected_fps_for_specified_bandwidth(int bandwidth, int fps, const char *resolution) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
LinphoneVideoPolicy pol = {0};
OrtpNetworkSimulatorParams simparams = { 0 };
if (ms_factory_get_cpu_count(linphone_core_get_ms_factory(marie->lc)) >= 2) {
linphone_core_set_video_device(marie->lc, "Mire: Mire (synthetic moving picture)");
linphone_core_enable_video_capture(marie->lc, TRUE);
linphone_core_enable_video_display(marie->lc, TRUE);
linphone_core_enable_video_capture(pauline->lc, TRUE);
linphone_core_enable_video_display(pauline->lc, TRUE);
pol.automatically_accept = TRUE;
pol.automatically_initiate = TRUE;
linphone_core_set_video_policy(marie->lc, &pol);
linphone_core_set_video_policy(pauline->lc, &pol);
linphone_core_set_preferred_video_size_by_name(marie->lc, resolution);
simparams.mode = OrtpNetworkSimulatorOutbound;
simparams.enabled = TRUE;
simparams.max_bandwidth = (float)bandwidth;
simparams.max_buffer_size = bandwidth;
simparams.latency = 60;
linphone_core_set_network_simulator_params(marie->lc, &simparams);
if (BC_ASSERT_TRUE(call(marie, pauline))){
LinphoneCall *call = linphone_core_get_current_call(marie->lc);
/*wait for the first TMMBR*/
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.last_tmmbr_value_received, 1, 10000));
VideoStream *vstream = (VideoStream *)linphone_call_get_stream(call, LinphoneStreamTypeVideo);
BC_ASSERT_EQUAL((int)vstream->configured_fps, fps, int, "%d");
end_call(marie, pauline);
}
} else {
BC_PASS("Test requires at least a dual core");
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
/*
* This test simulates a video call with a lower bandwidth than the required_bitrate of the lowest given configuration.
* The stream from pauline to marie is not under test.
* It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the lowest given configuration.
* This test requires at least a computer with 2 CPUs.
*
**/
static void video_call_expected_fps_for_low_bandwidth(void) {
#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM)
video_call_expected_fps_for_specified_bandwidth(80000, 10, "qvga");
#else
video_call_expected_fps_for_specified_bandwidth(250000, 15, "vga");
#endif
}
/*
* This test simulates a video call with a regular bandwidth that is between a given configuration.
* The stream from pauline to marie is not under test.
* It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the expected given configuration.
* This test requires at least a computer with 2 CPUs.
*
**/
static void video_call_expected_fps_for_regular_bandwidth(void) {
#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM)
video_call_expected_fps_for_specified_bandwidth(500000, 12, "vga");
#else
video_call_expected_fps_for_specified_bandwidth(450000, 25, "vga");
#endif
}
/*
* This test simulates a video call with a higher bandwidth than the bitrate_limit of the highest given configuration.
* The stream from pauline to marie is not under test.
* It checks that after a few seconds marie, after receiving a TMMBR, has her fps set to the highest given configuration.
* This test requires at least a computer with 2 CPUs.
*
**/
static void video_call_expected_fps_for_high_bandwidth(void) {
#if defined(__ANDROID__) || (TARGET_OS_IPHONE == 1) || defined(__arm__) || defined(_M_ARM)
video_call_expected_fps_for_specified_bandwidth(400000, 12, "qcif");
#else
video_call_expected_fps_for_specified_bandwidth(5000000, 30, "vga");
#endif
}
test_t call_video_tests[] = {
#ifdef VIDEO_ENABLED
TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video),
@ -2140,7 +2231,10 @@ test_t call_video_tests[] = {
TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec),
TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video),
TEST_NO_TAG("Video call with thin congestion", video_call_with_thin_congestion),
TEST_NO_TAG("Video call with high bandwidth available", video_call_with_high_bandwidth_available)
TEST_NO_TAG("Video call with high bandwidth available", video_call_with_high_bandwidth_available),
TEST_NO_TAG("Video call expected FPS for low bandwidth", video_call_expected_fps_for_low_bandwidth),
TEST_NO_TAG("Video call expected FPS for regular bandwidth", video_call_expected_fps_for_regular_bandwidth),
TEST_NO_TAG("Video call expected FPS for high bandwidth", video_call_expected_fps_for_high_bandwidth)
#endif
};

File diff suppressed because it is too large Load diff

View file

@ -2430,6 +2430,7 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) {
BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(paulineCr), 4, int, "%d");
// Activate groupchat on Pauline's side and wait for 5 seconds, the migration should now be done on next message sending
lp_config_set_int(linphone_core_get_config(marie->lc),"misc","basic_to_client_group_chat_room_migration_timer",5);
linphone_core_set_linphone_specs(pauline->lc, "groupchat");
linphone_core_set_network_reachable(pauline->lc, FALSE);
wait_for_list(coresList, &dummy, 1, 1000);
@ -2508,13 +2509,13 @@ static void group_chat_donot_room_migrate_from_basic_chat_room (void) {
linphone_chat_message_send(msg);
linphone_chat_message_unref(msg);
BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 1, 10000));
BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 10000));
BC_ASSERT_FALSE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 3000));
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesBasic);
BC_ASSERT_EQUAL(linphone_chat_room_get_nb_participants(marieCr), 1, int, "%d");
BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(marieCr), 2, int, "%d");
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomStateCreationPending, initialPaulineStats.number_of_LinphoneChatRoomStateCreationPending + 1, 10000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomStateCreated, initialPaulineStats.number_of_LinphoneChatRoomStateCreated + 1, 10000));
BC_ASSERT_FALSE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneChatRoomStateCreated, initialPaulineStats.number_of_LinphoneChatRoomStateCreated + 1, 3000));
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(paulineCr) & LinphoneChatRoomCapabilitiesBasic);
BC_ASSERT_EQUAL(linphone_chat_room_get_nb_participants(paulineCr), 1, int, "%d");
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 1000));

View file

@ -788,7 +788,7 @@ static void presence_list_subscribe_network_changes(void) {
linphone_core_set_presence_model(pauline->lc, presence);
linphone_presence_model_unref(presence);
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityAway, 1, 6000));
BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityAway, 2, 6000));
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d");
@ -829,6 +829,28 @@ static void long_term_presence_base(const char* addr, bool_t exist, const char*
linphone_friend_unref(friend2);
linphone_core_manager_destroy(pauline);
}
static void long_term_presence_large_number_of_subs(void) {
int i=0;
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
linphone_core_set_user_agent(pauline->lc, "bypass", NULL);
LinphoneFriendList *friends = linphone_core_create_friend_list(pauline->lc);
linphone_friend_list_set_rls_uri(friends, "sip:rls@sip.example.org");
for (i = 0 ; i <1000; i++ ) {
char user_id[256];
snprintf(user_id, sizeof(user_id), "sip:user_%i@sip.example.org",i);
LinphoneFriend* friend2 =linphone_core_create_friend_with_address(pauline->lc, user_id);
linphone_friend_list_add_friend(friends,friend2);
linphone_friend_unref(friend2);
}
linphone_core_add_friend_list(pauline->lc, friends);
linphone_friend_list_unref(friends);
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_NotifyPresenceReceived,i));
linphone_core_manager_destroy(pauline);
}
static void long_term_presence_existing_friend(void) {
// this friend is not online, but is known from flexisip to be registered (see flexisip/userdb.conf),
// so we expect to get a report that he is currently not online
@ -1739,6 +1761,7 @@ test_t presence_server_tests[] = {
TEST_ONE_TAG("Long term presence with +164 phone, without sip",long_term_presence_with_e164_phone_without_sip, "longterm"),
TEST_ONE_TAG("Long term presence with phone, without sip",long_term_presence_with_phone_without_sip, "longterm"),
TEST_ONE_TAG("Long term presence with cross references", long_term_presence_with_crossed_references,"longtern"),
TEST_ONE_TAG("Long term presence with large number of subs", long_term_presence_large_number_of_subs,"longtern"),
TEST_NO_TAG("Subscriber no longer reachable using server",subscriber_no_longer_reachable),
TEST_NO_TAG("Subscribe with late publish", subscribe_with_late_publish),
TEST_NO_TAG("Multiple publish aggregation", multiple_publish_aggregation),

View file

@ -1,7 +1,7 @@
[sip]
sip_port=5092
sip_tcp_port=5092
sip_tls_port=5093
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0

View file

@ -1,7 +1,7 @@
[sip]
sip_port=5092
sip_tcp_port=5092
sip_tls_port=5093
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0

View file

@ -1,7 +1,7 @@
[sip]
sip_port=5092
sip_tcp_port=5092
sip_tls_port=5093
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
ping_with_options=0

View file

@ -29,7 +29,7 @@ subscribe=0
[misc]
enable_basic_to_client_group_chat_room_migration=1
basic_to_client_group_chat_room_migration_timer=10
basic_to_client_group_chat_room_migration_timer=180
[rtp]
audio_rtp_port=18070-28000

View file

@ -1,7 +1,7 @@
[sip]
sip_port=5072
sip_tcp_port=5072
sip_tls_port=5073
sip_port=-1
sip_tcp_port=-1
sip_tls_port=-1
default_proxy=0
[auth_info_0]

View file

@ -19,6 +19,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "linphone/core.h"
#include "linphone/logging.h"
#include "logging-private.h"
#include "liblinphone_tester.h"
#include <bctoolbox/tester.h>
#include "tester_utils.h"
@ -504,7 +506,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
linphone_core_cbs_unref(mgr->cbs);
manager_count--;
linphone_core_set_log_level(old_log_level);
linphone_core_set_log_level_mask(old_log_level);
}
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr) {

View file

@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <linphone/linphone_tunnel.h>
#include <linphone/linphonecore_utils.h>
#include <linphone/wrapper_utils.h>
#include <linphone/logging.h>
#include "linphone++/linphone.hh"
#include "tools.hh"