diff --git a/media/webrtc/signaling/include/CC_Call.h b/media/webrtc/signaling/include/CC_Call.h index ef9089353083..ea386442089e 100644 --- a/media/webrtc/signaling/include/CC_Call.h +++ b/media/webrtc/signaling/include/CC_Call.h @@ -11,6 +11,7 @@ extern "C" { #include "ccapi_types.h" +#include "fsmdef_states.h" } #if defined(__cplusplus) && __cplusplus >= 201103L @@ -38,6 +39,14 @@ namespace CSF virtual void sendIFrame () = 0; + virtual void getLocalSdp(std::string *sdp) const = 0; + virtual void getRemoteSdp(std::string *sdp) const = 0; + virtual fsmdef_states_t getFsmState () const = 0; + virtual std::string fsmStateToString (fsmdef_states_t state) const = 0; + + virtual void getErrorString(std::string *error) const = 0; + virtual pc_error getError() const = 0; + virtual CC_CallInfoPtr getCallInfo () = 0; virtual std::string toString() = 0; @@ -278,27 +287,27 @@ namespace CSF */ virtual void originateP2PCall (cc_sdp_direction_t video_pref, const std::string & digits, const std::string & ip) = 0; - virtual void createOffer (cc_media_options_t* options, Timecard *) = 0; + virtual pc_error createOffer (cc_media_options_t* options, Timecard *) = 0; - virtual void createAnswer(Timecard *) = 0; + virtual pc_error createAnswer(Timecard *) = 0; - virtual void setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *) = 0; + virtual pc_error setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *) = 0; - virtual void setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *) = 0; + virtual pc_error setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *) = 0; - virtual void setPeerConnection(const std::string& handle) = 0; + virtual pc_error setPeerConnection(const std::string& handle) = 0; - virtual void addStream(cc_media_stream_id_t stream_id, + virtual pc_error addStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) = 0; - virtual void removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) = 0; + virtual pc_error removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) = 0; virtual const std::string& getPeerConnection() const = 0; - virtual void addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *) = 0; + virtual pc_error addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *) = 0; - virtual void foundICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *) = 0; + virtual pc_error foundICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *) = 0; }; } diff --git a/media/webrtc/signaling/include/CC_CallInfo.h b/media/webrtc/signaling/include/CC_CallInfo.h index ce59c0f39c71..7138af0dd54b 100644 --- a/media/webrtc/signaling/include/CC_CallInfo.h +++ b/media/webrtc/signaling/include/CC_CallInfo.h @@ -335,37 +335,5 @@ namespace CSF */ virtual int getVolume() = 0; - /** - get SDP from info object returned from JSEP functions - @param [in] handle - call info handle - @return SDP string - */ - virtual std::string getSDP() = 0; - - /** - get status code - @param [in] handle - call info handle - @return code - */ - virtual cc_int32_t getStatusCode() = 0; - - /** - get media streams - @return media stream table - Note:Ownership of the MediaStreamTable is responsibiliy of - the caller. - */ - virtual MediaStreamTable* getMediaStreams() const = 0; - - /** - Get the current operation's timecard (if any), and assume ownership - of its memory. - */ - virtual Timecard *takeTimecard() = 0; - - /** - Get the latest candidate. - */ - virtual std::string getCandidate() = 0; }; }; diff --git a/media/webrtc/signaling/signaling.gyp b/media/webrtc/signaling/signaling.gyp index e0b2407419db..b1520f55daf3 100644 --- a/media/webrtc/signaling/signaling.gyp +++ b/media/webrtc/signaling/signaling.gyp @@ -50,6 +50,11 @@ './include', './src/sipcc/include', './src/sipcc/cpr/include', + './src/sipcc/core/includes', + './src/sipcc/core/gsm/h', + './src/sipcc/core/common', + './src/sipcc/core/sipstack/h', + './src/sipcc/core/sdp', '../../../xpcom/base', '../../../dom/base', '../../../content/media', diff --git a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp index cf8469823c26..0427d02bc56e 100644 --- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp +++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp @@ -48,9 +48,10 @@ extern "C" { #include "ccsdp.h" -#include "vcm.h" +#include "ccapi.h" #include "cip_mmgr_mediadefinitions.h" #include "cip_Sipcc_CodecMask.h" +#include "peer_connection_types.h" extern void lsm_start_multipart_tone_timer (vcm_tones_t tone, uint32_t delay, @@ -71,13 +72,6 @@ static int vcmEnsureExternalCodec( static const char* logTag = "VcmSipccBinding"; -// Cloned from ccapi.h -typedef enum { - CC_AUDIO_1, - CC_VIDEO_1, - CC_DATACHANNEL_1 -} cc_media_cap_name; - #define SIPSDP_ILBC_MODE20 20 /* static */ @@ -1102,6 +1096,31 @@ int vcmRxStart(cc_mcapid_t mcap_id, } +void vcmOnRemoteStreamAdded(cc_call_handle_t call_handle, + const char* peer_connection_handle, + vcm_media_remote_track_table_t *sipcc_stream_table) { + sipcc::PeerConnectionWrapper wrapper(peer_connection_handle); + + if (wrapper.impl()) { + // TODO: We are copying between structs that are almost identical here. + // Seems kinda wasteful. + MediaStreamTable pc_stream_table; + memset(&pc_stream_table, 0, sizeof(pc_stream_table)); + pc_stream_table.media_stream_id = sipcc_stream_table->media_stream_id; + + // TODO: This was hard-coded to 1 before, is this safe? + pc_stream_table.num_tracks = sipcc_stream_table->num_tracks; + for (size_t i = 0; i < pc_stream_table.num_tracks; ++i) { + pc_stream_table.track[i].media_stream_track_id = + sipcc_stream_table->track[i].media_stream_track_id; + // TODO: This was hard-coded to false before, do we even need this member? + pc_stream_table.track[i].video = sipcc_stream_table->track[i].video; + } + + wrapper.impl()->OnRemoteStreamAdded(pc_stream_table); + } +} + /** * start rx stream * Same concept as vcmRxStart but for ICE/PeerConnection-based flows diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp index 3966c87c5974..200a81b2b4c6 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp @@ -527,15 +527,4 @@ void PeerConnectionCtx::onDeviceEvent(ccapi_device_event_e aDeviceEvent, } } -void PeerConnectionCtx::onCallEvent(ccapi_call_event_e aCallEvent, - CSF::CC_CallPtr aCall, - CSF::CC_CallInfoPtr aInfo) { - CSFLogDebug(logTag, "onCallEvent()"); - PeerConnectionWrapper pc(aCall->getPeerConnection()); - if (!pc.impl()) // This must be an event on a dead PC. Ignore - return; - CSFLogDebug(logTag, "Calling PC"); - pc.impl()->onCallEvent(OnCallEventArgs(aCallEvent, aInfo)); -} - } // namespace sipcc diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h index d6af2b54243c..9ea8c1f15d20 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.h @@ -22,6 +22,7 @@ #include "StaticPtr.h" #include "PeerConnectionImpl.h" #include "mozIGeckoMediaPluginService.h" +#include "nsIRunnable.h" namespace mozilla { class PeerConnectionCtxShutdown; @@ -69,7 +70,7 @@ class PeerConnectionCtx : public CSF::CC_Observer { virtual void onDeviceEvent(ccapi_device_event_e deviceEvent, CSF::CC_DevicePtr device, CSF::CC_DeviceInfoPtr info); virtual void onFeatureEvent(ccapi_device_event_e deviceEvent, CSF::CC_DevicePtr device, CSF::CC_FeatureInfoPtr feature_info) {} virtual void onLineEvent(ccapi_line_event_e lineEvent, CSF::CC_LinePtr line, CSF::CC_LineInfoPtr info) {} - virtual void onCallEvent(ccapi_call_event_e callEvent, CSF::CC_CallPtr call, CSF::CC_CallInfoPtr info); + virtual void onCallEvent(ccapi_call_event_e callEvent, CSF::CC_CallPtr call, CSF::CC_CallInfoPtr info) {} // Create a SIPCC Call CSF::CC_CallPtr createCall(); diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 3630c1c6df10..c6e7134e40e2 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -234,271 +234,6 @@ private: }; } -class PeerConnectionObserverDispatch : public nsRunnable { - -public: - PeerConnectionObserverDispatch(CSF::CC_CallInfoPtr aInfo, - nsRefPtr aPC, - PeerConnectionObserver* aObserver) - : mPC(aPC), - mObserver(aObserver), - mCode(static_cast(aInfo->getStatusCode())), - mReason(aInfo->getStatus()), - mSdpStr(), - mCandidateStr(), - mCallState(aInfo->getCallState()), - mFsmState(aInfo->getFsmState()), - mStateStr(aInfo->callStateToString(mCallState)), - mFsmStateStr(aInfo->fsmStateToString(mFsmState)) { - if (mCallState == REMOTESTREAMADD) { - MediaStreamTable *streams = nullptr; - streams = aInfo->getMediaStreams(); - mRemoteStream = mPC->media()->GetRemoteStream(streams->media_stream_id); - MOZ_ASSERT(mRemoteStream); - cpr_free(streams); - } else if (mCallState == FOUNDICECANDIDATE) { - mCandidateStr = aInfo->getCandidate(); - } else if ((mCallState == CREATEOFFERSUCCESS) || - (mCallState == CREATEANSWERSUCCESS)) { - mSdpStr = aInfo->getSDP(); - } - } - - ~PeerConnectionObserverDispatch(){} - -#ifdef MOZILLA_INTERNAL_API - class TracksAvailableCallback : public DOMMediaStream::OnTracksAvailableCallback - { - public: - TracksAvailableCallback(DOMMediaStream::TrackTypeHints aTrackTypeHints, - nsRefPtr aObserver) - : DOMMediaStream::OnTracksAvailableCallback(aTrackTypeHints) - , mObserver(aObserver) {} - - virtual void NotifyTracksAvailable(DOMMediaStream* aStream) MOZ_OVERRIDE - { - MOZ_ASSERT(NS_IsMainThread()); - - // Start currentTime from the point where this stream was successfully - // returned. - aStream->SetLogicalStreamStartTime(aStream->GetStream()->GetCurrentTime()); - - CSFLogInfo(logTag, "Returning success for OnAddStream()"); - // We are running on main thread here so we shouldn't have a race - // on this callback - - nsTArray> tracks; - aStream->GetTracks(tracks); - for (uint32_t i = 0; i < tracks.Length(); i++) { - JSErrorResult rv; - mObserver->OnAddTrack(*tracks[i], rv); - if (rv.Failed()) { - CSFLogError(logTag, ": OnAddTrack(%d) failed! Error: %d", i, - rv.ErrorCode()); - } - } - JSErrorResult rv; - mObserver->OnAddStream(*aStream, rv); - if (rv.Failed()) { - CSFLogError(logTag, ": OnAddStream() failed! Error: %d", rv.ErrorCode()); - } - } - private: - nsRefPtr mObserver; - }; -#endif - - NS_IMETHOD Run() { - - CSFLogInfo(logTag, "PeerConnectionObserverDispatch processing " - "mCallState = %d (%s), mFsmState = %d (%s)", - mCallState, mStateStr.c_str(), mFsmState, mFsmStateStr.c_str()); - - if (mCallState == SETLOCALDESCERROR || mCallState == SETREMOTEDESCERROR) { - const std::vector &errors = mPC->GetSdpParseErrors(); - std::vector::const_iterator i; - for (i = errors.begin(); i != errors.end(); ++i) { - mReason += " | SDP Parsing Error: " + *i; - } - if (errors.size()) { - mCode = PeerConnectionImpl::kInvalidSessionDescription; - } - mPC->ClearSdpParseErrorMessages(); - } - - if (mReason.length()) { - CSFLogInfo(logTag, "Message contains error: %d: %s", - 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 - int(PCImplSignalingState::SignalingStable); - mPC->SetSignalingState_m(static_cast(mFsmState - offset)); - } else { - CSFLogError(logTag, ": **** UNHANDLED SIGNALING STATE : %d (%s)", - mFsmState, mFsmStateStr.c_str()); - } - - JSErrorResult rv; - - switch (mCallState) { - case CREATEOFFERSUCCESS: - mObserver->OnCreateOfferSuccess(ObString(mSdpStr.c_str()), rv); - break; - - case CREATEANSWERSUCCESS: - mObserver->OnCreateAnswerSuccess(ObString(mSdpStr.c_str()), rv); - break; - - case CREATEOFFERERROR: - mObserver->OnCreateOfferError(mCode, ObString(mReason.c_str()), rv); - break; - - case CREATEANSWERERROR: - mObserver->OnCreateAnswerError(mCode, ObString(mReason.c_str()), rv); - break; - - case SETLOCALDESCSUCCESS: - // TODO: The SDP Parse error list should be copied out and sent up - // to the Javascript layer before being cleared here. Even though - // there was not a failure, it is possible that the SDP parse generated - // warnings. The WebRTC spec does not currently have a mechanism for - // providing non-fatal warnings. - mPC->ClearSdpParseErrorMessages(); - mObserver->OnSetLocalDescriptionSuccess(rv); - mPC->StartTrickle(); - break; - - case SETREMOTEDESCSUCCESS: - // TODO: The SDP Parse error list should be copied out and sent up - // to the Javascript layer before being cleared here. Even though - // there was not a failure, it is possible that the SDP parse generated - // warnings. The WebRTC spec does not currently have a mechanism for - // providing non-fatal warnings. - mPC->ClearSdpParseErrorMessages(); - mObserver->OnSetRemoteDescriptionSuccess(rv); -#ifdef MOZILLA_INTERNAL_API - mPC->startCallTelem(); -#endif - break; - - case SETLOCALDESCERROR: - mObserver->OnSetLocalDescriptionError(mCode, - ObString(mReason.c_str()), rv); - break; - - case SETREMOTEDESCERROR: - mObserver->OnSetRemoteDescriptionError(mCode, - ObString(mReason.c_str()), rv); - break; - - case ADDICECANDIDATE: - mObserver->OnAddIceCandidateSuccess(rv); - break; - - case ADDICECANDIDATEERROR: - mPC->OnAddIceCandidateError(); - mObserver->OnAddIceCandidateError(mCode, ObString(mReason.c_str()), rv); - break; - - case FOUNDICECANDIDATE: - { - size_t end_of_level = mCandidateStr.find('\t'); - if (end_of_level == std::string::npos) { - MOZ_ASSERT(false); - return NS_OK; - } - std::string level = mCandidateStr.substr(0, end_of_level); - if (!level.size()) { - MOZ_ASSERT(false); - return NS_OK; - } - char *endptr; - errno = 0; - unsigned long level_long = - strtoul(level.c_str(), &endptr, 10); - if (errno || *endptr != 0 || level_long > 65535) { - /* Conversion failure */ - MOZ_ASSERT(false); - return NS_OK; - } - size_t end_of_mid = mCandidateStr.find('\t', end_of_level + 1); - if (end_of_mid == std::string::npos) { - MOZ_ASSERT(false); - return NS_OK; - } - - std::string mid = mCandidateStr.substr(end_of_level + 1, - end_of_mid - (end_of_level + 1)); - - std::string candidate = mCandidateStr.substr(end_of_mid + 1); - - CSFLogDebug(logTag, "Passing local candidate to content: %s", - candidate.c_str()); - mObserver->OnIceCandidate(level_long & 0xffff, - ObString(mid.c_str()), - ObString(candidate.c_str()), rv); - } - break; - case REMOTESTREAMADD: - { - DOMMediaStream* stream = nullptr; - - if (!mRemoteStream) { - CSFLogError(logTag, "%s: GetRemoteStream returned NULL", __FUNCTION__); - } else { - stream = mRemoteStream->GetMediaStream(); - } - - if (!stream) { - CSFLogError(logTag, "%s: GetMediaStream returned NULL", __FUNCTION__); - } else { -#ifdef MOZILLA_INTERNAL_API - TracksAvailableCallback* tracksAvailableCallback = - new TracksAvailableCallback(mRemoteStream->mTrackTypeHints, mObserver); - - stream->OnTracksAvailable(tracksAvailableCallback); -#else - mObserver->OnAddStream(stream, rv); -#endif - } - break; - } - - case UPDATELOCALDESC: - /* No action necessary */ - break; - - default: - CSFLogError(logTag, ": **** UNHANDLED CALL STATE : %d (%s)", - mCallState, mStateStr.c_str()); - break; - } - return NS_OK; - } - -private: - nsRefPtr mPC; - nsRefPtr mObserver; - PeerConnectionImpl::Error mCode; - std::string mReason; - std::string mSdpStr; - std::string mCandidateStr; - cc_call_state_t mCallState; - fsmdef_states_t mFsmState; - std::string mStateStr; - std::string mFsmStateStr; - nsRefPtr mRemoteStream; -}; - NS_IMPL_ISUPPORTS0(PeerConnectionImpl) #ifdef MOZILLA_INTERNAL_API @@ -1123,7 +858,9 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel, if (!mHaveDataStream) { // XXX stream_id of 0 might confuse things... - mInternal->mCall->addStream(0, 2, DATA); + if (mInternal->mCall->addStream(0, 2, DATA)) { + return NS_ERROR_FAILURE; + } mHaveDataStream = true; } nsIDOMDataChannel *retval; @@ -1215,30 +952,59 @@ PeerConnectionImpl::CreateOffer(const RTCOfferOptions& aOptions) return CreateOffer(SipccOfferOptions(aOptions)); } +static void DeferredCreateOffer(const std::string& aPcHandle, + const SipccOfferOptions& aOptions) { + PeerConnectionWrapper wrapper(aPcHandle); + + if (wrapper.impl()) { + if (!PeerConnectionCtx::GetInstance()->isReady()) { + MOZ_CRASH("Why is DeferredCreateOffer being executed when the " + "PeerConnectionCtx isn't ready?"); + } + wrapper.impl()->CreateOffer(aOptions); + } +} + // Used by unit tests and the IDL CreateOffer. NS_IMETHODIMP PeerConnectionImpl::CreateOffer(const SipccOfferOptions& aOptions) { PC_AUTO_ENTER_API_CALL(true); - Timecard *tc = mTimeCard; - mTimeCard = nullptr; - STAMP_TIMECARD(tc, "Create Offer"); - - cc_media_options_t* cc_options = aOptions.build(); - NS_ENSURE_TRUE(cc_options, NS_ERROR_UNEXPECTED); + JSErrorResult rv; + nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + if (!pco) { + return NS_OK; + } if (!PeerConnectionCtx::GetInstance()->isReady()) { // Uh oh. We're not ready yet. Enqueue this operation. PeerConnectionCtx::GetInstance()->queueJSEPOperation( - WrapRunnable(mInternal->mCall, - &CSF::CC_Call::createOffer, - cc_options, - tc)); - } else { - mInternal->mCall->createOffer(cc_options, tc); + WrapRunnableNM(DeferredCreateOffer, mHandle, aOptions)); + STAMP_TIMECARD(mTimeCard, "Deferring CreateOffer (not ready)"); + return NS_OK; } + STAMP_TIMECARD(mTimeCard, "Create Offer"); + + cc_media_options_t* cc_options = aOptions.build(); + NS_ENSURE_TRUE(cc_options, NS_ERROR_UNEXPECTED); + + cc_int32_t error = mInternal->mCall->createOffer(cc_options, mTimeCard); + + if (error) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s: pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + pco->OnCreateOfferError(error, ObString(error_string.c_str()), rv); + } else { + std::string sdp; + mInternal->mCall->getLocalSdp(&sdp); + pco->OnCreateOfferSuccess(ObString(sdp.c_str()), rv); + } + + UpdateSignalingState(); return NS_OK; } @@ -1247,14 +1013,43 @@ PeerConnectionImpl::CreateAnswer() { PC_AUTO_ENTER_API_CALL(true); - Timecard *tc = mTimeCard; - mTimeCard = nullptr; - STAMP_TIMECARD(tc, "Create Answer"); + JSErrorResult rv; + nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + if (!pco) { + return NS_OK; + } - mInternal->mCall->createAnswer(tc); + STAMP_TIMECARD(mTimeCard, "Create Answer"); + + cc_int32_t error = mInternal->mCall->createAnswer(mTimeCard); + + if (error) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s: pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + pco->OnCreateAnswerError(error, ObString(error_string.c_str()), rv); + } else { + std::string sdp; + mInternal->mCall->getLocalSdp(&sdp); + pco->OnCreateAnswerSuccess(ObString(sdp.c_str()), rv); + } + + UpdateSignalingState(); return NS_OK; } +static void appendSdpParseErrors(const std::vector& aErrors, + std::string* aErrorString, + cc_int32_t* aErrorCode) { + for (auto i = aErrors.begin(); i != aErrors.end(); ++i) { + *aErrorString += " | SDP Parsing Error: " + *i; + } + if (aErrors.size()) { + *aErrorCode = PeerConnectionImpl::kInvalidSessionDescription; + } +} + NS_IMETHODIMP PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) { @@ -1265,9 +1060,13 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) return NS_ERROR_FAILURE; } - Timecard *tc = mTimeCard; - mTimeCard = nullptr; - STAMP_TIMECARD(tc, "Set Local Description"); + JSErrorResult rv; + nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + if (!pco) { + return NS_OK; + } + + STAMP_TIMECARD(mTimeCard, "Set Local Description"); #ifdef MOZILLA_INTERNAL_API bool isolated = mMedia->AnyLocalStreamHasPeerIdentity(); @@ -1275,11 +1074,43 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) #endif mLocalRequestedSDP = aSDP; - mInternal->mCall->setLocalDescription((cc_jsep_action_t)aAction, - mLocalRequestedSDP, tc); + cc_int32_t error = mInternal->mCall->setLocalDescription( + (cc_jsep_action_t)aAction, + mLocalRequestedSDP, mTimeCard); + + if (error) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + appendSdpParseErrors(mSDPParseErrorMessages, &error_string, &error); + CSFLogError(logTag, "%s: pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + pco->OnSetLocalDescriptionError(error, ObString(error_string.c_str()), rv); + } else { + mInternal->mCall->getLocalSdp(&mLocalSDP); + pco->OnSetLocalDescriptionSuccess(rv); + StartTrickle(); + } + + ClearSdpParseErrorMessages(); + + UpdateSignalingState(); return NS_OK; } +static void DeferredSetRemote(const std::string& aPcHandle, + int32_t aAction, + const std::string& aSdp) { + PeerConnectionWrapper wrapper(aPcHandle); + + if (wrapper.impl()) { + if (!PeerConnectionCtx::GetInstance()->isReady()) { + MOZ_CRASH("Why is DeferredSetRemote being executed when the " + "PeerConnectionCtx isn't ready?"); + } + wrapper.impl()->SetRemoteDescription(aAction, aSdp.c_str()); + } +} + NS_IMETHODIMP PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) { @@ -1290,26 +1121,50 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) return NS_ERROR_FAILURE; } - Timecard *tc = mTimeCard; - mTimeCard = nullptr; - STAMP_TIMECARD(tc, "Set Remote Description"); - - mRemoteRequestedSDP = aSDP; + JSErrorResult rv; + nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + if (!pco) { + return NS_OK; + } if (!PeerConnectionCtx::GetInstance()->isReady()) { // Uh oh. We're not ready yet. Enqueue this operation. (This must be a // remote offer, or else we would not have gotten this far) PeerConnectionCtx::GetInstance()->queueJSEPOperation( - WrapRunnable(mInternal->mCall, - &CSF::CC_Call::setRemoteDescription, - (cc_jsep_action_t)action, - mRemoteRequestedSDP, - tc)); - } else { - mInternal->mCall->setRemoteDescription((cc_jsep_action_t)action, - mRemoteRequestedSDP, tc); + WrapRunnableNM(DeferredSetRemote, + mHandle, + action, + std::string(aSDP))); + STAMP_TIMECARD(mTimeCard, "Deferring SetRemote (not ready)"); + return NS_OK; } + STAMP_TIMECARD(mTimeCard, "Set Remote Description"); + + mRemoteRequestedSDP = aSDP; + + cc_int32_t error = mInternal->mCall->setRemoteDescription( + (cc_jsep_action_t)action, + mRemoteRequestedSDP, mTimeCard); + + if (error) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + appendSdpParseErrors(mSDPParseErrorMessages, &error_string, &error); + CSFLogError(logTag, "%s: pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + pco->OnSetRemoteDescriptionError(error, ObString(error_string.c_str()), rv); + } else { + mInternal->mCall->getRemoteSdp(&mRemoteSDP); + pco->OnSetRemoteDescriptionSuccess(rv); +#ifdef MOZILLA_INTERNAL_API + startCallTelem(); +#endif + } + + ClearSdpParseErrorMessages(); + + UpdateSignalingState(); return NS_OK; } @@ -1372,9 +1227,13 @@ NS_IMETHODIMP PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) { PC_AUTO_ENTER_API_CALL(true); - Timecard *tc = mTimeCard; - mTimeCard = nullptr; - STAMP_TIMECARD(tc, "Add Ice Candidate"); + JSErrorResult rv; + nsRefPtr pco = do_QueryObjectReferent(mPCObserver); + if (!pco) { + return NS_OK; + } + + STAMP_TIMECARD(mTimeCard, "Add Ice Candidate"); #ifdef MOZILLA_INTERNAL_API // When remote candidates are added before our ICE ctx is up and running @@ -1392,10 +1251,103 @@ PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, un } #endif - mInternal->mCall->addICECandidate(aCandidate, aMid, aLevel, tc); + cc_int32_t error = mInternal->mCall->addICECandidate(aCandidate, aMid, aLevel, mTimeCard); + + if (error) { + OnAddIceCandidateError(); + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s: pc = %s, error = %s (note, this should not be " + "a show-stopper, since whether we incorporate " + "candidates into the SDP doesn't really matter since " + "we're full trickle)", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + pco->OnAddIceCandidateError(error, ObString(error_string.c_str()), rv); + } else { + pco->OnAddIceCandidateSuccess(rv); + mInternal->mCall->getRemoteSdp(&mRemoteSDP); + } + + UpdateSignalingState(); return NS_OK; } +#ifdef MOZILLA_INTERNAL_API +class TracksAvailableCallback : public DOMMediaStream::OnTracksAvailableCallback +{ +public: + TracksAvailableCallback(DOMMediaStream::TrackTypeHints aTrackTypeHints, + nsRefPtr aObserver) + : DOMMediaStream::OnTracksAvailableCallback(aTrackTypeHints) + , mObserver(aObserver) {} + + virtual void NotifyTracksAvailable(DOMMediaStream* aStream) MOZ_OVERRIDE + { + MOZ_ASSERT(NS_IsMainThread()); + + // Start currentTime from the point where this stream was successfully + // returned. + aStream->SetLogicalStreamStartTime(aStream->GetStream()->GetCurrentTime()); + + CSFLogInfo(logTag, "Returning success for OnAddStream()"); + // We are running on main thread here so we shouldn't have a race + // on this callback + + nsTArray> tracks; + aStream->GetTracks(tracks); + for (uint32_t i = 0; i < tracks.Length(); i++) { + JSErrorResult rv; + mObserver->OnAddTrack(*tracks[i], rv); + if (rv.Failed()) { + CSFLogError(logTag, ": OnAddTrack(%d) failed! Error: %d", i, + rv.ErrorCode()); + } + } + JSErrorResult rv; + mObserver->OnAddStream(*aStream, rv); + if (rv.Failed()) { + CSFLogError(logTag, ": OnAddStream() failed! Error: %d", rv.ErrorCode()); + } + } +private: + nsRefPtr mObserver; +}; +#endif + +void PeerConnectionImpl::OnRemoteStreamAdded(const MediaStreamTable& aStream) { + DOMMediaStream* stream = nullptr; + + nsRefPtr mRemoteStreamInfo = + media()->GetRemoteStream(aStream.media_stream_id); + MOZ_ASSERT(mRemoteStreamInfo); + + if (!mRemoteStreamInfo) { + CSFLogError(logTag, "%s: GetRemoteStream returned NULL", __FUNCTION__); + } else { + stream = mRemoteStreamInfo->GetMediaStream(); + } + + if (!stream) { + CSFLogError(logTag, "%s: GetMediaStream returned NULL", __FUNCTION__); + } else { + nsRefPtr pco = + do_QueryObjectReferent(mPCObserver); + if (!pco) { + return; + } + +#ifdef MOZILLA_INTERNAL_API + TracksAvailableCallback* tracksAvailableCallback = + new TracksAvailableCallback(mRemoteStreamInfo->mTrackTypeHints, pco); + + stream->OnTracksAvailable(tracksAvailableCallback); +#else + JSErrorResult rv; + pco->OnAddStream(stream, rv); +#endif + } +} + NS_IMETHODIMP PeerConnectionImpl::CloseStreams() { PC_AUTO_ENTER_API_CALL(false); @@ -1527,12 +1479,24 @@ PeerConnectionImpl::AddTrack(MediaStreamTrack& aTrack, // TODO(ekr@rtfm.com): these integers should be the track IDs if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) { - mInternal->mCall->addStream(stream_id, 0, AUDIO); + if (mInternal->mCall->addStream(stream_id, 0, AUDIO)) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s (audio) : pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + return NS_ERROR_FAILURE; + } mNumAudioStreams++; } if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) { - mInternal->mCall->addStream(stream_id, 1, VIDEO); + if (mInternal->mCall->addStream(stream_id, 1, VIDEO)) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s: (video) pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + return NS_ERROR_FAILURE; + } mNumVideoStreams++; } @@ -1574,13 +1538,25 @@ PeerConnectionImpl::RemoveTrack(MediaStreamTrack& aTrack) { } if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) { - mInternal->mCall->removeStream(stream_id, 0, AUDIO); + if (mInternal->mCall->removeStream(stream_id, 0, AUDIO)) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s (audio) : pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + return NS_ERROR_FAILURE; + } MOZ_ASSERT(mNumAudioStreams > 0); mNumAudioStreams--; } if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) { - mInternal->mCall->removeStream(stream_id, 1, VIDEO); + if (mInternal->mCall->removeStream(stream_id, 1, VIDEO)) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s (video) : pc = %s, error = %s", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + return NS_ERROR_FAILURE; + } MOZ_ASSERT(mNumVideoStreams > 0); mNumVideoStreams--; } @@ -1949,61 +1925,6 @@ PeerConnectionImpl::destructorSafeDestroyNSSReference() } #endif -void -PeerConnectionImpl::onCallEvent(const OnCallEventArgs& args) -{ - const ccapi_call_event_e &aCallEvent = args.mCallEvent; - const CSF::CC_CallInfoPtr &aInfo = args.mInfo; - - PC_AUTO_ENTER_API_CALL_NO_CHECK(); - MOZ_ASSERT(aInfo.get()); - - cc_call_state_t event = aInfo->getCallState(); - std::string statestr = aInfo->callStateToString(event); - Timecard *timecard = aInfo->takeTimecard(); - - if (timecard) { - mTimeCard = timecard; - STAMP_TIMECARD(mTimeCard, "Operation Completed"); - } - - if (CCAPI_CALL_EV_CREATED != aCallEvent && CCAPI_CALL_EV_STATE != aCallEvent) { - CSFLogDebug(logTag, "%s: **** CALL HANDLE IS: %s, **** CALL STATE IS: %s", - __FUNCTION__, mHandle.c_str(), statestr.c_str()); - return; - } - - switch (event) { - case SETLOCALDESCSUCCESS: - case UPDATELOCALDESC: - mLocalSDP = aInfo->getSDP(); - break; - - case SETREMOTEDESCSUCCESS: - case ADDICECANDIDATE: - mRemoteSDP = aInfo->getSDP(); - break; - - default: - break; - } - - nsRefPtr pco = do_QueryObjectReferent(mPCObserver); - if (!pco) { - return; - } - - PeerConnectionObserverDispatch* runnable = - new PeerConnectionObserverDispatch(aInfo, this, pco); - - if (mThread) { - mThread->Dispatch(runnable, NS_DISPATCH_NORMAL); - return; - } - runnable->Run(); - delete runnable; -} - void PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState) { @@ -2023,6 +1944,33 @@ PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState) MOZ_ASSERT(!rv.Failed()); } +void +PeerConnectionImpl::UpdateSignalingState() { + fsmdef_states_t state = mInternal->mCall->getFsmState(); + /* + * 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 (state >= FSMDEF_S_STABLE && state <= FSMDEF_S_CLOSED) { + int offset = FSMDEF_S_STABLE - int(PCImplSignalingState::SignalingStable); + PCImplSignalingState newState = + static_cast(state - offset); + if (newState == PCImplSignalingState::SignalingClosed) { + Close(); + } else { + SetSignalingState_m(newState); + } + } else { + CSFLogError(logTag, ": **** UNHANDLED SIGNALING STATE : %d (%s)", + state, + mInternal->mCall->fsmStateToString(state).c_str()); + } +} + bool PeerConnectionImpl::IsClosed() const { @@ -2146,7 +2094,7 @@ PeerConnectionImpl::CandidateReady_m(const std::string& candidate, mCandidateBuffer.push_back(std::make_pair(candidate, level)); } else { if (level <= mNumMlines) { - mInternal->mCall->foundICECandidate(candidate, "", level, nullptr); + FoundIceCandidate(candidate, level); } } @@ -2157,7 +2105,7 @@ void PeerConnectionImpl::StartTrickle() { for (auto it = mCandidateBuffer.begin(); it != mCandidateBuffer.end(); ++it) { if (it->second <= mNumMlines) { - mInternal->mCall->foundICECandidate(it->first, "", it->second, nullptr); + FoundIceCandidate(it->first, it->second); } } @@ -2165,29 +2113,72 @@ PeerConnectionImpl::StartTrickle() { // end-of-candidates event in IceGatheringStateChange_m. if (mIceGatheringState == PCImplIceGatheringState::Complete && !mCandidateBuffer.empty()) { - SendEndOfCandidates(); + SendLocalIceCandidateToContent(0, "", ""); } mCandidateBuffer.clear(); } +void PeerConnectionImpl::FoundIceCandidate(const std::string& candidate, + uint16_t level) { + // TODO: What about mid? Is this something that we will choose, or will + // SIPCC choose for us? If the latter, we'll need to make it an outparam or + // something. + std::string mid; + + cc_int32_t error = mInternal->mCall->foundICECandidate(candidate, + mid, + level, + nullptr); + + if (error) { + std::string error_string; + mInternal->mCall->getErrorString(&error_string); + CSFLogError(logTag, "%s: pc = %s, error = %s (note, this should not be " + "a show-stopper, since whether we incorporate " + "candidates into the SDP doesn't really matter since " + "we're full trickle)", + __FUNCTION__, mHandle.c_str(), error_string.c_str()); + } else { + CSFLogDebug(logTag, "Passing local candidate to content: %s", + candidate.c_str()); + mInternal->mCall->getLocalSdp(&mLocalSDP); + SendLocalIceCandidateToContent(level, mid, candidate); + } + UpdateSignalingState(); +} + static void -SendEndOfCandidatesImpl(nsWeakPtr weakPCObserver) { +SendLocalIceCandidateToContentImpl(nsWeakPtr weakPCObserver, + uint16_t level, + const std::string& mid, + const std::string& candidate) { nsRefPtr pco = do_QueryObjectReferent(weakPCObserver); if (!pco) { return; } JSErrorResult rv; - pco->OnIceCandidate(0, ObString(""), ObString(""), rv); + pco->OnIceCandidate(level, + ObString(mid.c_str()), + ObString(candidate.c_str()), + rv); } void -PeerConnectionImpl::SendEndOfCandidates() { - // We dispatch this because real candidates do a dispatch in - // PeerConnectionImpl::onCallEvent, and we don't want this to jump ahead. +PeerConnectionImpl::SendLocalIceCandidateToContent( + uint16_t level, + const std::string& mid, + const std::string& candidate) { + // We dispatch this because OnSetLocalDescriptionSuccess does a setTimeout(0) + // to unwind the stack, but the event handlers don't. We need to ensure that + // the candidates do not skip ahead of the callback. NS_DispatchToMainThread( - WrapRunnableNM(&SendEndOfCandidatesImpl, mPCObserver), + WrapRunnableNM(&SendLocalIceCandidateToContentImpl, + mPCObserver, + level, + mid, + candidate), NS_DISPATCH_NORMAL); } @@ -2329,7 +2320,7 @@ PeerConnectionImpl::IceGatheringStateChange_m(PCImplIceGatheringState aState) if (mIceGatheringState == PCImplIceGatheringState::Complete && mCandidateBuffer.empty()) { - SendEndOfCandidates(); + SendLocalIceCandidateToContent(0, "", ""); } return NS_OK; diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h index 31c5f89ad72c..ff5b8322735d 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h @@ -109,6 +109,8 @@ void func (__VA_ARGS__, rv) NS_IMETHODIMP func(__VA_ARGS__, resulttype **result); \ already_AddRefed func (__VA_ARGS__, rv) +struct MediaStreamTable; + namespace sipcc { using mozilla::dom::PeerConnectionObserver; @@ -128,7 +130,6 @@ using mozilla::PeerIdentity; class PeerConnectionWrapper; class PeerConnectionMedia; class RemoteSourceStreamInfo; -class OnCallEventArgs; class IceConfiguration { @@ -244,9 +245,6 @@ public: nsresult CreateRemoteSourceStreamInfo(nsRefPtr* aInfo); - // Implementation of the only observer we need - void onCallEvent(const OnCallEventArgs &args); - // DataConnection observers void NotifyDataChannel(already_AddRefed aChannel); @@ -363,6 +361,8 @@ public: NS_ConvertUTF16toUTF8(aMid).get(), aLevel); } + void OnRemoteStreamAdded(const MediaStreamTable& aStream); + NS_IMETHODIMP CloseStreams(); void CloseStreams(ErrorResult &rv) @@ -567,6 +567,9 @@ public: // Sets the RTC Signaling State void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState); + // Updates the RTC signaling state based on the sipcc state + void UpdateSignalingState(); + bool IsClosed() const; // called when DTLS connects; we only need this once nsresult SetDtlsConnected(bool aPrivacyRequested); @@ -634,7 +637,10 @@ private: void CandidateReady_s(const std::string& candidate, uint16_t level); nsresult CandidateReady_m(const std::string& candidate, uint16_t level); - void SendEndOfCandidates(); + void SendLocalIceCandidateToContent(uint16_t level, + const std::string& mid, + const std::string& candidate); + void FoundIceCandidate(const std::string& candidate, uint16_t level); NS_IMETHOD FingerprintSplitHelper( std::string& fingerprint, size_t& spaceIdx) const; diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/CCProvider.h b/media/webrtc/signaling/src/sipcc/core/ccapp/CCProvider.h index 0a24f582612d..d7ba0e898b22 100755 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/CCProvider.h +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/CCProvider.h @@ -103,12 +103,6 @@ typedef struct cc_call_info_t_{ cc_boolean audio_mute; cc_boolean video_mute; cc_call_conference_Info_t call_conference; - cc_string_t sdp; - unsigned int media_stream_track_id; - unsigned int media_stream_id; - cc_media_options_t* cc_options; - string_t candidate; - Timecard * timecard; } session_data_t; typedef enum { diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/cc_call_feature.c b/media/webrtc/signaling/src/sipcc/core/ccapp/cc_call_feature.c index f5a2108933d6..01464d47831d 100644 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/cc_call_feature.c +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/cc_call_feature.c @@ -95,79 +95,6 @@ cc_return_t cc_invokeFeature(cc_call_handle_t call_handle, group_cc_feature_t fe return CC_SUCCESS; } -/** - * Invoke a call feature. - */ -cc_return_t cc_invokeFeatureSDPMode(cc_call_handle_t call_handle, - group_cc_feature_t featureId, - cc_jsep_action_t action, - cc_media_stream_id_t stream_id, - cc_media_track_id_t track_id, - cc_media_type_t media_type, - uint16_t level, - cc_media_options_t *options, - string_t data, - string_t data1, - Timecard *tc) { - session_feature_t callFeature; - unsigned int session_id = 0; - callFeature.session_id = (SESSIONTYPE_CALLCONTROL << CC_SID_TYPE_SHIFT) + call_handle; - callFeature.featureID = featureId; - callFeature.featData.ccData.action = action; - callFeature.featData.ccData.media_type = media_type; - callFeature.featData.ccData.stream_id = stream_id; - callFeature.featData.ccData.track_id = track_id; - callFeature.featData.ccData.level = level; - callFeature.featData.ccData.options = options; - callFeature.featData.ccData.timecard = tc; - - CCAPP_DEBUG(DEB_F_PREFIX"cc_invokeFeatureSDPMode:sid=%d, line=%d, cid=%d, fid=%d, data=%s", - DEB_F_PREFIX_ARGS("cc_call_feature", "cc_invokeFeatureSDPMode"), - callFeature.session_id, - GET_LINE_ID(call_handle), - GET_CALL_ID(call_handle), - featureId, - ((featureId == CC_FEATURE_KEYPRESS) ? "...": data)); - - switch (featureId) { - case CC_FEATURE_KEYPRESS: - case CC_FEATURE_DIALSTR: - case CC_FEATURE_SPEEDDIAL: - case CC_FEATURE_BLIND_XFER_WITH_DIALSTRING: - case CC_FEATURE_END_CALL: - case CC_FEATURE_B2BCONF: - case CC_FEATURE_CONF: - case CC_FEATURE_XFER: - case CC_FEATURE_HOLD: - case CC_FEATURE_SETLOCALDESC: - case CC_FEATURE_SETREMOTEDESC: - case CC_FEATURE_SETPEERCONNECTION: - callFeature.featData.ccData.info = strlib_malloc(data, strlen(data)); - callFeature.featData.ccData.info1 = NULL; - break; - case CC_FEATURE_ADDICECANDIDATE: - callFeature.featData.ccData.info = strlib_malloc(data, strlen(data)); - callFeature.featData.ccData.info1 = strlib_malloc(data1, strlen(data1)); - break; - case CC_FEATURE_FOUNDICECANDIDATE: - callFeature.featData.ccData.info = strlib_malloc(data, strlen(data)); - callFeature.featData.ccData.info1 = NULL; - break; - - default: - callFeature.featData.ccData.info = NULL; - callFeature.featData.ccData.info1 = NULL; - break; - } - - if (ccappTaskPostMsg(CCAPP_INVOKE_FEATURE, &callFeature, sizeof(session_feature_t), CCAPP_CCPROVIER) == CPR_FAILURE) { - CCAPP_DEBUG(DEB_F_PREFIX"ccappTaskSendMsg failed", - DEB_F_PREFIX_ARGS("cc_call_feature", "cc_invokeFeatureSDPMode")); - return CC_FAILURE; - } - return CC_SUCCESS; -} - /***********************************Basic Call Feature Control Methods************************************ * This section defines all the call related methods that an upper layer can use to control * a call in progress. @@ -291,100 +218,6 @@ cc_return_t CC_CallFeature_dial(cc_call_handle_t call_handle, cc_sdp_direction_t return cc_invokeFeature(call_handle, CC_FEATURE_DIALSTR, video_pref, numbers); } -cc_return_t CC_CallFeature_CreateOffer(cc_call_handle_t call_handle, - cc_media_options_t *options, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_CREATEOFFER, JSEP_NO_ACTION, - 0, 0, NO_STREAM, 0, options, NULL, NULL, tc); -} - -cc_return_t CC_CallFeature_CreateAnswer(cc_call_handle_t call_handle, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_CREATEANSWER, JSEP_NO_ACTION, - 0, 0, NO_STREAM, 0, NULL, NULL, NULL, tc); -} - -cc_return_t CC_CallFeature_SetLocalDescription(cc_call_handle_t call_handle, - cc_jsep_action_t action, - string_t sdp, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_SETLOCALDESC, action, - 0, 0, NO_STREAM, 0, NULL, sdp, NULL, tc); -} - -cc_return_t CC_CallFeature_SetRemoteDescription(cc_call_handle_t call_handle, - cc_jsep_action_t action, - string_t sdp, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_SETREMOTEDESC, action, - 0, 0, NO_STREAM, 0, NULL, sdp, NULL, tc); -} - -cc_return_t CC_CallFeature_SetPeerConnection(cc_call_handle_t call_handle,cc_peerconnection_t pc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_SETPEERCONNECTION, JSEP_NO_ACTION, - 0, 0, NO_STREAM, 0, NULL, pc, NULL, NULL); -} - -cc_return_t CC_CallFeature_AddStream(cc_call_handle_t call_handle, - cc_media_stream_id_t stream_id, - cc_media_track_id_t track_id, - cc_media_type_t media_type) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_ADDSTREAM, JSEP_NO_ACTION, - stream_id, track_id, media_type, 0, NULL, NULL, NULL, NULL); -} - -cc_return_t CC_CallFeature_RemoveStream(cc_call_handle_t call_handle, cc_media_stream_id_t stream_id, - cc_media_track_id_t track_id, cc_media_type_t media_type) { - - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_REMOVESTREAM, JSEP_NO_ACTION, - stream_id, track_id, media_type, 0, NULL, NULL, NULL, NULL); -} - -cc_return_t CC_CallFeature_AddICECandidate(cc_call_handle_t call_handle, - const char* candidate, - const char *mid, - cc_level_t level, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_ADDICECANDIDATE, JSEP_NO_ACTION, - 0, 0, NO_STREAM, (uint16_t)level, NULL, candidate, mid, tc); -} - -cc_return_t CC_CallFeature_FoundICECandidate(cc_call_handle_t call_handle, - const char* candidate, - const char *mid, - cc_level_t level, - Timecard *tc) { - CCAPP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(SIP_CC_PROV, GET_CALL_ID(call_handle), - GET_LINE_ID(call_handle), __FUNCTION__)); - - return cc_invokeFeatureSDPMode(call_handle, CC_FEATURE_FOUNDICECANDIDATE, JSEP_NO_ACTION, - 0, 0, NO_STREAM, (uint16_t)level, NULL, candidate, mid, tc); -} - /** * Initiate a speed dial. * @param call handle diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call.c b/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call.c index aa01b70c31d5..15251aa9da69 100644 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call.c +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call.c @@ -91,62 +91,6 @@ cc_return_t CCAPI_Call_originateCall(cc_call_handle_t handle, cc_sdp_direction_t return CC_CallFeature_dial(handle, video_pref, digits); } -cc_return_t CCAPI_CreateOffer(cc_call_handle_t handle, - cc_media_options_t *options, - Timecard *tc) { - return CC_CallFeature_CreateOffer(handle, options, tc); -} - -cc_return_t CCAPI_CreateAnswer(cc_call_handle_t handle, - Timecard *tc) { - return CC_CallFeature_CreateAnswer(handle, tc); -} - -cc_return_t CCAPI_SetLocalDescription(cc_call_handle_t handle, - cc_jsep_action_t action, - cc_string_t sdp, - Timecard *tc) { - return CC_CallFeature_SetLocalDescription(handle, action, sdp, tc); -} - -cc_return_t CCAPI_SetRemoteDescription(cc_call_handle_t handle, - cc_jsep_action_t action, - cc_string_t sdp, - Timecard *tc) { - return CC_CallFeature_SetRemoteDescription(handle, action, sdp, tc); -} - -cc_return_t CCAPI_SetPeerConnection(cc_call_handle_t handle, cc_peerconnection_t pc) { - return CC_CallFeature_SetPeerConnection(handle, pc); -} - -cc_return_t CCAPI_AddStream(cc_call_handle_t handle, - cc_media_stream_id_t stream_id, - cc_media_track_id_t track_id, - cc_media_type_t media_type) { - return CC_CallFeature_AddStream(handle, stream_id, track_id, media_type); -} - -cc_return_t CCAPI_RemoveStream(cc_call_handle_t handle, cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) { - return CC_CallFeature_RemoveStream(handle, stream_id, track_id, media_type); -} - -cc_return_t CCAPI_AddICECandidate(cc_call_handle_t handle, - cc_string_t candidate, - cc_string_t mid, - cc_level_t level, - Timecard *tc) { - return CC_CallFeature_AddICECandidate(handle, candidate, mid, level, tc); -} - -cc_return_t CCAPI_FoundICECandidate(cc_call_handle_t handle, - cc_string_t candidate, - cc_string_t mid, - cc_level_t level, - Timecard *tc) { - return CC_CallFeature_FoundICECandidate(handle, candidate, mid, level, tc); -} - /** * Dial digits on the call * @param [in] handle - call handle diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call_info.c b/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call_info.c index 1a3044be1187..256c8538463e 100644 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call_info.c +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/ccapi_call_info.c @@ -729,113 +729,4 @@ cc_boolean CCAPI_CallInfo_isVideoMuted (cc_callinfo_ref_t handle){ return FALSE; } -/** - * get SDP for CreateOffer\Create answer success callback - * @param handle - call handle - * @return sdp - */ -cc_string_t CCAPI_CallInfo_getSDP(cc_callinfo_ref_t handle){ - static const char *fname="CCAPI_CallInfo_getSDP"; - session_data_t *data = (session_data_t *)handle; - CCAPP_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); - if (data != NULL){ - CCAPP_DEBUG(DEB_F_PREFIX"returned %s", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), data->sdp); - return data->sdp; - } - - return strlib_empty(); -} - -/** - * get candidate for trickle ICE - * @param handle - call handle - * @return sdp - */ -cc_string_t CCAPI_CallInfo_getCandidate(cc_callinfo_ref_t handle){ - static const char *fname="CCAPI_CallInfo_getCandiate"; - session_data_t *data = (session_data_t *)handle; - CCAPP_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); - - if (data){ - CCAPP_DEBUG(DEB_F_PREFIX"returned %s", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), data->candidate); - return data->candidate; - } - - return strlib_empty(); -} - -/** - * get status code from internal JSEP functions - * @param handle - call handle - * @return status code - */ -cc_int32_t CCAPI_CallInfo_getStatusCode(cc_callinfo_ref_t handle){ - static const char *fname="CCAPI_CallInfo_getStatusCode"; - session_data_t *data = (session_data_t *)handle; - CCAPP_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); - - if ( data != NULL){ - CCAPP_DEBUG(DEB_F_PREFIX"returned %d", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), data->cause); - return data->cause; - } - - return CC_CAUSE_NORMAL; -} - - -/** - * get media stream table - * @param handle - call handle - * @return status MediaStreamTable - */ -MediaStreamTable* CCAPI_CallInfo_getMediaStreams(cc_callinfo_ref_t handle) { - static const char *fname="CCAPI_CallInfo_getMediaStreams"; - session_data_t *data = (session_data_t *)handle; - MediaTrack track; - MediaStreamTable* table = cpr_malloc(sizeof(MediaStreamTable)); - if (!table) - return NULL; - - CCAPP_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname)); - - if (data != NULL) { - table->media_stream_id = data->media_stream_id; - table->num_tracks = 1; /* this will change when we have multiple tracks per stream */ - track.media_stream_track_id = data->media_stream_track_id; - track.video = FALSE; - table->track[0] = track; - - /* - * Partly implemented multi-track handling - cc_table = data->media_tracks; - table->stream_id = (unsigned int)cc_table->stream_id; - table->num_tracks = (unsigned int)cc_table->num_tracks; - track.track_id = cc_table->track[0].ref_id; - table->track[0] = track; - */ - return table; - } - - return table; -} - -/** - * Assume ownership of timecard - * @param handle - call handle - * @return Timecard pointer - */ -Timecard* CCAPI_CallInfo_takeTimecard(cc_callinfo_ref_t handle) { - session_data_t *data = (session_data_t *)handle; - Timecard *timecard = NULL; - - CCAPP_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(SIP_CC_PROV, - __FUNCTION__)); - - if (data) { - timecard = data->timecard; - data->timecard = NULL; - } - - return timecard; -} diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c b/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c index 693931296d9d..06b738069c8a 100755 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c @@ -661,61 +661,6 @@ processSessionEvent (line_t line_id, callid_t call_id, unsigned int event, sdp_d case CC_FEATURE_BKSPACE: dp_int_update_keypress(line_id, call_id, BKSP_KEY); break; - case CC_FEATURE_CREATEOFFER: - STAMP_TIMECARD(timecard, "Processing create offer event"); - featdata.session.options = ccData.options; - cc_createoffer (CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_CREATEOFFER, &featdata, timecard); - break; - case CC_FEATURE_CREATEANSWER: - STAMP_TIMECARD(timecard, "Processing create answer event"); - featdata.session.options = ccData.options; - cc_createanswer (CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_CREATEANSWER, data, &featdata, timecard); - break; - case CC_FEATURE_SETLOCALDESC: - STAMP_TIMECARD(timecard, "Processing set local event"); - cc_setlocaldesc (CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_SETLOCALDESC, ccData.action, data, &featdata, timecard); - break; - case CC_FEATURE_SETREMOTEDESC: - STAMP_TIMECARD(timecard, "Processing set remote event"); - cc_setremotedesc (CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_SETREMOTEDESC, ccData.action, data, &featdata, timecard); - break; - case CC_FEATURE_SETPEERCONNECTION: - PR_ASSERT(strlen(data) < PC_HANDLE_SIZE); - if (strlen(data) >= PC_HANDLE_SIZE) - return; - - sstrncpy(featdata.pc.pc_handle, data, sizeof(featdata.pc.pc_handle)); - - cc_int_feature2(CC_MSG_SETPEERCONNECTION, CC_SRC_UI, CC_SRC_GSM, - call_id, (line_t)instance, - CC_FEATURE_SETPEERCONNECTION, &featdata, NULL); - break; - case CC_FEATURE_ADDSTREAM: - featdata.track.stream_id = ccData.stream_id; - featdata.track.track_id = ccData.track_id; - featdata.track.media_type = ccData.media_type; - cc_int_feature2(CC_MSG_ADDSTREAM, CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_ADDSTREAM, &featdata, timecard); - break; - case CC_FEATURE_REMOVESTREAM: - featdata.track.stream_id = ccData.stream_id; - featdata.track.track_id = ccData.track_id; - featdata.track.media_type = ccData.media_type; - cc_int_feature2(CC_MSG_REMOVESTREAM, CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_REMOVESTREAM, &featdata, timecard); - break; - case CC_FEATURE_ADDICECANDIDATE: - STAMP_TIMECARD(timecard, "Processing add candidate event"); - featdata.candidate.level = ccData.level; - sstrncpy(featdata.candidate.candidate, data, sizeof(featdata.candidate.candidate)-1); - sstrncpy(featdata.candidate.mid, data1, sizeof(featdata.candidate.mid)-1); - cc_int_feature2(CC_MSG_ADDCANDIDATE, CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_ADDICECANDIDATE, &featdata, timecard); - break; - case CC_FEATURE_FOUNDICECANDIDATE: - STAMP_TIMECARD(timecard, "Processing found candidate event"); - featdata.candidate.level = ccData.level; - sstrncpy(featdata.candidate.candidate, data, sizeof(featdata.candidate.candidate)-1); - sstrncpy(featdata.candidate.mid, data1, sizeof(featdata.candidate.mid)-1); - cc_int_feature2(CC_MSG_FOUNDCANDIDATE, CC_SRC_UI, CC_SRC_GSM, call_id, (line_t)instance, CC_FEATURE_FOUNDICECANDIDATE, &featdata, timecard); - break; case CC_FEATURE_DIALSTR: if (CheckAndGetAvailableLine(&line_id, &call_id) == TRUE) { getDigits(data, digits, sizeof(digits)); @@ -1068,12 +1013,6 @@ session_data_t * getDeepCopyOfSessionData(session_data_t *data) newData->plcd_name = strlib_copy(data->plcd_name); newData->plcd_number = strlib_copy(data->plcd_number); newData->status = strlib_copy(data->status); - newData->sdp = strlib_copy(data->sdp); - newData->candidate = data->candidate ? - strlib_copy(data->candidate) : strlib_empty(); - /* The timecard can have only one owner */ - newData->timecard = data->timecard; - data->timecard = NULL; calllogger_copy_call_log(&newData->call_log, &data->call_log); } else { @@ -1093,9 +1032,6 @@ session_data_t * getDeepCopyOfSessionData(session_data_t *data) newData->plcd_name = strlib_empty(); newData->plcd_number = strlib_empty(); newData->status = strlib_empty(); - newData->sdp = strlib_empty(); - newData->candidate = strlib_empty(); - newData->timecard = NULL; calllogger_init_call_log(&newData->call_log); } @@ -1140,12 +1076,6 @@ void cleanSessionData(session_data_t *data) data->plcd_number = strlib_empty(); strlib_free(data->status); data->status = strlib_empty(); - strlib_free(data->sdp); - data->sdp = strlib_empty(); - if (data->candidate) - strlib_free(data->candidate); - data->candidate = strlib_empty(); - data->timecard = NULL; calllogger_free_call_log(&data->call_log); } } @@ -1410,15 +1340,7 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) if ( sessUpd->eventID == CALL_INFORMATION || sessUpd->eventID == CALL_STATE || - sessUpd->eventID == CALL_NEWCALL || - sessUpd->eventID == CREATE_OFFER || - sessUpd->eventID == CREATE_ANSWER || - sessUpd->eventID == SET_LOCAL_DESC || - sessUpd->eventID == SET_REMOTE_DESC || - sessUpd->eventID == UPDATE_LOCAL_DESC || - sessUpd->eventID == UPDATE_REMOTE_DESC || - sessUpd->eventID == ICE_CANDIDATE_ADD || - sessUpd->eventID == REMOTE_STREAM_ADD ) { + sessUpd->eventID == CALL_NEWCALL ) { CCAPP_DEBUG(DEB_F_PREFIX"CALL_SESSION_CREATED for session id 0x%x event is 0x%x", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->sessionID, @@ -1455,16 +1377,7 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) 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 || - sessUpd->eventID == CREATE_ANSWER || - sessUpd->eventID == SET_LOCAL_DESC || - sessUpd->eventID == SET_REMOTE_DESC || - sessUpd->eventID == UPDATE_LOCAL_DESC || - sessUpd->eventID == UPDATE_REMOTE_DESC || - sessUpd->eventID == ICE_CANDIDATE_ADD || - sessUpd->eventID == ICE_CANDIDATE_FOUND || - sessUpd->eventID == REMOTE_STREAM_ADD ) { + if (sessUpd->eventID == CALL_NEWCALL ) { data->attr = sessUpd->update.ccSessionUpd.data.state_data.attr; data->inst = sessUpd->update.ccSessionUpd.data.state_data.inst; } @@ -1484,37 +1397,8 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) data->gci[0] = 0; data->vid_dir = SDP_DIRECTION_INACTIVE; data->callref = 0; - data->sdp = strlib_empty(); - data->timecard = NULL; calllogger_init_call_log(&data->call_log); - switch (sessUpd->eventID) { - case CREATE_OFFER: - case CREATE_ANSWER: - case SET_LOCAL_DESC: - case SET_REMOTE_DESC: - case UPDATE_LOCAL_DESC: - case UPDATE_REMOTE_DESC: - case ICE_CANDIDATE_ADD: - data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp; - data->timecard = - sessUpd->update.ccSessionUpd.data.state_data.timecard; - /* Fall through to the next case... */ - case REMOTE_STREAM_ADD: - data->cause = - sessUpd->update.ccSessionUpd.data.state_data.cause; - 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); - data->status = - sessUpd->update.ccSessionUpd.data.state_data.reason_text; - break; - default: - break; - } - /* * If phone was idle, we not going to active state * send notification to resetmanager that we @@ -1841,36 +1725,6 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) ccsnap_gen_callEvent(CCAPI_CALL_EV_MEDIA_INTERFACE_UPDATE_FAIL, CREATE_CALL_HANDLE_FROM_SESSION_ID(sessUpd->sessionID)); break; - case CREATE_OFFER: - case CREATE_ANSWER: - case SET_LOCAL_DESC: - case SET_REMOTE_DESC: - case UPDATE_LOCAL_DESC: - case UPDATE_REMOTE_DESC: - case ICE_CANDIDATE_ADD: - case ICE_CANDIDATE_FOUND: - if (sessUpd->update.ccSessionUpd.data.state_data.extra) { - if (sessUpd->eventID == ICE_CANDIDATE_FOUND) { - strlib_free(data->candidate); - data->candidate = sessUpd->update.ccSessionUpd.data.state_data.extra; - } - } - strlib_free(data->sdp); - data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp; - /* Fall through to the next case... */ - case REMOTE_STREAM_ADD: - data->timecard = sessUpd->update.ccSessionUpd.data.state_data.timecard; - 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); - data->status = sessUpd->update.ccSessionUpd.data.state_data.reason_text; - capset_get_allowed_features(gCCApp.mode, data->state, data->allowed_features); - ccsnap_gen_callEvent(CCAPI_CALL_EV_STATE, CREATE_CALL_HANDLE_FROM_SESSION_ID(data->sess_id)); - break; default: DEF_DEBUG(DEB_F_PREFIX"Unknown event, id = %d", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->eventID); diff --git a/media/webrtc/signaling/src/sipcc/core/common/ui.c b/media/webrtc/signaling/src/sipcc/core/common/ui.c index f8ae568671d1..b85a11b6255e 100755 --- a/media/webrtc/signaling/src/sipcc/core/common/ui.c +++ b/media/webrtc/signaling/src/sipcc/core/common/ui.c @@ -1544,305 +1544,4 @@ ui_control_feature (line_t line_id, callid_t call_id, // do nothing. } -/* - * 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, - fsmdef_states_t new_state, - line_t nLine, - callid_t nCallId, - uint16_t call_instance_id, - string_t sdp, - string_t extra, - Timecard *timecard, - pc_error error, - const char *format, - va_list args) -{ - flex_string fs; - session_update_t msg; - memset( &msg, 0, sizeof(session_update_t)); - if (nCallId == CC_NO_CALL_ID) { - /* no operation when no call ID */ - return; - } - - STAMP_TIMECARD(timecard, "Posting message to PC"); - - msg.sessionID = createSessionId(nLine, nCallId); - - 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; - msg.update.ccSessionUpd.data.state_data.extra = extra; - msg.update.ccSessionUpd.data.state_data.cause = error; - msg.update.ccSessionUpd.data.state_data.timecard = timecard; - - if (format) { - flex_string_init(&fs); - flex_string_vsprintf(&fs, format, args); - msg.update.ccSessionUpd.data.state_data.reason_text = - strlib_malloc(fs.buffer, -1); - flex_string_free(&fs); - } else { - msg.update.ccSessionUpd.data.state_data.reason_text = strlib_empty(); - } - - if ( ccappTaskPostMsg(CCAPP_SESSION_UPDATE, &msg, sizeof(session_update_t), - CCAPP_CCPROVIER) != CPR_SUCCESS ) { - CCAPP_ERROR(CCAPP_F_PREFIX"failed to send CALL_STATE(%d) msg", - __FUNCTION__, event); - } - - return; -} - -/** - * Send data from createOffer to the UI, can send success with SDP string - * or can send error - * - * @return none - */ -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, - Timecard *timecard, - 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_OFFER, event, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); - - return; -} - -/** - * Send data from createAnswer to the UI, can send success with SDP string - * or can send error - * - * @return none - */ -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, - Timecard *timecard, - 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, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); - - return; -} - -/** - * Send data from setLocalDescription to the UI - * - * @return none - */ - -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, - Timecard *timecard, - 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, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); - - return; -} - -/** - * Send data from setRemoteDescription to the UI - * - * @return none - */ - -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, - Timecard *timecard, - 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_REMOTE_DESC, event, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); - - return; -} - -/** - * Let PeerConnection know about an updated local session description - * - * @return none - */ - -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, - Timecard *timecard, - 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(UPDATE_LOCAL_DESC, event, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); - - return; -} - -/** - * Send data from addIceCandidate to the UI - * - * @return none - */ - -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, - Timecard *timecard, - 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, new_state, nLine, nCallID, - call_instance_id, sdp, NULL, timecard, error, format, ap); - va_end(ap); -} - - -/** - * Send data from foundIceCandidate to the UI - * - * @return none - */ - -void ui_ice_candidate_found(call_events event, - fsmdef_states_t new_state, - line_t nLine, - callid_t nCallID, - uint16_t call_instance_id, - string_t sdp, - string_t candidate, - Timecard *timecard, - 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_FOUND, event, new_state, nLine, nCallID, - call_instance_id, sdp, candidate, timecard, error, format, ap); - va_end(ap); -} - -/** - * Send Remote Stream data to the UI - * - * @return none - */ - -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; - fsmdef_dcb_t *dcb = fsmdef_get_dcb_by_call_id(nCallID); - memset( &msg, 0, sizeof(session_update_t)); - - if (nCallID == CC_NO_CALL_ID || dcb == NULL) { - /* no operation when no call ID */ - return; - } - - 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); - - - msg.sessionID = createSessionId(nLine, nCallID); - - 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; - msg.update.ccSessionUpd.data.state_data.media_stream_id = (unsigned int)media_track.media_stream_id; - msg.update.ccSessionUpd.data.state_data.cause = PC_NO_ERROR; - msg.update.ccSessionUpd.data.state_data.timecard = NULL; - - if ( ccappTaskPostMsg(CCAPP_SESSION_UPDATE, &msg, sizeof(session_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { - CCAPP_ERROR(CCAPP_F_PREFIX"failed to send CALL_STATE(%d) msg", __FUNCTION__, event); - } - - return; -} diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c b/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c index 86ffd9482e29..b703973fb38a 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/ccapi.c @@ -1173,132 +1173,6 @@ cc_int_feature2 (cc_msgs_t msg_id, cc_srcs_t src_id, cc_srcs_t dst_id, return; } -/* - * Helper function for the next six functions that populates and sends - * a feature message - * - */ -static void send_message_helper( - cc_msgs_t msg_id, - cc_srcs_t src_id, - cc_srcs_t dst_id, - callid_t call_id, - line_t line, - cc_features_t feature_id, - cc_feature_data_t *data, - string_t sdp, - cc_jsep_action_t action, - Timecard *timecard) -{ - cc_feature_t *pmsg; - cc_msgbody_info_t *msg_body; - - pmsg = (cc_feature_t *) cc_get_msg_buf(sizeof(*pmsg)); - if (!pmsg) { - GSM_ERR_MSG("%s: no buffer available for feat=%s", __FUNCTION__, - cc_feature_name(feature_id)); - return; - } - - pmsg->msg_id = msg_id; - pmsg->src_id = src_id; - pmsg->call_id = call_id; - pmsg->line = line; - pmsg->feature_id = feature_id; - pmsg->data_valid = (data == NULL) ? (FALSE) : (TRUE); - pmsg->timecard = timecard; - - if (msg_id == CC_MSG_SETLOCALDESC || msg_id == CC_MSG_SETREMOTEDESC) { - pmsg->action = action; - } - - if (sdp && - (msg_id == CC_MSG_CREATEANSWER || - msg_id == CC_MSG_SETLOCALDESC || - msg_id == CC_MSG_SETREMOTEDESC)) { - /* This is safe because all of the queueing has been removed. - * From a few minutes of looking, it appears to be very messy to - * clean this up down in the implementation. */ - pmsg->sdp = sdp; - } else { - pmsg->sdp = NULL; - } - - if (pmsg->data_valid == TRUE) { - pmsg->data = *data; - /* - * For call Info feature, need to copy the caller ID - */ - if (feature_id == CC_FEATURE_CALLINFO) { - /* Copy the caller ID */ - cc_cp_caller(&pmsg->data.call_info.caller_id, - &data->call_info.caller_id); - } - /* - * Clear the msg body from the source now since the msg. bodies - * has been transferred to to the CCAPI msg. - */ - msg_body = cc_get_msg_body_info_ptr_from_feature_data(feature_id, data); - cc_initialize_msg_body_parts_info(msg_body); - } - - CC_DEBUG_ENTRY(__FUNCTION__, src_id, dst_id, call_id, line, cc_feature_name(feature_id)); - CC_DEBUG(DEB_L_C_F_PREFIX "feature= %s, data= %p", - DEB_L_C_F_PREFIX_ARGS(CC_API, line, call_id, __FUNCTION__), cc_feature_name(feature_id), data); - STAMP_TIMECARD(timecard, "Sending message to queue"); - if (cc_send_msg((cprBuffer_t) pmsg, sizeof(*pmsg), dst_id) != CC_RC_SUCCESS) { - // nobody checks the return code, so generate error message - GSM_ERR_MSG("%s: unable to send msg for feat=%s", __FUNCTION__, - cc_feature_name(feature_id)); - } - - return; -} - -void -cc_createoffer (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, - line_t line, cc_features_t feature_id, cc_feature_data_t *data, - Timecard *tc) -{ - send_message_helper(CC_MSG_CREATEOFFER, src_id, dst_id, call_id, line, - feature_id, data, NULL, 0, tc); - - return; -} - - -void -cc_createanswer (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, - line_t line, cc_features_t feature_id, string_t sdp, cc_feature_data_t *data, - Timecard *tc) -{ - send_message_helper(CC_MSG_CREATEANSWER, src_id, dst_id, call_id, line, - feature_id, data, sdp, 0, tc); - - return; -} - - -void cc_setlocaldesc (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, - cc_features_t feature_id, cc_jsep_action_t action, string_t sdp, cc_feature_data_t *data, - Timecard *tc) -{ - send_message_helper(CC_MSG_SETLOCALDESC, src_id, dst_id, call_id, line, - feature_id, data, sdp, action, tc); - - return; -} - -void cc_setremotedesc (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, - cc_features_t feature_id, cc_jsep_action_t action, string_t sdp, cc_feature_data_t *data, - Timecard *tc) -{ - send_message_helper(CC_MSG_SETREMOTEDESC, src_id, dst_id, call_id, line, - feature_id, data, sdp, action, tc); - - return; -} - void cc_int_feature_ack (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, cc_features_t feature_id, diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/fim.c b/media/webrtc/signaling/src/sipcc/core/gsm/fim.c index 125e9bb16e64..850b31605524 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/fim.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/fim.c @@ -141,7 +141,7 @@ fim_free_call_chn (fim_icb_t *call_chn, line_t line, boolean update_call_cnt) } -static fim_icb_t * +fim_icb_t * fim_get_call_chn_by_call_id (callid_t call_id) { static const char fname[] = "fim_get_call_chn_by_call_id"; @@ -161,7 +161,7 @@ fim_get_call_chn_by_call_id (callid_t call_id) return call_chn; } -static fim_icb_t * +fim_icb_t * fim_get_new_call_chn (callid_t call_id) { static const char fname[] = "fim_get_new_call_chn"; @@ -507,14 +507,6 @@ fim_process_event (void *data, boolean cac_passed) (event_id == CC_MSG_OFFHOOK) || (event_id == CC_MSG_DIALSTRING) || (event_id == CC_MSG_LINE) || - (event_id == CC_MSG_CREATEOFFER) || - (event_id == CC_MSG_CREATEANSWER) || - (event_id == CC_MSG_SETLOCALDESC) || - (event_id == CC_MSG_SETREMOTEDESC) || - (event_id == CC_MSG_SETPEERCONNECTION) || - (event_id == CC_MSG_ADDSTREAM) || - (event_id == CC_MSG_REMOVESTREAM) || - (event_id == CC_MSG_ADDCANDIDATE) || ((event_id == CC_MSG_FEATURE) && ((((cc_feature_t *) msg)->feature_id == CC_FEATURE_NEW_CALL)))) { call_chn = fim_get_new_call_chn(call_id); diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c b/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c index f3934e6e0db6..ae196ea2dade 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c @@ -86,17 +86,6 @@ static const char *fsmdef_state_names[] = { }; -static sm_rcs_t fsmdef_ev_createoffer(sm_event_t *event); -static sm_rcs_t fsmdef_ev_createanswer(sm_event_t *event); -static sm_rcs_t fsmdef_ev_setlocaldesc(sm_event_t *event); -static sm_rcs_t fsmdef_ev_setremotedesc(sm_event_t *event); -static sm_rcs_t fsmdef_ev_setpeerconnection(sm_event_t *event); -static sm_rcs_t fsmdef_ev_addstream(sm_event_t *event); -static sm_rcs_t fsmdef_ev_removestream(sm_event_t *event); -static sm_rcs_t fsmdef_ev_addcandidate(sm_event_t *event); -static sm_rcs_t fsmdef_ev_foundcandidate(sm_event_t *event); - -static sm_rcs_t fsmdef_ev_default(sm_event_t *event); static sm_rcs_t fsmdef_ev_default_feature_ack(sm_event_t *event); static sm_rcs_t fsmdef_ev_idle_setup(sm_event_t *event); static sm_rcs_t fsmdef_ev_idle_feature(sm_event_t *event); @@ -170,695 +159,491 @@ static void fsmdef_update_callinfo_security_status(fsmdef_dcb_t *dcb, cc_feature_data_call_info_t *call_info); static void fsmdef_update_calltype (fsm_fcb_t *fcb, cc_feature_t *msg); - -/* - * TODO Update events for correct JSEP transitions - * Instead of providing events for all states - */ static sm_function_t fsmdef_function_table[FSMDEF_S_MAX][CC_MSG_MAX] = { /* FSMDEF_S_IDLE ------------------------------------------------------------ */ { /* CC_MSG_SETUP */ fsmdef_ev_idle_setup, // New incoming - /* 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_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_release_complete, /* CC_MSG_FEATURE */ fsmdef_ev_idle_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_idle_offhook, - /* CC_MSG_ONHOOK */ fsmdef_ev_default, + /* CC_MSG_ONHOOK */ NULL, /* CC_MSG_LINE */ fsmdef_ev_idle_offhook, - /* CC_MSG_DIGIT_BEGIN */ fsmdef_ev_default, - /* CC_MSG_DIGIT_END */ fsmdef_ev_default, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, /* CC_MSG_DIALSTRING */ fsmdef_ev_idle_dialstring, // new outgoing - /* CC_MSG_MWI */ fsmdef_ev_default, - /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_setpeerconnection, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_COLLECT_INFO ---------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_collectinginfo_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_collectinginfo_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_OFFHOOK */ NULL, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, - /* CC_MSG_LINE */ fsmdef_ev_default, + /* CC_MSG_LINE */ NULL, /* CC_MSG_DIGIT_BEGIN */ fsmdef_ev_digit_begin, - /* CC_MSG_DIGIT_END */ fsmdef_ev_default, + /* CC_MSG_DIGIT_END */ NULL, /* CC_MSG_DIALSTRING */ fsmdef_ev_dialstring, - /* CC_MSG_MWI */ fsmdef_ev_default, - /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_CALL_SENT ------------------------------------------------------- */ { - /* CC_MSG_SETUP */ fsmdef_ev_default, - /* CC_MSG_SETUP_ACK */ fsmdef_ev_default, + /* CC_MSG_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, /* CC_MSG_PROCEEDING */ fsmdef_ev_proceeding, /* CC_MSG_ALERTING */ fsmdef_ev_out_alerting, /* CC_MSG_CONNECTED */ fsmdef_ev_connected, - /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_callsent_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_callsent_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_OUTGOING_PROCEEDING --------------------------------------------- */ { - /* CC_MSG_SETUP */ fsmdef_ev_default, - /* CC_MSG_SETUP_ACK */ fsmdef_ev_default, - /* CC_MSG_PROCEEDING */ fsmdef_ev_default, + /* CC_MSG_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, /* CC_MSG_ALERTING */ fsmdef_ev_out_alerting, /* CC_MSG_CONNECTED */ fsmdef_ev_connected, - /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_callsent_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_callsent_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_KPML_COLLECT_INFO ----------------------------------------------- */ { - /* CC_MSG_SETUP */ fsmdef_ev_default, - /* CC_MSG_SETUP_ACK */ fsmdef_ev_default, - /* CC_MSG_PROCEEDING */ fsmdef_ev_default, + /* CC_MSG_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, /* CC_MSG_ALERTING */ fsmdef_ev_out_alerting, /* CC_MSG_CONNECTED */ fsmdef_ev_connected, - /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_callsent_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_collectinginfo_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_OFFHOOK */ NULL, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, - /* CC_MSG_LINE */ fsmdef_ev_default, + /* CC_MSG_LINE */ NULL, /* CC_MSG_DIGIT_BEGIN */ fsmdef_ev_digit_begin, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_OUTGOING_ALERTING ----------------------------------------------- */ { - /* CC_MSG_SETUP */ fsmdef_ev_default, - /* CC_MSG_SETUP_ACK */ fsmdef_ev_default, - /* CC_MSG_PROCEEDING */ fsmdef_ev_default, + /* CC_MSG_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, /* CC_MSG_ALERTING */ fsmdef_ev_out_alerting, /* CC_MSG_CONNECTED */ fsmdef_ev_connected, - /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_default, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_callsent_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_callsent_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_INCOMING_ALERTING ----------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_inalerting_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_inalerting_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, /* CC_MSG_LINE */ fsmdef_ev_inalerting_offhook, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_CONNECTING ------------------------------------------------------ */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_connected_ack, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_connecting_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, /* CC_MSG_LINE */ fsmdef_ev_connected_line, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_JOINING --------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, /* CC_MSG_CONNECTED_ACK */ fsmdef_ev_joining_connected_ack, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_connecting_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_joining_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, /* CC_MSG_LINE */ fsmdef_ev_connected_line, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_CONNECTED ------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_connected_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, /* CC_MSG_LINE */ fsmdef_ev_connected_line, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_CONNECTED_MEDIA_PEND ------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_connected_media_pend_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_connected_media_pend_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_onhook, /* CC_MSG_LINE */ fsmdef_ev_connected_line, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_RELEASING ------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_releasing_release, /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_release_complete, /* CC_MSG_FEATURE */ fsmdef_ev_releasing_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default_feature_ack, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_OFFHOOK */ NULL, /* CC_MSG_ONHOOK */ fsmdef_ev_releasing_onhook, /* CC_MSG_LINE */ fsmdef_ev_connected_line, - /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_HOLD_PENDING ---------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_holding_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_hold_pending_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_hold_pending_feature_ack, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_OFFHOOK */ NULL, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_HOLDING --------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_holding_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_holding_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_holding_feature_ack, /* CC_MSG_OFFHOOK */ fsmdef_ev_holding_offhook, /* CC_MSG_ONHOOK */ fsmdef_ev_holding_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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_RESUME_PENDING -------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_resume_pending_feature, /* CC_MSG_FEATURE_ACK */ fsmdef_ev_resume_pending_feature_ack, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_OFFHOOK */ NULL, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_PRESERVED ------------------------------------------------------ */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, /* CC_MSG_RELEASE */ fsmdef_ev_release, - /* CC_MSG_RELEASE_COMPLETE */ fsmdef_ev_default, + /* CC_MSG_RELEASE_COMPLETE */ NULL, /* CC_MSG_FEATURE */ fsmdef_ev_preserved_feature, - /* CC_MSG_FEATURE_ACK */ fsmdef_ev_default, - /* CC_MSG_OFFHOOK */ fsmdef_ev_default, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_session_audit, - /* CC_MSG_CREATEOFFER */ fsmdef_ev_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ fsmdef_ev_session_audit }, /* FSMDEF_S_STABLE --------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_setlocaldesc, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_setremotedesc, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_addstream, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_removestream, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_foundcandidate + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL }, /* FSMDEF_S_HAVE_LOCAL_OFFER ----------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_setlocaldesc, - /* 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_default, /* Reject lame-duck - candidates */ - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_foundcandidate + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL }, /* FSMDEF_S_HAVE_REMOTE_OFFER ---------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_setlocaldesc, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_setremotedesc, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_addstream, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_removestream, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_foundcandidate + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL }, /* FSMDEF_S_HAVE_LOCAL_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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_setlocaldesc, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, /* Should not happen */ - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_addcandidate, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_foundcandidate + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL }, /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_foundcandidate + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL }, /* FSMDEF_S_CLOSED --------------------------------------------------------- */ { - /* 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_SETUP */ NULL, + /* CC_MSG_SETUP_ACK */ NULL, + /* CC_MSG_PROCEEDING */ NULL, + /* CC_MSG_ALERTING */ NULL, + /* CC_MSG_CONNECTED */ NULL, + /* CC_MSG_CONNECTED_ACK */ NULL, + /* CC_MSG_RELEASE */ NULL, + /* CC_MSG_RELEASE_COMPLETE */ NULL, + /* CC_MSG_FEATURE */ NULL, + /* CC_MSG_FEATURE_ACK */ NULL, + /* CC_MSG_OFFHOOK */ NULL, /* 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_default, - /* CC_MSG_CREATEANSWER */ fsmdef_ev_default, - /* CC_MSG_SETLOCALDESC */ fsmdef_ev_default, - /* CC_MSG_SETREMOTEDESC */ fsmdef_ev_default, - /* CC_MSG_SETPEERCONNECTION */fsmdef_ev_default, - /* CC_MSG_ADDSTREAM */ fsmdef_ev_default, - /* CC_MSG_REMOVESTREAM */ fsmdef_ev_default, - /* CC_MSG_ADDCANDIDATE */ fsmdef_ev_default, - /* CC_MSG_FOUNDCANDIDATE */ fsmdef_ev_default + /* CC_MSG_LINE */ NULL, + /* CC_MSG_DIGIT_BEGIN */ NULL, + /* CC_MSG_DIGIT_END */ NULL, + /* CC_MSG_DIALSTRING */ NULL, + /* CC_MSG_MWI */ NULL, + /* CC_MSG_SESSION_AUDIT */ NULL } }; @@ -1331,6 +1116,12 @@ fsmdef_free_dcb (fsmdef_dcb_t *dcb) strlib_free(dcb->caller_id.orig_called_number); strlib_free(dcb->caller_id.orig_rpid_number); + if (dcb->ice_ufrag) + cpr_free(dcb->ice_ufrag); + + if (dcb->ice_pwd) + cpr_free(dcb->ice_pwd); + // Free the call instance id if (dcb->caller_id.call_instance_id != 0) { fsmutil_free_ci_id(dcb->caller_id.call_instance_id, dcb->line); @@ -2024,6 +1815,7 @@ fsmdef_release (fsm_fcb_t *fcb, cc_causes_t cause, boolean send_release) dcb->line, cause, &kfactor); } + // TODO: Get rid of this setting when we simplify teardown config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); fsm_change_state(fcb, __LINE__, sdpmode ? FSMDEF_S_CLOSED : FSMDEF_S_IDLE); @@ -2320,95 +2112,10 @@ fsmdef_set_ringback_delay_timer (fsmdef_dcb_t *dcb) { } + /******************************************************************* * event functions */ -static sm_rcs_t -fsmdef_ev_default (sm_event_t *event) -{ - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; - fsmdef_dcb_t *dcb = fcb->dcb; - cc_feature_t *msg = (cc_feature_t *) event->msg; - - FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SM_DEFAULT_EVENT)); - - if (!dcb) { - return (SM_RC_END); - } - - /* - * For WebRTC events, we must send back a message to enable the - * corresponding error callback to be called. Arguably, these - * should always be caught by the PeerConnection and thrown as exceptions, - * but this enusres that the behavior is water-tight. - */ - switch (event->event) { - case CC_MSG_CREATEOFFER: - ui_create_offer(evCreateOfferError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot create offer in state %s", - fsmdef_state_name(fcb->state)); - break; - - case CC_MSG_CREATEANSWER: - ui_create_answer(evCreateAnswerError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot create answer in state %s", - fsmdef_state_name(fcb->state)); - break; - - case CC_MSG_SETLOCALDESC: - ui_set_local_description(evSetLocalDescError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot set local description in state %s", - fsmdef_state_name(fcb->state)); - break; - - case CC_MSG_SETREMOTEDESC: - ui_set_remote_description(evSetRemoteDescError, fcb->state, - msg->line, msg->call_id, dcb->caller_id.call_instance_id, - strlib_empty(), msg->timecard, 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, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot add ICE candidate in state %s", - fsmdef_state_name(fcb->state)); - break; - - case CC_MSG_FOUNDCANDIDATE: - ui_ice_candidate_found(evFoundIceCandidateError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - NULL, msg->timecard, - PC_INVALID_STATE, "Cannot add found ICE candidate in state %s", - fsmdef_state_name(fcb->state)); - break; - - case CC_MSG_ADDSTREAM: - case CC_MSG_REMOVESTREAM: - /* This shouldn't happen, since PeerConnection should check - * the state before sending these events to us. The debug message - * here is to catch the unexpected situation of such an 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(fcb->state)); - break; - - default: - cc_call_state(dcb->call_id, dcb->line, CC_STATE_UNKNOWN, NULL); - break; - } - - return (SM_RC_END); -} /* * Default event handler for feature_ack event @@ -3042,29 +2749,20 @@ fsmdef_ev_dialstring (sm_event_t *event) return (sm_rc); } - -/** - * fsmdef_ev_createoffer - * - * Generates Offer SDP - * - */ -static sm_rcs_t -fsmdef_ev_createoffer (sm_event_t *event) { - sm_rcs_t sm_rc; - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_createoffer(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; cc_msgbody_info_t msg_body; - cc_feature_t *msg = (cc_feature_t *) event->msg; line_t line = msg->line; callid_t call_id = msg->call_id; - cc_causes_t lsm_rc; int sdpmode = 0; char *ufrag = NULL; char *ice_pwd = NULL; short vcm_res; - session_data_t *sess_data_p = NULL; char *local_sdp = NULL; uint32_t local_sdp_len = 0; boolean has_stream = FALSE; @@ -3073,13 +2771,17 @@ fsmdef_ev_createoffer (sm_event_t *event) { config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { + *error_outparam = strlib_printf("sdpmode is not set!"); /* Force clean up call without sending release */ - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (dcb == NULL) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_CLEANUP; + *error_outparam = strlib_printf("dcb is NULL"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* For now, if the local SDP has been set, we don't allow it to be set @@ -3091,19 +2793,16 @@ 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, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not re-create local SDP for offer"); + *error_outparam = strlib_printf( + "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)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - ui_create_offer(evCreateOfferSuccess, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_malloc(local_sdp,-1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(local_sdp, -1); free(local_sdp); - return (SM_RC_END); + return (PC_NO_ERROR); } dcb->inbound = FALSE; @@ -3121,35 +2820,39 @@ fsmdef_ev_createoffer (sm_event_t *event) { } if (!has_stream) { - ui_create_offer(evCreateOfferError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot create SDP without any streams."); - return SM_RC_END; + *error_outparam = strlib_printf( + "Cannot create SDP without any streams."); + return (PC_INVALID_STATE); } vcm_res = vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); if (vcm_res) { - FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error", + FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_create_offer(evCreateOfferError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Failed to get ICE parameters for local SDP"); - return (fsmdef_release(fcb, cause, FALSE)); + *error_outparam = strlib_printf( + "Failed to get ICE parameters for local SDP"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } dcb->ice_ufrag = (char *)cpr_malloc(strlen(ufrag) + 1); - if (!dcb->ice_ufrag) - return SM_RC_END; + if (!dcb->ice_ufrag) { + *error_outparam = strlib_printf( + "Failed to allocate string for ICE ufrag"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); + } sstrncpy(dcb->ice_ufrag, ufrag, strlen(ufrag) + 1); free(ufrag); - dcb->ice_pwd = (char *)cpr_malloc(strlen(ice_pwd) + 1); - if (!dcb->ice_pwd) - return SM_RC_END; + if (!dcb->ice_pwd) { + *error_outparam = strlib_printf( + "Failed to allocate string for ICE password"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); + } sstrncpy(dcb->ice_pwd, ice_pwd, strlen(ice_pwd) + 1); free(ice_pwd); @@ -3159,71 +2862,56 @@ fsmdef_ev_createoffer (sm_event_t *event) { dcb->digest, FSMDEF_MAX_DIGEST_LEN); if (vcm_res) { - FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetDtlsIdentity returned an error", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_END; + FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetDtlsIdentity returned an error", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); + *error_outparam = strlib_printf("Failed to get DTLS identity"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } cause = gsmsdp_create_local_sdp(dcb, FALSE, TRUE, TRUE, TRUE, TRUE); if (cause != CC_CAUSE_OK) { - ui_create_offer(evCreateOfferError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not create local SDP for offer;" - " cause = %s", cc_cause_name(cause)); + *error_outparam = strlib_printf( + "Could not create local SDP for offer; cause = %s", + cc_cause_name(cause)); + FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR)); - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_create_offer(evCreateOfferError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not encode local SDP for offer;" - " cause = %s", cc_cause_name(cause)); + *error_outparam = strlib_printf( + "Could not encode local SDP for offer; cause = %s", + cc_cause_name(cause)); + FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR)); - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } dcb->local_sdp_complete = TRUE; - /* Pass offer SDP back to UI */ - ui_create_offer(evCreateOfferSuccess, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, - strlib_malloc(msg_body.parts[0].body, -1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(msg_body.parts[0].body, -1); cc_free_msg_body_parts(&msg_body); - return (SM_RC_END); + return (PC_NO_ERROR); } - -/** - * fsmdef_ev_createanswer - * - * Generates Answer SDP - * - */ -static sm_rcs_t -fsmdef_ev_createanswer (sm_event_t *event) { - sm_rcs_t sm_rc; - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_createanswer(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; - cc_feature_t *msg = (cc_feature_t *) event->msg; cc_causes_t cause = CC_CAUSE_NORMAL; cc_msgbody_info_t msg_body; line_t line = msg->line; callid_t call_id = msg->call_id; - line_t free_line; int sdpmode = 0; - const char *called_number = "1234"; - cc_causes_t lsm_rc; - cc_msgbody_t *part; - uint32_t body_length; char *ufrag = NULL; char *ice_pwd = NULL; short vcm_res; - session_data_t *sess_data_p; boolean has_audio; boolean has_video; boolean has_data; @@ -3234,13 +2922,17 @@ fsmdef_ev_createanswer (sm_event_t *event) { config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { - return (fsmdef_release(fcb, cause, FALSE)); + *error_outparam = strlib_printf("sdpmode is false!"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (dcb == NULL) { + *error_outparam = strlib_printf("dcb is NULL!"); FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_CLEANUP; + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* For now, if the local SDP has been set, we don't allow it to be set @@ -3252,45 +2944,55 @@ 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, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not re-create local SDP for answer"); + *error_outparam = strlib_printf( + "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)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - ui_create_answer(evCreateAnswerSuccess, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_malloc(local_sdp,-1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(local_sdp, -1); + free(local_sdp); - return (SM_RC_END); + return (PC_NO_ERROR); } dcb->inbound = TRUE; vcm_res = vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); if (vcm_res) { - FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error", + FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetIceParams returned an error", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_create_answer(evCreateAnswerError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not get ICE parameters for answer"); - return (fsmdef_release(fcb, cause, FALSE)); + + *error_outparam = strlib_printf( + "Could not get ICE parameters for answer"); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } dcb->ice_ufrag = (char *)cpr_malloc(strlen(ufrag) + 1); - if (!dcb->ice_ufrag) - return SM_RC_END; + if (!dcb->ice_ufrag) { + *error_outparam = strlib_printf( + "Could not alloc buffer for ICE ufrag"); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); + } sstrncpy(dcb->ice_ufrag, ufrag, strlen(ufrag) + 1); free(ufrag); dcb->ice_pwd = (char *)cpr_malloc(strlen(ice_pwd) + 1); - if (!dcb->ice_pwd) - return SM_RC_END; + if (!dcb->ice_pwd) { + *error_outparam = strlib_printf( + "Could not alloc buffer for ICE password"); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); + } sstrncpy(dcb->ice_pwd, ice_pwd, strlen(ice_pwd) + 1); free(ice_pwd); @@ -3301,7 +3003,11 @@ fsmdef_ev_createanswer (sm_event_t *event) { if (vcm_res) { FSM_DEBUG_SM(DEB_F_PREFIX"vcmGetDtlsIdentity returned an error", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_END; + + *error_outparam = strlib_printf("Could not get DTLS identity"); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* @@ -3316,14 +3022,14 @@ 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, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not create local SDP for answer;" - " cause = %s", cc_cause_name(cause)); + *error_outparam = strlib_printf( + "Could not create local SDP for answer; cause = %s", + cc_cause_name(cause)); + FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR)); // Force clean up call without sending release - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* TODO(ekr@rtfm.com): The second true is because we are acting as if we are @@ -3336,60 +3042,48 @@ fsmdef_ev_createanswer (sm_event_t *event) { /* create_answer */ TRUE); if (cause != CC_CAUSE_OK) { - ui_create_answer(evCreateAnswerError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not negotiate media lines; cause = %s", - cc_cause_name(cause)); - return (fsmdef_release(fcb, cause, FALSE)); + *error_outparam = strlib_printf( + "Could not negotiate media lines; cause = %s", + cc_cause_name(cause)); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_create_answer(evCreateAnswerError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not encode SDP for answer; cause = %s", - cc_cause_name(cause)); + *error_outparam = strlib_printf( + "Could not encode SDP for answer; cause = %s", + cc_cause_name(cause)); + FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR)); - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } dcb->local_sdp_complete = TRUE; - /* Pass SDP back to UI */ - ui_create_answer(evCreateAnswerSuccess, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, - strlib_malloc(msg_body.parts[0].body, -1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(msg_body.parts[0].body, -1); + cc_free_msg_body_parts(&msg_body); - return (SM_RC_END); + return (PC_NO_ERROR); } - -/** - * SetLocalDescription - * - * Because the PeerConnection relies on receiving either a success or - * an error callback, there must be no paths that return from this - * function without first calling ui_set_local_description. - */ -static sm_rcs_t -fsmdef_ev_setlocaldesc(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_setlocaldesc(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; - cc_feature_t *msg = (cc_feature_t *) event->msg; cc_causes_t cause = CC_CAUSE_NORMAL; int action = msg->action; string_t sdp = msg->sdp; int sdpmode = 0; callid_t call_id = msg->call_id; line_t line = msg->line; - cc_causes_t lsm_rc; char *local_sdp = NULL; uint32_t local_sdp_len = 0; - fsmdef_candidate_t *candidate = NULL; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); @@ -3397,31 +3091,29 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED); - ui_set_local_description(evSetLocalDescError, fcb->state, line, call_id, - 0, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Unrecoverable error: dcb is NULL."); - return (SM_RC_CLEANUP); + + *error_outparam = strlib_printf( + "Unrecoverable error: dcb is NULL."); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { 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(), - msg->timecard, - PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should " - "never ever happen. Run for your lives!"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "'sdpmode' configuration is false. This should never ever happen. " + "Run for your lives!"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (!dcb->sdp) { - ui_set_local_description(evSetLocalDescError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Setting of local SDP before calling " - "createOffer or createAnswer is not currently supported."); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Setting of local SDP before calling createOffer or createAnswer " + "is not currently supported."); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } switch (action) { @@ -3429,12 +3121,12 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { case JSEP_OFFER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set local offer in state %s", + + *error_outparam = strlib_printf( + "Cannot set local offer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } /* TODO: Parse incoming SDP and act on it. */ fsm_change_state(fcb, __LINE__, FSMDEF_S_HAVE_LOCAL_OFFER); @@ -3443,12 +3135,12 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { case JSEP_ANSWER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set local answer in state %s", + + *error_outparam = strlib_printf( + "Cannot set local answer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } /* TODO: Parse incoming SDP and act on it. */ FSM_SET_FLAGS(dcb->msgs_sent, FSMDEF_MSG_CONNECTED); @@ -3462,12 +3154,11 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { */ cause = gsmsdp_install_peer_ice_attributes(fcb); if (cause != CC_CAUSE_OK) { - ui_set_local_description(evSetLocalDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not configure local ICE state" - " from SDP; cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not configure local ICE state from SDP; cause = %s", + cc_cause_name(cause)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } STAMP_TIMECARD(msg->timecard, "ICE Attributes Installed"); @@ -3481,12 +3172,11 @@ 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, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Cannot start media channels; cause = %s", + *error_outparam = strlib_printf( + "Cannot start media channels cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* we may want to use the functionality in the following method * to handle media capability changes, needs discussion @@ -3498,64 +3188,51 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { case JSEP_PRANSWER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set local pranswer in state %s", + + *error_outparam = strlib_printf( + "Cannot set local pranswer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } - ui_set_local_description(evSetLocalDescError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Provisional answers are not yet supported"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Provisional answers are not yet supported"); + return (PC_INTERNAL_ERROR); default: - ui_set_local_description(evSetLocalDescError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Unknown session description type: %d",action); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Unknown session description type: %d", + action); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* 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, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not encode local SDP for local " - "description"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not encode local SDP for local description"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - ui_set_local_description(evSetLocalDescSuccess, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, - strlib_malloc(local_sdp,-1), msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(local_sdp,-1); free(local_sdp); - return (SM_RC_END); + return (PC_NO_ERROR); } -/** - * SetRemoteDescription - * - * Because the PeerConnection relies on receiving either a success or - * an error callback, there must be no paths that return from this - * function without first calling ui_set_remote_description. - */ -static sm_rcs_t -fsmdef_ev_setremotedesc(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_setremotedesc(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; - cc_feature_t *msg = (cc_feature_t *) event->msg; cc_causes_t cause = CC_CAUSE_NORMAL; int action = msg->action; int sdpmode = 0; callid_t call_id = msg->call_id; line_t line = msg->line; - cc_causes_t lsm_rc; cc_msgbody_t *part; uint32_t body_length; cc_msgbody_info_t msg_body; @@ -3571,22 +3248,20 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED); - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, 0, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Unrecoverable error: dcb is NULL."); - return (SM_RC_CLEANUP); + *error_outparam = strlib_printf( + "Unrecoverable error: dcb is NULL."); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { 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(), - msg->timecard, - PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should " - "never ever happen. Run for your lives!"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "'sdpmode' configuration is false. This should never ever happen. " + "Run for your lives!"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } // XXX We don't currently support renegotiation. If the remote SDP @@ -3595,12 +3270,10 @@ 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, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Renegotiation of session description is not " - "currently supported. See Bug 840728 for status."); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Renegotiation of session description is not currently supported. " + "See Bug 840728 for status."); + return (PC_INVALID_STATE); } cc_initialize_msg_body_parts_info(&msg_body); @@ -3627,21 +3300,22 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { case JSEP_OFFER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set remote offer in state %s", + + *error_outparam = strlib_printf( + "Cannot set remote offer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } cause = gsmsdp_process_offer_sdp(fcb, &msg_body, TRUE); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not process offer SDP; " - "cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + + *error_outparam = strlib_printf( + "Could not process offer SDP; cause = %s", + cc_cause_name(cause)); + + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* @@ -3658,37 +3332,34 @@ 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, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not create local SDP; cause = %s", - cc_cause_name(cause)); + *error_outparam = strlib_printf( + "Could not create local SDP; cause = %s", + cc_cause_name(cause)); FSM_DEBUG_SM("%s", get_debug_string(FSM_DBG_SDP_BUILD_ERR)); // Force clean up call without sending release - return (fsmdef_release(fcb, cause, FALSE)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, TRUE, FALSE); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not negotiate media lines; cause = %s", - cc_cause_name(cause)); - return (fsmdef_release(fcb, cause, FALSE)); + *error_outparam = strlib_printf( + "Could not negotiate media lines; cause = %s", + cc_cause_name(cause)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* Now that the SDP is digested we need to sanity check for ICE parameters */ cause = gsmsdp_check_ice_attributes_exist(fcb); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "ICE attributes missing; cause = %s", - cc_cause_name(cause)); - return (SM_RC_END); + *error_outparam = strlib_printf( + "ICE attributes missing; cause = %s", + cc_cause_name(cause)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } gsmsdp_clean_media_list(dcb); @@ -3699,21 +3370,20 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { case JSEP_ANSWER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set remote answer in state %s", + + *error_outparam = strlib_printf( + "Cannot set remote answer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } cause = gsmsdp_negotiate_answer_sdp(fcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not negotiate answer SDP; cause = %s", + *error_outparam = strlib_printf( + "Could not negotiate answer SDP; cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* @@ -3722,12 +3392,11 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { */ cause = gsmsdp_install_peer_ice_attributes(fcb); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not configure local ICE state" - " from SDP; cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not configure local ICE state from SDP; cause = %s", + cc_cause_name(cause)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } STAMP_TIMECARD(msg->timecard, "ICE Attributes Installed"); @@ -3746,25 +3415,23 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { case JSEP_PRANSWER: 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(), - msg->timecard, - PC_INVALID_STATE, "Cannot set remote pranswer in state %s", + + *error_outparam = strlib_printf( + "Cannot set remote pranswer in state %s", fsmdef_state_name(fcb->state)); - return (SM_RC_END); + + return (PC_INVALID_STATE); } - ui_set_remote_description(evSetRemoteDescError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Provisional answers are not yet supported"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Provisional answers are not yet supported"); + return (PC_INTERNAL_ERROR); default: - ui_set_remote_description(evSetRemoteDescError, fcb->state, msg->line, - msg->call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Unknown session description type: %d",action); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Unknown session description type: %d", + action); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } /* For the sake of accuracy, we regenerate the SDP text from our parsed @@ -3776,30 +3443,24 @@ 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, fcb->state, line, - call_id, dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not serialize remote description;" - " cause = %s", cc_cause_name(cause)); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not serialize remote description; cause = %s", + cc_cause_name(cause)); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - ui_set_remote_description(evSetRemoteDescSuccess, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(remote_sdp,-1); free(remote_sdp); - return (SM_RC_END); + return (PC_NO_ERROR); } - -static sm_rcs_t -fsmdef_ev_setpeerconnection(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_setpeerconnection(fsm_fcb_t *fcb, cc_feature_t *msg) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; - cc_feature_t *msg = (cc_feature_t *) event->msg; callid_t call_id = msg->call_id; int sdpmode = 0; line_t line = msg->line; @@ -3810,26 +3471,28 @@ fsmdef_ev_setpeerconnection(sm_event_t *event) { if (!sdpmode) { FSM_DEBUG_SM(DEB_F_PREFIX"sdpmode is false; cannot set peerconnection.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return (SM_RC_END); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - if (!msg) - return SM_RC_END; - - if (!msg->data_valid) - return SM_RC_END; + if (!msg) { + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; + } if (dcb == NULL) { dcb = fsmdef_get_new_dcb(call_id); if (dcb == NULL) { - return SM_RC_ERROR; + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } lsm_rc = lsm_get_facility_by_line(call_id, line, FALSE, dcb); if (lsm_rc != CC_CAUSE_OK) { FSM_DEBUG_SM(DEB_F_PREFIX"lsm_get_facility_by_line failed.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_END; + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } fsmdef_init_dcb(dcb, call_id, FSMDEF_CALL_TYPE_NONE, NULL, line, fcb); @@ -3849,32 +3512,30 @@ fsmdef_ev_setpeerconnection(sm_event_t *event) { /* WebRTC connections always start in state "STABLE". */ fsm_change_state(fcb, __LINE__, FSMDEF_S_STABLE); - return (SM_RC_END); + return (PC_NO_ERROR); } -static sm_rcs_t -fsmdef_ev_addstream(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_addstream(fsm_fcb_t *fcb, cc_feature_t *msg, string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; - cc_feature_t *msg = (cc_feature_t *) event->msg; int sdpmode = 0; - cc_causes_t lsm_rc; - cc_msgbody_t *part; - uint32_t body_length; - cc_msgbody_info_t msg_body; cc_media_cap_name cap_index = CC_INVALID_INDEX; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (sdpmode == FALSE) { - return (SM_RC_END); + *error_outparam = strlib_printf("sdpmode is false"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (dcb == NULL) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_CLEANUP; + *error_outparam = strlib_printf("dcb is NULL"); + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } @@ -3903,32 +3564,29 @@ fsmdef_ev_addstream(sm_event_t *event) { dcb->media_cap_tbl->cap[cap_index].pc_stream = msg->data.track.stream_id; dcb->media_cap_tbl->cap[cap_index].pc_track = msg->data.track.track_id; } - return (SM_RC_END); + return (PC_NO_ERROR); } -static sm_rcs_t -fsmdef_ev_removestream(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_removestream(fsm_fcb_t *fcb, cc_feature_t *msg, string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; - cc_feature_t *msg = (cc_feature_t *) event->msg; int sdpmode = 0; - cc_causes_t lsm_rc; - cc_msgbody_t *part; - uint32_t body_length; - cc_msgbody_info_t msg_body; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (sdpmode == FALSE) { - - return (SM_RC_END); + *error_outparam = strlib_printf("sdpmode is false"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (dcb == NULL) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - return SM_RC_CLEANUP; + *error_outparam = strlib_printf("dcb is NULL"); + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } /* @@ -3944,18 +3602,20 @@ fsmdef_ev_removestream(sm_event_t *event) { PR_ASSERT(dcb->media_cap_tbl->cap[CC_VIDEO_1].enabled); dcb->media_cap_tbl->cap[CC_VIDEO_1].support_direction = SDP_DIRECTION_RECVONLY; } else { - return (SM_RC_END); + /* Why weren't we doing the same thing for DATA? */ + return (PC_NO_ERROR); } - return (SM_RC_END); + return (PC_NO_ERROR); } -static sm_rcs_t -fsmdef_ev_addcandidate(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_addcandidate(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; - cc_feature_t *msg = (cc_feature_t *) event->msg; int sdpmode = 0; short vcm_res; uint16_t level; @@ -3963,27 +3623,25 @@ fsmdef_ev_addcandidate(sm_event_t *event) { callid_t call_id = msg->call_id; char *remote_sdp = 0; uint32_t remote_sdp_len = 0; - char *candidate = 0; + char *candidate = NULL; char candidate_tmp[CANDIDATE_SIZE]; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); if (!dcb) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id, - 0, strlib_empty(), msg->timecard, PC_INTERNAL_ERROR, - "DCB has not been created."); - return SM_RC_CLEANUP; + *error_outparam = strlib_printf("DCB has not been created."); + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (sdpmode == FALSE) { - ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "'sdpmode' configuration is false. This should " - "never ever happen. Run for your lives!"); - return (SM_RC_END); + *error_outparam = strlib_printf( + "'sdpmode' configuration is false. This should never ever happen. " + "Run for your lives!"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } if (!dcb->sdp) { @@ -3991,13 +3649,10 @@ fsmdef_ev_addcandidate(sm_event_t *event) { "remote description been set yet?\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INVALID_STATE, "Cannot add remote ICE candidates before " - "setting remote SDP."); + *error_outparam = strlib_printf( + "Cannot add remote ICE candidates before setting remote SDP."); - return SM_RC_END; + return PC_INVALID_STATE; } /* Perform level lookup based on mid value */ @@ -4030,7 +3685,10 @@ fsmdef_ev_addcandidate(sm_event_t *event) { vcm_res = vcmSetIceCandidate(dcb->peerconnection, candidate, msg->data.candidate.level); if(vcm_res) { + *error_outparam = strlib_printf( + "ICE failure; cannot add remote candidate"); FSM_DEBUG_SM(DEB_F_PREFIX"failure setting ice candidate.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); + return (PC_INTERNAL_ERROR); } /* Serialize the updated SDP and inform the PeerConnection of the @@ -4039,52 +3697,49 @@ 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, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - msg->timecard, - PC_INTERNAL_ERROR, "Could not serialize new SDP after adding ICE " - "candidate."); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not serialize new SDP after adding ICE candidate."); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - ui_ice_candidate_add(evAddIceCandidate, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(remote_sdp,-1); cpr_free(remote_sdp); - return (SM_RC_END); + return (PC_NO_ERROR); } - -static sm_rcs_t -fsmdef_ev_foundcandidate(sm_event_t *event) { - fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; +pc_error +fsmdef_foundcandidate(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam) { fsmdef_dcb_t *dcb = fcb->dcb; cc_causes_t cause = CC_CAUSE_NORMAL; - cc_feature_t *msg = (cc_feature_t *) event->msg; int sdpmode = 0; - short vcm_res; uint16_t level; line_t line = msg->line; callid_t call_id = msg->call_id; char *local_sdp = 0; uint32_t local_sdp_len = 0; - string_t candidate = 0; - char candidate_tmp[CANDIDATE_SIZE + 32]; /* Sort of arbitrary */ FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); if (!dcb) { FSM_DEBUG_SM(DEB_F_PREFIX"dcb is NULL.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_ice_candidate_add(evAddIceCandidateError, fcb->state, line, call_id, - 0, strlib_empty(), msg->timecard, PC_INTERNAL_ERROR, - "DCB has not been created."); - return SM_RC_CLEANUP; + *error_outparam = strlib_printf("DCB has not been created."); + fsmdef_release(fcb, cause, FALSE); + return PC_INTERNAL_ERROR; } config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { - MOZ_CRASH(); + fsm_change_state(fcb, __LINE__, FSMDEF_S_CLOSED); + *error_outparam = strlib_printf( + "'sdpmode' configuration is false. This should never ever happen. " + "Run for your lives!"); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } MOZ_ASSERT(dcb->sdp && dcb->sdp->src_sdp); @@ -4093,13 +3748,10 @@ fsmdef_ev_foundcandidate(sm_event_t *event) { "local description been set yet?\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); - ui_ice_candidate_found(evFoundIceCandidateError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), - NULL, msg->timecard, - PC_INVALID_STATE, "Cannot add found ICE candidates without" - "local SDP."); + *error_outparam = strlib_printf( + "Cannot add found ICE candidates without local SDP."); - return SM_RC_END; + return PC_INVALID_STATE; } /* Store the candidate in the SDP for future reference */ @@ -4111,30 +3763,18 @@ fsmdef_ev_foundcandidate(sm_event_t *event) { local_sdp = sipsdp_write_to_buf(dcb->sdp->src_sdp, &local_sdp_len); if (!local_sdp) { - ui_ice_candidate_found(evFoundIceCandidateError, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_empty(), NULL, - msg->timecard, - PC_INTERNAL_ERROR, "Could not serialize new SDP after adding ICE " - "candidate."); - return (SM_RC_END); + *error_outparam = strlib_printf( + "Could not serialize new SDP after adding ICE candidate."); + fsmdef_release(fcb, cause, FALSE); + return (PC_INTERNAL_ERROR); } - /* Smuggle the entire candidate structure in a string */ - PR_snprintf(candidate_tmp, sizeof(candidate_tmp), "%d\t%s\t%s", - msg->data.candidate.level, - (char *)msg->data.candidate.mid, - (char *)msg->data.candidate.candidate); - - ui_ice_candidate_found(evFoundIceCandidate, fcb->state, line, call_id, - dcb->caller_id.call_instance_id, strlib_malloc(local_sdp,-1), - strlib_malloc(candidate_tmp, -1), - msg->timecard, PC_NO_ERROR, NULL); + *sdp_outparam = strlib_malloc(local_sdp,-1); cpr_free(local_sdp); - return SM_RC_END; + return PC_NO_ERROR; } - static void fsmdef_check_active_feature (fsmdef_dcb_t *dcb, cc_features_t ftr_id) { @@ -6432,7 +6072,6 @@ fsmdef_ev_onhook (sm_event_t *event) fsmdef_dcb_t *dcb = fcb->dcb; sm_rcs_t sm_rc; cc_action_data_t data; - int sdpmode = 0; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); @@ -6444,16 +6083,6 @@ fsmdef_ev_onhook (sm_event_t *event) return SM_RC_END; } - config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); - - if (sdpmode) { - if(dcb->ice_ufrag) - cpr_free(dcb->ice_ufrag); - - if(dcb->ice_pwd) - cpr_free(dcb->ice_pwd); - } - /* * If the user presses the ENDCALL softkey for an * incoming call set the release cause to Busy. diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c index f5829d4c57ce..38533b210651 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c @@ -5438,10 +5438,10 @@ gsmsdp_negotiate_media_lines (fsm_fcb_t *fcb_p, cc_sdp_t *sdp_p, boolean initial changes from 0 -> !0 (i.e. on creation). TODO(adam@nostrum.com): Figure out how to notify when streams gain tracks */ - ui_on_remote_stream_added(evOnRemoteStreamAdd, - 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]); + vcmOnRemoteStreamAdded( + CREATE_CALL_HANDLE(dcb_p->line, dcb_p->call_id), + dcb_p->peerconnection, + &dcb_p->remote_media_stream_tbl->streams[j]); dcb_p->remote_media_stream_tbl->streams[j].num_tracks_notified = dcb_p->remote_media_stream_tbl->streams[j].num_tracks; diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/h/fim.h b/media/webrtc/signaling/src/sipcc/core/gsm/h/fim.h index 5eeb26a354bd..d4b5ff756805 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/h/fim.h +++ b/media/webrtc/signaling/src/sipcc/core/gsm/h/fim.h @@ -63,4 +63,6 @@ cc_causes_t fsm_cac_call_bandwidth_req(callid_t call_id, uint32_t sessions, void *msg); +fim_icb_t *fim_get_call_chn_by_call_id (callid_t call_id); +fim_icb_t *fim_get_new_call_chn (callid_t call_id); #endif /* _FIM_H_ */ diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/h/fsm.h b/media/webrtc/signaling/src/sipcc/core/gsm/h/fsm.h index 4543543c2736..ea77ffb6dd99 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/h/fsm.h +++ b/media/webrtc/signaling/src/sipcc/core/gsm/h/fsm.h @@ -748,4 +748,38 @@ void fsmdef_update_media_cap_feature_event(cc_feature_t *msg); boolean fsmcnd_conf_call_id_valid(fsmcnf_ccb_t *ccb); boolean fsmdef_check_retain_fwd_info_state(void); + + +pc_error fsmdef_setpeerconnection(fsm_fcb_t *fcb, cc_feature_t *msg); +pc_error fsmdef_createoffer(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_createanswer(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_setlocaldesc(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_setremotedesc(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_addcandidate(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_foundcandidate(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *sdp_outparam, + string_t *error_outparam); +pc_error fsmdef_removestream(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *error_outparam); +pc_error fsmdef_addstream(fsm_fcb_t *fcb, + cc_feature_t *msg, + string_t *error_outparam); + #endif diff --git a/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h b/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h index 9835cee819c2..4d157fbd4c2c 100755 --- a/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h +++ b/media/webrtc/signaling/src/sipcc/core/includes/ccapi.h @@ -6,7 +6,6 @@ #define _CCAPI_H_ #include "mozilla/ArrayUtils.h" -#include "mozilla/Assertions.h" #if defined(__cplusplus) && __cplusplus >= 201103L typedef struct Timecard Timecard; @@ -94,15 +93,6 @@ typedef enum { CC_FEATURE_CAC_RESP_FAIL, CC_FEATURE_FAST_PIC_UPD, CC_FEATURE_UNDEFINED, - CC_FEATURE_CREATEOFFER, - CC_FEATURE_CREATEANSWER, - CC_FEATURE_SETLOCALDESC, - CC_FEATURE_SETREMOTEDESC, - CC_FEATURE_SETPEERCONNECTION, - CC_FEATURE_ADDSTREAM, - CC_FEATURE_REMOVESTREAM, - CC_FEATURE_ADDICECANDIDATE, - CC_FEATURE_FOUNDICECANDIDATE, CC_FEATURE_MAX } group_cc_feature_t; @@ -160,15 +150,6 @@ static const char *const cc_feature_names[] = { "CAC FAILED", "FAST_PIC_UPD", "UNDEFINED", - "CREATEOFFER", - "CREATEANSWER", - "SETLOCALDESC", - "SETREMOTEDESC", - "SETPEERCONNECTION", - "ADDSTREAM", - "REMOVESTREAM", - "ADDICECANDIDATE", - "FOUNDICECANDIDATE", "MAX" }; @@ -234,15 +215,6 @@ typedef enum cc_msgs_t_ { CC_MSG_DIALSTRING, CC_MSG_MWI, CC_MSG_AUDIT, - CC_MSG_CREATEOFFER, - CC_MSG_CREATEANSWER, - CC_MSG_SETLOCALDESC, - CC_MSG_SETREMOTEDESC, - CC_MSG_SETPEERCONNECTION, - CC_MSG_ADDSTREAM, - CC_MSG_REMOVESTREAM, - CC_MSG_ADDCANDIDATE, - CC_MSG_FOUNDCANDIDATE, CC_MSG_AUDIT_ACK, CC_MSG_OPTIONS, CC_MSG_OPTIONS_ACK, @@ -274,15 +246,6 @@ static const char *const cc_msg_names[] = { "DIALSTRING", "MWI", "AUDIT", - "CREATEOFFER", - "CREATEANSWER", - "SETLOCALDESC", - "SETREMOTEDESC", - "SETPEERCONNECTION", - "ADDSTREAM", - "REMOVESTREAM", - "ADDCANDIDATE", - "FOUNDCANDIDATE", "AUDIT_ACK", "OPTIONS", "OPTIONS_ACK", @@ -1188,22 +1151,6 @@ void cc_int_feature2(cc_msgs_t msg_id, cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, cc_features_t feature_id, cc_feature_data_t *data, Timecard *); -void cc_createoffer(cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, - line_t line, cc_features_t feature_id, cc_feature_data_t *data, - Timecard *); - -void cc_createanswer (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, - line_t line, cc_features_t feature_id, string_t sdp, cc_feature_data_t *data, - Timecard *); - -void cc_setlocaldesc (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, - cc_features_t feature_id, cc_jsep_action_t action, string_t sdp, cc_feature_data_t *data, - Timecard *); - -void cc_setremotedesc (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, - cc_features_t feature_id, cc_jsep_action_t action, string_t sdp, cc_feature_data_t *data, - Timecard *); - void cc_int_feature_ack(cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, line_t line, cc_features_t feature_id, cc_feature_data_t *data, cc_causes_t cause); diff --git a/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h b/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h index 4c7ddad4c17e..54ba1994b221 100755 --- a/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h +++ b/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h @@ -215,16 +215,7 @@ typedef enum { CALL_CALLREF, MEDIA_INTERFACE_UPDATE_BEGIN, MEDIA_INTERFACE_UPDATE_SUCCESSFUL, - MEDIA_INTERFACE_UPDATE_FAIL, - CREATE_OFFER, - CREATE_ANSWER, - SET_LOCAL_DESC, - SET_REMOTE_DESC, - UPDATE_LOCAL_DESC, - UPDATE_REMOTE_DESC, - REMOTE_STREAM_ADD, - ICE_CANDIDATE_ADD, - ICE_CANDIDATE_FOUND + MEDIA_INTERFACE_UPDATE_FAIL } group_call_event_t; /* File Player Session Events */ diff --git a/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h b/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h index 3eb4a913b485..3033689e2f1e 100644 --- a/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h +++ b/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h @@ -32,47 +32,9 @@ typedef enum { evHoldRevert = HOLDREVERT, evWhisper = WHISPER, evWaitingForDigits = WAITINGFORDIGITS, - evCreateOfferSuccess = CREATEOFFERSUCCESS, - evCreateAnswerSuccess = CREATEANSWERSUCCESS, - evCreateOfferError = CREATEOFFERERROR, - evCreateAnswerError = CREATEANSWERERROR, - evSetLocalDescSuccess = SETLOCALDESCSUCCESS, - evSetRemoteDescSuccess = SETREMOTEDESCSUCCESS, - evUpdateLocalDesc = UPDATELOCALDESC, - evSetLocalDescError = SETLOCALDESCERROR, - evSetRemoteDescError = SETREMOTEDESCERROR, - evOnRemoteStreamAdd = REMOTESTREAMADD, - evAddIceCandidate = ADDICECANDIDATE, - evAddIceCandidateError = ADDICECANDIDATEERROR, - evFoundIceCandidate = FOUNDICECANDIDATE, - evFoundIceCandidateError = FOUNDICECANDIDATEERROR, evMaxEvent } call_events; -/* These values must be kept in sync with the equivalent values in: - * - * PeerConnectionImpl.h - * Peerconnection.js - * nsIDOMPeerConnection.idl - * - * Yes, this is far from ideal, but there isn't an obviously cleaner - * way to deal with the situation within the constraints imposed on us - * by IDL. - */ - -typedef enum { - PC_NO_ERROR = 0, - PC_INVALID_CONSTRAINTS_TYPE = 1, - PC_INVALID_CANDIDATE_TYPE = 2, - PC_INVALID_MEDIASTREAM_TRACK = 3, - PC_INVALID_STATE = 4, - PC_INVALID_SESSION_DESCRIPTION = 5, - PC_INCOMPATIBLE_SESSION_DESCRIPTION = 6, - PC_INCOMPATIBLE_CONSTRAINTS = 7, - PC_INCOMPATIBLE_MEDIA_STREAM_TRACK = 8, - PC_INTERNAL_ERROR = 9 -} pc_error; - #define MWI_STATUS_YES 1 /* call operations : dialing, state change and info related */ @@ -180,85 +142,5 @@ void ui_call_start_ringer(vcm_ring_mode_t ringMode, short once, line_t line, cal void ui_BLF_notification (int request_id, cc_blf_state_t blf_state, int app_id); void ui_update_media_interface_change(line_t line, callid_t call_id, group_call_event_t event); -/* 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, - string_t sdp, - Timecard *timecard, - 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, - Timecard *timecard, - 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, - Timecard *timecard, - pc_error error, - 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, - string_t sdp, - Timecard *timecard, - pc_error error, - 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, - string_t sdp, - Timecard *timecard, - 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, - Timecard *timecard, - pc_error error, - const char *format, ...); - -void ui_ice_candidate_found(call_events event, - fsmdef_states_t new_state, - line_t nLine, - callid_t nCallID, - uint16_t call_instance_id, - string_t sdp, - string_t candidate, - Timecard *timecard, - pc_error error, - 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, - cc_media_remote_track_table_t media_tracks); - #endif diff --git a/media/webrtc/signaling/src/sipcc/core/src-common/string_lib.c b/media/webrtc/signaling/src/sipcc/core/src-common/string_lib.c index c9741ec71e77..6ef5d83f0d52 100755 --- a/media/webrtc/signaling/src/sipcc/core/src-common/string_lib.c +++ b/media/webrtc/signaling/src/sipcc/core/src-common/string_lib.c @@ -303,6 +303,20 @@ strlib_close (char *str) return (str); } +string_t strlib_printf(const char *format, ...) { + string_t result = strlib_empty(); + va_list args; + flex_string fs; + if (format) { + va_start(args, format); + flex_string_init(&fs); + flex_string_vsprintf(&fs, format, args); + result = strlib_malloc(fs.buffer, -1, __FILE__, __LINE__); + flex_string_free(&fs); + va_end(args); + } + return result; +} /* * Function: strlib_is_string @@ -320,8 +334,6 @@ strlib_is_string (string_t str) string_block_t *temp; if (str == NULL) { - CSFLogError("src-common", - "Strlib Error: strlib_is_tring passed invalid string\n"); return (0); } diff --git a/media/webrtc/signaling/src/sipcc/include/cc_call_feature.h b/media/webrtc/signaling/src/sipcc/include/cc_call_feature.h index 3ef56453c5fa..72c6c7d92d8f 100644 --- a/media/webrtc/signaling/src/sipcc/include/cc_call_feature.h +++ b/media/webrtc/signaling/src/sipcc/include/cc_call_feature.h @@ -157,43 +157,6 @@ cc_return_t CC_CallFeature_backSpace(cc_call_handle_t call_handle); */ cc_return_t CC_CallFeature_dial(cc_call_handle_t call_handle, cc_sdp_direction_t video_pref, const cc_string_t numbers); -cc_return_t CC_CallFeature_CreateOffer(cc_call_handle_t call_handle, - cc_media_options_t *options, - Timecard *tc); - -cc_return_t CC_CallFeature_CreateAnswer(cc_call_handle_t call_handle, - Timecard *tc); - -cc_return_t CC_CallFeature_SetLocalDescription(cc_call_handle_t call_handle, - cc_jsep_action_t action, - const char* sdp, - Timecard *tc); - -cc_return_t CC_CallFeature_SetRemoteDescription(cc_call_handle_t call_handle, - cc_jsep_action_t action, - const char* sdp, - Timecard *tc); - -cc_return_t CC_CallFeature_SetPeerConnection(cc_call_handle_t call_handle, cc_peerconnection_t pc); - -cc_return_t CC_CallFeature_AddStream(cc_call_handle_t call_handle, - cc_media_stream_id_t stream_id, - cc_media_track_id_t id, - cc_media_type_t media_type); - -cc_return_t CC_CallFeature_RemoveStream(cc_call_handle_t call_handle, cc_media_stream_id_t stream_id, cc_media_track_id_t id, cc_media_type_t media_type); - -cc_return_t CC_CallFeature_AddICECandidate(cc_call_handle_t call_handle, - const char* candidate, - const char *mid, - cc_level_t level, - Timecard *tc); -cc_return_t CC_CallFeature_FoundICECandidate(cc_call_handle_t call_handle, - const char* candidate, - const char *mid, - cc_level_t level, - Timecard *tc); - /** * Initiate a speed dial. * @param call_handle call handle diff --git a/media/webrtc/signaling/src/sipcc/include/cc_constants.h b/media/webrtc/signaling/src/sipcc/include/cc_constants.h index b5f51ef85633..8f6503cef408 100644 --- a/media/webrtc/signaling/src/sipcc/include/cc_constants.h +++ b/media/webrtc/signaling/src/sipcc/include/cc_constants.h @@ -276,21 +276,6 @@ typedef enum { WHISPER, PRESERVATION, WAITINGFORDIGITS = 21, - CREATEOFFERSUCCESS, - CREATEANSWERSUCCESS, - CREATEOFFERERROR, - CREATEANSWERERROR, - SETLOCALDESCSUCCESS, - SETREMOTEDESCSUCCESS, - UPDATELOCALDESC, - UPDATEREMOTEDESC, - SETLOCALDESCERROR, - SETREMOTEDESCERROR, - REMOTESTREAMADD, - ADDICECANDIDATE, - ADDICECANDIDATEERROR, - FOUNDICECANDIDATE, - FOUNDICECANDIDATEERROR, MAX_CALL_STATES } cc_call_state_t; @@ -560,6 +545,30 @@ typedef enum { } cc_jsep_action_t; +/* These values must be kept in sync with the equivalent values in: + * + * PeerConnectionImpl.h + * Peerconnection.js + * nsIDOMPeerConnection.idl + * + * Yes, this is far from ideal, but there isn't an obviously cleaner + * way to deal with the situation within the constraints imposed on us + * by IDL. + */ + +typedef enum { + PC_NO_ERROR = 0, + PC_INVALID_CONSTRAINTS_TYPE = 1, + PC_INVALID_CANDIDATE_TYPE = 2, + PC_INVALID_MEDIASTREAM_TRACK = 3, + PC_INVALID_STATE = 4, + PC_INVALID_SESSION_DESCRIPTION = 5, + PC_INCOMPATIBLE_SESSION_DESCRIPTION = 6, + PC_INCOMPATIBLE_CONSTRAINTS = 7, + PC_INCOMPATIBLE_MEDIA_STREAM_TRACK = 8, + PC_INTERNAL_ERROR = 9 +} pc_error; + typedef cc_string_t cc_peerconnection_t; typedef unsigned int cc_media_stream_id_t; diff --git a/media/webrtc/signaling/src/sipcc/include/ccapi_call.h b/media/webrtc/signaling/src/sipcc/include/ccapi_call.h index 05a89957458f..3db77eda7464 100644 --- a/media/webrtc/signaling/src/sipcc/include/ccapi_call.h +++ b/media/webrtc/signaling/src/sipcc/include/ccapi_call.h @@ -54,44 +54,6 @@ cc_lineid_t CCAPI_Call_getLine(cc_call_handle_t call_handle); cc_return_t CCAPI_Call_originateCall(cc_call_handle_t handle, cc_sdp_direction_t video_pref, cc_string_t digits); -cc_return_t CCAPI_CreateOffer(cc_call_handle_t handle, - cc_media_options_t *options, - Timecard *tc); - -cc_return_t CCAPI_CreateAnswer(cc_call_handle_t handle, - Timecard *tc); - -cc_return_t CCAPI_SetLocalDescription(cc_call_handle_t handle, - cc_jsep_action_t action, - cc_string_t sdp, - Timecard *tc); - -cc_return_t CCAPI_SetRemoteDescription(cc_call_handle_t handle, - cc_jsep_action_t action, - cc_string_t sdp, - Timecard *tc); - -cc_return_t CCAPI_SetPeerConnection(cc_call_handle_t handle, cc_peerconnection_t pc); - -cc_return_t CCAPI_AddStream(cc_call_handle_t handle, - cc_media_stream_id_t stream_id, - cc_media_track_id_t track_id, - cc_media_type_t media_type); - -cc_return_t CCAPI_RemoveStream(cc_call_handle_t handle, cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type); - -cc_return_t CCAPI_AddICECandidate(cc_call_handle_t handle, - cc_string_t candidate, - cc_string_t mid, - cc_level_t level, - Timecard *tc); - -cc_return_t CCAPI_FoundICECandidate(cc_call_handle_t handle, - cc_string_t candidate, - cc_string_t mid, - cc_level_t level, - Timecard *tc); - /** * Send digits on the call - can be invoked either to dial additional digits or send DTMF * @param [in] handle - call handle diff --git a/media/webrtc/signaling/src/sipcc/include/ccapi_call_info.h b/media/webrtc/signaling/src/sipcc/include/ccapi_call_info.h index a121aae45df4..c07cfd1778fa 100644 --- a/media/webrtc/signaling/src/sipcc/include/ccapi_call_info.h +++ b/media/webrtc/signaling/src/sipcc/include/ccapi_call_info.h @@ -295,39 +295,4 @@ cc_boolean CCAPI_CallInfo_isAudioMuted(cc_callinfo_ref_t handle); */ cc_boolean CCAPI_CallInfo_isVideoMuted(cc_callinfo_ref_t handle); -/** - * get SDP string CreateOffer and CreateAnswer callback - * @param [in] handle - call info handle - * @return sdp - */ -cc_string_t CCAPI_CallInfo_getSDP(cc_callinfo_ref_t handle); - -/** - * get trickle candidate - * @param [in] handle - call info handle - * @return sdp - */ -cc_string_t CCAPI_CallInfo_getCandidate(cc_callinfo_ref_t handle); - -/** - * get status code from internal JSEP functions - * @param [in] handle - call info handle - * @return status code - */ -cc_int32_t CCAPI_CallInfo_getStatusCode(cc_callinfo_ref_t handle); - -/** - * get media stream table - * @param [in] handle - call info handle - * @return media track table - */ -MediaStreamTable* CCAPI_CallInfo_getMediaStreams(cc_callinfo_ref_t handle); - -/** - * Take posession of timecard - * @param [in] handle - call info handle - * @return timecard pointer - */ -Timecard* CCAPI_CallInfo_takeTimecard(cc_callinfo_ref_t handle); - #endif /* _CCAPIAPI_CALL_INFO_H_ */ diff --git a/media/webrtc/signaling/src/sipcc/include/vcm.h b/media/webrtc/signaling/src/sipcc/include/vcm.h index f23dff720123..7f868c32ea6b 100755 --- a/media/webrtc/signaling/src/sipcc/include/vcm.h +++ b/media/webrtc/signaling/src/sipcc/include/vcm.h @@ -598,6 +598,13 @@ int vcmRxStart(cc_mcapid_t mcap_id, vcm_mediaAttrs_t *attrs); +struct cc_media_remote_track_table_t_; +typedef struct cc_media_remote_track_table_t_ vcm_media_remote_track_table_t; + +void vcmOnRemoteStreamAdded(cc_call_handle_t call_handle, + const char* peer_connection_handle, + vcm_media_remote_track_table_t *media_tracks); + /** * start rx stream * Same concept as vcmRxStart but for ICE/PeerConnection-based flows diff --git a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.cpp b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.cpp index 9e71eda033bb..5475c2df076c 100644 --- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.cpp +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.cpp @@ -13,12 +13,20 @@ #include "CSFVideoTermination.h" #include "CSFAudioTermination.h" #include "CSFAudioControl.h" +// fsm.h picks this include up as a c header, causing trouble later +#include "mozilla/ArrayUtils.h" + extern "C" { #include "ccapi_call.h" #include "ccapi_call_listener.h" #include "config_api.h" +#include "cc_constants.h" +#include "phone_types.h" +#include "fsm.h" +#include "fim.h" +#include "string_lib.h" } using namespace std; @@ -30,7 +38,10 @@ CSF_IMPLEMENT_WRAP(CC_SIPCCCall, cc_call_handle_t); CC_SIPCCCall::CC_SIPCCCall (cc_call_handle_t aCallHandle) : callHandle(aCallHandle), - pMediaData(new CC_SIPCCCallMediaData(nullptr, false, false, -1)) + pMediaData(new CC_SIPCCCallMediaData(nullptr, false, false, -1)), + localSdp(NULL), + remoteSdp(NULL), + errorString(NULL) { CSFLogInfo( logTag, "Creating CC_SIPCCCall %u", callHandle ); @@ -42,6 +53,11 @@ CC_SIPCCCall::CC_SIPCCCall (cc_call_handle_t aCallHandle) : } } +CC_SIPCCCall::~CC_SIPCCCall() { + strlib_free(localSdp); + strlib_free(remoteSdp); + strlib_free(errorString); +} /* CCAPI_CALL_EV_CAPABILITY -- From phone team: "...CCAPI_CALL_EV_CAPABILITY is generated for the capability changes but we decided to @@ -121,11 +137,79 @@ void CC_SIPCCCall::sendIFrame() } } +fsm_fcb_t* CC_SIPCCCall::getFcb() const +{ + callid_t call_id = GET_CALL_ID(callHandle); + + // TODO(Bug 1065020): Create and hold our own call state + fim_icb_t *call_chn = fim_get_call_chn_by_call_id(call_id); + + if (!call_chn) + return nullptr; + + // The fcb (whatever that means) we want is buried in a fixed-size + // linked-list (arrays are for the weak) of icbs (whatever that means). + // We want FSM_TYPE_DEF (don't even ask what "DEF" means, of course it's + // the one we want, because its meaning is the most mysterious of available + // options). + fsm_fcb_t *fcb = (fsm_fcb_t*) call_chn->next_icb // FSM_TYPE_CNF + ->next_icb // FSM_TYPE_B2BCNF + ->next_icb // FSM_TYPE_XFR + ->next_icb->cb; // FSM_TYPE_DEF + return fcb; +} + +void CC_SIPCCCall::getLocalSdp(std::string *sdp) const { + if (localSdp) { + *sdp = localSdp; + } else { + sdp->clear(); + } +} + +void CC_SIPCCCall::getRemoteSdp(std::string *sdp) const { + if (remoteSdp) { + *sdp = remoteSdp; + } else { + sdp->clear(); + } +} + +fsmdef_states_t CC_SIPCCCall::getFsmState() const { + fsm_fcb_t *fcb = getFcb(); + if (!fcb) { + return FSMDEF_S_CLOSED; + } + + return (fsmdef_states_t)fcb->state; +} + +std::string CC_SIPCCCall::fsmStateToString (fsmdef_states_t state) const { + return fsmdef_state_name(state); +} + +void CC_SIPCCCall::getErrorString(std::string *error) const { + if (errorString) { + *error = errorString; + } else { + error->clear(); + } +} + +pc_error CC_SIPCCCall::getError() const { + return error; +} + + + CC_CallInfoPtr CC_SIPCCCall::getCallInfo () { cc_callinfo_ref_t callInfo = CCAPI_Call_getCallInfo(callHandle); CC_SIPCCCallInfoPtr callInfoPtr = CC_SIPCCCallInfo::wrap(callInfo); callInfoPtr->setMediaData( pMediaData); + // This starts out with a refcount of 1, and we've now bumped it to 2 by + // placing it in a CC_SIPCCCallInfoPtr + CCAPI_Call_releaseCallInfo(callInfo); return callInfoPtr.get(); } @@ -521,66 +605,294 @@ void CC_SIPCCCall::originateP2PCall (cc_sdp_direction_t video_pref, const std::s CCAPI_Call_originateCall(callHandle, video_pref, digits.c_str()); } -/* - * This method works asynchronously, is an onCallEvent with the resulting SDP - */ -void CC_SIPCCCall::createOffer (cc_media_options_t *options, Timecard *tc) { - CCAPI_CreateOffer(callHandle, options, tc); -} -/* - * This method works asynchronously, there is onCallEvent with the resulting SDP - */ -void CC_SIPCCCall::createAnswer (Timecard *tc) { - CCAPI_CreateAnswer(callHandle, tc); +fsm_fcb_t* CC_SIPCCCall::preOperationBoilerplate(cc_feature_t *command, + Timecard *tc) { + // Make sure the old error string doesn't hang around. + strlib_free(errorString); + errorString = NULL; + + // Get the fcb, and if it fails, set the appropriate error stuff + fsm_fcb_t *fcb = getFcb(); + if (!fcb) { + errorString = strlib_printf("No call state object"); + // Can happen if we create too many peerconnections simultaneously + error = PC_INTERNAL_ERROR; + return NULL; + } + + // Perform common init on the command struct + memset(command, 0, sizeof(cc_feature_t)); + command->call_id = GET_CALL_ID(callHandle); + command->line = GET_LINE_ID(callHandle); + command->timecard = tc; + return fcb; } -void CC_SIPCCCall::setLocalDescription(cc_jsep_action_t action, +pc_error CC_SIPCCCall::createOffer (cc_media_options_t *options, Timecard *tc) { + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + command.data.session.options = options; + + switch (fcb->state) { + case FSMDEF_S_STABLE: + strlib_free(localSdp); + localSdp = NULL; + error = fsmdef_createoffer(fcb, &command, &localSdp, &errorString); + break; + default: + error = PC_INVALID_STATE; + errorString = strlib_printf("Cannot create offer in state %s", + fsmdef_state_name(fcb->state)); + } + return error; +} + + +pc_error CC_SIPCCCall::createAnswer (Timecard *tc) { + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_REMOTE_OFFER: + strlib_free(localSdp); + localSdp = NULL; + error = fsmdef_createanswer(fcb, &command, &localSdp, &errorString); + break; + default: + error = PC_INVALID_STATE; + errorString = strlib_printf("Cannot create answer in state %s", + fsmdef_state_name(fcb->state)); + } + return error; +} + +pc_error CC_SIPCCCall::setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *tc) { - CCAPI_SetLocalDescription(callHandle, action, sdp.c_str(), tc); + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + command.action = action; + command.sdp = const_cast(sdp.c_str()); // Ugh + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_REMOTE_OFFER: + strlib_free(localSdp); + localSdp = NULL; + error = fsmdef_setlocaldesc(fcb, &command, &localSdp, &errorString); + break; + default: + error = PC_INVALID_STATE; + errorString = strlib_printf("Cannot set local SDP in state %s", + fsmdef_state_name(fcb->state)); + } + return error; } -void CC_SIPCCCall::setRemoteDescription(cc_jsep_action_t action, +pc_error CC_SIPCCCall::setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *tc) { - CCAPI_SetRemoteDescription(callHandle, action, sdp.c_str(), tc); + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + command.action = action; + command.sdp = const_cast(sdp.c_str()); // Ugh + + switch (fcb->state) { + case FSMDEF_S_STABLE: // should be an offer + case FSMDEF_S_HAVE_LOCAL_OFFER: // should be an answer + case FSMDEF_S_HAVE_REMOTE_PRANSWER: + // TODO: Refactor so that error-handling is performed here? + strlib_free(remoteSdp); + remoteSdp = NULL; + error = fsmdef_setremotedesc(fcb, &command, &remoteSdp, &errorString); + break; + default: + error = PC_INVALID_STATE; + errorString = strlib_printf("Cannot set remote SDP in state %s", + fsmdef_state_name(fcb->state)); + } + return error; } -void CC_SIPCCCall::setPeerConnection(const std::string& handle) +pc_error CC_SIPCCCall::setPeerConnection(const std::string& handle) { CSFLogDebug(logTag, "setPeerConnection"); + // Cause the fcb to be created + fim_get_new_call_chn(GET_CALL_ID(callHandle)); + + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, NULL); + + if (!fcb) { + return error; + } + peerconnection = handle; // Cache this here. we need it to make the CC_SIPCCCallInfo - CCAPI_SetPeerConnection(callHandle, handle.c_str()); + + strncpy(command.data.pc.pc_handle, + handle.c_str(), + sizeof(command.data.pc.pc_handle)); + + switch (fcb->state) { + case FSMDEF_S_IDLE: + fsmdef_setpeerconnection(fcb, &command); + // TODO Maybe let this return errors like the other stuff? + error = PC_NO_ERROR; + break; + default: + errorString = strlib_printf("Cannot set peerconnection in state %s", + fsmdef_state_name(fcb->state)); + error = PC_INVALID_STATE; + } + return error; } const std::string& CC_SIPCCCall::getPeerConnection() const { return peerconnection; } -void CC_SIPCCCall::addStream(cc_media_stream_id_t stream_id, +pc_error CC_SIPCCCall::addStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) { - CCAPI_AddStream(callHandle, stream_id, track_id, media_type); + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, NULL); + + if (!fcb) { + return error; + } + + command.data.track.stream_id = stream_id; + command.data.track.track_id = track_id; + command.data.track.media_type = media_type; + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_REMOTE_OFFER: + error = fsmdef_addstream(fcb, &command, &errorString); + break; + default: + errorString = strlib_printf("Cannot add stream in state %s", + fsmdef_state_name(fcb->state)); + error = PC_INVALID_STATE; + } + return error; } -void CC_SIPCCCall::removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) { - CCAPI_RemoveStream(callHandle, stream_id, track_id, media_type); +pc_error CC_SIPCCCall::removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type) { + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, NULL); + + if (!fcb) { + return error; + } + + command.data.track.stream_id = stream_id; + command.data.track.track_id = track_id; + command.data.track.media_type = media_type; + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_REMOTE_OFFER: + error = fsmdef_removestream(fcb, &command, &errorString); + break; + default: + errorString = strlib_printf("Cannot remove stream in state %s", + fsmdef_state_name(fcb->state)); + error = PC_INVALID_STATE; + } + return error; } -void CC_SIPCCCall::addICECandidate(const std::string & candidate, +pc_error CC_SIPCCCall::addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *tc) { - CCAPI_AddICECandidate(callHandle, candidate.c_str(), mid.c_str(), - (cc_level_t) level, tc); + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + command.data.candidate.level = level; + strncpy(command.data.candidate.candidate, + candidate.c_str(), + sizeof(command.data.candidate.candidate)); + strncpy(command.data.candidate.mid, + mid.c_str(), + sizeof(command.data.candidate.mid)); + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_REMOTE_OFFER: + case FSMDEF_S_HAVE_LOCAL_PRANSWER: + case FSMDEF_S_HAVE_REMOTE_PRANSWER: + strlib_free(remoteSdp); + remoteSdp = NULL; + error = fsmdef_addcandidate(fcb, &command, &remoteSdp, &errorString); + break; + default: + errorString = strlib_printf("Cannot add remote candidate in state %s", + fsmdef_state_name(fcb->state)); + error = PC_INVALID_STATE; + } + return error; } -void CC_SIPCCCall::foundICECandidate(const std::string & candidate, +pc_error CC_SIPCCCall::foundICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *tc) { - CCAPI_FoundICECandidate(callHandle, candidate.c_str(), mid.c_str(), - (cc_level_t) level, tc); + cc_feature_t command; + fsm_fcb_t *fcb = preOperationBoilerplate(&command, tc); + + if (!fcb) { + return error; + } + + command.data.candidate.level = level; + strncpy(command.data.candidate.candidate, + candidate.c_str(), + sizeof(command.data.candidate.candidate)); + strncpy(command.data.candidate.mid, + mid.c_str(), + sizeof(command.data.candidate.mid)); + + switch (fcb->state) { + case FSMDEF_S_STABLE: + case FSMDEF_S_HAVE_LOCAL_OFFER: + case FSMDEF_S_HAVE_LOCAL_PRANSWER: + case FSMDEF_S_HAVE_REMOTE_PRANSWER: + strlib_free(localSdp); + localSdp = NULL; + error = fsmdef_foundcandidate(fcb, &command, &localSdp, &errorString); + break; + default: + errorString = strlib_printf("Cannot add local candidate in state %s", + fsmdef_state_name(fcb->state)); + error = PC_INVALID_STATE; + } + return error; } diff --git a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.h b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.h index 8164f8179299..f7bc796d01df 100644 --- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.h +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCall.h @@ -18,6 +18,16 @@ typedef struct Timecard Timecard; #include "common/Wrapper.h" #include "common/csf_common.h" +extern "C" { +#include "cpr_types.h" +} + +struct fsm_fcb_t_; +typedef struct fsm_fcb_t_ fsm_fcb_t; + +struct cc_feature_t_; +typedef struct cc_feature_t_ cc_feature_t; + namespace CSF { struct StreamInfo @@ -65,8 +75,16 @@ namespace CSF private: cc_call_handle_t callHandle; explicit CC_SIPCCCall (cc_call_handle_t aCallHandle); + virtual ~CC_SIPCCCall(); CC_SIPCCCallMediaDataPtr pMediaData; std::string peerconnection; // The peerconnection handle + fsm_fcb_t* getFcb() const; + fsm_fcb_t* preOperationBoilerplate(cc_feature_t *command, Timecard *tc); + string_t localSdp; + string_t remoteSdp; + string_t errorString; + pc_error error; + public: virtual inline std::string toString() { @@ -77,6 +95,13 @@ namespace CSF return result; }; + virtual void getLocalSdp(std::string *sdp) const; + virtual void getRemoteSdp(std::string *sdp) const; + virtual fsmdef_states_t getFsmState () const; + virtual std::string fsmStateToString (fsmdef_states_t state) const; + virtual void getErrorString(std::string *error) const; + virtual pc_error getError() const; + virtual void setRemoteWindow (VideoWindowHandle window); virtual int setExternalRenderer(VideoFormat vFormat, ExternalRendererHandle renderer); virtual void sendIFrame(); @@ -113,19 +138,19 @@ namespace CSF virtual void removeStream(int streamId); virtual bool setVolume(int volume); virtual void originateP2PCall (cc_sdp_direction_t video_pref, const std::string & digits, const std::string & ip); - virtual void createOffer(cc_media_options_t *options, Timecard *); - virtual void createAnswer(Timecard *); - virtual void setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *); - virtual void setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *); - virtual void setPeerConnection(const std::string& handle); + virtual pc_error createOffer(cc_media_options_t *options, Timecard*); + virtual pc_error createAnswer(Timecard*); + virtual pc_error setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard*); + virtual pc_error setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard*); + virtual pc_error setPeerConnection(const std::string& handle); virtual const std::string& getPeerConnection() const; - virtual void addStream(cc_media_stream_id_t stream_id, + virtual pc_error addStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type); - virtual void removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type); + virtual pc_error removeStream(cc_media_stream_id_t stream_id, cc_media_track_id_t track_id, cc_media_type_t media_type); virtual CC_SIPCCCallMediaDataPtr getMediaData(); - virtual void addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *); - virtual void foundICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard *); + virtual pc_error addICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard*); + virtual pc_error foundICECandidate(const std::string & candidate, const std::string & mid, unsigned short level, Timecard*); private: virtual bool setAudioMute(bool mute); diff --git a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp index 847c33ef537e..1b79448b2a0e 100644 --- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp @@ -126,42 +126,6 @@ std::string CC_SIPCCCallInfo::callStateToString (cc_call_state_t state) case WAITINGFORDIGITS: statestr = "WAITINGFORDIGITS"; break; - case CREATEOFFERSUCCESS: - statestr = "CREATEOFFERSUCCESS"; - break; - case CREATEANSWERSUCCESS: - statestr = "CREATEANSWERSUCCESS"; - break; - case CREATEOFFERERROR: - statestr = "CREATEOFFERERROR"; - break; - case CREATEANSWERERROR: - statestr = "CREATEANSWERERROR"; - break; - case SETLOCALDESCSUCCESS: - statestr = "SETLOCALDESCSUCCESS"; - break; - case SETREMOTEDESCSUCCESS: - statestr = "SETREMOTEDESCSUCCESS"; - break; - case UPDATELOCALDESC: - statestr = "UPDATELOCALDESC"; - break; - case SETLOCALDESCERROR: - statestr = "SETLOCALDESCERROR"; - break; - case SETREMOTEDESCERROR: - statestr = "SETREMOTEDESCERROR"; - break; - case REMOTESTREAMADD: - statestr = "REMOTESTREAMADD"; - break; - case ADDICECANDIDATE: - statestr = "ADDICECANDIDATE"; - break; - case ADDICECANDIDATEERROR: - statestr = "ADDICECANDIDATEERROR"; - break; default: break; } @@ -434,31 +398,6 @@ bool CC_SIPCCCallInfo::isVideoMuted() return (CCAPI_CallInfo_isVideoMuted(callinfo_ref) != 0); } -string CC_SIPCCCallInfo::getSDP() -{ - return CCAPI_CallInfo_getSDP(callinfo_ref); -} - -cc_int32_t CC_SIPCCCallInfo::getStatusCode() -{ - return CCAPI_CallInfo_getStatusCode(callinfo_ref); -} - -MediaStreamTable* CC_SIPCCCallInfo::getMediaStreams() const -{ - return CCAPI_CallInfo_getMediaStreams(callinfo_ref); -} - -Timecard *CC_SIPCCCallInfo::takeTimecard() -{ - return CCAPI_CallInfo_takeTimecard(callinfo_ref); -} - -std::string CC_SIPCCCallInfo::getCandidate() -{ - return CCAPI_CallInfo_getCandidate(callinfo_ref); -} - bool CC_SIPCCCallInfo::isMediaStateAvailable() { // for softphone it will always be possible to query the mute state and video direction diff --git a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.h b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.h index fb6dd057c03e..6538bdd9b601 100644 --- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.h +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.h @@ -79,11 +79,6 @@ namespace CSF virtual bool isMediaStateAvailable(); virtual bool isAudioMuted(); virtual bool isVideoMuted(); - virtual std::string getSDP(); - virtual std::string getCandidate(); - virtual cc_int32_t getStatusCode(); - virtual MediaStreamTable* getMediaStreams() const; - virtual Timecard *takeTimecard(); virtual void setMediaData(CC_SIPCCCallMediaDataPtr pMediaData);