Bug 1060625: Remove sipcc wrapper code around SDP operations. r=mt

This commit is contained in:
Byron Campen [:bwc] 2014-09-08 13:49:37 -07:00
Родитель 62fae135f8
Коммит 940a3086a0
33 изменённых файлов: 1533 добавлений и 2790 удалений

Просмотреть файл

@ -11,6 +11,7 @@
extern "C" extern "C"
{ {
#include "ccapi_types.h" #include "ccapi_types.h"
#include "fsmdef_states.h"
} }
#if defined(__cplusplus) && __cplusplus >= 201103L #if defined(__cplusplus) && __cplusplus >= 201103L
@ -38,6 +39,14 @@ namespace CSF
virtual void sendIFrame () = 0; 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 CC_CallInfoPtr getCallInfo () = 0;
virtual std::string toString() = 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 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_track_id_t track_id,
cc_media_type_t media_type) = 0; 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 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;
}; };
} }

Просмотреть файл

@ -335,37 +335,5 @@ namespace CSF
*/ */
virtual int getVolume() = 0; 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;
}; };
}; };

Просмотреть файл

@ -50,6 +50,11 @@
'./include', './include',
'./src/sipcc/include', './src/sipcc/include',
'./src/sipcc/cpr/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', '../../../xpcom/base',
'../../../dom/base', '../../../dom/base',
'../../../content/media', '../../../content/media',

Просмотреть файл

@ -48,9 +48,10 @@
extern "C" { extern "C" {
#include "ccsdp.h" #include "ccsdp.h"
#include "vcm.h" #include "ccapi.h"
#include "cip_mmgr_mediadefinitions.h" #include "cip_mmgr_mediadefinitions.h"
#include "cip_Sipcc_CodecMask.h" #include "cip_Sipcc_CodecMask.h"
#include "peer_connection_types.h"
extern void lsm_start_multipart_tone_timer (vcm_tones_t tone, extern void lsm_start_multipart_tone_timer (vcm_tones_t tone,
uint32_t delay, uint32_t delay,
@ -71,13 +72,6 @@ static int vcmEnsureExternalCodec(
static const char* logTag = "VcmSipccBinding"; 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 #define SIPSDP_ILBC_MODE20 20
/* static */ /* 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 * start rx stream
* Same concept as vcmRxStart but for ICE/PeerConnection-based flows * Same concept as vcmRxStart but for ICE/PeerConnection-based flows

Просмотреть файл

@ -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 } // namespace sipcc

Просмотреть файл

@ -22,6 +22,7 @@
#include "StaticPtr.h" #include "StaticPtr.h"
#include "PeerConnectionImpl.h" #include "PeerConnectionImpl.h"
#include "mozIGeckoMediaPluginService.h" #include "mozIGeckoMediaPluginService.h"
#include "nsIRunnable.h"
namespace mozilla { namespace mozilla {
class PeerConnectionCtxShutdown; 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 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 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 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 // Create a SIPCC Call
CSF::CC_CallPtr createCall(); CSF::CC_CallPtr createCall();

Просмотреть файл

@ -234,271 +234,6 @@ private:
}; };
} }
class PeerConnectionObserverDispatch : public nsRunnable {
public:
PeerConnectionObserverDispatch(CSF::CC_CallInfoPtr aInfo,
nsRefPtr<PeerConnectionImpl> aPC,
PeerConnectionObserver* aObserver)
: mPC(aPC),
mObserver(aObserver),
mCode(static_cast<PeerConnectionImpl::Error>(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<PeerConnectionObserver> 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<nsRefPtr<MediaStreamTrack>> 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<PeerConnectionObserver> 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<std::string> &errors = mPC->GetSdpParseErrors();
std::vector<std::string>::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<PCImplSignalingState>(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<PeerConnectionImpl> mPC;
nsRefPtr<PeerConnectionObserver> 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<RemoteSourceStreamInfo> mRemoteStream;
};
NS_IMPL_ISUPPORTS0(PeerConnectionImpl) NS_IMPL_ISUPPORTS0(PeerConnectionImpl)
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
@ -1123,7 +858,9 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
if (!mHaveDataStream) { if (!mHaveDataStream) {
// XXX stream_id of 0 might confuse things... // 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; mHaveDataStream = true;
} }
nsIDOMDataChannel *retval; nsIDOMDataChannel *retval;
@ -1215,30 +952,59 @@ PeerConnectionImpl::CreateOffer(const RTCOfferOptions& aOptions)
return CreateOffer(SipccOfferOptions(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. // Used by unit tests and the IDL CreateOffer.
NS_IMETHODIMP NS_IMETHODIMP
PeerConnectionImpl::CreateOffer(const SipccOfferOptions& aOptions) PeerConnectionImpl::CreateOffer(const SipccOfferOptions& aOptions)
{ {
PC_AUTO_ENTER_API_CALL(true); PC_AUTO_ENTER_API_CALL(true);
Timecard *tc = mTimeCard; JSErrorResult rv;
mTimeCard = nullptr; nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
STAMP_TIMECARD(tc, "Create Offer"); if (!pco) {
return NS_OK;
cc_media_options_t* cc_options = aOptions.build(); }
NS_ENSURE_TRUE(cc_options, NS_ERROR_UNEXPECTED);
if (!PeerConnectionCtx::GetInstance()->isReady()) { if (!PeerConnectionCtx::GetInstance()->isReady()) {
// Uh oh. We're not ready yet. Enqueue this operation. // Uh oh. We're not ready yet. Enqueue this operation.
PeerConnectionCtx::GetInstance()->queueJSEPOperation( PeerConnectionCtx::GetInstance()->queueJSEPOperation(
WrapRunnable(mInternal->mCall, WrapRunnableNM(DeferredCreateOffer, mHandle, aOptions));
&CSF::CC_Call::createOffer, STAMP_TIMECARD(mTimeCard, "Deferring CreateOffer (not ready)");
cc_options, return NS_OK;
tc));
} else {
mInternal->mCall->createOffer(cc_options, tc);
} }
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; return NS_OK;
} }
@ -1247,14 +1013,43 @@ PeerConnectionImpl::CreateAnswer()
{ {
PC_AUTO_ENTER_API_CALL(true); PC_AUTO_ENTER_API_CALL(true);
Timecard *tc = mTimeCard; JSErrorResult rv;
mTimeCard = nullptr; nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
STAMP_TIMECARD(tc, "Create Answer"); 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; return NS_OK;
} }
static void appendSdpParseErrors(const std::vector<std::string>& 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 NS_IMETHODIMP
PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP)
{ {
@ -1265,9 +1060,13 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
Timecard *tc = mTimeCard; JSErrorResult rv;
mTimeCard = nullptr; nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
STAMP_TIMECARD(tc, "Set Local Description"); if (!pco) {
return NS_OK;
}
STAMP_TIMECARD(mTimeCard, "Set Local Description");
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
bool isolated = mMedia->AnyLocalStreamHasPeerIdentity(); bool isolated = mMedia->AnyLocalStreamHasPeerIdentity();
@ -1275,11 +1074,43 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP)
#endif #endif
mLocalRequestedSDP = aSDP; mLocalRequestedSDP = aSDP;
mInternal->mCall->setLocalDescription((cc_jsep_action_t)aAction, cc_int32_t error = mInternal->mCall->setLocalDescription(
mLocalRequestedSDP, tc); (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; 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 NS_IMETHODIMP
PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP)
{ {
@ -1290,26 +1121,50 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
Timecard *tc = mTimeCard; JSErrorResult rv;
mTimeCard = nullptr; nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
STAMP_TIMECARD(tc, "Set Remote Description"); if (!pco) {
return NS_OK;
mRemoteRequestedSDP = aSDP; }
if (!PeerConnectionCtx::GetInstance()->isReady()) { if (!PeerConnectionCtx::GetInstance()->isReady()) {
// Uh oh. We're not ready yet. Enqueue this operation. (This must be a // 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) // remote offer, or else we would not have gotten this far)
PeerConnectionCtx::GetInstance()->queueJSEPOperation( PeerConnectionCtx::GetInstance()->queueJSEPOperation(
WrapRunnable(mInternal->mCall, WrapRunnableNM(DeferredSetRemote,
&CSF::CC_Call::setRemoteDescription, mHandle,
(cc_jsep_action_t)action, action,
mRemoteRequestedSDP, std::string(aSDP)));
tc)); STAMP_TIMECARD(mTimeCard, "Deferring SetRemote (not ready)");
} else { return NS_OK;
mInternal->mCall->setRemoteDescription((cc_jsep_action_t)action,
mRemoteRequestedSDP, tc);
} }
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; return NS_OK;
} }
@ -1372,9 +1227,13 @@ NS_IMETHODIMP
PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) { PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) {
PC_AUTO_ENTER_API_CALL(true); PC_AUTO_ENTER_API_CALL(true);
Timecard *tc = mTimeCard; JSErrorResult rv;
mTimeCard = nullptr; nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
STAMP_TIMECARD(tc, "Add Ice Candidate"); if (!pco) {
return NS_OK;
}
STAMP_TIMECARD(mTimeCard, "Add Ice Candidate");
#ifdef MOZILLA_INTERNAL_API #ifdef MOZILLA_INTERNAL_API
// When remote candidates are added before our ICE ctx is up and running // 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 #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; return NS_OK;
} }
#ifdef MOZILLA_INTERNAL_API
class TracksAvailableCallback : public DOMMediaStream::OnTracksAvailableCallback
{
public:
TracksAvailableCallback(DOMMediaStream::TrackTypeHints aTrackTypeHints,
nsRefPtr<PeerConnectionObserver> 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<nsRefPtr<MediaStreamTrack>> 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<PeerConnectionObserver> mObserver;
};
#endif
void PeerConnectionImpl::OnRemoteStreamAdded(const MediaStreamTable& aStream) {
DOMMediaStream* stream = nullptr;
nsRefPtr<RemoteSourceStreamInfo> 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<PeerConnectionObserver> 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 NS_IMETHODIMP
PeerConnectionImpl::CloseStreams() { PeerConnectionImpl::CloseStreams() {
PC_AUTO_ENTER_API_CALL(false); 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 // TODO(ekr@rtfm.com): these integers should be the track IDs
if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) { 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++; mNumAudioStreams++;
} }
if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) { 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++; mNumVideoStreams++;
} }
@ -1574,13 +1538,25 @@ PeerConnectionImpl::RemoveTrack(MediaStreamTrack& aTrack) {
} }
if (hints & DOMMediaStream::HINT_CONTENTS_AUDIO) { 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); MOZ_ASSERT(mNumAudioStreams > 0);
mNumAudioStreams--; mNumAudioStreams--;
} }
if (hints & DOMMediaStream::HINT_CONTENTS_VIDEO) { 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); MOZ_ASSERT(mNumVideoStreams > 0);
mNumVideoStreams--; mNumVideoStreams--;
} }
@ -1949,61 +1925,6 @@ PeerConnectionImpl::destructorSafeDestroyNSSReference()
} }
#endif #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<PeerConnectionObserver> 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 void
PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState) PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState)
{ {
@ -2023,6 +1944,33 @@ PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState)
MOZ_ASSERT(!rv.Failed()); 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<PCImplSignalingState>(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 bool
PeerConnectionImpl::IsClosed() const PeerConnectionImpl::IsClosed() const
{ {
@ -2146,7 +2094,7 @@ PeerConnectionImpl::CandidateReady_m(const std::string& candidate,
mCandidateBuffer.push_back(std::make_pair(candidate, level)); mCandidateBuffer.push_back(std::make_pair(candidate, level));
} else { } else {
if (level <= mNumMlines) { if (level <= mNumMlines) {
mInternal->mCall->foundICECandidate(candidate, "", level, nullptr); FoundIceCandidate(candidate, level);
} }
} }
@ -2157,7 +2105,7 @@ void
PeerConnectionImpl::StartTrickle() { PeerConnectionImpl::StartTrickle() {
for (auto it = mCandidateBuffer.begin(); it != mCandidateBuffer.end(); ++it) { for (auto it = mCandidateBuffer.begin(); it != mCandidateBuffer.end(); ++it) {
if (it->second <= mNumMlines) { 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. // end-of-candidates event in IceGatheringStateChange_m.
if (mIceGatheringState == PCImplIceGatheringState::Complete && if (mIceGatheringState == PCImplIceGatheringState::Complete &&
!mCandidateBuffer.empty()) { !mCandidateBuffer.empty()) {
SendEndOfCandidates(); SendLocalIceCandidateToContent(0, "", "");
} }
mCandidateBuffer.clear(); 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 static void
SendEndOfCandidatesImpl(nsWeakPtr weakPCObserver) { SendLocalIceCandidateToContentImpl(nsWeakPtr weakPCObserver,
uint16_t level,
const std::string& mid,
const std::string& candidate) {
nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(weakPCObserver); nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(weakPCObserver);
if (!pco) { if (!pco) {
return; return;
} }
JSErrorResult rv; JSErrorResult rv;
pco->OnIceCandidate(0, ObString(""), ObString(""), rv); pco->OnIceCandidate(level,
ObString(mid.c_str()),
ObString(candidate.c_str()),
rv);
} }
void void
PeerConnectionImpl::SendEndOfCandidates() { PeerConnectionImpl::SendLocalIceCandidateToContent(
// We dispatch this because real candidates do a dispatch in uint16_t level,
// PeerConnectionImpl::onCallEvent, and we don't want this to jump ahead. 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( NS_DispatchToMainThread(
WrapRunnableNM(&SendEndOfCandidatesImpl, mPCObserver), WrapRunnableNM(&SendLocalIceCandidateToContentImpl,
mPCObserver,
level,
mid,
candidate),
NS_DISPATCH_NORMAL); NS_DISPATCH_NORMAL);
} }
@ -2329,7 +2320,7 @@ PeerConnectionImpl::IceGatheringStateChange_m(PCImplIceGatheringState aState)
if (mIceGatheringState == PCImplIceGatheringState::Complete && if (mIceGatheringState == PCImplIceGatheringState::Complete &&
mCandidateBuffer.empty()) { mCandidateBuffer.empty()) {
SendEndOfCandidates(); SendLocalIceCandidateToContent(0, "", "");
} }
return NS_OK; return NS_OK;

Просмотреть файл

@ -109,6 +109,8 @@ void func (__VA_ARGS__, rv)
NS_IMETHODIMP func(__VA_ARGS__, resulttype **result); \ NS_IMETHODIMP func(__VA_ARGS__, resulttype **result); \
already_AddRefed<resulttype> func (__VA_ARGS__, rv) already_AddRefed<resulttype> func (__VA_ARGS__, rv)
struct MediaStreamTable;
namespace sipcc { namespace sipcc {
using mozilla::dom::PeerConnectionObserver; using mozilla::dom::PeerConnectionObserver;
@ -128,7 +130,6 @@ using mozilla::PeerIdentity;
class PeerConnectionWrapper; class PeerConnectionWrapper;
class PeerConnectionMedia; class PeerConnectionMedia;
class RemoteSourceStreamInfo; class RemoteSourceStreamInfo;
class OnCallEventArgs;
class IceConfiguration class IceConfiguration
{ {
@ -244,9 +245,6 @@ public:
nsresult CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo>* aInfo); nsresult CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo>* aInfo);
// Implementation of the only observer we need
void onCallEvent(const OnCallEventArgs &args);
// DataConnection observers // DataConnection observers
void NotifyDataChannel(already_AddRefed<mozilla::DataChannel> aChannel); void NotifyDataChannel(already_AddRefed<mozilla::DataChannel> aChannel);
@ -363,6 +361,8 @@ public:
NS_ConvertUTF16toUTF8(aMid).get(), aLevel); NS_ConvertUTF16toUTF8(aMid).get(), aLevel);
} }
void OnRemoteStreamAdded(const MediaStreamTable& aStream);
NS_IMETHODIMP CloseStreams(); NS_IMETHODIMP CloseStreams();
void CloseStreams(ErrorResult &rv) void CloseStreams(ErrorResult &rv)
@ -567,6 +567,9 @@ public:
// Sets the RTC Signaling State // Sets the RTC Signaling State
void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState); void SetSignalingState_m(mozilla::dom::PCImplSignalingState aSignalingState);
// Updates the RTC signaling state based on the sipcc state
void UpdateSignalingState();
bool IsClosed() const; bool IsClosed() const;
// called when DTLS connects; we only need this once // called when DTLS connects; we only need this once
nsresult SetDtlsConnected(bool aPrivacyRequested); nsresult SetDtlsConnected(bool aPrivacyRequested);
@ -634,7 +637,10 @@ private:
void CandidateReady_s(const std::string& candidate, uint16_t level); void CandidateReady_s(const std::string& candidate, uint16_t level);
nsresult CandidateReady_m(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( NS_IMETHOD FingerprintSplitHelper(
std::string& fingerprint, size_t& spaceIdx) const; std::string& fingerprint, size_t& spaceIdx) const;

Просмотреть файл

@ -103,12 +103,6 @@ typedef struct cc_call_info_t_{
cc_boolean audio_mute; cc_boolean audio_mute;
cc_boolean video_mute; cc_boolean video_mute;
cc_call_conference_Info_t call_conference; 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; } session_data_t;
typedef enum { typedef enum {

Просмотреть файл

@ -95,79 +95,6 @@ cc_return_t cc_invokeFeature(cc_call_handle_t call_handle, group_cc_feature_t fe
return CC_SUCCESS; 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************************************ /***********************************Basic Call Feature Control Methods************************************
* This section defines all the call related methods that an upper layer can use to control * This section defines all the call related methods that an upper layer can use to control
* a call in progress. * 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); 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. * Initiate a speed dial.
* @param call handle * @param call handle

Просмотреть файл

@ -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); 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 * Dial digits on the call
* @param [in] handle - call handle * @param [in] handle - call handle

Просмотреть файл

@ -729,113 +729,4 @@ cc_boolean CCAPI_CallInfo_isVideoMuted (cc_callinfo_ref_t handle){
return FALSE; 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;
}

Просмотреть файл

@ -661,61 +661,6 @@ processSessionEvent (line_t line_id, callid_t call_id, unsigned int event, sdp_d
case CC_FEATURE_BKSPACE: case CC_FEATURE_BKSPACE:
dp_int_update_keypress(line_id, call_id, BKSP_KEY); dp_int_update_keypress(line_id, call_id, BKSP_KEY);
break; 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: case CC_FEATURE_DIALSTR:
if (CheckAndGetAvailableLine(&line_id, &call_id) == TRUE) { if (CheckAndGetAvailableLine(&line_id, &call_id) == TRUE) {
getDigits(data, digits, sizeof(digits)); 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_name = strlib_copy(data->plcd_name);
newData->plcd_number = strlib_copy(data->plcd_number); newData->plcd_number = strlib_copy(data->plcd_number);
newData->status = strlib_copy(data->status); 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); calllogger_copy_call_log(&newData->call_log, &data->call_log);
} else { } else {
@ -1093,9 +1032,6 @@ session_data_t * getDeepCopyOfSessionData(session_data_t *data)
newData->plcd_name = strlib_empty(); newData->plcd_name = strlib_empty();
newData->plcd_number = strlib_empty(); newData->plcd_number = strlib_empty();
newData->status = strlib_empty(); newData->status = strlib_empty();
newData->sdp = strlib_empty();
newData->candidate = strlib_empty();
newData->timecard = NULL;
calllogger_init_call_log(&newData->call_log); calllogger_init_call_log(&newData->call_log);
} }
@ -1140,12 +1076,6 @@ void cleanSessionData(session_data_t *data)
data->plcd_number = strlib_empty(); data->plcd_number = strlib_empty();
strlib_free(data->status); strlib_free(data->status);
data->status = strlib_empty(); 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); calllogger_free_call_log(&data->call_log);
} }
} }
@ -1410,15 +1340,7 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
if ( sessUpd->eventID == CALL_INFORMATION || if ( sessUpd->eventID == CALL_INFORMATION ||
sessUpd->eventID == CALL_STATE || sessUpd->eventID == CALL_STATE ||
sessUpd->eventID == CALL_NEWCALL || 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 ) {
CCAPP_DEBUG(DEB_F_PREFIX"CALL_SESSION_CREATED for session id 0x%x event is 0x%x", 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, DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->sessionID,
@ -1455,16 +1377,7 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
data->fsm_state = data->fsm_state =
sessUpd->update.ccSessionUpd.data.state_data.fsm_state; sessUpd->update.ccSessionUpd.data.state_data.fsm_state;
data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id; data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id;
if (sessUpd->eventID == CALL_NEWCALL || 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 ) {
data->attr = sessUpd->update.ccSessionUpd.data.state_data.attr; data->attr = sessUpd->update.ccSessionUpd.data.state_data.attr;
data->inst = sessUpd->update.ccSessionUpd.data.state_data.inst; 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->gci[0] = 0;
data->vid_dir = SDP_DIRECTION_INACTIVE; data->vid_dir = SDP_DIRECTION_INACTIVE;
data->callref = 0; data->callref = 0;
data->sdp = strlib_empty();
data->timecard = NULL;
calllogger_init_call_log(&data->call_log); 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 * If phone was idle, we not going to active state
* send notification to resetmanager that we * 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, ccsnap_gen_callEvent(CCAPI_CALL_EV_MEDIA_INTERFACE_UPDATE_FAIL,
CREATE_CALL_HANDLE_FROM_SESSION_ID(sessUpd->sessionID)); CREATE_CALL_HANDLE_FROM_SESSION_ID(sessUpd->sessionID));
break; 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: default:
DEF_DEBUG(DEB_F_PREFIX"Unknown event, id = %d", DEF_DEBUG(DEB_F_PREFIX"Unknown event, id = %d",
DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->eventID); DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->eventID);

Просмотреть файл

@ -1544,305 +1544,4 @@ ui_control_feature (line_t line_id, callid_t call_id,
// do nothing. // 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;
}

Просмотреть файл

@ -1173,132 +1173,6 @@ cc_int_feature2 (cc_msgs_t msg_id, cc_srcs_t src_id, cc_srcs_t dst_id,
return; 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 void
cc_int_feature_ack (cc_srcs_t src_id, cc_srcs_t dst_id, callid_t call_id, 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, line_t line, cc_features_t feature_id,

Просмотреть файл

@ -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) fim_get_call_chn_by_call_id (callid_t call_id)
{ {
static const char fname[] = "fim_get_call_chn_by_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; return call_chn;
} }
static fim_icb_t * fim_icb_t *
fim_get_new_call_chn (callid_t call_id) fim_get_new_call_chn (callid_t call_id)
{ {
static const char fname[] = "fim_get_new_call_chn"; 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_OFFHOOK) ||
(event_id == CC_MSG_DIALSTRING) || (event_id == CC_MSG_DIALSTRING) ||
(event_id == CC_MSG_LINE) || (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) && ((event_id == CC_MSG_FEATURE) &&
((((cc_feature_t *) msg)->feature_id == CC_FEATURE_NEW_CALL)))) { ((((cc_feature_t *) msg)->feature_id == CC_FEATURE_NEW_CALL)))) {
call_chn = fim_get_new_call_chn(call_id); call_chn = fim_get_new_call_chn(call_id);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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). changes from 0 -> !0 (i.e. on creation).
TODO(adam@nostrum.com): Figure out how to notify TODO(adam@nostrum.com): Figure out how to notify
when streams gain tracks */ when streams gain tracks */
ui_on_remote_stream_added(evOnRemoteStreamAdd, vcmOnRemoteStreamAdded(
fcb_p->state, dcb_p->line, dcb_p->call_id, CREATE_CALL_HANDLE(dcb_p->line, dcb_p->call_id),
dcb_p->caller_id.call_instance_id, dcb_p->peerconnection,
dcb_p->remote_media_stream_tbl->streams[j]); &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_notified =
dcb_p->remote_media_stream_tbl->streams[j].num_tracks; dcb_p->remote_media_stream_tbl->streams[j].num_tracks;

Просмотреть файл

@ -63,4 +63,6 @@ cc_causes_t
fsm_cac_call_bandwidth_req(callid_t call_id, uint32_t sessions, fsm_cac_call_bandwidth_req(callid_t call_id, uint32_t sessions,
void *msg); 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_ */ #endif /* _FIM_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 fsmcnd_conf_call_id_valid(fsmcnf_ccb_t *ccb);
boolean fsmdef_check_retain_fwd_info_state(void); 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 #endif

Просмотреть файл

@ -6,7 +6,6 @@
#define _CCAPI_H_ #define _CCAPI_H_
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#if defined(__cplusplus) && __cplusplus >= 201103L #if defined(__cplusplus) && __cplusplus >= 201103L
typedef struct Timecard Timecard; typedef struct Timecard Timecard;
@ -94,15 +93,6 @@ typedef enum {
CC_FEATURE_CAC_RESP_FAIL, CC_FEATURE_CAC_RESP_FAIL,
CC_FEATURE_FAST_PIC_UPD, CC_FEATURE_FAST_PIC_UPD,
CC_FEATURE_UNDEFINED, 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 CC_FEATURE_MAX
} group_cc_feature_t; } group_cc_feature_t;
@ -160,15 +150,6 @@ static const char *const cc_feature_names[] = {
"CAC FAILED", "CAC FAILED",
"FAST_PIC_UPD", "FAST_PIC_UPD",
"UNDEFINED", "UNDEFINED",
"CREATEOFFER",
"CREATEANSWER",
"SETLOCALDESC",
"SETREMOTEDESC",
"SETPEERCONNECTION",
"ADDSTREAM",
"REMOVESTREAM",
"ADDICECANDIDATE",
"FOUNDICECANDIDATE",
"MAX" "MAX"
}; };
@ -234,15 +215,6 @@ typedef enum cc_msgs_t_ {
CC_MSG_DIALSTRING, CC_MSG_DIALSTRING,
CC_MSG_MWI, CC_MSG_MWI,
CC_MSG_AUDIT, 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_AUDIT_ACK,
CC_MSG_OPTIONS, CC_MSG_OPTIONS,
CC_MSG_OPTIONS_ACK, CC_MSG_OPTIONS_ACK,
@ -274,15 +246,6 @@ static const char *const cc_msg_names[] = {
"DIALSTRING", "DIALSTRING",
"MWI", "MWI",
"AUDIT", "AUDIT",
"CREATEOFFER",
"CREATEANSWER",
"SETLOCALDESC",
"SETREMOTEDESC",
"SETPEERCONNECTION",
"ADDSTREAM",
"REMOVESTREAM",
"ADDCANDIDATE",
"FOUNDCANDIDATE",
"AUDIT_ACK", "AUDIT_ACK",
"OPTIONS", "OPTIONS",
"OPTIONS_ACK", "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, callid_t call_id, line_t line, cc_features_t feature_id,
cc_feature_data_t *data, Timecard *); 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, 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, line_t line, cc_features_t feature_id,
cc_feature_data_t *data, cc_causes_t cause); cc_feature_data_t *data, cc_causes_t cause);

Просмотреть файл

@ -215,16 +215,7 @@ typedef enum {
CALL_CALLREF, CALL_CALLREF,
MEDIA_INTERFACE_UPDATE_BEGIN, MEDIA_INTERFACE_UPDATE_BEGIN,
MEDIA_INTERFACE_UPDATE_SUCCESSFUL, MEDIA_INTERFACE_UPDATE_SUCCESSFUL,
MEDIA_INTERFACE_UPDATE_FAIL, 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
} group_call_event_t; } group_call_event_t;
/* File Player Session Events */ /* File Player Session Events */

Просмотреть файл

@ -32,47 +32,9 @@ typedef enum {
evHoldRevert = HOLDREVERT, evHoldRevert = HOLDREVERT,
evWhisper = WHISPER, evWhisper = WHISPER,
evWaitingForDigits = WAITINGFORDIGITS, 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 evMaxEvent
} call_events; } 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 #define MWI_STATUS_YES 1
/* call operations : dialing, state change and info related */ /* 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_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); 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 #endif

Просмотреть файл

@ -303,6 +303,20 @@ strlib_close (char *str)
return (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 * Function: strlib_is_string
@ -320,8 +334,6 @@ strlib_is_string (string_t str)
string_block_t *temp; string_block_t *temp;
if (str == NULL) { if (str == NULL) {
CSFLogError("src-common",
"Strlib Error: strlib_is_tring passed invalid string\n");
return (0); return (0);
} }

Просмотреть файл

@ -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_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. * Initiate a speed dial.
* @param call_handle call handle * @param call_handle call handle

Просмотреть файл

@ -276,21 +276,6 @@ typedef enum {
WHISPER, WHISPER,
PRESERVATION, PRESERVATION,
WAITINGFORDIGITS = 21, WAITINGFORDIGITS = 21,
CREATEOFFERSUCCESS,
CREATEANSWERSUCCESS,
CREATEOFFERERROR,
CREATEANSWERERROR,
SETLOCALDESCSUCCESS,
SETREMOTEDESCSUCCESS,
UPDATELOCALDESC,
UPDATEREMOTEDESC,
SETLOCALDESCERROR,
SETREMOTEDESCERROR,
REMOTESTREAMADD,
ADDICECANDIDATE,
ADDICECANDIDATEERROR,
FOUNDICECANDIDATE,
FOUNDICECANDIDATEERROR,
MAX_CALL_STATES MAX_CALL_STATES
} cc_call_state_t; } cc_call_state_t;
@ -560,6 +545,30 @@ typedef enum {
} cc_jsep_action_t; } 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 cc_string_t cc_peerconnection_t;
typedef unsigned int cc_media_stream_id_t; typedef unsigned int cc_media_stream_id_t;

Просмотреть файл

@ -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_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 * Send digits on the call - can be invoked either to dial additional digits or send DTMF
* @param [in] handle - call handle * @param [in] handle - call handle

Просмотреть файл

@ -295,39 +295,4 @@ cc_boolean CCAPI_CallInfo_isAudioMuted(cc_callinfo_ref_t handle);
*/ */
cc_boolean CCAPI_CallInfo_isVideoMuted(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_ */ #endif /* _CCAPIAPI_CALL_INFO_H_ */

Просмотреть файл

@ -598,6 +598,13 @@ int vcmRxStart(cc_mcapid_t mcap_id,
vcm_mediaAttrs_t *attrs); 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 * start rx stream
* Same concept as vcmRxStart but for ICE/PeerConnection-based flows * Same concept as vcmRxStart but for ICE/PeerConnection-based flows

Просмотреть файл

@ -13,12 +13,20 @@
#include "CSFVideoTermination.h" #include "CSFVideoTermination.h"
#include "CSFAudioTermination.h" #include "CSFAudioTermination.h"
#include "CSFAudioControl.h" #include "CSFAudioControl.h"
// fsm.h picks this include up as a c header, causing trouble later
#include "mozilla/ArrayUtils.h"
extern "C" extern "C"
{ {
#include "ccapi_call.h" #include "ccapi_call.h"
#include "ccapi_call_listener.h" #include "ccapi_call_listener.h"
#include "config_api.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; 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) : CC_SIPCCCall::CC_SIPCCCall (cc_call_handle_t aCallHandle) :
callHandle(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 ); 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 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_CallInfoPtr CC_SIPCCCall::getCallInfo ()
{ {
cc_callinfo_ref_t callInfo = CCAPI_Call_getCallInfo(callHandle); cc_callinfo_ref_t callInfo = CCAPI_Call_getCallInfo(callHandle);
CC_SIPCCCallInfoPtr callInfoPtr = CC_SIPCCCallInfo::wrap(callInfo); CC_SIPCCCallInfoPtr callInfoPtr = CC_SIPCCCallInfo::wrap(callInfo);
callInfoPtr->setMediaData( pMediaData); 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(); 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()); CCAPI_Call_originateCall(callHandle, video_pref, digits.c_str());
} }
/* fsm_fcb_t* CC_SIPCCCall::preOperationBoilerplate(cc_feature_t *command,
* This method works asynchronously, is an onCallEvent with the resulting SDP Timecard *tc) {
*/ // Make sure the old error string doesn't hang around.
void CC_SIPCCCall::createOffer (cc_media_options_t *options, Timecard *tc) { strlib_free(errorString);
CCAPI_CreateOffer(callHandle, options, tc); errorString = NULL;
}
/* // Get the fcb, and if it fails, set the appropriate error stuff
* This method works asynchronously, there is onCallEvent with the resulting SDP fsm_fcb_t *fcb = getFcb();
*/ if (!fcb) {
void CC_SIPCCCall::createAnswer (Timecard *tc) { errorString = strlib_printf("No call state object");
CCAPI_CreateAnswer(callHandle, tc); // 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, const std::string & sdp,
Timecard *tc) { 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<char*>(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, const std::string & sdp,
Timecard *tc) { 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<char*>(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"); 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 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 { const std::string& CC_SIPCCCall::getPeerConnection() const {
return peerconnection; 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_track_id_t track_id,
cc_media_type_t media_type) { 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) { 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) {
CCAPI_RemoveStream(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_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, const std::string & mid,
unsigned short level, unsigned short level,
Timecard *tc) { Timecard *tc) {
CCAPI_AddICECandidate(callHandle, candidate.c_str(), mid.c_str(), cc_feature_t command;
(cc_level_t) level, tc); 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, const std::string & mid,
unsigned short level, unsigned short level,
Timecard *tc) { Timecard *tc) {
CCAPI_FoundICECandidate(callHandle, candidate.c_str(), mid.c_str(), cc_feature_t command;
(cc_level_t) level, tc); 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;
} }

Просмотреть файл

@ -18,6 +18,16 @@ typedef struct Timecard Timecard;
#include "common/Wrapper.h" #include "common/Wrapper.h"
#include "common/csf_common.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 namespace CSF
{ {
struct StreamInfo struct StreamInfo
@ -65,8 +75,16 @@ namespace CSF
private: private:
cc_call_handle_t callHandle; cc_call_handle_t callHandle;
explicit CC_SIPCCCall (cc_call_handle_t aCallHandle); explicit CC_SIPCCCall (cc_call_handle_t aCallHandle);
virtual ~CC_SIPCCCall();
CC_SIPCCCallMediaDataPtr pMediaData; CC_SIPCCCallMediaDataPtr pMediaData;
std::string peerconnection; // The peerconnection handle 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: public:
virtual inline std::string toString() { virtual inline std::string toString() {
@ -77,6 +95,13 @@ namespace CSF
return result; 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 void setRemoteWindow (VideoWindowHandle window);
virtual int setExternalRenderer(VideoFormat vFormat, ExternalRendererHandle renderer); virtual int setExternalRenderer(VideoFormat vFormat, ExternalRendererHandle renderer);
virtual void sendIFrame(); virtual void sendIFrame();
@ -113,19 +138,19 @@ namespace CSF
virtual void removeStream(int streamId); virtual void removeStream(int streamId);
virtual bool setVolume(int volume); virtual bool setVolume(int volume);
virtual void originateP2PCall (cc_sdp_direction_t video_pref, const std::string & digits, const std::string & ip); 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 pc_error createOffer(cc_media_options_t *options, Timecard*);
virtual void createAnswer(Timecard *); virtual pc_error createAnswer(Timecard*);
virtual void setLocalDescription(cc_jsep_action_t action, const std::string & sdp, Timecard *); virtual pc_error 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 pc_error setRemoteDescription(cc_jsep_action_t action, const std::string & sdp, Timecard*);
virtual void setPeerConnection(const std::string& handle); virtual pc_error setPeerConnection(const std::string& handle);
virtual const std::string& getPeerConnection() const; 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_track_id_t track_id,
cc_media_type_t media_type); 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 CC_SIPCCCallMediaDataPtr getMediaData();
virtual void addICECandidate(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 void foundICECandidate(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: private:
virtual bool setAudioMute(bool mute); virtual bool setAudioMute(bool mute);

Просмотреть файл

@ -126,42 +126,6 @@ std::string CC_SIPCCCallInfo::callStateToString (cc_call_state_t state)
case WAITINGFORDIGITS: case WAITINGFORDIGITS:
statestr = "WAITINGFORDIGITS"; statestr = "WAITINGFORDIGITS";
break; 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: default:
break; break;
} }
@ -434,31 +398,6 @@ bool CC_SIPCCCallInfo::isVideoMuted()
return (CCAPI_CallInfo_isVideoMuted(callinfo_ref) != 0); 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() bool CC_SIPCCCallInfo::isMediaStateAvailable()
{ {
// for softphone it will always be possible to query the mute state and video direction // for softphone it will always be possible to query the mute state and video direction

Просмотреть файл

@ -79,11 +79,6 @@ namespace CSF
virtual bool isMediaStateAvailable(); virtual bool isMediaStateAvailable();
virtual bool isAudioMuted(); virtual bool isAudioMuted();
virtual bool isVideoMuted(); 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); virtual void setMediaData(CC_SIPCCCallMediaDataPtr pMediaData);