Bug 784519 - Part 3: Send Signaling State from SIPCC to PeerConnection r=ekr

This commit is contained in:
Adam Roach [:abr] 2013-05-16 18:41:46 -05:00
parent e4b4f21044
commit 28a89d3601
21 changed files with 472 additions and 227 deletions

View File

@ -17,4 +17,4 @@
#
# Modifying this file will now automatically clobber the buildbot machines \o/
#
Bug 875929 removed a file from js/src/moz.build and apparently the build system didn't notice.
Bug 784519 causes mystery Android build failures and mochi/crashtest failures

View File

@ -765,10 +765,29 @@ RTCPeerConnection.prototype = {
sdp: sdp });
},
get signalingState() { return "stable"; }, // not yet implemented
get iceGatheringState() { return this._iceGatheringState; },
get iceConnectionState() { return this._iceConnectionState; },
// Corresponds to constants in IPeerConnection.idl
_signalingStateMap: [
'invalid',
'stable',
'have-local-offer',
'have-remote-offer',
'have-local-pranswer',
'have-remote-pranswer',
'closed'
],
get signalingState() {
// checking for our local pc closed indication
// before invoking the pc methods.
if(this._closed) {
return "closed";
}
return this._signalingStateMap[this._getPC().signalingState];
},
changeIceGatheringState: function(state) {
this._iceGatheringState = state;
},
@ -990,14 +1009,10 @@ PeerConnectionObserver.prototype = {
this._dompc._executeNext();
},
onStateChange: function(state) {
if (state != Ci.IPeerConnectionObserver.kIceState) {
return;
}
switch (this._dompc._pc.iceState) {
handleIceStateChanges: function(iceState) {
switch (iceState) {
case Ci.IPeerConnection.kIceWaiting:
this._dompc.changeIceConnectionState("completed");
this._dompc.changeIceConnectionState("new");
this.callCB(this._dompc.ongatheringchange, "complete");
this.callCB(this._onicechange, "starting");
// Now that the PC is ready to go, execute any pending operations.
@ -1021,7 +1036,33 @@ PeerConnectionObserver.prototype = {
this.callCB(this._onicechange, "failed");
break;
default:
// Unknown state!
// Unknown ICE state!
this._dompc.reportWarning("Unhandled ice state: " + iceState, null, 0);
break;
}
},
onStateChange: function(state) {
switch (state) {
case Ci.IPeerConnectionObserver.kSignalingState:
this.callCB(this._dompc.onsignalingstatechange,
this._dompc.signalingState);
break;
case Ci.IPeerConnectionObserver.kIceState:
this.handleIceStateChanges(this._dompc._pc.iceState);
break;
case Ci.IPeerConnectionObserver.kSdpState:
// No-op
break;
case Ci.IPeerConnectionObserver.kSipccState:
// No-op
break;
default:
this._dompc.reportWarning("Unhandled state type: " + state, null, 0);
break;
}
},

View File

@ -32,6 +32,7 @@ interface IPeerConnectionObserver : nsISupports
const long kIceState = 0x2;
const long kSdpState = 0x3;
const long kSipccState = 0x4;
const long kSignalingState = 0x5;
/* JSEP callbacks */
void onCreateOfferSuccess(in string offer);
@ -91,6 +92,15 @@ interface IPeerConnection : nsISupports
const long kClosing = 3;
const long kClosed = 4;
/* RTCSignalingState from WebRTC spec */
const long kSignalingInvalid = 0;
const long kSignalingStable = 1;
const long kSignalingHaveLocalOffer = 2;
const long kSignalingHaveRemoteOffer = 3;
const long kSignalingHaveLocalPranswer = 4;
const long kSignalingHaveRemotePranswer = 5;
const long kSignalingClosed = 6;
/* for 'type' in DataChannelInit dictionary */
const unsigned short kDataChannelReliable = 0;
const unsigned short kDataChannelPartialReliableRexmit = 1;
@ -144,6 +154,7 @@ interface IPeerConnection : nsISupports
readonly attribute unsigned long iceState;
readonly attribute unsigned long readyState;
readonly attribute unsigned long signalingState;
readonly attribute unsigned long sipccState;
/* Data channels */

View File

@ -9,12 +9,14 @@
extern "C"
{
#include "ccapi_types.h"
#include "fsmdef_states.h"
}
#include "CC_Common.h"
#include "CC_CallTypes.h"
#include "peer_connection_types.h"
namespace CSF
{
@ -43,6 +45,13 @@ namespace CSF
*/
virtual cc_call_state_t getCallState () = 0;
/**
get FSM state
@param [in] handle - call info handle
@return FSM state
*/
virtual fsmdef_states_t getFsmState () const = 0;
/**
print Call state
@param [in] handle - call info handle
@ -50,6 +59,13 @@ namespace CSF
*/
virtual std::string callStateToString (cc_call_state_t state) = 0;
/**
print FSM state
@param [in] handle - call info handle
@return call state as string
*/
virtual std::string fsmStateToString (fsmdef_states_t state) const = 0;
/**
print Call event
@param [in] call event

View File

@ -387,6 +387,7 @@
'./src/sipcc/core/includes/dns_utils.h',
'./src/sipcc/core/includes/dtmf.h',
'./src/sipcc/core/includes/embedded.h',
'./src/sipcc/core/includes/fsmdef_states.h',
'./src/sipcc/core/includes/intelpentiumtypes.h',
'./src/sipcc/core/includes/kpml_common_util.h',
'./src/sipcc/core/includes/kpmlmap.h',

View File

@ -129,7 +129,9 @@ public:
mReason(aInfo->getStatus()),
mSdpStr(),
mCallState(aInfo->getCallState()),
mStateStr(aInfo->callStateToString(mCallState)) {
mFsmState(aInfo->getFsmState()),
mStateStr(aInfo->callStateToString(mCallState)),
mFsmStateStr(aInfo->fsmStateToString(mFsmState)) {
if (mCallState == REMOTESTREAMADD) {
MediaStreamTable *streams = NULL;
streams = aInfo->getMediaStreams();
@ -173,7 +175,8 @@ public:
NS_IMETHOD Run() {
CSFLogInfo(logTag, "PeerConnectionObserverDispatch processing "
"mCallState = %d (%s)", mCallState, mStateStr.c_str());
"mCallState = %d (%s), mFsmState = %d (%s)",
mCallState, mStateStr.c_str(), mFsmState, mFsmStateStr.c_str());
if (mCallState == SETLOCALDESCERROR || mCallState == SETREMOTEDESCERROR) {
const std::vector<std::string> &errors = mPC->GetSdpParseErrors();
@ -192,6 +195,23 @@ public:
mCode, mReason.c_str());
}
/*
* While the fsm_states_t (FSM_DEF_*) constants are a proper superset
* of SignalingState, and the order in which the SignalingState values
* appear matches the order they appear in fsm_states_t, their underlying
* numeric representation is different. Hence, we need to perform an
* offset calculation to map from one to the other.
*/
if (mFsmState >= FSMDEF_S_STABLE && mFsmState <= FSMDEF_S_CLOSED) {
int offset = FSMDEF_S_STABLE - PeerConnectionImpl::kSignalingStable;
mPC->SetSignalingState_m(
static_cast<PeerConnectionImpl::SignalingState>(mFsmState - offset));
} else {
CSFLogError(logTag, ": **** UNHANDLED SIGNALING STATE : %d (%s)",
mFsmState, mFsmStateStr.c_str());
}
switch (mCallState) {
case CREATEOFFERSUCCESS:
mObserver->OnCreateOfferSuccess(mSdpStr.c_str());
@ -290,7 +310,9 @@ private:
std::string mReason;
std::string mSdpStr;
cc_call_state_t mCallState;
fsmdef_states_t mFsmState;
std::string mStateStr;
std::string mFsmStateStr;
nsRefPtr<RemoteSourceStreamInfo> mRemoteStream;
};
@ -300,6 +322,7 @@ PeerConnectionImpl::PeerConnectionImpl()
: mRole(kRoleUnknown)
, mCall(NULL)
, mReadyState(kNew)
, mSignalingState(kSignalingStable)
, mIceState(kIceGathering)
, mPCObserver(NULL)
, mWindow(NULL)
@ -1217,6 +1240,16 @@ PeerConnectionImpl::GetReadyState(uint32_t* aState)
return NS_OK;
}
NS_IMETHODIMP
PeerConnectionImpl::GetSignalingState(uint32_t* aState)
{
PC_AUTO_ENTER_API_CALL_NO_CHECK();
MOZ_ASSERT(aState);
*aState = mSignalingState;
return NS_OK;
}
NS_IMETHODIMP
PeerConnectionImpl::GetSipccState(uint32_t* aState)
{
@ -1383,6 +1416,22 @@ PeerConnectionImpl::ChangeReadyState(PeerConnectionImpl::ReadyState aReadyState)
NS_DISPATCH_NORMAL);
}
void
PeerConnectionImpl::SetSignalingState_m(SignalingState aSignalingState)
{
PC_AUTO_ENTER_API_CALL_NO_CHECK();
if (mSignalingState == aSignalingState) {
return;
}
mSignalingState = aSignalingState;
nsCOMPtr<IPeerConnectionObserver> pco = do_QueryReferent(mPCObserver);
if (!pco) {
return;
}
pco->OnStateChange(IPeerConnectionObserver::kSignalingState);
}
PeerConnectionWrapper::PeerConnectionWrapper(const std::string& handle)
: impl_(nullptr) {
if (PeerConnectionCtx::GetInstance()->mPeerConnections.find(handle) ==

View File

@ -133,6 +133,18 @@ public:
kClosed
};
/* Must match constants in IPeerConnection.idl */
/* Must also be int the same order as in fsmdef_states.h */
enum SignalingState {
kSignalingInvalid = 0,
kSignalingStable = 1,
kSignalingHaveLocalOffer = 2,
kSignalingHaveRemoteOffer = 3,
kSignalingHaveLocalPranswer = 4,
kSignalingHaveRemotePranswer = 5,
kSignalingClosed = 6
};
enum SipccState {
kIdle,
kStarting,
@ -268,6 +280,9 @@ public:
// Called to retreive the list of parsing errors.
const std::vector<std::string> &GetSdpParseErrors();
// Sets the RTC Signaling State
void SetSignalingState_m(SignalingState aSignalingState);
private:
PeerConnectionImpl(const PeerConnectionImpl&rhs);
PeerConnectionImpl& operator=(PeerConnectionImpl);
@ -315,6 +330,7 @@ private:
// The call
CSF::CC_CallPtr mCall;
ReadyState mReadyState;
SignalingState mSignalingState;
// ICE State
IceState mIceState;

View File

@ -396,7 +396,8 @@ PeerConnectionMedia::AddRemoteStream(nsRefPtr<RemoteSourceStreamInfo> aInfo,
nsresult
PeerConnectionMedia::AddRemoteStreamHint(int aIndex, bool aIsVideo)
{
if (aIndex >= mRemoteSourceStreams.Length()) {
if (aIndex < 0 ||
static_cast<unsigned int>(aIndex) >= mRemoteSourceStreams.Length()) {
return NS_ERROR_ILLEGAL_VALUE;
}

View File

@ -16,6 +16,7 @@
#include "cpr_threads.h"
#include "phone_types.h"
#include "session.h"
#include "fsmdef_states.h"
#include "cc_constants.h"
#include "ccapi_types.h"
@ -60,6 +61,7 @@ typedef struct cc_call_info_t_{
callid_t id;
uint16_t inst;
cc_call_state_t state;
fsmdef_states_t fsm_state;
cc_call_attr_t attr;
cc_call_type_t type;
cc_call_security_t security;

View File

@ -47,6 +47,25 @@ cc_call_state_t CCAPI_CallInfo_getCallState(cc_callinfo_ref_t handle){
return ONHOOK;
}
/**
* get FSM state
* @param handle - call handle
* @return call state
*/
fsmdef_states_t CCAPI_CallInfo_getFsmState(cc_callinfo_ref_t handle){
session_data_t *data = (session_data_t *)handle;
CCAPP_DEBUG(DEB_F_PREFIX"Entering",
DEB_F_PREFIX_ARGS(SIP_CC_PROV, __FUNCTION__));
if ( data ){
CCAPP_DEBUG(DEB_F_PREFIX"returned %02X",
DEB_F_PREFIX_ARGS(SIP_CC_PROV, __FUNCTION__), data->state);
return data->fsm_state;
}
return FSMDEF_S_IDLE;
}
/**
* get call attributes
* @param handle - call handle

View File

@ -1416,7 +1416,9 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
//Populate the session hash data the first time.
memset(data, 0, sizeof(session_data_t));
data->sess_id = sessUpd->sessionID;
data->state = call_state;
data->state = call_state;
data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id;
if (sessUpd->eventID == CALL_NEWCALL ||
sessUpd->eventID == CREATE_OFFER ||
@ -1506,8 +1508,12 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
if (createdSessionData == FALSE) {
return;
}
data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id;
data->state =
sessUpd->update.ccSessionUpd.data.state_data.state;
data->line =
sessUpd->update.ccSessionUpd.data.state_data.line_id;
data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
break;
default:
break;
@ -1572,6 +1578,8 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
}
data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id;
data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
sessUpd->update.ccSessionUpd.data.state_data.attr = data->attr;
sessUpd->update.ccSessionUpd.data.state_data.inst = data->inst;
@ -1629,8 +1637,10 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
ccsnap_gen_callEvent(CCAPI_CALL_EV_GCID, CREATE_CALL_HANDLE_FROM_SESSION_ID(sessUpd->sessionID));
break;
case CALL_NEWCALL:
data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id;
data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
data->attr = sessUpd->update.ccSessionUpd.data.state_data.attr;
data->inst = sessUpd->update.ccSessionUpd.data.state_data.inst;
return;
@ -1802,6 +1812,8 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
case REMOTE_STREAM_ADD:
data->cause = sessUpd->update.ccSessionUpd.data.state_data.cause;
data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
data->media_stream_track_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_track_id;
data->media_stream_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_id;
strlib_free(data->status);
@ -2155,7 +2167,8 @@ void ccappFeatureUpdated (feature_update_t *featUpd) {
break;
case DEVICE_FEATURE_MWILAMP:
g_deviceInfo.mwi_lamp = featUpd->update.ccFeatUpd.data.state_data.state;
g_deviceInfo.mwi_lamp =
featUpd->update.ccFeatUpd.data.mwi_status.status;
ccsnap_gen_deviceEvent(CCAPI_DEVICE_EV_MWI_LAMP, CC_DEVICE_ID);
break;
case DEVICE_FEATURE_BLF:

View File

@ -737,7 +737,7 @@ ui_change_mwi_lamp (int status)
msg.sessionType = SESSIONTYPE_CALLCONTROL;
msg.featureID = DEVICE_FEATURE_MWILAMP;
msg.update.ccFeatUpd.data.state_data.state = status;
msg.update.ccFeatUpd.data.mwi_status.status = status;
if ( ccappTaskPostMsg(CCAPP_FEATURE_UPDATE, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) {
CCAPP_ERROR(CCAPP_F_PREFIX"failed to send DEVICE_FEATURE_MWILAMP(%d) msg", __FUNCTION__, status);
@ -1544,20 +1544,20 @@ ui_control_feature (line_t line_id, callid_t call_id,
}
/*
* Helper for the following four functions which all load up a
* Helper for the following several functions which all load up a
* session_update message and post it.
*
*/
static void post_message_helper(
group_call_event_t eventId,
call_events event,
line_t nLine,
callid_t nCallId,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format,
va_list args)
static void post_message_helper(group_call_event_t eventId,
call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallId,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format,
va_list args)
{
flex_string fs;
session_update_t msg;
@ -1572,6 +1572,7 @@ static void post_message_helper(
msg.eventID = eventId;
msg.update.ccSessionUpd.data.state_data.state = event;
msg.update.ccSessionUpd.data.state_data.fsm_state = new_state;
msg.update.ccSessionUpd.data.state_data.inst = call_instance_id;
msg.update.ccSessionUpd.data.state_data.line_id = nLine;
msg.update.ccSessionUpd.data.state_data.sdp = sdp;
@ -1602,9 +1603,14 @@ static void post_message_helper(
*
* @return none
*/
void ui_create_offer(call_events event, line_t nLine, callid_t nCallID,
uint16_t call_instance_id, string_t sdp,
pc_error error, const char *format, ...)
void ui_create_offer(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
@ -1614,8 +1620,8 @@ void ui_create_offer(call_events event, line_t nLine, callid_t nCallID,
va_start(ap, format);
post_message_helper(CREATE_OFFER, event, nLine, nCallID, call_instance_id,
sdp, error, format, ap);
post_message_helper(CREATE_OFFER, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
return;
@ -1627,17 +1633,22 @@ void ui_create_offer(call_events event, line_t nLine, callid_t nCallID,
*
* @return none
*/
void ui_create_answer(call_events event, line_t nLine, callid_t nCallID,
uint16_t call_instance_id, string_t sdp,
pc_error error, const char *format, ...)
void ui_create_answer(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d",
DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id);
va_start(ap, format);
post_message_helper(CREATE_ANSWER, event, nLine, nCallID, call_instance_id,
sdp, error, format, ap);
post_message_helper(CREATE_ANSWER, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
return;
@ -1649,17 +1660,22 @@ void ui_create_answer(call_events event, line_t nLine, callid_t nCallID,
* @return none
*/
void ui_set_local_description(call_events event, line_t nLine, callid_t nCallID,
uint16_t call_instance_id, string_t sdp,
pc_error error, const char *format, ...)
void ui_set_local_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d",
DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id);
va_start(ap, format);
post_message_helper(SET_LOCAL_DESC, event, nLine, nCallID, call_instance_id,
sdp, error, format, ap);
post_message_helper(SET_LOCAL_DESC, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
return;
@ -1671,9 +1687,13 @@ void ui_set_local_description(call_events event, line_t nLine, callid_t nCallID,
* @return none
*/
void ui_set_remote_description(call_events event, line_t nLine,
callid_t nCallID, uint16_t call_instance_id,
string_t sdp, pc_error error,
void ui_set_remote_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
@ -1681,7 +1701,7 @@ void ui_set_remote_description(call_events event, line_t nLine,
DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id);
va_start(ap, format);
post_message_helper(SET_REMOTE_DESC, event, nLine, nCallID,
post_message_helper(SET_REMOTE_DESC, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
@ -1694,9 +1714,13 @@ void ui_set_remote_description(call_events event, line_t nLine,
* @return none
*/
void ui_update_local_description(call_events event, line_t nLine,
callid_t nCallID, uint16_t call_instance_id,
string_t sdp, pc_error error,
void ui_update_local_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
@ -1705,7 +1729,7 @@ void ui_update_local_description(call_events event, line_t nLine,
event, call_instance_id);
va_start(ap, format);
post_message_helper(UPDATE_LOCAL_DESC, event, nLine, nCallID,
post_message_helper(UPDATE_LOCAL_DESC, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
@ -1718,16 +1742,21 @@ void ui_update_local_description(call_events event, line_t nLine,
* @return none
*/
void ui_ice_candidate_add(call_events event, line_t nLine, callid_t nCallID,
uint16_t call_instance_id, string_t sdp,
pc_error error, const char *format, ...)
void ui_ice_candidate_add(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
string_t sdp,
pc_error error,
const char *format, ...)
{
va_list ap;
TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d",
DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id);
va_start(ap, format);
post_message_helper(ICE_CANDIDATE_ADD, event, nLine, nCallID,
post_message_helper(ICE_CANDIDATE_ADD, event, new_state, nLine, nCallID,
call_instance_id, sdp, error, format, ap);
va_end(ap);
}
@ -1738,8 +1767,11 @@ void ui_ice_candidate_add(call_events event, line_t nLine, callid_t nCallID,
* @return none
*/
void ui_on_remote_stream_added(call_events event, line_t nLine,
callid_t nCallID, uint16_t call_instance_id,
void ui_on_remote_stream_added(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
cc_media_remote_track_table_t media_track)
{
session_update_t msg;
@ -1759,6 +1791,7 @@ void ui_on_remote_stream_added(call_events event, line_t nLine,
msg.eventID = REMOTE_STREAM_ADD;
msg.update.ccSessionUpd.data.state_data.state = event;
msg.update.ccSessionUpd.data.state_data.fsm_state = new_state;
msg.update.ccSessionUpd.data.state_data.inst = call_instance_id;
msg.update.ccSessionUpd.data.state_data.line_id = nLine;
msg.update.ccSessionUpd.data.state_data.media_stream_track_id = media_track.track[0].media_stream_track_id;

View File

@ -747,36 +747,6 @@ static sm_function_t fsmdef_function_table[FSMDEF_S_MAX][CC_MSG_MAX] =
/* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate
},
/* FSMDEF_S_HAVE_REMOTE_PRANSWER ------------------------------------------- */
{
/* CC_MSG_SETUP */ fsmdef_ev_default,
/* CC_MSG_SETUP_ACK */ fsmdef_ev_default,
/* CC_MSG_PROCEEDING */ fsmdef_ev_default,
/* CC_MSG_ALERTING */ fsmdef_ev_default,
/* CC_MSG_CONNECTED */ fsmdef_ev_default,
/* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default,
/* CC_MSG_RELEASE */ fsmdef_ev_default,
/* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default,
/* CC_MSG_FEATURE */ fsmdef_ev_default,
/* CC_MSG_FEATURE_ACK */ fsmdef_ev_default,
/* CC_MSG_OFFHOOK */ fsmdef_ev_default,
/* CC_MSG_ONHOOK */ fsmdef_ev_onhook,
/* CC_MSG_LINE */ fsmdef_ev_default,
/* CC_MSG_DIGIT_BEGIN */ fsmdef_ev_default,
/* CC_MSG_DIGIT_END */ fsmdef_ev_default,
/* CC_MSG_DIALSTRING */ fsmdef_ev_default,
/* CC_MSG_MWI */ fsmdef_ev_default,
/* CC_MSG_SESSION_AUDIT */ fsmdef_ev_default,
/* CC_MSG_CREATEOFFER */ fsmdef_ev_createoffer,
/* CC_MSG_CREATEANSWER */ fsmdef_ev_createanswer,
/* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, /* Should not happen */
/* CC_MSG_SETREMOTEDESC */ fsmdef_ev_setremotedesc,
/* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default,
/* CC_MSG_ADDSTREAM */ fsmdef_ev_default,
/* CC_MSG_REMOVESTREAM */ fsmdef_ev_default,
/* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate
},
/* FSMDEF_S_HAVE_LOCAL_PRANSWER -------------------------------------------- */
{
/* CC_MSG_SETUP */ fsmdef_ev_default,
@ -807,6 +777,36 @@ static sm_function_t fsmdef_function_table[FSMDEF_S_MAX][CC_MSG_MAX] =
/* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate
},
/* FSMDEF_S_HAVE_REMOTE_PRANSWER ------------------------------------------- */
{
/* CC_MSG_SETUP */ fsmdef_ev_default,
/* CC_MSG_SETUP_ACK */ fsmdef_ev_default,
/* CC_MSG_PROCEEDING */ fsmdef_ev_default,
/* CC_MSG_ALERTING */ fsmdef_ev_default,
/* CC_MSG_CONNECTED */ fsmdef_ev_default,
/* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default,
/* CC_MSG_RELEASE */ fsmdef_ev_default,
/* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default,
/* CC_MSG_FEATURE */ fsmdef_ev_default,
/* CC_MSG_FEATURE_ACK */ fsmdef_ev_default,
/* CC_MSG_OFFHOOK */ fsmdef_ev_default,
/* CC_MSG_ONHOOK */ fsmdef_ev_onhook,
/* CC_MSG_LINE */ fsmdef_ev_default,
/* CC_MSG_DIGIT_BEGIN */ fsmdef_ev_default,
/* CC_MSG_DIGIT_END */ fsmdef_ev_default,
/* CC_MSG_DIALSTRING */ fsmdef_ev_default,
/* CC_MSG_MWI */ fsmdef_ev_default,
/* CC_MSG_SESSION_AUDIT */ fsmdef_ev_default,
/* CC_MSG_CREATEOFFER */ fsmdef_ev_createoffer,
/* CC_MSG_CREATEANSWER */ fsmdef_ev_createanswer,
/* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, /* Should not happen */
/* CC_MSG_SETREMOTEDESC */ fsmdef_ev_setremotedesc,
/* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default,
/* CC_MSG_ADDSTREAM */ fsmdef_ev_default,
/* CC_MSG_REMOVESTREAM */ fsmdef_ev_default,
/* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate
},
/* FSMDEF_S_CLOSED --------------------------------------------------------- */
{
/* CC_MSG_SETUP */ fsmdef_ev_default,
@ -2416,38 +2416,39 @@ fsmdef_ev_default (sm_event_t *event)
*/
switch (event->event) {
case CC_MSG_CREATEOFFER:
ui_create_offer(evCreateOfferError, msg->line, msg->call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_create_offer(evCreateOfferError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot create offer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
break;
case CC_MSG_CREATEANSWER:
ui_create_answer(evCreateAnswerError, msg->line, msg->call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_create_answer(evCreateAnswerError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot create answer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
break;
case CC_MSG_SETLOCALDESC:
ui_set_local_description(evSetLocalDescError, msg->line,
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set local description in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
break;
case CC_MSG_SETREMOTEDESC:
ui_set_remote_description(evSetRemoteDescError, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set remote description in state %s",
fsmdef_state_name(event->state));
ui_set_remote_description(evSetRemoteDescError, fcb->state,
msg->line, msg->call_id, dcb->caller_id.call_instance_id,
strlib_empty(), PC_INVALID_STATE,
"Cannot set remote description in state %s",
fsmdef_state_name(fcb->state));
break;
case CC_MSG_ADDCANDIDATE:
ui_ice_candidate_add(evAddIceCandidateError, msg->line, msg->call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_ice_candidate_add(evAddIceCandidateError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot add ICE candidate in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
break;
case CC_MSG_ADDSTREAM:
@ -2458,7 +2459,7 @@ fsmdef_ev_default (sm_event_t *event)
* getting through anyway. */
FSM_DEBUG_SM(DEB_L_C_F_PREFIX"Cannot add or remove streams "
"in state %s", DEB_L_C_F_PREFIX_ARGS(FSM, dcb->line,
msg->call_id, __FUNCTION__), fsmdef_state_name(event->state));
msg->call_id, __FUNCTION__), fsmdef_state_name(fcb->state));
break;
default:
@ -3150,14 +3151,14 @@ fsmdef_ev_createoffer (sm_event_t *event) {
local_sdp = sipsdp_write_to_buf(dcb->sdp->src_sdp, &local_sdp_len);
if (!local_sdp) {
ui_create_offer(evCreateOfferError, line, call_id,
ui_create_offer(evCreateOfferError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not re-create local SDP for offer");
FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR));
return (fsmdef_release(fcb, cause, FALSE));
}
ui_create_offer(evCreateOfferSuccess, line, call_id,
ui_create_offer(evCreateOfferSuccess, fcb->state, line, call_id,
dcb->caller_id.call_instance_id,
strlib_malloc(local_sdp,-1), PC_NO_ERROR, NULL);
free(local_sdp);
@ -3179,7 +3180,7 @@ fsmdef_ev_createoffer (sm_event_t *event) {
}
if (!has_stream) {
ui_create_offer(evCreateOfferError, line, call_id,
ui_create_offer(evCreateOfferError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot create SDP without any streams.");
return SM_RC_END;
@ -3189,7 +3190,7 @@ fsmdef_ev_createoffer (sm_event_t *event) {
if (vcm_res) {
FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_create_offer(evCreateOfferError, line, call_id,
ui_create_offer(evCreateOfferError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Failed to get ICE parameters for local SDP");
return (fsmdef_release(fcb, cause, FALSE));
@ -3221,7 +3222,7 @@ fsmdef_ev_createoffer (sm_event_t *event) {
cause = gsmsdp_create_local_sdp(dcb, FALSE, TRUE, TRUE, TRUE, TRUE);
if (cause != CC_CAUSE_OK) {
ui_create_offer(evCreateOfferError, line, call_id,
ui_create_offer(evCreateOfferError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not create local SDP for offer;"
" cause = %s", cc_cause_name(cause));
@ -3231,7 +3232,7 @@ fsmdef_ev_createoffer (sm_event_t *event) {
cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body);
if (cause != CC_CAUSE_OK) {
ui_create_offer(evCreateOfferError, line, call_id,
ui_create_offer(evCreateOfferError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not encode local SDP for offer;"
" cause = %s", cc_cause_name(cause));
@ -3242,7 +3243,7 @@ fsmdef_ev_createoffer (sm_event_t *event) {
dcb->local_sdp_complete = TRUE;
/* Pass offer SDP back to UI */
ui_create_offer(evCreateOfferSuccess, line, call_id,
ui_create_offer(evCreateOfferSuccess, fcb->state, line, call_id,
dcb->caller_id.call_instance_id,
strlib_malloc(msg_body.parts[0].body, -1), PC_NO_ERROR, NULL);
cc_free_msg_body_parts(&msg_body);
@ -3305,14 +3306,14 @@ fsmdef_ev_createanswer (sm_event_t *event) {
local_sdp = sipsdp_write_to_buf(dcb->sdp->src_sdp, &local_sdp_len);
if (!local_sdp) {
ui_create_answer(evCreateAnswerError, line, call_id,
ui_create_answer(evCreateAnswerError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not re-create local SDP for answer");
FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR));
return (fsmdef_release(fcb, cause, FALSE));
}
ui_create_answer(evCreateAnswerSuccess, line, call_id,
ui_create_answer(evCreateAnswerSuccess, fcb->state, line, call_id,
dcb->caller_id.call_instance_id,
strlib_malloc(local_sdp,-1), PC_NO_ERROR, NULL);
free(local_sdp);
@ -3331,7 +3332,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
if (vcm_res) {
FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_create_answer(evCreateAnswerError, line, call_id,
ui_create_answer(evCreateAnswerError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not get ICE parameters for answer");
return (fsmdef_release(fcb, cause, FALSE));
@ -3373,7 +3374,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
*/
cause = gsmsdp_create_local_sdp(dcb, TRUE, has_audio, has_video, has_data, FALSE);
if (cause != CC_CAUSE_OK) {
ui_create_answer(evCreateAnswerError, line, call_id,
ui_create_answer(evCreateAnswerError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not create local SDP for answer;"
" cause = %s", cc_cause_name(cause));
@ -3392,7 +3393,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
/* create_answer */ TRUE);
if (cause != CC_CAUSE_OK) {
ui_create_answer(evCreateAnswerError, line, call_id,
ui_create_answer(evCreateAnswerError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not negotiate media lines; cause = %s",
cc_cause_name(cause));
@ -3401,7 +3402,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body);
if (cause != CC_CAUSE_OK) {
ui_create_answer(evCreateAnswerError, line, call_id,
ui_create_answer(evCreateAnswerError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not encode SDP for answer; cause = %s",
cc_cause_name(cause));
@ -3412,7 +3413,7 @@ fsmdef_ev_createanswer (sm_event_t *event) {
dcb->local_sdp_complete = TRUE;
/* Pass SDP back to UI */
ui_create_answer(evCreateAnswerSuccess, line, call_id,
ui_create_answer(evCreateAnswerSuccess, fcb->state, line, call_id,
dcb->caller_id.call_instance_id,
strlib_malloc(msg_body.parts[0].body, -1), PC_NO_ERROR, NULL);
cc_free_msg_body_parts(&msg_body);
@ -3448,25 +3449,25 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
if (dcb == NULL) {
FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_set_local_description(evSetLocalDescError, line, call_id,
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
ui_set_local_description(evSetLocalDescError, fcb->state, line, call_id,
0, strlib_empty(),
PC_INTERNAL_ERROR, "Unrecoverable error: dcb is NULL.");
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
return (SM_RC_CLEANUP);
}
config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
if (!sdpmode) {
ui_set_local_description(evSetLocalDescError, line, call_id,
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
ui_set_local_description(evSetLocalDescError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should "
"never ever happen. Run for your lives!");
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
return (SM_RC_END);
}
if (!dcb->sdp) {
ui_set_local_description(evSetLocalDescError, line, call_id,
ui_set_local_description(evSetLocalDescError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Setting of local SDP before calling "
"createOffer or createAnswer is not currently supported.");
@ -3476,12 +3477,12 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
switch (action) {
case JSEP_OFFER:
if (event->state != FSMDEF_S_STABLE &&
event->state != FSMDEF_S_HAVE_LOCAL_OFFER) {
ui_set_local_description(evSetLocalDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_STABLE &&
fcb->state != FSMDEF_S_HAVE_LOCAL_OFFER) {
ui_set_local_description(evSetLocalDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set local offer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
/* TODO: Parse incoming SDP and act on it. */
@ -3489,12 +3490,12 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
break;
case JSEP_ANSWER:
if (event->state != FSMDEF_S_HAVE_REMOTE_OFFER &&
event->state != FSMDEF_S_HAVE_LOCAL_PRANSWER) {
ui_set_local_description(evSetLocalDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_HAVE_REMOTE_OFFER &&
fcb->state != FSMDEF_S_HAVE_LOCAL_PRANSWER) {
ui_set_local_description(evSetLocalDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set local answer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
/* TODO: Parse incoming SDP and act on it. */
@ -3509,8 +3510,8 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
*/
cause = gsmsdp_install_peer_ice_attributes(fcb);
if (cause != CC_CAUSE_OK) {
ui_set_local_description(evSetLocalDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_local_description(evSetLocalDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not configure local ICE state"
" from SDP; cause = %s", cc_cause_name(cause));
return (SM_RC_END);
@ -3525,8 +3526,8 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
if (dcb->dsp_out_of_resources == TRUE) {
cc_call_state(fcb->dcb->call_id, fcb->dcb->line,
CC_STATE_UNKNOWN, NULL);
ui_set_local_description(evSetLocalDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_local_description(evSetLocalDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Cannot start media channels; cause = %s",
cc_cause_name(cause));
return (SM_RC_END);
@ -3539,21 +3540,21 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
break;
case JSEP_PRANSWER:
if (event->state != FSMDEF_S_HAVE_REMOTE_OFFER &&
event->state != FSMDEF_S_HAVE_LOCAL_PRANSWER) {
ui_set_local_description(evSetLocalDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_HAVE_REMOTE_OFFER &&
fcb->state != FSMDEF_S_HAVE_LOCAL_PRANSWER) {
ui_set_local_description(evSetLocalDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set local pranswer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
ui_set_local_description(evSetLocalDescError, msg->line,
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Provisional answers are not yet supported");
return (SM_RC_END);
default:
ui_set_local_description(evSetLocalDescError, msg->line,
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Unknown session description type: %d",action);
return (SM_RC_END);
@ -3562,16 +3563,16 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
/* Encode the current local SDP structure into a char buffer */
local_sdp = sipsdp_write_to_buf(dcb->sdp->src_sdp, &local_sdp_len);
if (!local_sdp) {
ui_set_local_description(evSetLocalDescError, msg->line, msg->call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not encode local SDP for local "
"description");
return (SM_RC_END);
}
ui_set_local_description(evSetLocalDescSuccess, msg->line, msg->call_id,
dcb->caller_id.call_instance_id, strlib_malloc(local_sdp,-1),
PC_NO_ERROR, NULL);
ui_set_local_description(evSetLocalDescSuccess, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id,
strlib_malloc(local_sdp,-1), PC_NO_ERROR, NULL);
free(local_sdp);
return (SM_RC_END);
@ -3609,20 +3610,20 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
if (dcb == NULL) {
FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_set_remote_description(evSetRemoteDescError, line, call_id,
0, strlib_empty(),
PC_INTERNAL_ERROR, "Unrecoverable error: dcb is NULL.");
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, 0, strlib_empty(),
PC_INTERNAL_ERROR, "Unrecoverable error: dcb is NULL.");
return (SM_RC_CLEANUP);
}
config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
if (!sdpmode) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should "
"never ever happen. Run for your lives!");
fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED);
return (SM_RC_END);
}
@ -3632,8 +3633,8 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
if (dcb->sdp && dcb->sdp->dest_sdp) {
FSM_DEBUG_SM(DEB_F_PREFIX"Renegotiation not currently supported.",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Renegotiation of session description is not "
"currently supported. See Bug 840728 for status.");
return (SM_RC_END);
@ -3661,18 +3662,18 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
switch (action) {
case JSEP_OFFER:
if (event->state != FSMDEF_S_STABLE &&
event->state != FSMDEF_S_HAVE_REMOTE_OFFER) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_STABLE &&
fcb->state != FSMDEF_S_HAVE_REMOTE_OFFER) {
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set remote offer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
cause = gsmsdp_process_offer_sdp(fcb, &msg_body, TRUE);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not process offer SDP; "
"cause = %s", cc_cause_name(cause));
return (SM_RC_END);
@ -3692,8 +3693,8 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
cause = gsmsdp_create_local_sdp(dcb, TRUE, has_audio, has_video,
has_data, FALSE);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not create local SDP; cause = %s",
cc_cause_name(cause));
FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR));
@ -3704,8 +3705,8 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp,
TRUE, TRUE, TRUE, FALSE);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not negotiate media lines; cause = %s",
cc_cause_name(cause));
return (fsmdef_release(fcb, cause, FALSE));
@ -3717,18 +3718,18 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
break;
case JSEP_ANSWER:
if (event->state != FSMDEF_S_HAVE_LOCAL_OFFER &&
event->state != FSMDEF_S_HAVE_REMOTE_PRANSWER) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_HAVE_LOCAL_OFFER &&
fcb->state != FSMDEF_S_HAVE_REMOTE_PRANSWER) {
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set remote answer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
cause = gsmsdp_negotiate_answer_sdp(fcb, &msg_body);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not negotiate answer SDP; cause = %s",
cc_cause_name(cause));
return (SM_RC_END);
@ -3740,8 +3741,8 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
*/
cause = gsmsdp_install_peer_ice_attributes(fcb);
if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not configure local ICE state"
" from SDP; cause = %s", cc_cause_name(cause));
return (SM_RC_END);
@ -3759,21 +3760,21 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
break;
case JSEP_PRANSWER:
if (event->state != FSMDEF_S_HAVE_LOCAL_OFFER &&
event->state != FSMDEF_S_HAVE_REMOTE_PRANSWER) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
if (fcb->state != FSMDEF_S_HAVE_LOCAL_OFFER &&
fcb->state != FSMDEF_S_HAVE_REMOTE_PRANSWER) {
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot set remote pranswer in state %s",
fsmdef_state_name(event->state));
fsmdef_state_name(fcb->state));
return (SM_RC_END);
}
ui_set_local_description(evSetLocalDescError, msg->line,
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Provisional answers are not yet supported");
return (SM_RC_END);
default:
ui_set_local_description(evSetLocalDescError, msg->line,
ui_set_local_description(evSetLocalDescError, fcb->state, msg->line,
msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Unknown session description type: %d",action);
return (SM_RC_END);
@ -3788,14 +3789,14 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
remote_sdp = sipsdp_write_to_buf(dcb->sdp->dest_sdp, &remote_sdp_len);
if (!remote_sdp) {
ui_set_remote_description(evSetRemoteDescError, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
ui_set_remote_description(evSetRemoteDescError, fcb->state, line,
call_id, dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not serialize remote description;"
" cause = %s", cc_cause_name(cause));
return (SM_RC_END);
}
ui_set_remote_description(evSetRemoteDescSuccess, line, call_id,
ui_set_remote_description(evSetRemoteDescSuccess, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1),
PC_NO_ERROR, NULL);
@ -3979,14 +3980,14 @@ fsmdef_ev_addcandidate(sm_event_t *event) {
if (!dcb) {
FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_ice_candidate_add(evAddIceCandidateError, line, call_id,
ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id,
0, strlib_empty(), PC_INTERNAL_ERROR, "DCB has not been created.");
return SM_RC_CLEANUP;
}
config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
if (sdpmode == FALSE) {
ui_ice_candidate_add(evAddIceCandidateError, line, call_id,
ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should "
"never ever happen. Run for your lives!");
@ -3998,7 +3999,7 @@ fsmdef_ev_addcandidate(sm_event_t *event) {
"remote description been set yet?\n",
DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
ui_ice_candidate_add(evAddIceCandidateError, line, call_id,
ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INVALID_STATE, "Cannot add remote ICE candidates before "
"setting remote SDP.");
@ -4045,14 +4046,14 @@ fsmdef_ev_addcandidate(sm_event_t *event) {
remote_sdp = sipsdp_write_to_buf(dcb->sdp->dest_sdp, &remote_sdp_len);
if (!remote_sdp) {
ui_ice_candidate_add(evAddIceCandidateError, line, call_id,
ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_empty(),
PC_INTERNAL_ERROR, "Could not serialize new SDP after adding ICE "
"candidate.");
return (SM_RC_END);
}
ui_ice_candidate_add(evAddIceCandidate, line, call_id,
ui_ice_candidate_add(evAddIceCandidate, fcb->state, line, call_id,
dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1),
PC_NO_ERROR, NULL);

View File

@ -4749,7 +4749,7 @@ gsmsdp_negotiate_media_lines (fsm_fcb_t *fcb_p, cc_sdp_t *sdp_p, boolean initial
TODO(adam@nostrum.com): Figure out how to notify
when streams gain tracks */
ui_on_remote_stream_added(evOnRemoteStreamAdd,
dcb_p->line, dcb_p->call_id,
fcb_p->state, dcb_p->line, dcb_p->call_id,
dcb_p->caller_id.call_instance_id,
dcb_p->remote_media_stream_tbl->streams[j]);

View File

@ -13,6 +13,7 @@
#include "sll_lite.h"
#include "sessionConstants.h"
#include "ccsdp.h"
#include "fsmdef_states.h"
/* TODO: BLASBERG
* fsm.h only needs the following from ccsip_core.h
@ -65,39 +66,6 @@ typedef enum {
FSMDEF_CALL_TYPE_MAX
} fsmdef_call_types_t;
typedef enum {
FSMDEF_S_MIN = -1,
FSMDEF_S_IDLE,
/* SIP States */
FSMDEF_S_COLLECT_INFO,
FSMDEF_S_CALL_SENT,
FSMDEF_S_OUTGOING_PROCEEDING,
FSMDEF_S_KPML_COLLECT_INFO,
FSMDEF_S_OUTGOING_ALERTING,
FSMDEF_S_INCOMING_ALERTING,
FSMDEF_S_CONNECTING,
FSMDEF_S_JOINING,
FSMDEF_S_CONNECTED,
FSMDEF_S_CONNECTED_MEDIA_PEND,
FSMDEF_S_RELEASING,
FSMDEF_S_HOLD_PENDING,
FSMDEF_S_HOLDING,
FSMDEF_S_RESUME_PENDING,
FSMDEF_S_PRESERVED,
/* WebRTC States */
FSMDEF_S_STABLE,
FSMDEF_S_HAVE_LOCAL_OFFER,
FSMDEF_S_HAVE_REMOTE_OFFER,
FSMDEF_S_HAVE_REMOTE_PRANSWER,
FSMDEF_S_HAVE_LOCAL_PRANSWER,
FSMDEF_S_CLOSED,
FSMDEF_S_MAX
} fsmdef_states_t;
typedef enum {
FSMDEF_MRTONE_NO_ACTION = 0,
FSMDEF_MRTONE_PLAYED_MONITOR_TONE,

View File

@ -52,6 +52,7 @@ typedef struct {
typedef struct {
int state;
int fsm_state;
int attr;
int inst;
line_t line_id;

View File

@ -9,6 +9,7 @@
#include "phone_types.h"
#include "string_lib.h"
#include "vcm.h"
#include "fsm.h"
#include "ccapi.h"
#include "sessionConstants.h"
@ -180,6 +181,7 @@ void ui_update_media_interface_change(line_t line, callid_t call_id, group_call_
/* WebRTC upcalls for PeerConnectionImpl */
void ui_create_offer(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -188,6 +190,7 @@ void ui_create_offer(call_events event,
const char *format, ...);
void ui_create_answer(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -196,6 +199,7 @@ void ui_create_answer(call_events event,
const char *format, ...);
void ui_set_local_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -204,6 +208,7 @@ void ui_set_local_description(call_events event,
const char *format, ...);
void ui_set_remote_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -212,6 +217,7 @@ void ui_set_remote_description(call_events event,
const char *format, ...);
void ui_update_local_description(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -220,6 +226,7 @@ void ui_update_local_description(call_events event,
const char *format, ...);
void ui_ice_candidate_add(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,
@ -228,6 +235,7 @@ void ui_ice_candidate_add(call_events event,
const char *format, ...);
void ui_on_remote_stream_added(call_events event,
fsmdef_states_t new_state,
line_t nLine,
callid_t nCallID,
uint16_t call_instance_id,

View File

@ -7,6 +7,7 @@
#include "ccapi_types.h"
#include "peer_connection_types.h"
#include "fsmdef_states.h"
/**
* get Line on which this call is
@ -22,6 +23,13 @@ cc_lineid_t CCAPI_CallInfo_getLine(cc_callinfo_ref_t handle);
*/
cc_call_state_t CCAPI_CallInfo_getCallState(cc_callinfo_ref_t handle);
/**
* get FSM state
* @param [in] handle - call info handle
* @return fsm state
*/
fsmdef_states_t CCAPI_CallInfo_getFsmState(cc_callinfo_ref_t handle);
/**
* get call attributes
* @param [in] handle - call info handle

View File

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _FSMDEF_STATES_H_
#define _FSMDEF_STATES_H_
typedef enum {
FSMDEF_S_MIN = -1,
FSMDEF_S_IDLE,
/* SIP States */
FSMDEF_S_COLLECT_INFO,
FSMDEF_S_CALL_SENT,
FSMDEF_S_OUTGOING_PROCEEDING,
FSMDEF_S_KPML_COLLECT_INFO,
FSMDEF_S_OUTGOING_ALERTING,
FSMDEF_S_INCOMING_ALERTING,
FSMDEF_S_CONNECTING,
FSMDEF_S_JOINING,
FSMDEF_S_CONNECTED,
FSMDEF_S_CONNECTED_MEDIA_PEND,
FSMDEF_S_RELEASING,
FSMDEF_S_HOLD_PENDING,
FSMDEF_S_HOLDING,
FSMDEF_S_RESUME_PENDING,
FSMDEF_S_PRESERVED,
/* WebRTC States */
/* MUST be in the same order as PeerConnectionImpl::SignalingState */
FSMDEF_S_STABLE,
FSMDEF_S_HAVE_LOCAL_OFFER,
FSMDEF_S_HAVE_REMOTE_OFFER,
FSMDEF_S_HAVE_LOCAL_PRANSWER,
FSMDEF_S_HAVE_REMOTE_PRANSWER,
FSMDEF_S_CLOSED,
FSMDEF_S_MAX
} fsmdef_states_t;
const char * fsmdef_state_name (int state);
#endif

View File

@ -13,6 +13,7 @@ extern "C"
{
#include "ccapi_call.h"
#include "ccapi_call_info.h"
#include "fsmdef_states.h"
}
static const char* logTag = "CC_SIPCCCallInfo";
@ -56,6 +57,16 @@ cc_call_state_t CC_SIPCCCallInfo::getCallState()
return CCAPI_CallInfo_getCallState(callinfo_ref);
}
fsmdef_states_t CC_SIPCCCallInfo::getFsmState() const
{
return CCAPI_CallInfo_getFsmState(callinfo_ref);
}
std::string CC_SIPCCCallInfo::fsmStateToString (fsmdef_states_t state) const
{
return fsmdef_state_name(state);
}
std::string CC_SIPCCCallInfo::callStateToString (cc_call_state_t state)
{
std::string statestr = "";

View File

@ -35,6 +35,7 @@ namespace CSF
~CC_SIPCCCallInfo ();
cc_call_state_t getCallState ();
fsmdef_states_t getFsmState () const;
bool getRingerState();
virtual cc_call_attr_t getCallAttr();
@ -42,6 +43,7 @@ namespace CSF
virtual CC_LinePtr getline ();
virtual std::string callStateToString (cc_call_state_t state);
virtual std::string fsmStateToString (fsmdef_states_t state) const;
virtual std::string callEventToString (ccapi_call_event_e callEvent);
virtual cc_call_type_t getCallType();
virtual std::string getCalledPartyName();