Commit 4cc7985d authored by Ghislain MARY's avatar Ghislain MARY

Correctly define call session state enumeration.

parent 4c0c1b6a
......@@ -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
}
......
......@@ -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:
......
......@@ -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);
......
......@@ -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
......
......@@ -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.
// -----------------------------------------------------------------------------
......
/*
* 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_
......@@ -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.
*
......
......@@ -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__)), \
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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;
......
......@@ -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 "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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -94,7 +94,7 @@ void ServerGroupChatRoomPrivate::onChatRoomDeleteRequested (const shared_ptr<Abs
void ServerGroupChatRoomPrivate::onCallSessionStateChanged (
const shared_ptr<const CallSession> &,
LinphoneCallState,
CallSession::State,
const string &
) {}
......
......@@ -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) {}
......
......@@ -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;
......
This diff is collapsed.
......@@ -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: