Correctly define call session state enumeration.

This commit is contained in:
Ghislain MARY 2017-12-28 12:43:56 +01:00
parent 4c0c1b6ae5
commit 4cc7985da9
26 changed files with 518 additions and 415 deletions

View file

@ -248,7 +248,7 @@ static void call_released(SalOp *op) {
* when declining an incoming call with busy because maximum number of calls is reached. */
return;
}
L_GET_PRIVATE(session)->setState(LinphoneCallReleased, "Call released");
L_GET_PRIVATE(session)->setState(LinphonePrivate::CallSession::State::Released, "Call released");
}
static void call_cancel_done(SalOp *op) {
@ -506,23 +506,21 @@ static void notify_refer(SalOp *op, SalReferStatus status) {
ms_warning("Receiving notify_refer for unknown CallSession");
return;
}
LinphoneCallState cstate;
LinphonePrivate::CallSession::State cstate;
switch (status) {
case SalReferTrying:
cstate = LinphoneCallOutgoingProgress;
cstate = LinphonePrivate::CallSession::State::OutgoingProgress;
break;
case SalReferSuccess:
cstate = LinphoneCallConnected;
cstate = LinphonePrivate::CallSession::State::Connected;
break;
case SalReferFailed:
cstate = LinphoneCallError;
break;
default:
cstate = LinphoneCallError;
cstate = LinphonePrivate::CallSession::State::Error;
break;
}
L_GET_PRIVATE(session)->setTransferState(cstate);
if (cstate == LinphoneCallConnected)
if (cstate == LinphonePrivate::CallSession::State::Connected)
session->terminate(); // Automatically terminate the call as the transfer is complete
}

View file

