Commit 6aec4218 authored by DanmeiChen's avatar DanmeiChen
Browse files

merge call classes and and new call state PushIncomingReceived

parent ba24938c
......@@ -39,7 +39,7 @@
#endif
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "call/call.h"
#include "chat/chat-message/chat-message-p.h"
#include "chat/chat-room/chat-room.h"
#ifdef HAVE_ADVANCED_IM
......@@ -253,10 +253,16 @@ static void call_received(SalCallOp *h) {
linphone_address_unref(fromAddressToSearchIfMe);
}
LinphoneCall *call = linphone_call_new_incoming(lc, fromAddr, toAddr, h);
LinphoneCall *call = linphone_core_get_call_by_callid(lc, h->getCallId().c_str());
if (call) {
// There is already a call created when PushIncomingReceived
linphone_call_configure(call, fromAddr, toAddr, h);
} else {
call = linphone_call_new_incoming(lc, fromAddr, toAddr, h);
}
linphone_address_unref(fromAddr);
linphone_address_unref(toAddr);
L_GET_PRIVATE_FROM_C_OBJECT(call)->startIncomingNotification();
LinphonePrivate::Call::toCpp(call)->startIncomingNotification();
}
static void call_rejected(SalCallOp *h){
......
......@@ -241,7 +241,7 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, LinphonePrivate:
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call) {
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & LinphonePrivate::ChatRoom::Capabilities::RealTimeText))
return;
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->realtimeTextReceived(character, L_GET_CPP_PTR_FROM_C_OBJECT(call));
L_GET_PRIVATE_FROM_C_OBJECT(cr, RealTimeTextChatRoom)->realtimeTextReceived(character, LinphonePrivate::Call::toCpp(call)->getSharedFromThis());
}
unsigned int linphone_chat_message_store(LinphoneChatMessage *msg) {
......
......@@ -29,7 +29,7 @@
#include "conference_private.h"
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "call/call.h"
#include "conference/params/media-session-params-p.h"
#include "core/core-p.h"
#include "conference/session/mixers.h"
......@@ -211,7 +211,7 @@ int LocalConference::addParticipant (LinphoneCall *call) {
case LinphoneCallOutgoingProgress:
case LinphoneCallIncomingReceived:
const_cast<LinphonePrivate::MediaSessionParamsPrivate *>(
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams()))->setInConference(true);
L_GET_PRIVATE(Call::toCpp(call)->getParams()))->setInConference(true);
break;
case LinphoneCallPaused:
/*
......@@ -219,9 +219,9 @@ int LocalConference::addParticipant (LinphoneCall *call) {
* However, the resume() method doesn't accept parameters.
*/
const_cast<LinphonePrivate::MediaSessionParamsPrivate *>(
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams()))->setInConference(true);
L_GET_PRIVATE(Call::toCpp(call)->getParams()))->setInConference(true);
const_cast<LinphonePrivate::MediaSessionParams *>(
L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams())->enableVideo(getCurrentParams().videoEnabled());
Call::toCpp(call)->getParams())->enableVideo(getCurrentParams().videoEnabled());
linphone_call_resume(call);
break;
case LinphoneCallStreamsRunning:
......@@ -244,7 +244,7 @@ int LocalConference::addParticipant (LinphoneCall *call) {
if (call == linphone_core_get_current_call(m_core))
L_GET_PRIVATE_FROM_C_OBJECT(m_core)->setCurrentCall(nullptr);
_linphone_call_set_conf_ref(call, toC());
mMixerSession->joinStreamsGroup(L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(call))->getMediaSession()->getStreamsGroup());
mMixerSession->joinStreamsGroup(Call::toCpp(call)->getMediaSession()->getStreamsGroup());
Conference::addParticipant(call);
if (starting) setState(LinphoneConferenceRunning);
if (localEndpointCanBeAdded){
......@@ -268,15 +268,16 @@ int LocalConference::removeParticipant (LinphoneCall *call) {
lError() << "Call " << call << " is not part of conference " << this->toC();
return -1;
}
if (remoteParticipantsCount() >= 2){
/* Kick the call out of the conference by moving to the Paused state. */
const_cast<LinphonePrivate::MediaSessionParamsPrivate *>(
L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getParams()))->setInConference(false);
L_GET_PRIVATE(Call::toCpp(call)->getParams()))->setInConference(false);
err = _linphone_call_pause(call);
}
Conference::removeParticipant(call);
mMixerSession->unjoinStreamsGroup(L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(call))->getMediaSession()->getStreamsGroup());
mMixerSession->unjoinStreamsGroup(Call::toCpp(call)->getMediaSession()->getStreamsGroup());
_linphone_call_set_conf_ref(call, nullptr);
/*
* Handle the case where only the local participant and a unique remote participant are remaining.
......@@ -287,7 +288,7 @@ int LocalConference::removeParticipant (LinphoneCall *call) {
/* Obtain the last LinphoneCall from the list: FIXME: for the moment this list only contains remote participants so it works
* but it should contains all participants ideally.*/
LinphoneCall *remaining_call = (*m_participants.begin())->getCall();
lInfo() << "Call [" << remaining_call << "] with " << L_GET_CPP_PTR_FROM_C_OBJECT(remaining_call)->getRemoteAddress().asString() <<
lInfo() << "Call [" << remaining_call << "] with " << Call::toCpp(remaining_call)->getRemoteAddress()->asString() <<
" is our last call in our conference, we will reconnect directly to it.";
LinphoneCallParams *params = linphone_core_create_call_params(m_core, remaining_call);
linphone_call_params_set_in_conference(params, FALSE);
......@@ -319,7 +320,7 @@ int LocalConference::terminate () {
list<shared_ptr<LinphonePrivate::Call>> calls = L_GET_CPP_PTR_FROM_C_OBJECT(m_core)->getCalls();
for (auto it = calls.begin(); it != calls.end(); it++) {
shared_ptr<LinphonePrivate::Call> call(*it);
LinphoneCall *cCall = L_GET_C_BACK_PTR(call);
LinphoneCall *cCall = call->toC();
if (linphone_call_get_conference(cCall) == this->toC())
call->terminate();
}
......@@ -701,23 +702,20 @@ void RemoteConference::transferStateChanged (LinphoneCore *lc, LinphoneCall *tra
AudioControlInterface * RemoteConference::getAudioControlInterface() const{
if (!m_focusCall) return nullptr;
CallPrivate *callPriv = L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(m_focusCall));
shared_ptr<MediaSession> ms = callPriv->getMediaSession();
shared_ptr<MediaSession> ms = Call::toCpp(m_focusCall)->getMediaSession();
return ms->getStreamsGroup().lookupMainStreamInterface<AudioControlInterface>(SalAudio);
}
VideoControlInterface * RemoteConference::getVideoControlInterface() const{
if (!m_focusCall) return nullptr;
CallPrivate *callPriv = L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(m_focusCall));
shared_ptr<MediaSession> ms = callPriv->getMediaSession();
shared_ptr<MediaSession> ms = Call::toCpp(m_focusCall)->getMediaSession();
return ms->getStreamsGroup().lookupMainStreamInterface<VideoControlInterface>(SalVideo);
}
AudioStream *RemoteConference::getAudioStream(){
if (!m_focusCall) return nullptr;
CallPrivate *callPriv = L_GET_PRIVATE(L_GET_CPP_PTR_FROM_C_OBJECT(m_focusCall));
shared_ptr<MediaSession> ms = callPriv->getMediaSession();
shared_ptr<MediaSession> ms = Call::toCpp(m_focusCall)->getMediaSession();
MS2AudioStream *stream = ms->getStreamsGroup().lookupMainStreamInterface<MS2AudioStream>(SalAudio);
return stream ? (AudioStream*)stream->getMediaStream() : nullptr;
}
......
......@@ -31,6 +31,8 @@ const char *linphone_call_state_to_string(LinphoneCallState cs){
return "LinphoneCallIdle";
case LinphoneCallIncomingReceived:
return "LinphoneCallIncomingReceived";
case LinphoneCallPushIncomingReceived:
return "LinphoneCallPushIncomingReceived";
case LinphoneCallOutgoingInit:
return "LinphoneCallOutgoingInit";
case LinphoneCallOutgoingProgress:
......
......@@ -97,7 +97,7 @@
#endif
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "call/call.h"
#include "conference/params/media-session-params-p.h"
#include "sal/sal.h"
......@@ -1588,6 +1588,9 @@ static void sip_config_read(LinphoneCore *lc) {
tmp=lp_config_get_int(lc->config,"sip","inc_timeout",30);
linphone_core_set_inc_timeout(lc,tmp);
tmp=lp_config_get_int(lc->config,"sip","push_incoming_call_timeout",15);
lc->sip_conf.push_incoming_call_timeout = tmp;
tmp=lp_config_get_int(lc->config,"sip","in_call_timeout",0);
linphone_core_set_in_call_timeout(lc,tmp);
......@@ -3317,8 +3320,8 @@ bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc){
static void apply_jitter_value(LinphoneCore *lc, int value, MSFormatType stype){
for (const auto &call : L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls()) {
MediaStream *ms = (stype == MSAudio)
? L_GET_PRIVATE(call)->getMediaStream(LinphoneStreamTypeAudio)
: L_GET_PRIVATE(call)->getMediaStream(LinphoneStreamTypeVideo);
? call->getMediaStream(LinphoneStreamTypeAudio)
: call->getMediaStream(LinphoneStreamTypeVideo);
if (ms) {
RtpSession *s=ms->sessions.rtp_session;
if (s){
......@@ -3927,9 +3930,9 @@ const char * linphone_core_get_route(LinphoneCore *lc){
}
LinphoneCall * linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params) {
shared_ptr<LinphonePrivate::Call> referredCall = L_GET_PRIVATE_FROM_C_OBJECT(call)->startReferredCall(params
shared_ptr<LinphonePrivate::Call> referredCall = Call::toCpp(call)->startReferredCall(params
? L_GET_CPP_PTR_FROM_C_OBJECT(params) : nullptr);
return L_GET_C_BACK_PTR(referredCall);
return referredCall->toC();
}
/*
......@@ -4188,7 +4191,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
call=linphone_call_new_outgoing(lc,parsed_url2,addr,cp,proxy);
linphone_address_unref(parsed_url2);
if (L_GET_PRIVATE_FROM_C_OBJECT(lc)->addCall(L_GET_CPP_PTR_FROM_C_OBJECT(call)) != 0) {
if (L_GET_PRIVATE_FROM_C_OBJECT(lc)->addCall(Call::toCpp(call)->getSharedFromThis()) != 0) {
ms_warning("we had a problem in adding the call into the invite ... weird");
linphone_call_unref(call);
linphone_call_params_unref(cp);
......@@ -4197,10 +4200,10 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
/* Unless this call is for a conference, it becomes now the current one*/
if (linphone_call_params_get_local_conference_mode(params) == FALSE)
L_GET_PRIVATE_FROM_C_OBJECT(lc)->setCurrentCall(L_GET_CPP_PTR_FROM_C_OBJECT(call));
bool defer = L_GET_PRIVATE_FROM_C_OBJECT(call)->initiateOutgoing();
L_GET_PRIVATE_FROM_C_OBJECT(lc)->setCurrentCall(Call::toCpp(call)->getSharedFromThis());
bool defer = Call::toCpp(call)->initiateOutgoing();
if (!defer) {
if (L_GET_PRIVATE_FROM_C_OBJECT(call)->startInvite(nullptr) != 0) {
if (Call::toCpp(call)->startInvite(nullptr) != 0) {
/* The call has already gone to error and released state, so do not return it */
call = nullptr;
}
......@@ -4311,17 +4314,22 @@ const bctbx_list_t *linphone_core_get_calls(LinphoneCore *lc) {
bctbx_list_free_with_data(lc->callsCache, (bctbx_list_free_func)linphone_call_unref);
lc->callsCache = NULL;
}
lc->callsCache = L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls());
lc->callsCache = Call::getCListFromCppList(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls());
return lc->callsCache;
}
LinphoneCall *linphone_core_get_call_by_callid(const LinphoneCore *lc, const char *call_id) {
shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCallByCallId(call_id);
return call ? call->toC() : NULL;
}
bool_t linphone_core_in_call(const LinphoneCore *lc){
return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL || linphone_core_is_in_conference(lc);
}
LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc) {
shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCurrentCall();
return call ? L_GET_C_BACK_PTR(call) : NULL;
return call ? call->toC() : NULL;
}
LinphoneStatus linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call) {
......@@ -4344,7 +4352,7 @@ int linphone_core_preempt_sound_resources(LinphoneCore *lc){
current_call=linphone_core_get_current_call(lc);
if(current_call != NULL){
ms_message("Pausing automatically the current call.");
err = L_GET_CPP_PTR_FROM_C_OBJECT(current_call)->pause();
err = Call::toCpp(current_call)->pause();
}
return err;
}
......@@ -4369,7 +4377,7 @@ LinphoneCall *linphone_core_find_call_from_uri(const LinphoneCore *lc, const cha
LinphoneCall *linphone_core_get_call_by_remote_address2(const LinphoneCore *lc, const LinphoneAddress *raddr) {
shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCallByRemoteAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(raddr));
return call ? L_GET_C_BACK_PTR(call) : NULL;
return call ? call->toC() : NULL;
}
int linphone_core_send_publish(LinphoneCore *lc, LinphonePresenceModel *presence) {
......@@ -4392,6 +4400,17 @@ int linphone_core_get_inc_timeout(LinphoneCore *lc){
return lc->sip_conf.inc_timeout;
}
void linphone_core_set_push_incoming_call_timeout(LinphoneCore *lc, int seconds) {
lc->sip_conf.push_incoming_call_timeout=seconds;
if (linphone_core_ready(lc)){
lp_config_set_int(lc->config,"sip","push_incoming_call_timeout",seconds);
}
}
int linphone_core_get_push_incoming_call_timeout(const LinphoneCore *lc) {
return lc->sip_conf.push_incoming_call_timeout;
}
void linphone_core_set_in_call_timeout(LinphoneCore *lc, int seconds){
lc->sip_conf.in_call_timeout=seconds;
if( linphone_core_ready(lc)){
......@@ -5890,7 +5909,7 @@ void * linphone_core_get_native_video_window_id(const LinphoneCore *lc){
LinphoneCall *call=linphone_core_get_current_call (lc);
if (call) {
auto ms = dynamic_pointer_cast<LinphonePrivate::MediaSession>(L_GET_PRIVATE_FROM_C_OBJECT(call)->getActiveSession());
auto ms = dynamic_pointer_cast<LinphonePrivate::MediaSession>(Call::toCpp(call)->getActiveSession());
if (ms) return ms->getNativeVideoWindowId();
}
#endif
......@@ -5922,7 +5941,7 @@ void * linphone_core_get_native_preview_window_id(const LinphoneCore *lc){
LinphoneCall *call=linphone_core_get_current_call(lc);
if (call) {
auto ms = dynamic_pointer_cast<LinphonePrivate::MediaSession>(L_GET_PRIVATE_FROM_C_OBJECT(call)->getActiveSession());
auto ms = dynamic_pointer_cast<LinphonePrivate::MediaSession>(Call::toCpp(call)->getActiveSession());
if (ms) return ms->getNativePreviewVideoWindowId();
}
if (lc->previewstream)
......@@ -7754,8 +7773,8 @@ LinphoneStatus linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *c
LinphoneStatus linphone_core_add_all_to_conference(LinphoneCore *lc) {
for (const auto &call : L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls()) {
if (!linphone_call_get_conference(L_GET_C_BACK_PTR(call))) // Prevent the call to the conference server from being added to the conference
linphone_core_add_to_conference(lc, L_GET_C_BACK_PTR(call));
if (!linphone_call_get_conference(call->toC())) // Prevent the call to the conference server from being added to the conference
linphone_core_add_to_conference(lc, call->toC());
}
if(lc->conf_ctx && linphone_conference_check_class(lc->conf_ctx, LinphoneConferenceClassLocal)) {
linphone_core_enter_conference(lc);
......
......@@ -904,8 +904,10 @@ void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log){
}
linphone_address_unref(conference_factory_addr);
}
const char *usernameFrom = linphone_address_get_username(call_log->from);
const char *usernameTo = linphone_address_get_username(call_log->to);
// For PushIncomingState call, from and to address are unknow.
const char *usernameFrom = call_log->from ? linphone_address_get_username(call_log->from) : nullptr;
const char *usernameTo = call_log->to ? linphone_address_get_username(call_log->to) : nullptr;
if ((usernameFrom && (strstr(usernameFrom, "chatroom-") == usernameFrom))
|| (usernameTo && (strstr(usernameTo, "chatroom-") == usernameTo))
)
......
......@@ -56,6 +56,8 @@ void linphone_call_notify_audio_device_changed(LinphoneCall *call, LinphoneAudio
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg);
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op);
void linphone_call_configure (LinphoneCall *call, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op);
LINPHONE_PUBLIC LinphoneCallLog *linphone_call_log_new(LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress * to);
void linphone_call_log_set_call_id(LinphoneCallLog *cl, const char *call_id);
LinphonePlayer *linphone_call_build_player(LinphoneCall*call);
......@@ -67,9 +69,6 @@ LINPHONE_PUBLIC LinphoneProxyConfig *linphone_call_get_dest_proxy(const Linphone
LINPHONE_PUBLIC MediaStream * linphone_call_get_stream(LinphoneCall *call, LinphoneStreamType type);
// FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h
LINPHONE_PUBLIC LinphoneCallLog * linphone_call_get_log(const LinphoneCall *call);
// FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h
LINPHONE_PUBLIC IceSession *linphone_call_get_ice_session(const LinphoneCall *call);
......@@ -122,8 +121,13 @@ void linphone_call_params_set_used_video_codec(LinphoneCallParams *params, OrtpP
void linphone_call_params_set_used_text_codec(LinphoneCallParams *params, OrtpPayloadType *codec);
bool_t linphone_call_params_get_no_user_consent(const LinphoneCallParams *params);
// FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h
LINPHONE_PUBLIC void linphone_call_params_set_no_user_consent(LinphoneCallParams *params, bool_t value);
LINPHONE_PUBLIC void linphone_call_start_basic_incoming_notification(LinphoneCall *call);
LINPHONE_PUBLIC void linphone_call_start_push_incoming_notification(LinphoneCall *call);
LINPHONE_PUBLIC LinphoneCall *linphone_call_new_incoming_with_callid(LinphoneCore *lc, const char *callid);
LINPHONE_PUBLIC bool_t linphone_call_is_op_configured (const LinphoneCall *call);
void _linphone_core_uninit(LinphoneCore *lc);
void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai);
......
......@@ -227,6 +227,7 @@ struct sip_config
MSList *proxies;
MSList *deleted_proxies;
int inc_timeout; /*timeout after an un-answered incoming call is rejected*/
int push_incoming_call_timeout; /*timeout after push incoming received if stream not received*/
int in_call_timeout; /*timeout after a call is hangup */
int delayed_timeout; /*timeout after a delayed call is resumed */
unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/
......
......@@ -40,7 +40,7 @@
// For migration purpose.
#include "address/address-p.h"
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "call/call.h"
#include "conference/session/media-session-p.h"
#define STR_REASSIGN(dest, src) {\
......@@ -49,6 +49,8 @@
dest = src; \
}
using namespace LinphonePrivate;
/*since printf family functions are LOCALE dependent, float separator may differ
depending on the user's locale (LC_NUMERIC environment var).*/
static char * float_to_one_decimal_string(float f) {
......@@ -161,8 +163,8 @@ static uint8_t are_metrics_filled(const reporting_content_metrics_t *rm) {
}
static bool_t quality_reporting_enabled(const LinphoneCall * call) {
return (L_GET_PRIVATE_FROM_C_OBJECT(call)->getDestProxy()
&& linphone_proxy_config_quality_reporting_enabled(L_GET_PRIVATE_FROM_C_OBJECT(call)->getDestProxy()));
return (Call::toCpp(call)->getDestProxy()
&& linphone_proxy_config_quality_reporting_enabled(Call::toCpp(call)->getDestProxy()));
}
static bool_t media_report_enabled(LinphoneCall * call, int stats_type){
......@@ -170,7 +172,7 @@ static bool_t media_report_enabled(LinphoneCall * call, int stats_type){
return FALSE;
if (stats_type == LINPHONE_CALL_STATS_VIDEO){
if (!(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog()->reporting.was_video_running
if (!(Call::toCpp(call)->getLog()->reporting.was_video_running
|| linphone_call_params_video_enabled(linphone_call_get_current_params(call))) )
return FALSE;
}
......@@ -178,7 +180,7 @@ static bool_t media_report_enabled(LinphoneCall * call, int stats_type){
if (stats_type == LINPHONE_CALL_STATS_TEXT && !linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call)))
return FALSE;
return (L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog()->reporting.reports[stats_type] != NULL);
return (Call::toCpp(call)->getLog()->reporting.reports[stats_type] != NULL);
}
static void append_metrics_to_buffer(char ** buffer, size_t * size, size_t * offset, const reporting_content_metrics_t *rm) {
......@@ -362,9 +364,9 @@ static int send_report(LinphoneCall* call, reporting_session_report_t * report,
linphone_content_set_buffer(content, (uint8_t *)buffer, strlen(buffer));
ms_free(buffer);
if (linphone_call_get_log(call)->reporting.on_report_sent != NULL) {
SalStreamType type = report == linphone_call_get_log(call)->reporting.reports[0] ? SalAudio : report == linphone_call_get_log(call)->reporting.reports[1] ? SalVideo : SalText;
linphone_call_get_log(call)->reporting.on_report_sent(call, type, content);
if (linphone_call_get_call_log(call)->reporting.on_report_sent != NULL) {
SalStreamType type = report == linphone_call_get_call_log(call)->reporting.reports[0] ? SalAudio : report == linphone_call_get_call_log(call)->reporting.reports[1] ? SalVideo : SalText;
linphone_call_get_call_log(call)->reporting.on_report_sent(call, type, content);
}
......@@ -427,8 +429,8 @@ static const SalStreamDescription * get_media_stream_for_desc(const SalMediaDesc
static void update_ip(LinphoneCall * call, int stats_type) {
SalStreamType sal_stream_type = stats_type == LINPHONE_CALL_STATS_AUDIO ? SalAudio : stats_type == LINPHONE_CALL_STATS_VIDEO ? SalVideo : SalText;
const SalStreamDescription * local_desc = get_media_stream_for_desc(_linphone_call_get_local_desc(call), sal_stream_type);
const SalStreamDescription * remote_desc = get_media_stream_for_desc(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getRemoteMediaDescription(), sal_stream_type);
LinphoneCallLog *log = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog();
const SalStreamDescription * remote_desc = get_media_stream_for_desc(Call::toCpp(call)->getOp()->getRemoteMediaDescription(), sal_stream_type);
LinphoneCallLog *log = Call::toCpp(call)->getLog();
if (local_desc != NULL) {
/*since this function might be called for video stream AFTER it has been uninitialized, local description might
......@@ -447,7 +449,7 @@ static void update_ip(LinphoneCall * call, int stats_type) {
if (strlen(remote_desc->rtp_addr) > 0) {
STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(remote_desc->rtp_addr));
} else {
STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getRemoteMediaDescription()->addr));
STR_REASSIGN(log->reporting.reports[stats_type]->info.remote_addr.ip, ms_strdup(Call::toCpp(call)->getOp()->getRemoteMediaDescription()->addr));
}
}
}
......@@ -506,14 +508,14 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
const PayloadType * local_payload = NULL;
const PayloadType * remote_payload = NULL;
const LinphoneCallParams * current_params = linphone_call_get_current_params(call);
LinphoneCallLog *log = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog();
LinphoneCallLog *log = Call::toCpp(call)->getLog();
reporting_session_report_t * report = log->reporting.reports[stats_type];
// call->op might be already released if hanging up in state LinphoneCallOutgoingInit
if (!media_report_enabled(call, stats_type) || !L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp())
if (!media_report_enabled(call, stats_type) || !Call::toCpp(call)->getOp())
return;
std::string dialogId = L_GET_PRIVATE_FROM_C_OBJECT(call)->getOp()->getDialogId();
std::string dialogId = Call::toCpp(call)->getOp()->getDialogId();
STR_REASSIGN(report->info.call_id, ms_strdup(log->call_id));
......@@ -536,7 +538,7 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
);
if (L_GET_CPP_PTR_FROM_C_OBJECT(call)->getDirection() == LinphoneCallIncoming) {
if (Call::toCpp(call)->getDirection() == LinphoneCallIncoming) {
STR_REASSIGN(report->info.remote_addr.id, linphone_address_as_string(log->from));
STR_REASSIGN(report->info.local_addr.id, linphone_address_as_string(log->to));
STR_REASSIGN(report->info.orig_id, ms_strdup(report->info.remote_addr.id));
......@@ -556,16 +558,16 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
/*yet we use the same payload config for local and remote, since this is the largest use case*/
if (stats_type == LINPHONE_CALL_STATS_AUDIO && L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeAudio)) {
stream = L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeAudio);
if (stats_type == LINPHONE_CALL_STATS_AUDIO && Call::toCpp(call)->getMediaStream(LinphoneStreamTypeAudio)) {
stream = Call::toCpp(call)->getMediaStream(LinphoneStreamTypeAudio);
local_payload = linphone_call_params_get_used_audio_codec(current_params);
remote_payload = local_payload;
} else if (stats_type == LINPHONE_CALL_STATS_VIDEO && L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeVideo)) {
stream = L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeVideo);
} else if (stats_type == LINPHONE_CALL_STATS_VIDEO && Call::toCpp(call)->getMediaStream(LinphoneStreamTypeVideo)) {
stream = Call::toCpp(call)->getMediaStream(LinphoneStreamTypeVideo);
local_payload = linphone_call_params_get_used_video_codec(current_params);
remote_payload = local_payload;
} else if (stats_type == LINPHONE_CALL_STATS_TEXT && L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeText)) {
stream = L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeText);
} else if (stats_type == LINPHONE_CALL_STATS_TEXT && Call::toCpp(call)->getMediaStream(LinphoneStreamTypeText)) {
stream = Call::toCpp(call)->getMediaStream(LinphoneStreamTypeText);
local_payload = linphone_call_params_get_used_text_codec(current_params);
remote_payload = local_payload;
}
......@@ -607,24 +609,24 @@ static float reporting_rand(float t){
}
void linphone_reporting_on_rtcp_update(LinphoneCall *call, SalStreamType stats_type) {
reporting_session_report_t * report = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog()->reporting.reports[stats_type];
reporting_session_report_t * report = Call::toCpp(call)->getLog()->reporting.reports[stats_type];
reporting_content_metrics_t * metrics = NULL;
LinphoneCallStats *stats = NULL;
mblk_t *block = NULL;
int report_interval;
if (stats_type == 0) {
stats = L_GET_PRIVATE_FROM_C_OBJECT(call)->getStats(LinphoneStreamTypeAudio);
stats = Call::toCpp(call)->getPrivateStats(LinphoneStreamTypeAudio);
} else if (stats_type == 1) {
stats = L_GET_PRIVATE_FROM_C_OBJECT(call)->getStats(LinphoneStreamTypeVideo);
stats = Call::toCpp(call)->getPrivateStats(LinphoneStreamTypeVideo);
} else {
stats = L_GET_PRIVATE_FROM_C_OBJECT(call)->getStats(LinphoneStreamTypeText);
stats = Call::toCpp(call)->getPrivateStats(LinphoneStreamTypeText);
}
if (! media_report_enabled(call,stats_type))
return;
report_interval = linphone_proxy_config_get_quality_reporting_interval(L_GET_PRIVATE_FROM_C_OBJECT(call)->getDestProxy());
report_interval = linphone_proxy_config_get_quality_reporting_interval(Call::toCpp(call)->getDestProxy());
if (_linphone_call_stats_get_updated(stats) == LINPHONE_CALL_STATS_RECEIVED_RTCP_UPDATE) {
metrics = &report->remote_metrics;
......@@ -661,8 +663,8 @@ void linphone_reporting_on_rtcp_update(LinphoneCall *call, SalStreamType stats_t
metrics->delay.round_trip_delay += rtcp_XR_voip_metrics_get_round_trip_delay(block);
}else if (rtcp_is_SR(block)){
MediaStream *ms = (stats_type == 0)
? L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeAudio)
: L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeVideo);
? Call::toCpp(call)->getMediaStream(LinphoneStreamTypeAudio)
: Call::toCpp(call)->getMediaStream(LinphoneStreamTypeVideo);
float rtt = rtp_session_get_round_trip_propagation(ms->sessions.rtp_session);
if (rtt > 1e-6){
......@@ -688,7 +690,7 @@ static int publish_report(LinphoneCall *call, const char *event_type){
if (media_report_enabled(call, stream_index)) {
int sndret;
linphone_reporting_update_media_info(call, stream_index);
sndret=send_report(call, L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog()->reporting.reports[stream_index], event_type);
sndret=send_report(call, Call::toCpp(call)->getLog()->reporting.reports[stream_index], event_type);
if (sndret>0){
ret += 10+(i+1)*sndret;
}
......@@ -723,7 +725,7 @@ static bool_t set_on_action_suggested_cb(MediaStream *stream,void (*on_action_su
void linphone_reporting_call_state_updated(LinphoneCall *call){
LinphoneCallState state=linphone_call_get_state(call);
LinphoneCallLog *log = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getLog();
LinphoneCallLog *log = Call::toCpp(call)->getLog();
if (state == LinphoneCallReleased||!quality_reporting_enabled(call)){
return;
}
......@@ -731,9 +733,9 @@ void linphone_reporting_call_state_updated(LinphoneCall *call){
case LinphoneCallStreamsRunning:{
int i = 0;
MediaStream *streams[3] = {
L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeAudio),
L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeVideo),
L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeText)
Call::toCpp(call)->getMediaStream(LinphoneStreamTypeAudio),
Call::toCpp(call)->getMediaStream(LinphoneStreamTypeVideo),
Call::toCpp(call)->getMediaStream(LinphoneStreamTypeText)
};
for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
int stream_index = i == _linphone_call_get_main_audio_stream_index(call) ? LINPHONE_CALL_STATS_AUDIO : _linphone_call_get_main_video_stream_index(call) ? LINPHONE_CALL_STATS_VIDEO : LINPHONE_CALL_STATS_TEXT;
......@@ -751,8 +753,8 @@ void linphone_reporting_call_state_updated(LinphoneCall *call){
break;
}
case LinphoneCallEnd:{
set_on_action_suggested_cb(L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeAudio), NULL, NULL);
set_on_action_suggested_cb(L_GET_PRIVATE_FROM_C_OBJECT(call)->getMediaStream(LinphoneStreamTypeVideo), NULL, NULL);
set_on_action_suggested_cb(Call::toCpp(call)->getMediaStream(LinphoneStreamTypeAudio), NULL, NULL);
set_on_action_suggested_cb(Call::toCpp(call)->getMediaStream(LinphoneStreamTypeVideo), NULL, NULL);
if (log->status==LinphoneCallSuccess || log->status==LinphoneCallAborted){
linphone_reporting_publish_session_report(call, TRUE);
}
......@@ -826,5 +828,5 @@ void linphone_reporting_destroy(reporting_session_report_t * report) {
void linphone_reporting_set_on_report_send(LinphoneCall *call, LinphoneQualityReportingReportSendCb cb){
linphone_call_get_log(call)->reporting.on_report_sent = cb;
linphone_call_get_call_log(call)->reporting.on_report_sent = cb;
}
......@@ -20,7 +20,7 @@
#include "tester_utils.h"
#include "private.h"
#include "call/call-p.h"
#include "call/call.h"