@ -27,35 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "private.h"
bool_t linphone_call_state_is_early(LinphoneCallState state){
switch (state){
case LinphoneCallIdle:
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingProgress:
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallEarlyUpdatedByRemote:
case LinphoneCallEarlyUpdating:
return TRUE;
case LinphoneCallResuming:
case LinphoneCallEnd:
case LinphoneCallUpdating:
case LinphoneCallRefered:
case LinphoneCallPausing:
case LinphoneCallPausedByRemote:
case LinphoneCallPaused:
case LinphoneCallConnected:
case LinphoneCallError:
case LinphoneCallUpdatedByRemote:
case LinphoneCallReleased:
case LinphoneCallStreamsRunning:
break;
}
return FALSE;
}
const char *linphone_call_state_to_string(LinphoneCallState cs){
switch (cs){
case LinphoneCallIdle:

View file

@ -526,8 +526,6 @@ int linphone_core_get_default_proxy_config_index(LinphoneCore *lc);
char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ;
bool_t linphone_call_state_is_early(LinphoneCallState state);
void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log);
void linphone_core_report_early_failed_call(LinphoneCore *lc, LinphoneCallDir dir, LinphoneAddress *from, LinphoneAddress *to, LinphoneErrorInfo *ei);

View file

@ -91,6 +91,7 @@ set(C_API_HEADER_FILES
)
set(ENUMS_HEADER_FILES
call-enums.h
chat-message-enums.h
chat-room-enums.h
event-log-enums.h

View file

@ -23,6 +23,7 @@
// TODO: Remove me in the future.
#include "linphone/types.h"
#include "linphone/enums/call-enums.h"
#include "linphone/enums/chat-message-enums.h"
#include "linphone/enums/chat-room-enums.h"
#include "linphone/enums/event-log-enums.h"
@ -159,6 +160,17 @@ typedef struct _LinphoneParticipant LinphoneParticipant;
// C Enums.
// =============================================================================
// -----------------------------------------------------------------------------
// Call.
// -----------------------------------------------------------------------------
/**
* LinphoneCallState enum represents the different state a call can reach into.
* The application is notified of state changes through the LinphoneCoreVTable::call_state_changed callback.
* @ingroup call_control
**/
L_DECLARE_C_ENUM(CallState, L_ENUM_VALUES_CALL_SESSION_STATE);
// -----------------------------------------------------------------------------
// ChatRoom.
// -----------------------------------------------------------------------------

View file

@ -0,0 +1,74 @@
/*
* call-enums.h
* Copyright (C) 2010-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 _CALL_ENUMS_H_
#define _CALL_ENUMS_H_
// =============================================================================
#define L_ENUM_VALUES_CALL_SESSION_STATE(F) \
F(Idle) \
F(IncomingReceived) \
F(OutgoingInit) \
F(OutgoingProgress) \
F(OutgoingRinging) \
F(OutgoingEarlyMedia) \
F(Connected) \
F(StreamsRunning) \
F(Pausing) \
F(Paused) \
F(Resuming) \
F(Referred) \
F(Error) \
F(End) \
F(PausedByRemote) \
F(UpdatedByRemote) \
F(IncomingEarlyMedia) \
F(Updating) \
F(Released) \
F(EarlyUpdatedByRemote) \
F(EarlyUpdating)
// =============================================================================
// DEPRECATED
// =============================================================================
#define LinphoneCallIdle LinphoneCallStateIdle
#define LinphoneCallIncomingReceived LinphoneCallStateIncomingReceived
#define LinphoneCallOutgoingInit LinphoneCallStateOutgoingInit
#define LinphoneCallOutgoingProgress LinphoneCallStateOutgoingProgress
#define LinphoneCallOutgoingRinging LinphoneCallStateOutgoingRinging
#define LinphoneCallOutgoingEarlyMedia LinphoneCallStateOutgoingEarlyMedia
#define LinphoneCallConnected LinphoneCallStateConnected
#define LinphoneCallStreamsRunning LinphoneCallStateStreamsRunning
#define LinphoneCallPausing LinphoneCallStatePausing
#define LinphoneCallPaused LinphoneCallStatePaused
#define LinphoneCallResuming LinphoneCallStateResuming
#define LinphoneCallRefered LinphoneCallStateReferred
#define LinphoneCallError LinphoneCallStateError
#define LinphoneCallEnd LinphoneCallStateEnd
#define LinphoneCallPausedByRemote LinphoneCallStatePausedByRemote
#define LinphoneCallUpdatedByRemote LinphoneCallStateUpdatedByRemote
#define LinphoneCallIncomingEarlyMedia LinphoneCallStateIncomingEarlyMedia
#define LinphoneCallUpdating LinphoneCallStateUpdating
#define LinphoneCallReleased LinphoneCallStateReleased
#define LinphoneCallEarlyUpdatedByRemote LinphoneCallStateEarlyUpdatedByRemote
#define LinphoneCallEarlyUpdating LinphoneCallStateEarlyUpdating
#endif // ifndef _CALL_ENUMS_H_

View file

@ -264,35 +264,6 @@ typedef struct _LinphoneCallLog LinphoneCallLog;
**/
typedef struct _LinphoneCallParams LinphoneCallParams;
/**
* LinphoneCallState enum represents the different state a call can reach into.
* The application is notified of state changes through the LinphoneCoreVTable::call_state_changed callback.
* @ingroup call_control
**/
typedef enum _LinphoneCallState{
LinphoneCallIdle, /**< Initial call state */
LinphoneCallIncomingReceived, /**< This is a new incoming call */
LinphoneCallOutgoingInit, /**< An outgoing call is started */
LinphoneCallOutgoingProgress, /**< An outgoing call is in progress */
LinphoneCallOutgoingRinging, /**< An outgoing call is ringing at remote end */
LinphoneCallOutgoingEarlyMedia, /**< An outgoing call is proposed early media */
LinphoneCallConnected, /**< Connected, the call is answered */
LinphoneCallStreamsRunning, /**< The media streams are established and running */
LinphoneCallPausing, /**< The call is pausing at the initiative of local end */
LinphoneCallPaused, /**< The call is paused, remote end has accepted the pause */
LinphoneCallResuming, /**< The call is being resumed by local end */
LinphoneCallRefered, /**< The call is being transfered to another party, resulting in a new outgoing call to follow immediately */
LinphoneCallError, /**< The call encountered an error */
LinphoneCallEnd, /**< The call ended normally */
LinphoneCallPausedByRemote, /**< The call is paused by remote end */
LinphoneCallUpdatedByRemote, /**< The call's parameters change is requested by remote end, used for example when video is added by remote */
LinphoneCallIncomingEarlyMedia, /**< We are proposing early media to an incoming call */
LinphoneCallUpdating, /**< A call update has been initiated by us */
LinphoneCallReleased, /**< The call object is no more retained by the core */
LinphoneCallEarlyUpdatedByRemote, /**< The call is updated by remote while not yet answered (early dialog SIP UPDATE received) */
LinphoneCallEarlyUpdating /**< We are updating the call while not yet answered (early dialog SIP UPDATE sent) */
} LinphoneCallState;
/**
* The LinphoneCallStats objects carries various statistic informations regarding quality of audio or video streams.
*

View file

@ -34,14 +34,14 @@ LINPHONE_BEGIN_NAMESPACE
// Get argument numbers from variadic.
#define L_ARG_N( \
A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, \
A11, A12, A13, A14, A15, A16, N, ... \
A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, N, ... \
) N
#define L_EXPAND(X) X
#define L_GET_N_ARGS(...) L_EXPAND(L_ARG_N( \
__VA_ARGS__, \
16, 15, 14, 13, 12, 11, 10, \
21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0 \
))
@ -65,6 +65,11 @@ LINPHONE_BEGIN_NAMESPACE
#define L_GET_ARG_14(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, ...) A14
#define L_GET_ARG_15(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, ...) A15
#define L_GET_ARG_16(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, ...) A16
#define L_GET_ARG_17(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, ...) A17
#define L_GET_ARG_18(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, ...) A18
#define L_GET_ARG_19(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, ...) A19
#define L_GET_ARG_20(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, ...) A20
#define L_GET_ARG_21(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, ...) A21
// Get left part of variadic.
#define L_GET_HEAP_1(A1, ...) A1
@ -83,6 +88,11 @@ LINPHONE_BEGIN_NAMESPACE
#define L_GET_HEAP_14(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14
#define L_GET_HEAP_15(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15
#define L_GET_HEAP_16(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16
#define L_GET_HEAP_17(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17
#define L_GET_HEAP_18(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18
#define L_GET_HEAP_19(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19
#define L_GET_HEAP_20(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20
#define L_GET_HEAP_21(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, ...) A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21
#define L_GET_HEAP(...) L_EXPAND( \
L_CONCAT(L_GET_HEAP_, L_GET_N_ARGS_SUB(__VA_ARGS__)) (__VA_ARGS__) \
@ -156,6 +166,26 @@ LINPHONE_BEGIN_NAMESPACE
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_15(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
#define L_APPLY_17(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_16(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17)
#define L_APPLY_18(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_17(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18)
#define L_APPLY_19(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_18(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19)
#define L_APPLY_20(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_19(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)
#define L_APPLY_21(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) \
L_CALL_HELPER(MACRONAME, (DATA, A1)), \
L_APPLY_20(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21)
#define L_APPLY(MACRONAME, DATA, ...) \
L_CALL( \
L_CONCAT(L_APPLY_, L_GET_N_ARGS(__VA_ARGS__)), \
@ -226,6 +256,26 @@ LINPHONE_BEGIN_NAMESPACE
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_15(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16)
#define L_APPLY_WITHOUT_COMMA_17(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17) \
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_16(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17)
#define L_APPLY_WITHOUT_COMMA_18(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18) \
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_17(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18)
#define L_APPLY_WITHOUT_COMMA_19(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19) \
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_18(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19)
#define L_APPLY_WITHOUT_COMMA_20(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20) \
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_19(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20)
#define L_APPLY_WITHOUT_COMMA_21(MACRONAME, DATA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21) \
L_CALL_HELPER(MACRONAME, (DATA, A1)) \
L_APPLY_WITHOUT_COMMA_20(MACRONAME, DATA, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21)
#define L_APPLY_WITHOUT_COMMA(MACRONAME, DATA, ...) \
L_CALL( \
L_CONCAT(L_APPLY_WITHOUT_COMMA_, L_GET_N_ARGS(__VA_ARGS__)), \

View file

@ -215,7 +215,7 @@ LinphoneCore *linphone_call_get_core (const LinphoneCall *call) {
}
LinphoneCallState linphone_call_get_state (const LinphoneCall *call) {
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getState();
return static_cast<LinphoneCallState>(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getState());
}
bool_t linphone_call_asked_to_autoanswer (LinphoneCall *call) {
@ -388,7 +388,7 @@ void linphone_call_set_next_video_frame_decoded_callback (LinphoneCall *call, Li
}
LinphoneCallState linphone_call_get_transfer_state (LinphoneCall *call) {
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getTransferState();
return static_cast<LinphoneCallState>(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getTransferState());
}
void linphone_call_zoom_video (LinphoneCall* call, float zoom_factor, float* cx, float* cy) {

View file

@ -82,8 +82,8 @@ private:
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionSetTerminated (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionStartReferred (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
void onCallSessionTransferStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state, const std::string &message) override;
void onCallSessionTransferStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state) override;
void onCheckForAcceptation (const std::shared_ptr<const CallSession> &session) override;
void onDtmfReceived (const std::shared_ptr<const CallSession> &session, char dtmf) override;
void onIncomingCallSessionNotified (const std::shared_ptr<const CallSession> &session) override;

View file

@ -89,7 +89,7 @@ int CallPrivate::startInvite (const Address *destination) {
shared_ptr<Call> CallPrivate::startReferredCall (const MediaSessionParams *params) {
L_Q();
if (q->getState() != LinphoneCallPaused) {
if (q->getState() != CallSession::State::Paused) {
pauseForTransfer();
}
MediaSessionParams msp;
@ -266,14 +266,14 @@ void CallPrivate::onCallSessionStartReferred (const shared_ptr<const CallSession
startReferredCall(nullptr);
}
void CallPrivate::onCallSessionStateChanged (const shared_ptr<const CallSession> &session, LinphoneCallState state, const string &message) {
void CallPrivate::onCallSessionStateChanged (const shared_ptr<const CallSession> &session, CallSession::State state, const string &message) {
L_Q();
linphone_call_notify_state_changed(L_GET_C_BACK_PTR(q), state, message.c_str());
linphone_call_notify_state_changed(L_GET_C_BACK_PTR(q), static_cast<LinphoneCallState>(state), message.c_str());
}
void CallPrivate::onCallSessionTransferStateChanged (const shared_ptr<const CallSession> &session, LinphoneCallState state) {
void CallPrivate::onCallSessionTransferStateChanged (const shared_ptr<const CallSession> &session, CallSession::State state) {
L_Q();
linphone_call_notify_transfer_state_changed(L_GET_C_BACK_PTR(q), state);
linphone_call_notify_transfer_state_changed(L_GET_C_BACK_PTR(q), static_cast<LinphoneCallState>(state));
}
void CallPrivate::onCheckForAcceptation (const shared_ptr<const CallSession> &session) {
@ -283,11 +283,11 @@ void CallPrivate::onCheckForAcceptation (const shared_ptr<const CallSession> &se
for (bctbx_list_t *it = copy; it != nullptr; it = bctbx_list_next(it)) {
LinphoneCall *call = reinterpret_cast<LinphoneCall *>(bctbx_list_get_data(it));
if (call == lcall) continue;
switch (linphone_call_get_state(call)) {
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
switch (L_GET_CPP_PTR_FROM_C_OBJECT(call)->getState()) {
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
lInfo() << "Already existing call [" << call << "] in state [" << linphone_call_state_to_string(linphone_call_get_state(call)) <<
"], canceling it before accepting new call [" << lcall << "]";
linphone_call_terminate(call);
@ -337,7 +337,7 @@ void CallPrivate::onNoMediaTimeoutCheck (const shared_ptr<const CallSession> &se
int disconnectTimeout = linphone_core_get_nortp_timeout(q->getCore()->getCCore());
bool disconnected = false;
AudioStream *as = reinterpret_cast<AudioStream *>(getMediaStream(LinphoneStreamTypeAudio));
if (((q->getState() == LinphoneCallStreamsRunning) || (q->getState() == LinphoneCallPausedByRemote))
if (((q->getState() == CallSession::State::StreamsRunning) || (q->getState() == CallSession::State::PausedByRemote))
&& oneSecondElapsed && as && (as->ms.state == MSStreamStarted) && (disconnectTimeout > 0))
disconnected = !audio_stream_alive(as, disconnectTimeout);
if (disconnected)
@ -418,8 +418,8 @@ void CallPrivate::onStopRingingIfNeeded (const shared_ptr<const CallSession> &se
bool stopRinging = true;
bool ringDuringEarlyMedia = linphone_core_get_ring_during_incoming_early_media(lc);
for (const auto &call : q->getCore()->getCalls()) {
if ((call->getState() == LinphoneCallIncomingReceived)
|| (ringDuringEarlyMedia && call->getState() == LinphoneCallIncomingEarlyMedia)) {
if ((call->getState() == CallSession::State::IncomingReceived)
|| (ringDuringEarlyMedia && call->getState() == CallSession::State::IncomingEarlyMedia)) {
stopRinging = false;
break;
}
@ -771,7 +771,7 @@ float Call::getSpeakerVolumeGain () const {
return static_pointer_cast<const MediaSession>(d->getActiveSession())->getSpeakerVolumeGain();
}
LinphoneCallState Call::getState () const {
CallSession::State Call::getState () const {
L_D();
return d->getActiveSession()->getState();
}
@ -806,7 +806,7 @@ string Call::getToHeader (const std::string &name) const {
return d->getActiveSession()->getToHeader(name);
}
LinphoneCallState Call::getTransferState () const {
CallSession::State Call::getTransferState () const {
L_D();
return d->getActiveSession()->getTransferState();
}

View file

@ -21,6 +21,7 @@
#define _CALL_CALL_H_
#include "conference/params/media-session-params.h"
#include "conference/session/call-session.h"
#include "core/core-accessor.h"
#include "object/object.h"
@ -103,14 +104,14 @@ public:
std::string getRemoteUserAgent () const;
std::shared_ptr<Call> getReplacedCall () const;
float getSpeakerVolumeGain () const;
LinphoneCallState getState () const;
CallSession::State getState () const;
LinphoneCallStats *getStats (LinphoneStreamType type) const;
int getStreamCount () const;
MSFormatType getStreamType (int streamIndex) const;
LinphoneCallStats *getTextStats () const;
const Address &getToAddress () const;
std::string getToHeader (const std::string &name) const;
LinphoneCallState getTransferState () const;
CallSession::State getTransferState () const;
std::shared_ptr<Call> getTransferTarget () const;
LinphoneCallStats *getVideoStats () const;
bool isInConference () const;

View file

@ -22,11 +22,11 @@
#include "linphone/core.h"
#include "linphone/lpconfig.h"
#include "linphone/utils/utils.h"
#include "c-wrapper/c-wrapper.h"
#include "address/address.h"
#include "c-wrapper/c-wrapper.h"
#include "call/call.h"
#include "chat/chat-message/chat-message-p.h"
#include "chat/chat-room/chat-room-p.h"
#include "chat/chat-room/client-group-to-basic-chat-room.h"
#include "chat/chat-room/real-time-text-chat-room.h"
@ -482,7 +482,7 @@ LinphoneReason ChatMessagePrivate::receive () {
void ChatMessagePrivate::send () {
L_Q();
SalOp *op = salOp;
LinphoneCall *call = nullptr;
LinphoneCall *lcall = nullptr;
int errorCode = 0;
if ((currentSendStep & ChatMessagePrivate::Step::FileUpload) == ChatMessagePrivate::Step::FileUpload) {
@ -501,14 +501,18 @@ void ChatMessagePrivate::send () {
shared_ptr<Core> core = q->getCore();
if (lp_config_get_int(core->getCCore()->config, "sip", "chat_use_call_dialogs", 0) != 0) {
call = linphone_core_get_call_by_remote_address(core->getCCore(), q->getToAddress().asString().c_str());
if (call) {
if (linphone_call_get_state(call) == LinphoneCallConnected || linphone_call_get_state(call) == LinphoneCallStreamsRunning ||
linphone_call_get_state(call) == LinphoneCallPaused || linphone_call_get_state(call) == LinphoneCallPausing ||
linphone_call_get_state(call) == LinphoneCallPausedByRemote) {
lcall = linphone_core_get_call_by_remote_address(core->getCCore(), q->getToAddress().asString().c_str());
if (lcall) {
shared_ptr<Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lcall);
if ((call->getState() == CallSession::State::Connected)
|| (call->getState() == CallSession::State::StreamsRunning)
|| (call->getState() == CallSession::State::Paused)
|| (call->getState() == CallSession::State::Pausing)
|| (call->getState() == CallSession::State::PausedByRemote)
) {
lInfo() << "send SIP msg through the existing call.";
op = linphone_call_get_op(call);
string identity = linphone_core_find_best_identity(core->getCCore(), linphone_call_get_remote_address(call));
op = linphone_call_get_op(lcall);
string identity = linphone_core_find_best_identity(core->getCCore(), linphone_call_get_remote_address(lcall));
if (identity.empty()) {
LinphoneAddress *addr = linphone_address_new(q->getToAddress().asString().c_str());
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(core->getCCore(), addr);
@ -617,7 +621,7 @@ void ChatMessagePrivate::send () {
//store(); // Store will be done right below in the setState(InProgress)
if (call && linphone_call_get_op(call) == op) {
if (lcall && linphone_call_get_op(lcall) == op) {
/* In this case, chat delivery status is not notified, so unrefing chat message right now */
/* Might be better fixed by delivering status, but too costly for now */
return;

View file

@ -72,12 +72,12 @@ public:
void onCallSessionStateChanged (
const shared_ptr<const CallSession> &session,
LinphoneCallState newState,
CallSession::State newState,
const string &message
) override {
if (!clientGroupChatRoom)
return;
if ((newState == LinphoneCallError) && (clientGroupChatRoom->getState() == ChatRoom::State::CreationPending)) {
if ((newState == CallSession::State::Error) && (clientGroupChatRoom->getState() == ChatRoom::State::CreationPending)) {
Core::deleteChatRoom(clientGroupChatRoom);
if (session->getReason() == LinphoneReasonNotAcceptable) {
clientGroupChatRoom = nullptr;

View file

@ -45,7 +45,7 @@ public:
// CallSessionListener
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) override;
void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state, const std::string &message) override;
private:
CallSessionListener *callSessionListener = this;

View file

@ -123,13 +123,13 @@ void ClientGroupChatRoomPrivate::onCallSessionSetReleased (const shared_ptr<cons
void ClientGroupChatRoomPrivate::onCallSessionStateChanged (
const shared_ptr<const CallSession> &session,
LinphoneCallState newState,
CallSession::State newState,
const string &message
) {
L_Q();
L_Q_T(RemoteConference, qConference);
if (newState == LinphoneCallConnected) {
if (newState == CallSession::State::Connected) {
if (q->getState() == ChatRoom::State::CreationPending) {
IdentityAddress addr(session->getRemoteContactAddress()->asStringUriOnly());
q->onConferenceCreated(addr);
@ -137,9 +137,9 @@ void ClientGroupChatRoomPrivate::onCallSessionStateChanged (
qConference->getPrivate()->eventHandler->subscribe(q->getChatRoomId());
} else if (q->getState() == ChatRoom::State::TerminationPending)
qConference->getPrivate()->focus->getPrivate()->getSession()->terminate();
} else if ((newState == LinphoneCallReleased) && (q->getState() == ChatRoom::State::TerminationPending)) {
} else if ((newState == CallSession::State::Released) && (q->getState() == ChatRoom::State::TerminationPending)) {
q->onConferenceTerminated(q->getConferenceAddress());
} else if ((newState == LinphoneCallError) && (q->getState() == ChatRoom::State::CreationPending)) {
} else if ((newState == CallSession::State::Error) && (q->getState() == ChatRoom::State::CreationPending)) {
setState(ChatRoom::State::CreationFailed);
}
}

View file

@ -54,14 +54,14 @@ public:
void onCallSessionStateChanged (
const shared_ptr<const CallSession> &session,
LinphoneCallState newState,
CallSession::State newState,
const string &message
) override {
L_Q();
shared_ptr<ClientGroupChatRoom> cgcr = dynamic_pointer_cast<ClientGroupChatRoom>(chatRoom);
if (!cgcr)
return;
if ((newState == LinphoneCallError) && (cgcr->getState() == ChatRoom::State::CreationPending)
if ((newState == CallSession::State::Error) && (cgcr->getState() == ChatRoom::State::CreationPending)
&& (session->getReason() == LinphoneReasonNotAcceptable) && (invitedAddresses.size() == 1)) {
cgcr->getPrivate()->onCallSessionStateChanged(session, newState, message);
cgcr->getPrivate()->setCallSessionListener(nullptr);

View file

@ -63,7 +63,7 @@ private:
// CallSessionListener
void onCallSessionStateChanged (
const std::shared_ptr<const CallSession> &session,
LinphoneCallState state,
CallSession::State state,
const std::string &message
) override;

View file

@ -94,7 +94,7 @@ void ServerGroupChatRoomPrivate::onChatRoomDeleteRequested (const shared_ptr<Abs
void ServerGroupChatRoomPrivate::onCallSessionStateChanged (
const shared_ptr<const CallSession> &,
LinphoneCallState,
CallSession::State,
const string &
) {}

View file

@ -20,6 +20,8 @@
#ifndef _CALL_SESSION_LISTENER_H_
#define _CALL_SESSION_LISTENER_H_
#include "conference/session/call-session.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
@ -41,8 +43,8 @@ public:
virtual void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) {}
virtual void onCallSessionSetTerminated (const std::shared_ptr<const CallSession> &session) {}
virtual void onCallSessionStartReferred (const std::shared_ptr<const CallSession> &session) {}
virtual void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state, const std::string &message) {}
virtual void onCallSessionTransferStateChanged (const std::shared_ptr<const CallSession> &session, LinphoneCallState state) {}
virtual void onCallSessionStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state, const std::string &message) {}
virtual void onCallSessionTransferStateChanged (const std::shared_ptr<const CallSession> &session, CallSession::State state) {}
virtual void onCheckForAcceptation (const std::shared_ptr<const CallSession> &session) {}
virtual void onDtmfReceived (const std::shared_ptr<const CallSession> &session, char dtmf) {}
virtual void onIncomingCallSessionNotified (const std::shared_ptr<const CallSession> &session) {}

View file

@ -36,8 +36,8 @@ public:
int computeDuration () const;
virtual void initializeParamsAccordingToIncomingCallParams ();
void notifyReferState ();
virtual void setState (LinphoneCallState newState, const std::string &message);
void setTransferState (LinphoneCallState newState);
virtual void setState (CallSession::State newState, const std::string &message);
void setTransferState (CallSession::State newState);
void startIncomingNotification ();
bool startPing ();
void setPingTime (int value) { pingTime = value; }
@ -73,15 +73,15 @@ protected:
void init ();
void accept (const CallSessionParams *params);
virtual LinphoneStatus acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const std::string &stateInfo);
virtual LinphoneStatus acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const std::string &stateInfo);
LinphoneStatus checkForAcceptation () const;
virtual void handleIncomingReceivedStateInIncomingNotification ();
virtual bool isReadyForInvite () const;
bool isUpdateAllowed (LinphoneCallState &nextState) const;
bool isUpdateAllowed (CallSession::State &nextState) const;
virtual int restartInvite ();
virtual void setReleased ();
virtual void setTerminated ();
virtual LinphoneStatus startAcceptUpdate (LinphoneCallState nextState, const std::string &stateInfo);
virtual LinphoneStatus startAcceptUpdate (CallSession::State nextState, const std::string &stateInfo);
virtual LinphoneStatus startUpdate (const std::string &subject);
virtual void terminate ();
virtual void updateCurrentParams () const;
@ -115,9 +115,9 @@ protected:
std::string subject;
LinphoneCallDir direction = LinphoneCallOutgoing;
LinphoneCallState state = LinphoneCallIdle;
LinphoneCallState prevState = LinphoneCallIdle;
LinphoneCallState transferState = LinphoneCallIdle;
CallSession::State state = CallSession::State::Idle;
CallSession::State prevState = CallSession::State::Idle;
CallSession::State transferState = CallSession::State::Idle;
LinphoneProxyConfig *destProxy = nullptr;
LinphoneErrorInfo *ei = nullptr;
LinphoneCallLog *log = nullptr;

View file

@ -60,40 +60,40 @@ void CallSessionPrivate::notifyReferState () {
refererOp->notify_refer_state(op);
}
void CallSessionPrivate::setState(LinphoneCallState newState, const string &message) {
void CallSessionPrivate::setState (CallSession::State newState, const string &message) {
L_Q();
if (state != newState){
prevState = state;
/* Make sanity checks with call state changes. Any bad transition can result in unpredictable results
or irrecoverable errors in the application. */
if ((state == LinphoneCallEnd) || (state == LinphoneCallError)) {
if (newState != LinphoneCallReleased) {
lFatal() << "Abnormal call resurection from " << linphone_call_state_to_string(state) <<
" to " << linphone_call_state_to_string(newState) << " , aborting";
if ((state == CallSession::State::End) || (state == CallSession::State::Error)) {
if (newState != CallSession::State::Released) {
lFatal() << "Abnormal call resurection from " << Utils::toString(state) <<
" to " << Utils::toString(newState) << " , aborting";
return;
}
} else if ((newState == LinphoneCallReleased) && (prevState != LinphoneCallError) && (prevState != LinphoneCallEnd)) {
} else if ((newState == CallSession::State::Released) && (prevState != CallSession::State::Error) && (prevState != CallSession::State::End)) {
lFatal() << "Attempt to move CallSession [" << q << "] to Released state while it was not previously in Error or End state, aborting";
return;
}
lInfo() << "CallSession [" << q << "] moving from state " << linphone_call_state_to_string(state) << " to " << linphone_call_state_to_string(newState);
lInfo() << "CallSession [" << q << "] moving from state " << Utils::toString(state) << " to " << Utils::toString(newState);
if (newState != LinphoneCallRefered) {
/* LinphoneCallRefered is rather an event, not a state.
if (newState != CallSession::State::Referred) {
/* CallSession::State::Referred is rather an event, not a state.
Indeed it does not change the state of the call (still paused or running). */
state = newState;
}
switch (newState) {
case LinphoneCallOutgoingInit:
case LinphoneCallIncomingReceived:
case CallSession::State::OutgoingInit:
case CallSession::State::IncomingReceived:
getPlatformHelpers(q->getCore()->getCCore())->acquireWifiLock();
getPlatformHelpers(q->getCore()->getCCore())->acquireMcastLock();
getPlatformHelpers(q->getCore()->getCCore())->acquireCpuLock();
break;
case LinphoneCallEnd:
case LinphoneCallError:
case CallSession::State::End:
case CallSession::State::Error:
switch (linphone_error_info_get_reason(q->getErrorInfo())) {
case LinphoneReasonDeclined:
log->status = LinphoneCallDeclined;
@ -125,11 +125,11 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
}
setTerminated();
break;
case LinphoneCallConnected:
case CallSession::State::Connected:
log->status = LinphoneCallSuccess;
log->connected_date_time = ms_time(nullptr);
break;
case LinphoneCallReleased:
case CallSession::State::Released:
getPlatformHelpers(q->getCore()->getCCore())->acquireWifiLock();
getPlatformHelpers(q->getCore()->getCCore())->acquireMcastLock();
getPlatformHelpers(q->getCore()->getCCore())->acquireCpuLock();
@ -140,21 +140,21 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
if (message.empty()) {
lError() << "You must fill a reason when changing call state (from " <<
linphone_call_state_to_string(prevState) << " to " << linphone_call_state_to_string(state) << ")";
Utils::toString(prevState) << " to " << Utils::toString(state) << ")";
}
if (listener)
listener->onCallSessionStateChanged(q->getSharedFromThis(), newState, message);
if (newState == LinphoneCallReleased)
if (newState == CallSession::State::Released)
setReleased(); /* Shall be performed after app notification */
}
}
void CallSessionPrivate::setTransferState (LinphoneCallState newState) {
void CallSessionPrivate::setTransferState (CallSession::State newState) {
L_Q();
if (newState == transferState)
return;
lInfo() << "Transfer state for CallSession [" << q << "] changed from ["
<< linphone_call_state_to_string(transferState) << "] to [" << linphone_call_state_to_string(newState) << "]";
<< Utils::toString(transferState) << "] to [" << Utils::toString(newState) << "]";
transferState = newState;
if (listener)
listener->onCallSessionTransferStateChanged(q->getSharedFromThis(), newState);
@ -165,14 +165,14 @@ void CallSessionPrivate::startIncomingNotification () {
if (listener)
listener->onIncomingCallSessionStarted(q->getSharedFromThis());
setState(LinphoneCallIncomingReceived, "Incoming CallSession");
setState(CallSession::State::IncomingReceived, "Incoming CallSession");
// From now on, the application is aware of the call and supposed to take background task or already submitted
// notification to the user. We can then drop our background task.
if (listener)
listener->onBackgroundTaskToBeStopped(q->getSharedFromThis());
if (state == LinphoneCallIncomingReceived) {
if (state == CallSession::State::IncomingReceived) {
handleIncomingReceivedStateInIncomingNotification();
}
}
@ -220,17 +220,17 @@ bool CallSessionPrivate::isInConference () const {
void CallSessionPrivate::abort (const string &errorMsg) {
op->terminate();
setState(LinphoneCallError, errorMsg);
setState(CallSession::State::Error, errorMsg);
}
void CallSessionPrivate::accepted () {
/* Immediately notify the connected state, even if errors occur after */
switch (state) {
case LinphoneCallOutgoingProgress:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
case CallSession::State::OutgoingProgress:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
/* Immediately notify the connected state */
setState(LinphoneCallConnected, "Connected");
setState(CallSession::State::Connected, "Connected");
break;
default:
break;
@ -262,8 +262,8 @@ bool CallSessionPrivate::failure () {
const SalErrorInfo *ei = op->get_error_info();
switch (ei->reason) {
case SalReasonRedirect:
if ((state == LinphoneCallOutgoingInit) || (state == LinphoneCallOutgoingProgress)
|| (state == LinphoneCallOutgoingRinging) /* Push notification case */ || (state == LinphoneCallOutgoingEarlyMedia)) {
if ((state == CallSession::State::OutgoingInit) || (state == CallSession::State::OutgoingProgress)
|| (state == CallSession::State::OutgoingRinging) /* Push notification case */ || (state == CallSession::State::OutgoingEarlyMedia)) {
const SalAddress *redirectionTo = op->get_remote_contact_address();
if (redirectionTo) {
char *url = sal_address_as_string(redirectionTo);
@ -283,11 +283,11 @@ bool CallSessionPrivate::failure () {
/* Some call errors are not fatal */
switch (state) {
case LinphoneCallUpdating:
case LinphoneCallPausing:
case LinphoneCallResuming:
case CallSession::State::Updating:
case CallSession::State::Pausing:
case CallSession::State::Resuming:
if (ei->reason != SalReasonNoMatch) {
lInfo() << "Call error on state [" << linphone_call_state_to_string(state) << "], restoring previous state [" << linphone_call_state_to_string(prevState) << "]";
lInfo() << "Call error on state [" << Utils::toString(state) << "], restoring previous state [" << Utils::toString(prevState) << "]";
setState(prevState, ei->full_string);
return true;
}
@ -295,14 +295,14 @@ bool CallSessionPrivate::failure () {
break;
}
if ((state != LinphoneCallEnd) && (state != LinphoneCallError)) {
if ((state != CallSession::State::End) && (state != CallSession::State::Error)) {
if (ei->reason == SalReasonDeclined)
setState(LinphoneCallEnd, "Call declined");
setState(CallSession::State::End, "Call declined");
else {
if (linphone_call_state_is_early(state))
setState(LinphoneCallError, ei->full_string ? ei->full_string : "");
if (CallSession::isEarlyState(state))
setState(CallSession::State::Error, ei->full_string ? ei->full_string : "");
else
setState(LinphoneCallEnd, ei->full_string ? ei->full_string : "");
setState(CallSession::State::End, ei->full_string ? ei->full_string : "");
}
if ((ei->reason != SalReasonNone) && listener)
listener->onPlayErrorTone(q->getSharedFromThis(), linphone_reason_from_sal(ei->reason));
@ -330,7 +330,7 @@ void CallSessionPrivate::infoReceived (SalBodyHandler *bodyHandler) {
void CallSessionPrivate::pingReply () {
L_Q();
if (state == LinphoneCallOutgoingInit) {
if (state == CallSession::State::OutgoingInit) {
pingReplied = true;
if (isReadyForInvite())
q->startInvite(nullptr, "");
@ -341,7 +341,7 @@ void CallSessionPrivate::referred (const Address &referToAddr) {
L_Q();
referTo = referToAddr.asString();
referPending = true;
setState(LinphoneCallRefered, "Referred");
setState(CallSession::State::Referred, "Referred");
if (referPending && listener)
listener->onCallSessionStartReferred(q->getSharedFromThis());
}
@ -353,32 +353,32 @@ void CallSessionPrivate::remoteRinging () {
if (listener)
listener->onStartRinging(q->getSharedFromThis());
lInfo() << "Remote ringing...";
setState(LinphoneCallOutgoingRinging, "Remote ringing");
setState(CallSession::State::OutgoingRinging, "Remote ringing");
}
void CallSessionPrivate::replaceOp (SalCallOp *newOp) {
L_Q();
SalCallOp *oldOp = op;
LinphoneCallState oldState = state;
CallSession::State oldState = state;
op = newOp;
op->set_user_pointer(q);
op->set_local_media_description(oldOp->get_local_media_description());
switch (state) {
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallIncomingReceived:
op->notify_ringing((state == LinphoneCallIncomingEarlyMedia) ? true : false);
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::IncomingReceived:
op->notify_ringing((state == CallSession::State::IncomingEarlyMedia) ? true : false);
break;
case LinphoneCallConnected:
case LinphoneCallStreamsRunning:
case CallSession::State::Connected:
case CallSession::State::StreamsRunning:
op->accept();
break;
default:
lWarning() << "CallSessionPrivate::replaceOp(): don't know what to do in state [" << linphone_call_state_to_string(state) << "]";
lWarning() << "CallSessionPrivate::replaceOp(): don't know what to do in state [" << Utils::toString(state) << "]";
break;
}
switch (oldState) {
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallIncomingReceived:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::IncomingReceived:
op->set_user_pointer(nullptr); // In order for the call session to not get terminated by terminating this op
// Do not terminate a forked INVITE
if (op->get_replaces())
@ -386,8 +386,8 @@ void CallSessionPrivate::replaceOp (SalCallOp *newOp) {
else
oldOp->kill_dialog();
break;
case LinphoneCallConnected:
case LinphoneCallStreamsRunning:
case CallSession::State::Connected:
case CallSession::State::StreamsRunning:
oldOp->terminate();
oldOp->kill_dialog();
break;
@ -400,12 +400,12 @@ void CallSessionPrivate::replaceOp (SalCallOp *newOp) {
void CallSessionPrivate::terminated () {
L_Q();
switch (state) {
case LinphoneCallEnd:
case LinphoneCallError:
case CallSession::State::End:
case CallSession::State::Error:
lWarning() << "terminated: already terminated, ignoring";
return;
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
if (!op->get_reason_error_info()->protocol || strcmp(op->get_reason_error_info()->protocol, "") == 0) {
linphone_error_info_set(ei, nullptr, LinphoneReasonNotAnswered, 0, "Incoming call cancelled", nullptr);
nonOpError = true;
@ -418,7 +418,7 @@ void CallSessionPrivate::terminated () {
listener->onCallSessionStartReferred(q->getSharedFromThis());
if (listener)
listener->onStopRingingIfInCall(q->getSharedFromThis());
setState(LinphoneCallEnd, "Call ended");
setState(CallSession::State::End, "Call ended");
}
void CallSessionPrivate::updated (bool isUpdate) {
@ -427,56 +427,56 @@ void CallSessionPrivate::updated (bool isUpdate) {
SalErrorInfo sei;
memset(&sei, 0, sizeof(sei));
switch (state) {
case LinphoneCallPausedByRemote:
case CallSession::State::PausedByRemote:
updatedByRemote();
break;
/* SIP UPDATE CASE */
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::IncomingEarlyMedia:
if (isUpdate) {
setState(LinphoneCallEarlyUpdatedByRemote, "EarlyUpdatedByRemote");
acceptUpdate(nullptr, prevState, linphone_call_state_to_string(prevState));
setState(CallSession::State::EarlyUpdatedByRemote, "EarlyUpdatedByRemote");
acceptUpdate(nullptr, prevState, Utils::toString(prevState));
}
break;
case LinphoneCallStreamsRunning:
case LinphoneCallConnected:
case LinphoneCallUpdatedByRemote: /* Can happen on UAC connectivity loss */
case CallSession::State::StreamsRunning:
case CallSession::State::Connected:
case CallSession::State::UpdatedByRemote: /* Can happen on UAC connectivity loss */
updatedByRemote();
break;
case LinphoneCallPaused:
case CallSession::State::Paused:
/* We'll remain in pause state but accept the offer anyway according to default parameters */
acceptUpdate(nullptr, state, linphone_call_state_to_string(state));
acceptUpdate(nullptr, state, Utils::toString(state));
break;
case LinphoneCallUpdating:
case LinphoneCallPausing:
case LinphoneCallResuming:
case CallSession::State::Updating:
case CallSession::State::Pausing:
case CallSession::State::Resuming:
sal_error_info_set(&sei, SalReasonInternalError, "SIP", 0, nullptr, nullptr);
op->decline_with_error_info(&sei, nullptr);
BCTBX_NO_BREAK; /* no break */
case LinphoneCallIdle:
case LinphoneCallOutgoingInit:
case LinphoneCallEnd:
case LinphoneCallIncomingReceived:
case LinphoneCallOutgoingProgress:
case LinphoneCallRefered:
case LinphoneCallError:
case LinphoneCallReleased:
case LinphoneCallEarlyUpdatedByRemote:
case LinphoneCallEarlyUpdating:
lWarning() << "Receiving reINVITE or UPDATE while in state [" << linphone_call_state_to_string(state) << "], should not happen";
case CallSession::State::Idle:
case CallSession::State::OutgoingInit:
case CallSession::State::End:
case CallSession::State::IncomingReceived:
case CallSession::State::OutgoingProgress:
case CallSession::State::Referred:
case CallSession::State::Error:
case CallSession::State::Released:
case CallSession::State::EarlyUpdatedByRemote:
case CallSession::State::EarlyUpdating:
lWarning() << "Receiving reINVITE or UPDATE while in state [" << Utils::toString(state) << "], should not happen";
break;
}
}
void CallSessionPrivate::updatedByRemote () {
L_Q();
setState(LinphoneCallUpdatedByRemote,"Call updated by remote");
setState(CallSession::State::UpdatedByRemote,"Call updated by remote");
if (deferUpdate) {
if (state == LinphoneCallUpdatedByRemote)
if (state == CallSession::State::UpdatedByRemote)
lInfo() << "CallSession [" << q << "]: UpdatedByRemoted was signaled but defered. LinphoneCore expects the application to call linphone_core_accept_call_update() later.";
} else {
if (state == LinphoneCallUpdatedByRemote)
if (state == CallSession::State::UpdatedByRemote)
q->acceptUpdate(nullptr);
else {
/* Otherwise it means that the app responded by linphone_core_accept_call_update
@ -510,21 +510,21 @@ void CallSessionPrivate::accept (const CallSessionParams *csp) {
op->accept();
if (listener)
listener->onSetCurrentSession(q->getSharedFromThis());
setState(LinphoneCallConnected, "Connected");
setState(CallSession::State::Connected, "Connected");
}
LinphoneStatus CallSessionPrivate::acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const string &stateInfo) {
LinphoneStatus CallSessionPrivate::acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const string &stateInfo) {
return startAcceptUpdate(nextState, stateInfo);
}
LinphoneStatus CallSessionPrivate::checkForAcceptation () const {
L_Q();
switch (state) {
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
break;
default:
lError() << "checkForAcceptation() CallSession [" << q << "] is in state [" << linphone_call_state_to_string(state) << "], operation not permitted";
lError() << "checkForAcceptation() CallSession [" << q << "] is in state [" << Utils::toString(state) << "], operation not permitted";
return -1;
}
if (listener)
@ -561,31 +561,31 @@ bool CallSessionPrivate::isReadyForInvite () const {
return pingReady;
}
bool CallSessionPrivate::isUpdateAllowed (LinphoneCallState &nextState) const {
bool CallSessionPrivate::isUpdateAllowed (CallSession::State &nextState) const {
switch (state) {
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
nextState = LinphoneCallEarlyUpdating;
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
nextState = CallSession::State::EarlyUpdating;
break;
case LinphoneCallConnected:
case LinphoneCallStreamsRunning:
case LinphoneCallPausedByRemote:
case LinphoneCallUpdatedByRemote:
nextState = LinphoneCallUpdating;
case CallSession::State::Connected:
case CallSession::State::StreamsRunning:
case CallSession::State::PausedByRemote:
case CallSession::State::UpdatedByRemote:
nextState = CallSession::State::Updating;
break;
case LinphoneCallPaused:
nextState = LinphoneCallPausing;
case CallSession::State::Paused:
nextState = CallSession::State::Pausing;
break;
case LinphoneCallOutgoingProgress:
case LinphoneCallPausing:
case LinphoneCallResuming:
case LinphoneCallUpdating:
case CallSession::State::OutgoingProgress:
case CallSession::State::Pausing:
case CallSession::State::Resuming:
case CallSession::State::Updating:
nextState = state;
break;
default:
lError() << "Update is not allowed in [" << linphone_call_state_to_string(state) << "] state";
lError() << "Update is not allowed in [" << Utils::toString(state) << "] state";
return false;
}
return true;
@ -629,7 +629,7 @@ void CallSessionPrivate::setTerminated() {
listener->onCallSessionSetTerminated(q->getSharedFromThis());
}
LinphoneStatus CallSessionPrivate::startAcceptUpdate (LinphoneCallState nextState, const std::string &stateInfo) {
LinphoneStatus CallSessionPrivate::startAcceptUpdate (CallSession::State nextState, const std::string &stateInfo) {
op->accept();
setState(nextState, stateInfo);
return 0;
@ -657,11 +657,11 @@ LinphoneStatus CallSessionPrivate::startUpdate (const string &subject) {
}
void CallSessionPrivate::terminate () {
if ((state == LinphoneCallIncomingReceived) && (linphone_error_info_get_reason(ei) != LinphoneReasonNotAnswered)) {
if ((state == CallSession::State::IncomingReceived) && (linphone_error_info_get_reason(ei) != LinphoneReasonNotAnswered)) {
linphone_error_info_set_reason(ei, LinphoneReasonDeclined);
nonOpError = true;
}
setState(LinphoneCallEnd, "Call terminated");
setState(CallSession::State::End, "Call terminated");
}
void CallSessionPrivate::updateCurrentParams () const {}
@ -690,21 +690,21 @@ void CallSessionPrivate::onNetworkReachable (bool reachable) {
} else {
switch(state) {
// For all the early states, we prefer to drop the call
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
// During the early states, the SAL layer reports the failure from the dialog or transaction layer,
// hence, there is nothing special to do
case LinphoneCallStreamsRunning:
case LinphoneCallUpdating:
case LinphoneCallPausing:
case LinphoneCallResuming:
case LinphoneCallPaused:
case LinphoneCallPausedByRemote:
case LinphoneCallUpdatedByRemote:
case CallSession::State::StreamsRunning:
case CallSession::State::Updating:
case CallSession::State::Pausing:
case CallSession::State::Resuming:
case CallSession::State::Paused:
case CallSession::State::PausedByRemote:
case CallSession::State::UpdatedByRemote:
// During these states, the dialog is established. A failure of a transaction is not expected to close it.
// Instead we have to repair the dialog by sending a reINVITE
broken = true;
@ -821,43 +821,42 @@ void CallSessionPrivate::repairIfBroken () {
SalErrorInfo sei;
memset(&sei, 0, sizeof(sei));
switch (state) {
case LinphoneCallUpdating:
case LinphoneCallPausing:
case CallSession::State::Updating:
case CallSession::State::Pausing:
if (op->dialog_request_pending()) {
// Need to cancel first re-INVITE as described in section 5.5 of RFC 6141
op->cancel_invite();
reinviteOnCancelResponseRequested = true;
}
break;
case LinphoneCallStreamsRunning:
case LinphoneCallPaused:
case LinphoneCallPausedByRemote:
case CallSession::State::StreamsRunning:
case CallSession::State::Paused:
case CallSession::State::PausedByRemote:
if (!op->dialog_request_pending())
reinviteToRecoverFromConnectionLoss();
break;
case LinphoneCallUpdatedByRemote:
case CallSession::State::UpdatedByRemote:
if (op->dialog_request_pending()) {
sal_error_info_set(&sei, SalReasonServiceUnavailable, "SIP", 0, nullptr, nullptr);
op->decline_with_error_info(&sei, nullptr);
}
reinviteToRecoverFromConnectionLoss();
break;
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
op->cancel_invite();
reinviteOnCancelResponseRequested = true;
break;
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallOutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::OutgoingRinging:
repairByInviteWithReplaces();
break;
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallIncomingReceived:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::IncomingReceived:
// Keep the call broken until a forked INVITE is received from the server
break;
default:
lWarning() << "CallSessionPrivate::repairIfBroken: don't know what to do in state ["
<< linphone_call_state_to_string(state);
lWarning() << "CallSessionPrivate::repairIfBroken: don't know what to do in state [" << Utils::toString(state);
broken = false;
break;
}
@ -912,11 +911,11 @@ LinphoneStatus CallSession::accept (const CallSessionParams *csp) {
LinphoneStatus CallSession::acceptUpdate (const CallSessionParams *csp) {
L_D();
if (d->state != LinphoneCallUpdatedByRemote) {
lError() << "CallSession::acceptUpdate(): invalid state " << linphone_call_state_to_string(d->state) << " to call this method";
if (d->state != CallSession::State::UpdatedByRemote) {
lError() << "CallSession::acceptUpdate(): invalid state " << Utils::toString(d->state) << " to call this method";
return -1;
}
return d->acceptUpdate(csp, d->prevState, linphone_call_state_to_string(d->prevState));
return d->acceptUpdate(csp, d->prevState, Utils::toString(d->prevState));
}
void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg, SalCallOp *op, const Address &from, const Address &to) {
@ -965,8 +964,8 @@ LinphoneStatus CallSession::decline (const LinphoneErrorInfo *ei) {
memset(&sei, 0, sizeof(sei));
memset(&sub_sei, 0, sizeof(sub_sei));
sei.sub_sei = &sub_sei;
if ((d->state != LinphoneCallIncomingReceived) && (d->state != LinphoneCallIncomingEarlyMedia)) {
lError() << "Cannot decline a CallSession that is in state " << linphone_call_state_to_string(d->state);
if ((d->state != CallSession::State::IncomingReceived) && (d->state != CallSession::State::IncomingEarlyMedia)) {
lError() << "Cannot decline a CallSession that is in state " << Utils::toString(d->state);
return -1;
}
if (ei) {
@ -990,8 +989,8 @@ LinphoneStatus CallSession::declineNotAnswered (LinphoneReason reason) {
LinphoneStatus CallSession::deferUpdate () {
L_D();
if (d->state != LinphoneCallUpdatedByRemote) {
lError() << "CallSession::deferUpdate() not done in state LinphoneCallUpdatedByRemote";
if (d->state != CallSession::State::UpdatedByRemote) {
lError() << "CallSession::deferUpdate() not done in state CallSession::State::UpdatedByRemote";
return -1;
}
d->deferUpdate = true;
@ -1008,7 +1007,7 @@ void CallSession::initiateIncoming () {}
bool CallSession::initiateOutgoing () {
L_D();
bool defer = false;
d->setState(LinphoneCallOutgoingInit, "Starting outgoing call");
d->setState(CallSession::State::OutgoingInit, "Starting outgoing call");
d->log->start_date_time = ms_time(nullptr);
if (!d->destProxy)
defer = d->startPing();
@ -1021,11 +1020,11 @@ bool CallSession::initiateOutgoing () {
void CallSession::iterate (time_t currentRealTime, bool oneSecondElapsed) {
L_D();
int elapsed = (int)(currentRealTime - d->log->start_date_time);
if ((d->state == LinphoneCallOutgoingInit) && (elapsed >= getCore()->getCCore()->sip_conf.delayed_timeout)) {
if ((d->state == CallSession::State::OutgoingInit) && (elapsed >= getCore()->getCCore()->sip_conf.delayed_timeout)) {
/* Start the call even if the OPTIONS reply did not arrive */
startInvite(nullptr, "");
}
if ((d->state == LinphoneCallIncomingReceived) || (d->state == LinphoneCallIncomingEarlyMedia)) {
if ((d->state == CallSession::State::IncomingReceived) || (d->state == CallSession::State::IncomingEarlyMedia)) {
if (d->listener)
d->listener->onIncomingCallSessionTimeoutCheck(getSharedFromThis(), elapsed, oneSecondElapsed);
}
@ -1052,7 +1051,7 @@ LinphoneStatus CallSession::redirect (const string &redirectUri) {
LinphoneStatus CallSession::redirect (const Address &redirectAddr) {
L_D();
if (d->state != LinphoneCallIncomingReceived) {
if (d->state != CallSession::State::IncomingReceived) {
lError() << "Bad state for CallSession redirection";
return -1;
}
@ -1105,33 +1104,33 @@ int CallSession::startInvite (const Address *destination, const string &subject,
int result = d->op->call(from, destinationStr.c_str(), subject.empty() ? nullptr : subject.c_str());
ms_free(from);
if (result < 0) {
if ((d->state != LinphoneCallError) && (d->state != LinphoneCallReleased)) {
if ((d->state != CallSession::State::Error) && (d->state != CallSession::State::Released)) {
/* sal_call() may invoke call_failure() and call_released() SAL callbacks synchronously,
in which case there is no need to perform a state change here. */
d->setState(LinphoneCallError, "Call failed");
d->setState(CallSession::State::Error, "Call failed");
}
} else {
d->log->call_id = ms_strdup(d->op->get_call_id()); /* Must be known at that time */
d->setState(LinphoneCallOutgoingProgress, "Outgoing call in progress");
d->setState(CallSession::State::OutgoingProgress, "Outgoing call in progress");
}
return result;
}
LinphoneStatus CallSession::terminate (const LinphoneErrorInfo *ei) {
L_D();
lInfo() << "Terminate CallSession [" << this << "] which is currently in state [" << linphone_call_state_to_string(d->state) << "]";
lInfo() << "Terminate CallSession [" << this << "] which is currently in state [" << Utils::toString(d->state) << "]";
SalErrorInfo sei;
memset(&sei, 0, sizeof(sei));
switch (d->state) {
case LinphoneCallReleased:
case LinphoneCallEnd:
case LinphoneCallError:
lWarning() << "No need to terminate CallSession [" << this << "] in state [" << linphone_call_state_to_string(d->state) << "]";
case CallSession::State::Released:
case CallSession::State::End:
case CallSession::State::Error:
lWarning() << "No need to terminate CallSession [" << this << "] in state [" << Utils::toString(d->state) << "]";
return -1;
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
return decline(ei);
case LinphoneCallOutgoingInit:
case CallSession::State::OutgoingInit:
/* In state OutgoingInit, op has to be destroyed */
d->op->release();
d->op = nullptr;
@ -1153,7 +1152,7 @@ LinphoneStatus CallSession::terminate (const LinphoneErrorInfo *ei) {
LinphoneStatus CallSession::transfer (const shared_ptr<CallSession> &dest) {
L_D();
int result = d->op->refer_with_replaces(dest->getPrivate()->op);
d->setTransferState(LinphoneCallOutgoingInit);
d->setTransferState(CallSession::State::OutgoingInit);
return result;
}
@ -1166,14 +1165,14 @@ LinphoneStatus CallSession::transfer (const string &dest) {
d->op->refer(addrStr);
bctbx_free(addrStr);
linphone_address_unref(destAddr);
d->setTransferState(LinphoneCallOutgoingInit);
d->setTransferState(CallSession::State::OutgoingInit);
return 0;
}
LinphoneStatus CallSession::update (const CallSessionParams *csp, const string &subject, const Content *content) {
L_D();
LinphoneCallState nextState;
LinphoneCallState initialState = d->state;
CallSession::State nextState;
CallSession::State initialState = d->state;
if (!d->isUpdateAllowed(nextState))
return -1;
if (d->currentParams == csp)
@ -1211,9 +1210,9 @@ const Address& CallSession::getDiversionAddress () const {
int CallSession::getDuration () const {
L_D();
switch (d->state) {
case LinphoneCallEnd:
case LinphoneCallError:
case LinphoneCallReleased:
case CallSession::State::End:
case CallSession::State::Error:
case CallSession::State::Released:
return d->log->duration;
default:
return d->computeDuration();
@ -1291,7 +1290,7 @@ const CallSessionParams * CallSession::getRemoteParams () {
return nullptr;
}
LinphoneCallState CallSession::getState () const {
CallSession::State CallSession::getState () const {
L_D();
return d->state;
}
@ -1302,7 +1301,7 @@ const Address& CallSession::getToAddress () const {
return d->toAddress;
}
LinphoneCallState CallSession::getTransferState () const {
CallSession::State CallSession::getTransferState () const {
L_D();
return d->transferState;
}
@ -1347,4 +1346,23 @@ const CallSessionParams * CallSession::getParams () const {
return d->params;
}
// -----------------------------------------------------------------------------
bool CallSession::isEarlyState (CallSession::State state) {
switch (state) {
case CallSession::State::Idle:
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingProgress:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::EarlyUpdatedByRemote:
case CallSession::State::EarlyUpdating:
return true;
default:
return false;
}
}
LINPHONE_END_NAMESPACE

View file

@ -24,7 +24,6 @@
#include "address/address.h"
#include "conference/conference.h"
#include "conference/params/call-session-params.h"
#include "conference/session/call-session-listener.h"
#include "core/core-listener.h"
#include "sal/call-op.h"
@ -50,6 +49,8 @@ class LINPHONE_PUBLIC CallSession : public Object, public CoreAccessor {
public:
L_OVERRIDE_SHARED_FROM_THIS(CallSession);
L_DECLARE_ENUM(State, L_ENUM_VALUES_CALL_SESSION_STATE);
CallSession (const std::shared_ptr<Core> &core, const CallSessionParams *params, CallSessionListener *listener);
virtual ~CallSession ();
@ -90,12 +91,14 @@ public:
const CallSessionParams *getRemoteParams ();
std::string getRemoteUserAgent () const;
std::shared_ptr<CallSession> getReplacedCallSession () const;
LinphoneCallState getState () const;
CallSession::State getState () const;
const Address& getToAddress () const;
LinphoneCallState getTransferState () const;
CallSession::State getTransferState () const;
std::shared_ptr<CallSession> getTransferTarget () const;
std::string getToHeader (const std::string &name) const;
static bool isEarlyState (CallSession::State state);
protected:
explicit CallSession (CallSessionPrivate &p, const std::shared_ptr<Core> &core);

View file

@ -125,7 +125,7 @@ private:
static float aggregateQualityRatings (float audioRating, float videoRating);
std::shared_ptr<Participant> getMe () const;
void setState (LinphoneCallState newState, const std::string &message) override;
void setState (CallSession::State newState, const std::string &message) override;
void computeStreamsIndexes (const SalMediaDescription *md);
void fixCallParams (SalMediaDescription *rmd);
@ -204,16 +204,16 @@ private:
void postConfigureAudioStreams (bool muted);
void setSymmetricRtp (bool value);
void setupRingbackPlayer ();
void startAudioStream (LinphoneCallState targetState, bool videoWillBeUsed);
void startStreams (LinphoneCallState targetState);
void startAudioStream (CallSession::State targetState, bool videoWillBeUsed);
void startStreams (CallSession::State targetState);
void startTextStream ();
void startVideoStream (LinphoneCallState targetState);
void startVideoStream (CallSession::State targetState);
void stopAudioStream ();
void stopTextStream ();
void stopVideoStream ();
void tryEarlyMediaForking (SalMediaDescription *md);
void updateFrozenPayloads (SalMediaDescription *result);
void updateStreams (SalMediaDescription *newMd, LinphoneCallState targetState);
void updateStreams (SalMediaDescription *newMd, CallSession::State targetState);
void updateStreamsDestinations (SalMediaDescription *oldMd, SalMediaDescription *newMd);
bool allStreamsAvpfEnabled () const;
@ -246,13 +246,13 @@ private:
LinphoneStatus pause ();
int restartInvite () override;
void setTerminated () override;
LinphoneStatus startAcceptUpdate (LinphoneCallState nextState, const std::string &stateInfo) override;
LinphoneStatus startAcceptUpdate (CallSession::State nextState, const std::string &stateInfo) override;
LinphoneStatus startUpdate (const std::string &subject = "") override;
void terminate () override;
void updateCurrentParams () const override;
void accept (const MediaSessionParams *params, bool wasRinging);
LinphoneStatus acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const std::string &stateInfo) override;
LinphoneStatus acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const std::string &stateInfo) override;
void refreshSockets ();
void reinviteToRecoverFromConnectionLoss () override;

View file

@ -85,7 +85,7 @@ void MediaSessionPrivate::accepted () {
getParams()->getPrivate()->setInternalCallUpdate(false);
SalMediaDescription *rmd = op->get_remote_media_description();
SalMediaDescription *md = op->get_final_media_description();
if (!md && (prevState == LinphoneCallOutgoingEarlyMedia) && resultDesc) {
if (!md && (prevState == CallSession::State::OutgoingEarlyMedia) && resultDesc) {
lInfo() << "Using early media SDP since none was received with the 200 OK";
md = resultDesc;
}
@ -97,46 +97,46 @@ void MediaSessionPrivate::accepted () {
/* Handle remote ICE attributes if any. */
iceAgent->updateFromRemoteMediaDescription(localDesc, rmd, !op->is_offerer());
}
LinphoneCallState nextState = LinphoneCallIdle;
CallSession::State nextState = CallSession::State::Idle;
string nextStateMsg;
switch (state) {
case LinphoneCallResuming:
case LinphoneCallConnected:
case CallSession::State::Resuming:
case CallSession::State::Connected:
if (referer)
notifyReferState();
BCTBX_NO_BREAK; /* Intentional no break */
case LinphoneCallUpdating:
case LinphoneCallUpdatedByRemote:
case CallSession::State::Updating:
case CallSession::State::UpdatedByRemote:
if (!sal_media_description_has_dir(localDesc, SalStreamInactive)
&& (sal_media_description_has_dir(md, SalStreamRecvOnly) || sal_media_description_has_dir(md, SalStreamInactive))) {
nextState = LinphoneCallPausedByRemote;
nextState = CallSession::State::PausedByRemote;
nextStateMsg = "Call paused by remote";
} else {
if (!getParams()->getPrivate()->getInConference() && listener)
listener->onSetCurrentSession(q->getSharedFromThis());
nextState = LinphoneCallStreamsRunning;
nextState = CallSession::State::StreamsRunning;
nextStateMsg = "Streams running";
}
break;
case LinphoneCallEarlyUpdating:
case CallSession::State::EarlyUpdating:
nextState = prevState;
nextStateMsg = "Early update accepted";
break;
case LinphoneCallPausing:
case CallSession::State::Pausing:
/* When we entered the pausing state, we always reach the paused state whatever the content of the remote SDP is.
* Our streams are all send-only (with music), soundcard and camera are never used. */
nextState = LinphoneCallPaused;
nextState = CallSession::State::Paused;
nextStateMsg = "Call paused";
if (referPending)
linphone_task_list_add(&tl, &MediaSessionPrivate::startPendingRefer, q);
break;
default:
lError() << "accepted(): don't know what to do in state [" << linphone_call_state_to_string(state) << "]";
lError() << "accepted(): don't know what to do in state [" << Utils::toString(state) << "]";
break;
}
if (nextState == LinphoneCallIdle)
lError() << "BUG: nextState is not set in accepted(), current state is " << linphone_call_state_to_string(state);
if (nextState == CallSession::State::Idle)
lError() << "BUG: nextState is not set in accepted(), current state is " << Utils::toString(state);
else {
updateRemoteSessionIdAndVer();
iceAgent->updateIceStateInCallStats();
@ -147,12 +147,12 @@ void MediaSessionPrivate::accepted () {
} else { /* Invalid or no SDP */
switch (prevState) {
/* Send a bye only in case of early states */
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallIncomingReceived:
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::IncomingReceived:
case CallSession::State::IncomingEarlyMedia:
lError() << "Incompatible SDP answer received, need to abort the call";
abort("Incompatible, check codecs or security settings...");
break;
@ -160,12 +160,12 @@ void MediaSessionPrivate::accepted () {
default:
lError() << "Incompatible SDP answer received";
switch(state) {
case LinphoneCallPausedByRemote:
case LinphoneCallPaused:
case LinphoneCallStreamsRunning:
case CallSession::State::PausedByRemote:
case CallSession::State::Paused:
case CallSession::State::StreamsRunning:
break;
default:
lInfo() << "Incompatible SDP answer received, restoring previous state [" << linphone_call_state_to_string(prevState) << "]";
lInfo() << "Incompatible SDP answer received, restoring previous state [" << Utils::toString(prevState) << "]";
setState(prevState, "Incompatible media parameters.");
break;
}
@ -180,9 +180,9 @@ void MediaSessionPrivate::ackReceived (LinphoneHeaders *headers) {
CallSessionPrivate::ackReceived(headers);
if (expectMediaInAck) {
switch (state) {
case LinphoneCallStreamsRunning:
case LinphoneCallPausedByRemote:
setState(LinphoneCallUpdatedByRemote, "UpdatedByRemote");
case CallSession::State::StreamsRunning:
case CallSession::State::PausedByRemote:
setState(CallSession::State::UpdatedByRemote, "UpdatedByRemote");
break;
default:
break;
@ -207,8 +207,8 @@ bool MediaSessionPrivate::failure () {
case SalReasonUnsupportedContent: /* This is for compatibility: linphone sent 415 because of SDP offer answer failure */
case SalReasonNotAcceptable:
lInfo() << "Outgoing CallSession [" << q << "] failed with SRTP and/or AVPF enabled";
if ((state == LinphoneCallOutgoingInit) || (state == LinphoneCallOutgoingProgress)
|| (state == LinphoneCallOutgoingRinging) /* Push notification case */ || (state == LinphoneCallOutgoingEarlyMedia)) {
if ((state == CallSession::State::OutgoingInit) || (state == CallSession::State::OutgoingProgress)
|| (state == CallSession::State::OutgoingRinging) /* Push notification case */ || (state == CallSession::State::OutgoingEarlyMedia)) {
for (int i = 0; i < localDesc->nb_streams; i++) {
if (!sal_stream_description_active(&localDesc->streams[i]))
continue;
@ -270,7 +270,7 @@ void MediaSessionPrivate::pausedByRemote () {
MediaSessionParams *newParams = new MediaSessionParams(*getParams());
if (lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "inactive_video_on_pause", 0))
newParams->setVideoDirection(LinphoneMediaDirectionInactive);
acceptUpdate(newParams, LinphoneCallPausedByRemote, "Call paused by remote");
acceptUpdate(newParams, CallSession::State::PausedByRemote, "Call paused by remote");
}
void MediaSessionPrivate::remoteRinging () {
@ -296,7 +296,7 @@ void MediaSessionPrivate::remoteRinging () {
return;
}
setState(LinphoneCallOutgoingEarlyMedia, "Early media");
setState(CallSession::State::OutgoingEarlyMedia, "Early media");
if (listener)
listener->onStopRinging(q->getSharedFromThis());
lInfo() << "Doing early media...";
@ -307,22 +307,22 @@ void MediaSessionPrivate::remoteRinging () {
}
} else {
linphone_core_stop_dtmf_stream(q->getCore()->getCCore());
if (state == LinphoneCallOutgoingEarlyMedia) {
if (state == CallSession::State::OutgoingEarlyMedia) {
/* Already doing early media */
return;
}
if (listener)
listener->onStartRinging(q->getSharedFromThis());
lInfo() << "Remote ringing...";
setState(LinphoneCallOutgoingRinging, "Remote ringing");
setState(CallSession::State::OutgoingRinging, "Remote ringing");
}
}
int MediaSessionPrivate::resumeAfterFailedTransfer () {
L_Q();
if (automaticallyPaused && (state == LinphoneCallPausing))
if (automaticallyPaused && (state == CallSession::State::Pausing))
return BELLE_SIP_CONTINUE; // Was still in pausing state
if (automaticallyPaused && (state == LinphoneCallPaused)) {
if (automaticallyPaused && (state == CallSession::State::Paused)) {
if (op->is_idle())
q->resume();
else {
@ -334,7 +334,7 @@ int MediaSessionPrivate::resumeAfterFailedTransfer () {
}
void MediaSessionPrivate::resumed () {
acceptUpdate(nullptr, LinphoneCallStreamsRunning, "Connected (streams running)");
acceptUpdate(nullptr, CallSession::State::StreamsRunning, "Connected (streams running)");
}
void MediaSessionPrivate::startPendingRefer () {
@ -361,15 +361,15 @@ void MediaSessionPrivate::terminated () {
void MediaSessionPrivate::updated (bool isUpdate) {
SalMediaDescription *rmd = op->get_remote_media_description();
switch (state) {
case LinphoneCallPausedByRemote:
case CallSession::State::PausedByRemote:
if (sal_media_description_has_dir(rmd, SalStreamSendRecv) || sal_media_description_has_dir(rmd, SalStreamRecvOnly)) {
resumed();
return;
}
break;
case LinphoneCallStreamsRunning:
case LinphoneCallConnected:
case LinphoneCallUpdatedByRemote: /* Can happen on UAC connectivity loss */
case CallSession::State::StreamsRunning:
case CallSession::State::Connected:
case CallSession::State::UpdatedByRemote: /* Can happen on UAC connectivity loss */
if (sal_media_description_has_dir(rmd, SalStreamSendOnly) || sal_media_description_has_dir(rmd, SalStreamInactive)) {
pausedByRemote();
return;
@ -386,7 +386,7 @@ void MediaSessionPrivate::updating (bool isUpdate) {
L_Q();
SalMediaDescription *rmd = op->get_remote_media_description();
fixCallParams(rmd);
if (state != LinphoneCallPaused) {
if (state != CallSession::State::Paused) {
/* Refresh the local description, but in paused state, we don't change anything. */
if (!rmd && lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "sdp_200_ack_follow_video_policy", 0)) {
lInfo() << "Applying default policy for offering SDP on CallSession [" << q << "]";
@ -568,7 +568,7 @@ int MediaSessionPrivate::getStreamIndex (MediaStream *ms) const {
MSWebCam * MediaSessionPrivate::getVideoDevice () const {
L_Q();
bool paused = (state == LinphoneCallPausing) || (state == LinphoneCallPaused);
bool paused = (state == CallSession::State::Pausing) || (state == CallSession::State::Paused);
if (paused || allMuted || !cameraEnabled)
#ifdef VIDEO_ENABLED
return ms_web_cam_manager_get_cam(ms_factory_get_web_cam_manager(q->getCore()->getCCore()->factory),
@ -698,11 +698,11 @@ shared_ptr<Participant> MediaSessionPrivate::getMe () const {
return participant;
}
void MediaSessionPrivate::setState (LinphoneCallState newState, const string &message) {
void MediaSessionPrivate::setState (CallSession::State newState, const string &message) {
L_Q();
/* Take a ref on the session otherwise it might get destroyed during the call to setState */
shared_ptr<CallSession> sessionRef = q->getSharedFromThis();
if ((newState != state) && (newState != LinphoneCallStreamsRunning))
if ((newState != state) && (newState != CallSession::State::StreamsRunning))
q->cancelDtmfs();
CallSessionPrivate::setState(newState, message);
updateReportingCallState();
@ -1242,8 +1242,8 @@ void MediaSessionPrivate::forceStreamsDirAccordingToState (SalMediaDescription *
for (int i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
SalStreamDescription *sd = &md->streams[i];
switch (state) {
case LinphoneCallPausing:
case LinphoneCallPaused:
case CallSession::State::Pausing:
case CallSession::State::Paused:
if (sd->dir != SalStreamInactive) {
sd->dir = SalStreamSendOnly;
if ((sd->type == SalVideo) && lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "inactive_video_on_pause", 0))
@ -2194,18 +2194,18 @@ void MediaSessionPrivate::handleIceEvents (OrtpEvent *ev) {
lWarning() << "No STUN answer from [" << linphone_core_get_stun_server(q->getCore()->getCCore()) << "], continuing without STUN";
iceAgent->gatheringFinished();
switch (state) {
case LinphoneCallUpdating:
case CallSession::State::Updating:
startUpdate();
break;
case LinphoneCallUpdatedByRemote:
startAcceptUpdate(prevState, linphone_call_state_to_string(prevState));
case CallSession::State::UpdatedByRemote:
startAcceptUpdate(prevState, Utils::toString(prevState));
break;
case LinphoneCallOutgoingInit:
case CallSession::State::OutgoingInit:
stopStreamsForIceGathering();
if (isReadyForInvite())
q->startInvite(nullptr, "");
break;
case LinphoneCallIdle:
case CallSession::State::Idle:
stopStreamsForIceGathering();
updateLocalMediaDescriptionFromIce();
op->set_local_media_description(localDesc);
@ -2216,8 +2216,8 @@ void MediaSessionPrivate::handleIceEvents (OrtpEvent *ev) {
break;
}
} else if (evt == ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED) {
if (state == LinphoneCallUpdatedByRemote) {
startAcceptUpdate(prevState, linphone_call_state_to_string(prevState));
if (state == CallSession::State::UpdatedByRemote) {
startAcceptUpdate(prevState, Utils::toString(prevState));
iceAgent->updateIceStateInCallStats();
}
} else if (evt == ORTP_EVENT_ICE_RESTART_NEEDED) {
@ -2548,7 +2548,7 @@ void MediaSessionPrivate::setupRingbackPlayer () {
ms_filter_call_method(audioStream->soundread, MS_FILE_PLAYER_LOOP, &pauseTime);
}
void MediaSessionPrivate::startAudioStream (LinphoneCallState targetState, bool videoWillBeUsed) {
void MediaSessionPrivate::startAudioStream (CallSession::State targetState, bool videoWillBeUsed) {
L_Q();
const SalStreamDescription *stream = sal_media_description_find_best_stream(resultDesc, SalAudio);
if (stream && (stream->dir != SalStreamInactive) && (stream->rtp_port != 0)) {
@ -2576,7 +2576,7 @@ void MediaSessionPrivate::startAudioStream (LinphoneCallState targetState, bool
captcard = nullptr;
playfile = "";
}
if (targetState == LinphoneCallPaused) {
if (targetState == CallSession::State::Paused) {
// In paused state, we never use soundcard
playcard = captcard = nullptr;
recfile = "";
@ -2679,7 +2679,7 @@ void MediaSessionPrivate::startAudioStream (LinphoneCallState targetState, bool
postConfigureAudioStreams((allMuted || audioMuted) && (listener && !listener->isPlayingRingbackTone(q->getSharedFromThis())));
}
ms_media_stream_sessions_set_encryption_mandatory(&audioStream->ms.sessions, isEncryptionMandatory());
if ((targetState == LinphoneCallPaused) && !captcard && !playfile.empty()) {
if ((targetState == CallSession::State::Paused) && !captcard && !playfile.empty()) {
int pauseTime = 500;
ms_filter_call_method(audioStream->soundread, MS_FILE_PLAYER_LOOP, &pauseTime);
}
@ -2708,14 +2708,14 @@ void MediaSessionPrivate::startAudioStream (LinphoneCallState targetState, bool
}
}
void MediaSessionPrivate::startStreams (LinphoneCallState targetState) {
void MediaSessionPrivate::startStreams (CallSession::State targetState) {
L_Q();
switch (targetState) {
case LinphoneCallIncomingEarlyMedia:
case CallSession::State::IncomingEarlyMedia:
if (listener)
listener->onRingbackToneRequested(q->getSharedFromThis(), true);
BCTBX_NO_BREAK;
case LinphoneCallOutgoingEarlyMedia:
case CallSession::State::OutgoingEarlyMedia:
if (!getParams()->earlyMediaSendingEnabled())
allMuted = true;
break;
@ -2824,7 +2824,7 @@ void MediaSessionPrivate::startTextStream () {
lInfo() << "No valid text stream defined";
}
void MediaSessionPrivate::startVideoStream (LinphoneCallState targetState) {
void MediaSessionPrivate::startVideoStream (CallSession::State targetState) {
#ifdef VIDEO_ENABLED
L_Q();
bool reusedPreview = false;
@ -3085,9 +3085,9 @@ void MediaSessionPrivate::updateFrozenPayloads (SalMediaDescription *result) {
}
}
void MediaSessionPrivate::updateStreams (SalMediaDescription *newMd, LinphoneCallState targetState) {
void MediaSessionPrivate::updateStreams (SalMediaDescription *newMd, CallSession::State targetState) {
L_Q();
if (!((state == LinphoneCallIncomingEarlyMedia) && linphone_core_get_ring_during_incoming_early_media(q->getCore()->getCCore())))
if (!((state == CallSession::State::IncomingEarlyMedia) && linphone_core_get_ring_during_incoming_early_media(q->getCore()->getCCore())))
linphone_core_stop_ringing(q->getCore()->getCCore());
if (!newMd) {
lError() << "updateStreams() called with null media description";
@ -3114,7 +3114,7 @@ void MediaSessionPrivate::updateStreams (SalMediaDescription *newMd, LinphoneCal
else if (listener && listener->isPlayingRingbackTone(q->getSharedFromThis()))
lInfo() << "Playing ringback tone, will restart the streams";
else {
if (allMuted && (targetState == LinphoneCallStreamsRunning)) {
if (allMuted && (targetState == CallSession::State::StreamsRunning)) {
lInfo() << "Early media finished, unmuting inputs...";
/* We were in early media, now we want to enable real media */
allMuted = false;
@ -3161,10 +3161,10 @@ void MediaSessionPrivate::updateStreams (SalMediaDescription *newMd, LinphoneCal
initializeStreams();
}
if (getParams()->earlyMediaSendingEnabled() && (state == LinphoneCallOutgoingEarlyMedia))
if (getParams()->earlyMediaSendingEnabled() && (state == CallSession::State::OutgoingEarlyMedia))
prepareEarlyMediaForking();
startStreams(targetState);
if ((state == LinphoneCallPausing) && pausedByApp && (q->getCore()->getCallCount() == 1))
if ((state == CallSession::State::Pausing) && pausedByApp && (q->getCore()->getCallCount() == 1))
linphone_core_play_named_tone(q->getCore()->getCCore(), LinphoneToneCallOnHold);
updateFrozenPayloads(newMd);
@ -3388,10 +3388,10 @@ bool MediaSessionPrivate::qualityReportingEnabled () const {
}
void MediaSessionPrivate::updateReportingCallState () {
if ((state == LinphoneCallReleased) || !qualityReportingEnabled())
if ((state == CallSession::State::Released) || !qualityReportingEnabled())
return;
switch (state) {
case LinphoneCallStreamsRunning:
case CallSession::State::StreamsRunning:
#if 0
for (int i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++) {
int streamIndex = (i == mainAudioStreamIndex) ? LINPHONE_CALL_STATS_AUDIO : mainVideoStreamIndex ? LINPHONE_CALL_STATS_VIDEO : LINPHONE_CALL_STATS_TEXT;
@ -3408,7 +3408,7 @@ void MediaSessionPrivate::updateReportingCallState () {
#endif
log->reporting.was_video_running = mediaReportEnabled(LINPHONE_CALL_STATS_VIDEO);
break;
case LinphoneCallEnd:
case CallSession::State::End:
#if 0
set_on_action_suggested_cb(&audioStream->ms, nullptr, nullptr);
set_on_action_suggested_cb(&videoStream->ms, nullptr, nullptr);
@ -3423,7 +3423,7 @@ void MediaSessionPrivate::updateReportingCallState () {
void MediaSessionPrivate::updateReportingMediaInfo (int statsType) {
L_Q();
/* op might be already released if hanging up in state LinphoneCallOutgoingInit */
/* op might be already released if hanging up in state CallSession::State::OutgoingInit */
if (!op || !mediaReportEnabled(statsType))
return;
@ -3514,11 +3514,11 @@ void MediaSessionPrivate::updateReportingMediaInfo (int statsType) {
void MediaSessionPrivate::executeBackgroundTasks (bool oneSecondElapsed) {
L_Q();
switch (state) {
case LinphoneCallStreamsRunning:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallPausedByRemote:
case LinphoneCallPaused:
case CallSession::State::StreamsRunning:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::PausedByRemote:
case CallSession::State::Paused:
if (oneSecondElapsed) {
float audioLoad = 0.f;
float videoLoad = 0.f;
@ -3627,7 +3627,7 @@ bool MediaSessionPrivate::isReadyForInvite () const {
LinphoneStatus MediaSessionPrivate::pause () {
L_Q();
if ((state != LinphoneCallStreamsRunning) && (state != LinphoneCallPausedByRemote)) {
if ((state != CallSession::State::StreamsRunning) && (state != CallSession::State::PausedByRemote)) {
lWarning() << "Cannot pause this MediaSession, it is not active";
return -1;
}
@ -3641,7 +3641,7 @@ LinphoneStatus MediaSessionPrivate::pause () {
return -1;
}
broken = false;
setState(LinphoneCallPausing, "Pausing call");
setState(CallSession::State::Pausing, "Pausing call");
makeLocalMediaDescription();
op->set_local_media_description(localDesc);
op->update(subject.c_str(), false);
@ -3664,7 +3664,7 @@ void MediaSessionPrivate::setTerminated () {
CallSessionPrivate::setTerminated();
}
LinphoneStatus MediaSessionPrivate::startAcceptUpdate (LinphoneCallState nextState, const string &stateInfo) {
LinphoneStatus MediaSessionPrivate::startAcceptUpdate (CallSession::State nextState, const string &stateInfo) {
if (iceAgent->hasSession() && (iceAgent->getNbLosingPairs() > 0)) {
/* Defer the sending of the answer until there are no losing pairs left */
return 0;
@ -3830,13 +3830,13 @@ void MediaSessionPrivate::accept (const MediaSessionParams *msp, bool wasRinging
SalMediaDescription *newMd = op->get_final_media_description();
iceAgent->stopIceForInactiveStreams(newMd);
if (newMd) {
updateStreams(newMd, LinphoneCallStreamsRunning);
setState(LinphoneCallStreamsRunning, "Connected (streams running)");
updateStreams(newMd, CallSession::State::StreamsRunning);
setState(CallSession::State::StreamsRunning, "Connected (streams running)");
} else
expectMediaInAck = true;
}
LinphoneStatus MediaSessionPrivate::acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const string &stateInfo) {
LinphoneStatus MediaSessionPrivate::acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const string &stateInfo) {
L_Q();
SalMediaDescription *desc = op->get_remote_media_description();
bool keepSdpVersion = !!lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "keep_sdp_version", 0);
@ -4092,8 +4092,8 @@ LinphoneStatus MediaSession::accept (const MediaSessionParams *msp) {
LinphoneStatus MediaSession::acceptEarlyMedia (const MediaSessionParams *msp) {
L_D();
if (d->state != LinphoneCallIncomingReceived) {
lError() << "Bad state " << linphone_call_state_to_string(d->state) << " for MediaSession::acceptEarlyMedia()";
if (d->state != CallSession::State::IncomingReceived) {
lError() << "Bad state " << Utils::toString(d->state) << " for MediaSession::acceptEarlyMedia()";
return -1;
}
/* Try to be best-effort in giving real local or routable contact address for 100Rel case */
@ -4106,7 +4106,7 @@ LinphoneStatus MediaSession::acceptEarlyMedia (const MediaSessionParams *msp) {
d->op->set_sent_custom_header(d->getParams()->getPrivate()->getCustomHeaders());
}
d->op->notify_ringing(true);
d->setState(LinphoneCallIncomingEarlyMedia, "Incoming call early media");
d->setState(CallSession::State::IncomingEarlyMedia, "Incoming call early media");
SalMediaDescription *md = d->op->get_final_media_description();
if (md)
d->updateStreams(md, d->state);
@ -4180,8 +4180,8 @@ void MediaSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cf
LinphoneStatus MediaSession::deferUpdate () {
L_D();
if (d->state != LinphoneCallUpdatedByRemote) {
lError() << "MediaSession::deferUpdate() not done in state LinphoneCallUpdatedByRemote";
if (d->state != CallSession::State::UpdatedByRemote) {
lError() << "MediaSession::deferUpdate() not done in state CallSession::State::UpdatedByRemote";
return -1;
}
if (d->expectMediaInAck) {
@ -4221,7 +4221,7 @@ void MediaSession::iterate (time_t currentRealTime, bool oneSecondElapsed) {
L_D();
int elapsed = (int)(currentRealTime - d->log->start_date_time);
d->executeBackgroundTasks(oneSecondElapsed);
if ((d->state == LinphoneCallOutgoingInit) && (elapsed >= getCore()->getCCore()->sip_conf.delayed_timeout)) {
if ((d->state == CallSession::State::OutgoingInit) && (elapsed >= getCore()->getCCore()->sip_conf.delayed_timeout)) {
if (d->iceAgent->hasSession()) {
lWarning() << "ICE candidates gathering from [" << linphone_nat_policy_get_stun_server(d->natPolicy) << "] has not finished yet, proceed with the call without ICE anyway";
d->iceAgent->deleteSession();
@ -4240,7 +4240,7 @@ LinphoneStatus MediaSession::pause () {
LinphoneStatus MediaSession::resume () {
L_D();
if (d->state != LinphoneCallPaused) {
if (d->state != CallSession::State::Paused) {
lWarning() << "we cannot resume a call that has not been established and paused before";
return -1;
}
@ -4269,7 +4269,7 @@ LinphoneStatus MediaSession::resume () {
subject = "Conference";
if (d->op->update(subject.c_str(), false) != 0)
return -1;
d->setState(LinphoneCallResuming,"Resuming");
d->setState(CallSession::State::Resuming,"Resuming");
if (!d->getParams()->getPrivate()->getInConference() && d->listener)
d->listener->onSetCurrentSession(getSharedFromThis());
if (getCore()->getCCore()->sip_conf.sdp_200_ack) {
@ -4313,7 +4313,7 @@ void MediaSession::sendVfuRequest () {
video_stream_send_fir(d->videoStream);
} else if (getCore()->getCCore()->sip_conf.vfu_with_info) {
lInfo() << "Request SIP INFO FIR on CallSession [" << this << "]";
if (d->state == LinphoneCallStreamsRunning)
if (d->state == CallSession::State::StreamsRunning)
d->op->send_vfu_request();
} else
lInfo() << "vfu request using sip disabled from config [sip,vfu_with_info]";
@ -4357,7 +4357,7 @@ int MediaSession::startInvite (const Address *destination, const string &subject
int result = CallSession::startInvite(destination, subject, content);
if (result < 0) {
if (d->state == LinphoneCallError)
if (d->state == CallSession::State::Error)
d->stopStreams();
return result;
}
@ -4396,8 +4396,8 @@ void MediaSession::terminateBecauseOfLostMedia () {
LinphoneStatus MediaSession::update (const MediaSessionParams *msp, const string &subject) {
L_D();
LinphoneCallState nextState;
LinphoneCallState initialState = d->state;
CallSession::State nextState;
CallSession::State initialState = d->state;
LinphoneStatus result = 0;
if (!d->isUpdateAllowed(nextState))
return -1;
@ -4419,7 +4419,7 @@ LinphoneStatus MediaSession::update (const MediaSessionParams *msp, const string
}
} else {
#ifdef VIDEO_ENABLED
if (d->videoStream && (d->state == LinphoneCallStreamsRunning)) {
if (d->videoStream && (d->state == CallSession::State::StreamsRunning)) {
const LinphoneVideoDefinition *vdef = linphone_core_get_preferred_video_definition(getCore()->getCCore());
MSVideoSize vsize;
vsize.width = static_cast<int>(linphone_video_definition_get_width(vdef));
@ -4521,10 +4521,10 @@ void MediaSession::enableCamera (bool value) {
L_D();
d->cameraEnabled = value;
switch (d->state) {
case LinphoneCallStreamsRunning:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallConnected:
case CallSession::State::StreamsRunning:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::Connected:
if (d->videoStream && video_stream_started(d->videoStream) && (video_stream_get_camera(d->videoStream) != d->getVideoDevice())) {
string currentCam = video_stream_get_camera(d->videoStream) ? ms_web_cam_get_name(video_stream_get_camera(d->videoStream)) : "NULL";
string newCam = d->getVideoDevice() ? ms_web_cam_get_name(d->getVideoDevice()) : "NULL";
@ -4674,7 +4674,7 @@ float MediaSession::getPlayVolume () const {
float MediaSession::getRecordVolume () const {
L_D();
if (d->audioStream && d->audioStream->volsend && !d->audioMuted && (d->state == LinphoneCallStreamsRunning)) {
if (d->audioStream && d->audioStream->volsend && !d->audioMuted && (d->state == CallSession::State::StreamsRunning)) {
float vol = 0;
ms_filter_call_method(d->audioStream->volsend, MS_VOLUME_GET, &vol);
return vol;
@ -4848,10 +4848,10 @@ void MediaSession::setNativeVideoWindowId (void *id) {
void MediaSession::setParams (const MediaSessionParams *msp) {
L_D();
if ((d->state == LinphoneCallOutgoingInit) || (d->state == LinphoneCallIncomingReceived))
if ((d->state == CallSession::State::OutgoingInit) || (d->state == CallSession::State::IncomingReceived))
d->setParams(msp ? new MediaSessionParams(*msp) : nullptr);
else
lError() << "MediaSession::setParams(): Invalid state %s", linphone_call_state_to_string(d->state);
lError() << "MediaSession::setParams(): Invalid state %s", Utils::toString(d->state);
}
void MediaSession::setSpeakerVolumeGain (float value) {

View file

@ -232,14 +232,14 @@ bool Core::areSoundResourcesLocked () const {
if (call->mediaInProgress())
return true;
switch (call->getState()) {
case LinphoneCallOutgoingInit:
case LinphoneCallOutgoingProgress:
case LinphoneCallOutgoingRinging:
case LinphoneCallOutgoingEarlyMedia:
case LinphoneCallConnected:
case LinphoneCallRefered:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallUpdating:
case CallSession::State::OutgoingInit:
case CallSession::State::OutgoingProgress:
case CallSession::State::OutgoingRinging:
case CallSession::State::OutgoingEarlyMedia:
case CallSession::State::Connected:
case CallSession::State::Referred:
case CallSession::State::IncomingEarlyMedia:
case CallSession::State::Updating:
lInfo() << "Call " << call << " is locking sound resources";
return true;
default:
@ -276,7 +276,7 @@ shared_ptr<Call> Core::getCurrentCall () const {
LinphoneStatus Core::pauseAllCalls () {
L_D();
for (const auto &call : d->calls) {
if ((call->getState() == LinphoneCallStreamsRunning) || (call->getState() == LinphoneCallPausedByRemote))
if ((call->getState() == CallSession::State::StreamsRunning) || (call->getState() == CallSession::State::PausedByRemote))
call->pause();
}
return 0;
@ -287,10 +287,10 @@ void Core::soundcardHintCheck () {
bool noNeedForSound = true;
// Check if the remaining calls are paused
for (const auto &call : d->calls) {
if ((call->getState() != LinphoneCallPausing)
&& (call->getState() != LinphoneCallPaused)
&& (call->getState() != LinphoneCallEnd)
&& (call->getState() != LinphoneCallError)) {
if ((call->getState() != CallSession::State::Pausing)
&& (call->getState() != CallSession::State::Paused)
&& (call->getState() != CallSession::State::End)
&& (call->getState() != CallSession::State::Error)) {
noNeedForSound = false;
break;
}