diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 62fe188a6178..c1b3b771b156 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -210,6 +210,7 @@ function PeerConnection() { this.onstatechange = null; this.ongatheringchange = null; this.onicechange = null; + this.localDescription = null; this.remoteDescription = null; // Data channel. @@ -441,6 +442,11 @@ PeerConnection.prototype = { break; } + this.localDescription = { + type: desc.type, sdp: desc.sdp, + __exposedProps__: { type: "rw", sdp: "rw"} + }; + this.remoteDescription = { type: desc.type, sdp: desc.sdp, __exposedProps__: { type: "rw", sdp: "rw" } diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index cdb25944e8a2..75472238dd55 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -186,6 +186,12 @@ public: } break; } + + case UPDATELOCALDESC: + case UPDATEREMOTEDESC: + /* No action necessary */ + break; + default: CSFLogDebugS(logTag, ": **** UNHANDLED CALL STATE : " << mStateStr); break; @@ -980,11 +986,15 @@ PeerConnectionImpl::onCallEvent(ccapi_call_event_e aCallEvent, switch (event) { case SETLOCALDESC: - mLocalSDP = mLocalRequestedSDP; + case UPDATELOCALDESC: + mLocalSDP = aInfo->getSDP(); break; + case SETREMOTEDESC: - mRemoteSDP = mRemoteRequestedSDP; + case UPDATEREMOTEDESC: + mRemoteSDP = aInfo->getSDP(); break; + case CONNECTED: CSFLogDebugS(logTag, "Setting PeerConnnection state to kActive"); ChangeReadyState(kActive); diff --git a/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c b/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c index f6c2d944effe..881fe99c301d 100755 --- a/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c +++ b/media/webrtc/signaling/src/sipcc/core/ccapp/ccprovider.c @@ -983,6 +983,7 @@ session_data_t * getDeepCopyOfSessionData(session_data_t *data) newData->plcd_name = strlib_copy(data->plcd_name); newData->plcd_number = strlib_copy(data->plcd_number); newData->status = strlib_copy(data->status); + newData->sdp = strlib_copy(data->sdp); calllogger_copy_call_log(&newData->call_log, &data->call_log); } else { newData->ref_count = 1; @@ -1001,6 +1002,7 @@ session_data_t * getDeepCopyOfSessionData(session_data_t *data) newData->plcd_name = strlib_empty(); newData->plcd_number = strlib_empty(); newData->status = strlib_empty(); + newData->sdp = strlib_empty(); calllogger_init_call_log(&newData->call_log); } @@ -1045,6 +1047,8 @@ void cleanSessionData(session_data_t *data) data->plcd_number = strlib_empty(); strlib_free(data->status); data->status = strlib_empty(); + strlib_free(data->sdp); + data->sdp = strlib_empty(); calllogger_free_call_log(&data->call_log); } } @@ -1296,7 +1300,11 @@ cc_call_handle_t ccappGetConnectedCall(){ static void ccappUpdateSessionData (session_update_t *sessUpd) { static const char fname[] = "ccappUpdateSessionData"; - session_data_t * data = (session_data_t *)findhash(sessUpd->sessionID), *sess_data_p; + /* TODO -- I don't think the hash handling is synchronized; we could + end up with data integrity issues here if we end up in a race. + */ + session_data_t *data = (session_data_t *)findhash(sessUpd->sessionID); + session_data_t *sess_data_p; boolean createdSessionData = TRUE; cc_deviceinfo_ref_t handle = 0; boolean previouslyInConference = FALSE; @@ -1304,11 +1312,16 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) if ( data == NULL ) { cc_call_state_t call_state = sessUpd->update.ccSessionUpd.data.state_data.state; - if ( ( sessUpd->eventID == CALL_INFORMATION ) || - ( sessUpd->eventID == CALL_STATE || sessUpd->eventID == CALL_NEWCALL - || sessUpd->eventID == CREATE_OFFER || sessUpd->eventID == CREATE_ANSWER - || sessUpd->eventID == SET_LOCAL_DESC || sessUpd->eventID == SET_REMOTE_DESC - || sessUpd->eventID == REMOTE_STREAM_ADD)) { + if ( sessUpd->eventID == CALL_INFORMATION || + sessUpd->eventID == CALL_STATE || + sessUpd->eventID == CALL_NEWCALL || + sessUpd->eventID == CREATE_OFFER || + sessUpd->eventID == CREATE_ANSWER || + sessUpd->eventID == SET_LOCAL_DESC || + sessUpd->eventID == SET_REMOTE_DESC || + sessUpd->eventID == UPDATE_LOCAL_DESC || + sessUpd->eventID == UPDATE_REMOTE_DESC || + sessUpd->eventID == REMOTE_STREAM_ADD ) { CCAPP_DEBUG(DEB_F_PREFIX"CALL_SESSION_CREATED for session id 0x%x event is 0x%x \n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), sessUpd->sessionID, @@ -1343,9 +1356,14 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) data->sess_id = sessUpd->sessionID; data->state = call_state; data->line = sessUpd->update.ccSessionUpd.data.state_data.line_id; - if (sessUpd->eventID == CALL_NEWCALL || sessUpd->eventID == CREATE_OFFER || - sessUpd->eventID == CREATE_ANSWER || sessUpd->eventID == SET_LOCAL_DESC || - sessUpd->eventID == SET_REMOTE_DESC || sessUpd->eventID == REMOTE_STREAM_ADD ) { + 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 == REMOTE_STREAM_ADD ) { data->attr = sessUpd->update.ccSessionUpd.data.state_data.attr; data->inst = sessUpd->update.ccSessionUpd.data.state_data.inst; } @@ -1365,15 +1383,28 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) data->gci[0] = 0; data->vid_dir = SDP_DIRECTION_INACTIVE; data->callref = 0; + data->sdp = strlib_empty(); calllogger_init_call_log(&data->call_log); - if ( sessUpd->eventID == CREATE_OFFER || sessUpd->eventID == CREATE_ANSWER - || sessUpd->eventID == SET_LOCAL_DESC || sessUpd->eventID == SET_REMOTE_DESC - || sessUpd->eventID == REMOTE_STREAM_ADD) { - data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp; - 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; + 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: + data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp; + /* 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; + break; + default: + break; } /* @@ -1697,8 +1728,11 @@ static void ccappUpdateSessionData (session_update_t *sessUpd) case CREATE_ANSWER: case SET_LOCAL_DESC: case SET_REMOTE_DESC: - case REMOTE_STREAM_ADD: + case UPDATE_LOCAL_DESC: + case UPDATE_REMOTE_DESC: data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp; + /* Fall through to the next case... */ + case REMOTE_STREAM_ADD: data->cause = sessUpd->update.ccSessionUpd.data.state_data.cause; data->state = sessUpd->update.ccSessionUpd.data.state_data.state; data->media_stream_track_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_track_id; diff --git a/media/webrtc/signaling/src/sipcc/core/common/ui.c b/media/webrtc/signaling/src/sipcc/core/common/ui.c index 750a43539d6b..1970c5aafd72 100755 --- a/media/webrtc/signaling/src/sipcc/core/common/ui.c +++ b/media/webrtc/signaling/src/sipcc/core/common/ui.c @@ -25,6 +25,7 @@ #include "platform_api.h" #include "vcm.h" #include "ccapp_task.h" +#include "peer_connection_types.h" /* * Note: Do not include "msprovider.h" here unless the dependencies on @@ -95,6 +96,7 @@ void ui_call_state (call_events event, line_t nLine, callid_t nCallID, cc_causes_t cause) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"event=%d \n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event); @@ -131,6 +133,7 @@ ui_new_call (call_events event, line_t nLine, callid_t nCallID, int call_attr, uint16_t call_instance_id, boolean dialed_digits) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d attr=%d call_instance=%d, dialed_digits=%s\n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_attr, call_instance_id, (dialed_digits)? "true" : "false"); @@ -172,6 +175,7 @@ void ui_set_call_attr (line_t line_id, callid_t call_id, call_attr_t attr) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"attr=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__), attr); @@ -202,6 +206,7 @@ void ui_update_callref (line_t line, callid_t call_id, unsigned int callref) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"callref = %d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), callref); @@ -237,6 +242,7 @@ void ui_update_gcid (line_t line, callid_t call_id, char *gcid) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"gcid = %s\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), gcid); @@ -270,6 +276,7 @@ void ui_update_video_avail (line_t line, callid_t call_id, int avail) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__)); @@ -291,6 +298,7 @@ ui_update_video_avail (line_t line, callid_t call_id, int avail) void ui_update_media_interface_change(line_t line, callid_t call_id, group_call_event_t event) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); if (event != MEDIA_INTERFACE_UPDATE_BEGIN && event != MEDIA_INTERFACE_UPDATE_SUCCESSFUL && @@ -324,6 +332,7 @@ void ui_call_stop_ringer (line_t line, callid_t call_id) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__)); @@ -348,6 +357,7 @@ void ui_call_start_ringer (vcm_ring_mode_t ringMode, short once, line_t line, callid_t call_id) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__)); @@ -381,6 +391,7 @@ void ui_update_video_offered (line_t line, callid_t call_id, int avail) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX, DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__)); @@ -447,6 +458,8 @@ ui_call_info (string_t pCallingPartyNameStr, char lineName[MAX_LINE_NAME_SIZE]; char lineNumber[MAX_LINE_NAME_SIZE]; + memset( &msg, 0, sizeof(session_update_t)); + TNP_DEBUG(DEB_L_C_F_PREFIX"call instance=%d callednum=%s calledname=%s clngnum=%s clngname = %s\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), call_instance_id, pCalledPartyNumberStr, @@ -531,6 +544,7 @@ void ui_cc_capability (line_t line, callid_t call_id, string_t recv_info_list) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"recv_info_list:%s\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), @@ -592,6 +606,7 @@ static void ui_set_call_status_display (string_t status, line_t line, callid_t callID, int timeout, char priority) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"the stat string =%s, timeout= %d, priority=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, callID, __FUNCTION__), status, @@ -1036,6 +1051,7 @@ ui_update_placed_call_info (line_t line, callid_t call_id, string_t cldName, string_t cldNumber) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"calledName:calledNumber %s:%s\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), cldName, cldNumber); @@ -1077,6 +1093,7 @@ void ui_delete_last_digit (line_t line_id, callid_t call_id) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"called\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__)); @@ -1106,6 +1123,7 @@ void ui_control_featurekey_bksp (line_t line_id, callid_t call_id, boolean enable) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"enable=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__), enable); @@ -1134,6 +1152,7 @@ void ui_call_selected (line_t line_id, callid_t call_id, int selected) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"selected=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__), selected); @@ -1221,6 +1240,7 @@ ui_select_feature_key_set (line_t line_id, callid_t call_id, char *set_name, { int i; session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"called\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__)); @@ -1234,8 +1254,6 @@ ui_select_feature_key_set (line_t line_id, callid_t call_id, char *set_name, return; } - memset( &msg, 0, sizeof(session_update_t)); - msg.sessionID = createSessionId(line_id, call_id); msg.eventID = CALL_SELECT_FEATURE_SET; @@ -1299,6 +1317,7 @@ ui_update_call_security (line_t line, callid_t call_id, cc_security_e call_security) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"security=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), call_security); @@ -1338,6 +1357,7 @@ ui_terminate_feature (line_t line, callid_t call_id, callid_t target_call_id) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); TNP_DEBUG(DEB_L_C_F_PREFIX"target_call_id=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), target_call_id); @@ -1486,6 +1506,7 @@ void ui_log_disposition (callid_t call_id, int logdisp) { session_update_t msg; fsmdef_dcb_t *dcb = fsmdef_get_dcb_by_call_id(call_id); + memset( &msg, 0, sizeof(session_update_t)); if (call_id == CC_NO_CALL_ID || dcb == NULL) { @@ -1532,10 +1553,11 @@ static void post_message_helper( line_t nLine, callid_t nCallId, uint16_t call_instance_id, - char *sdp, + string_t sdp, cc_int32_t status) { session_update_t msg; + memset( &msg, 0, sizeof(session_update_t)); if (nCallId == CC_NO_CALL_ID) { /* no operation when no call ID */ @@ -1567,7 +1589,7 @@ static void post_message_helper( * @return none */ void ui_create_offer(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp) + uint16_t call_instance_id, string_t sdp) { TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d attr=%d call_instance=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id); @@ -1584,7 +1606,7 @@ void ui_create_offer(call_events event, line_t nLine, callid_t nCallID, * @return none */ void ui_create_answer(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp) + uint16_t call_instance_id, string_t sdp) { TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id); @@ -1601,7 +1623,7 @@ void ui_create_answer(call_events event, line_t nLine, callid_t nCallID, */ void ui_set_local_description(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp, cc_int32_t status) + uint16_t call_instance_id, string_t sdp, cc_int32_t status) { TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id); @@ -1618,7 +1640,7 @@ void ui_set_local_description(call_events event, line_t nLine, callid_t nCallID, */ void ui_set_remote_description(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp, cc_int32_t status) + uint16_t call_instance_id, string_t sdp, cc_int32_t status) { TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), event, call_instance_id); @@ -1628,6 +1650,44 @@ void ui_set_remote_description(call_events event, line_t nLine, callid_t nCallID return; } +/** + * Let PeerConnection know about an updated local session description + * + * @return none + */ + +void ui_update_local_description(call_events event, line_t nLine, callid_t nCallID, + uint16_t call_instance_id, string_t sdp) +{ + TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d\n", + DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), + event, call_instance_id); + + post_message_helper(UPDATE_LOCAL_DESC, event, nLine, nCallID, call_instance_id, + sdp, PC_OK); + + return; +} + +/** + * Let PeerConnection know about an updated remote session description + * + * @return none + */ + +void ui_update_remote_description(call_events event, line_t nLine, callid_t nCallID, + uint16_t call_instance_id, string_t sdp) +{ + TNP_DEBUG(DEB_L_C_F_PREFIX"state=%d call_instance=%d\n", + DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__), + event, call_instance_id); + + post_message_helper(UPDATE_REMOTE_DESC, event, nLine, nCallID, + call_instance_id, sdp, PC_OK); + + return; +} + /** * Send Remote Stream data to the UI @@ -1639,6 +1699,7 @@ void ui_on_remote_stream_added(call_events event, line_t nLine, callid_t nCallID { 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 */ diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c b/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c index 33a31ffc86dc..6d9d1b335dad 100755 --- a/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/fsmdef.c @@ -2905,7 +2905,8 @@ fsmdef_ev_createoffer (sm_event_t *event) { vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); if (!ufrag || !ice_pwd) { - ui_create_offer(evCreateOfferError, line, call_id, dcb->caller_id.call_instance_id, NULL); + ui_create_offer(evCreateOfferError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); return (fsmdef_release(fcb, cause, FALSE)); } @@ -2935,20 +2936,26 @@ fsmdef_ev_createoffer (sm_event_t *event) { cause = gsmsdp_create_local_sdp(dcb, FALSE, TRUE, TRUE, TRUE, TRUE); if (cause != CC_CAUSE_OK) { - ui_create_offer(evCreateOfferError, line, call_id, dcb->caller_id.call_instance_id, NULL); + ui_create_offer(evCreateOfferError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); return (fsmdef_release(fcb, cause, FALSE)); } cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_create_offer(evCreateOfferError, line, call_id, dcb->caller_id.call_instance_id, NULL); + cc_free_msg_body_parts(&msg_body); + ui_create_offer(evCreateOfferError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); return (fsmdef_release(fcb, cause, FALSE)); } /* Pass offer SDP back to UI */ - ui_create_offer(evCreateOffer, line, call_id, dcb->caller_id.call_instance_id, msg_body.parts[0].body); + ui_create_offer(evCreateOffer, line, call_id, + dcb->caller_id.call_instance_id, + strlib_malloc(msg_body.parts[0].body, -1)); + cc_free_msg_body_parts(&msg_body); return (SM_RC_END); } @@ -3012,7 +3019,8 @@ fsmdef_ev_createanswer (sm_event_t *event) { vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); if (!ufrag || !ice_pwd) { - ui_create_offer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL); + ui_create_offer(evCreateAnswerError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); return (fsmdef_release(fcb, cause, FALSE)); } @@ -3052,7 +3060,8 @@ fsmdef_ev_createanswer (sm_event_t *event) { */ cause = gsmsdp_create_local_sdp(dcb, FALSE, has_audio, has_video, has_data, FALSE); if (cause != CC_CAUSE_OK) { - ui_create_answer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL); + ui_create_answer(evCreateAnswerError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); // Force clean up call without sending release return (fsmdef_release(fcb, cause, FALSE)); @@ -3064,19 +3073,25 @@ fsmdef_ev_createanswer (sm_event_t *event) { cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, FALSE, TRUE); if (cause != CC_CAUSE_OK) { - ui_create_answer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL); + ui_create_answer(evCreateAnswerError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); return (fsmdef_release(fcb, cause, FALSE)); } cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_create_answer(evCreateAnswerError, line, call_id, dcb->caller_id.call_instance_id, NULL); + cc_free_msg_body_parts(&msg_body); + ui_create_answer(evCreateAnswerError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty()); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); return (fsmdef_release(fcb, cause, FALSE)); } /* Pass SDP back to UI */ - ui_create_answer(evCreateAnswer, line, call_id, dcb->caller_id.call_instance_id, msg_body.parts[0].body); + ui_create_answer(evCreateAnswer, line, call_id, + dcb->caller_id.call_instance_id, + strlib_malloc(msg_body.parts[0].body, -1)); + cc_free_msg_body_parts(&msg_body); return (SM_RC_END); } @@ -3099,12 +3114,16 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { callid_t call_id = msg->call_id; line_t line = msg->line; cc_causes_t lsm_rc; + char *local_sdp = 0; + uint32_t local_sdp_len = 0; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SETLOCALDESCERROR); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETLOCALDESCERROR); return (SM_RC_END); } @@ -3116,15 +3135,20 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { if (JSEP_OFFER == action) { cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body); if (cause != CC_CAUSE_OK) { + cc_free_msg_body_parts(&msg_body); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SETLOCALDESCERROR); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETLOCALDESCERROR); return (SM_RC_END); } /* compare and fail if different: * anant: Why? The JS should be able to modify the SDP. Commenting out for now (same for answer) if (strcmp(msg_body.parts[0].body, sdp) != 0) { - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SDPCHANGED); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), PC_SDPCHANGED); + cc_free_msg_body_parts(&msg_body); return (SM_RC_END); } */ @@ -3136,14 +3160,19 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { /* compare SDP generated from CreateAnswer */ cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body); if (cause != CC_CAUSE_OK) { + cc_free_msg_body_parts(&msg_body); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SETLOCALDESCERROR); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETLOCALDESCERROR); return (SM_RC_END); } /* compare and fail if different if (strcmp(msg_body.parts[0].body, sdp) != 0) { - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SDPCHANGED); + cc_free_msg_body_parts(&msg_body); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), PC_SDPCHANGED); return (SM_RC_END); }*/ @@ -3161,7 +3190,8 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { */ cause = gsmsdp_install_peer_ice_attributes(fcb); if (cause != CC_CAUSE_OK) { - ui_set_local_description(evSetLocalDescError, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_SDPCHANGED); + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), PC_SDPCHANGED); return (SM_RC_END); } @@ -3183,8 +3213,20 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) { fsm_change_state(fcb, __LINE__, FSMDEF_S_CONNECTED); } + /* We're done with the msg_body contents -- free them.*/ + cc_free_msg_body_parts(&msg_body); - ui_set_local_description(evSetLocalDesc, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_OK); + /* Encode the current local SDP structure into a char buffer */ + local_sdp = sipsdp_write_to_buf(dcb->sdp->src_sdp, &local_sdp_len); + if (!local_sdp) { + ui_set_local_description(evSetLocalDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETLOCALDESCERROR); + return (SM_RC_END); + } + ui_set_local_description(evSetLocalDesc, line, call_id, + dcb->caller_id.call_instance_id, strlib_malloc(local_sdp,-1), PC_OK); + free(local_sdp); return (SM_RC_END); } @@ -3211,13 +3253,16 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { boolean has_audio; boolean has_video; boolean has_data; + char *remote_sdp = 0; + uint32_t remote_sdp_len = 0; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (!sdpmode) { ui_set_remote_description(evSetRemoteDescError, line, call_id, - dcb->caller_id.call_instance_id, NULL, PC_SETREMOTEDESCERROR); + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); return (SM_RC_END); } @@ -3228,6 +3273,13 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { cc_initialize_msg_body_parts_info(&msg_body); + /* !!! NOTE !!! The following code sets up the pointers inside + msg_body.parts[0] to point directly to the buffers from the + event->msg structure. While this is more efficient than + copying them, we must take exceptional care not to call + cc_free_msg_body_parts() on this particular msg_body, since + doing so would result in the buffers being freed twice. */ + msg_body.num_parts = 1; msg_body.content_type = cc_content_type_SDP; part = &msg_body.parts[0]; @@ -3244,7 +3296,8 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { cause = gsmsdp_process_offer_sdp(fcb, &msg_body, TRUE); if (cause != CC_CAUSE_OK) { ui_set_remote_description(evSetRemoteDescError, line, call_id, - dcb->caller_id.call_instance_id, NULL, PC_SETREMOTEDESCERROR); + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); return (SM_RC_END); } @@ -3260,8 +3313,9 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { */ cause = gsmsdp_create_local_sdp(dcb, TRUE, has_audio, has_video, has_data, FALSE); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, - NULL, PC_SETREMOTEDESCERROR); + ui_set_remote_description(evSetRemoteDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); // Force clean up call without sending release return (fsmdef_release(fcb, cause, FALSE)); @@ -3269,8 +3323,9 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, TRUE, FALSE); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, - NULL, PC_SETREMOTEDESCERROR); + ui_set_remote_description(evSetRemoteDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); return (fsmdef_release(fcb, cause, FALSE)); } @@ -3282,8 +3337,9 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { cause = gsmsdp_negotiate_answer_sdp(fcb, &msg_body); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, - NULL, PC_SETREMOTEDESCERROR); + ui_set_remote_description(evSetRemoteDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); return (SM_RC_END); } @@ -3293,8 +3349,9 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { */ cause = gsmsdp_install_peer_ice_attributes(fcb); if (cause != CC_CAUSE_OK) { - ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, - NULL, PC_SETREMOTEDESCERROR); + ui_set_remote_description(evSetRemoteDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); return (SM_RC_END); } @@ -3309,12 +3366,31 @@ fsmdef_ev_setremotedesc(sm_event_t *event) { fsm_change_state(fcb, __LINE__, FSMDEF_S_CONNECTED); } - ui_set_remote_description(evSetRemoteDesc, line, call_id, dcb->caller_id.call_instance_id, NULL, PC_OK); + /* For the sake of accuracy, we regenerate the SDP text from our parsed + version: if we have any local variation in how we've interpreted the + received SDP, then localDescription will reflect that variation. In + practice, this shouldn't happen; but, if it does, at least this will + allow the WebRTC application to figure out what's going on. */ + + remote_sdp = sipsdp_write_to_buf(dcb->sdp->dest_sdp, &remote_sdp_len); + + if (!remote_sdp) { + ui_set_remote_description(evSetRemoteDescError, line, call_id, + dcb->caller_id.call_instance_id, strlib_empty(), + PC_SETREMOTEDESCERROR); + return (SM_RC_END); + } + + ui_set_remote_description(evSetRemoteDesc, line, call_id, + dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1), + PC_OK); + + free(remote_sdp); return (SM_RC_END); } - +/* TODO -- remove me. See bug 821066. */ static sm_rcs_t fsmdef_ev_localdesc(sm_event_t *event) { fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; @@ -3342,6 +3418,7 @@ fsmdef_ev_localdesc(sm_event_t *event) { return (SM_RC_END); } +/* TODO -- remove me. See bug 821066. */ static sm_rcs_t fsmdef_ev_remotedesc(sm_event_t *event) { fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; @@ -3517,6 +3594,10 @@ fsmdef_ev_addcandidate(sm_event_t *event) { int sdpmode = 0; short vcm_res; uint16_t level; + line_t line = msg->line; + callid_t call_id = msg->call_id; + char *remote_sdp = 0; + uint32_t remote_sdp_len = 0; FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); @@ -3532,19 +3613,35 @@ fsmdef_ev_addcandidate(sm_event_t *event) { return SM_RC_CLEANUP; } - /* Perform level lookup based on mid value */ /* comment until mid is properly updated cause = gsmsdp_find_level_from_mid(dcb, (const char *)msg->data.candidate.mid, &level); */ + /* Update remote SDP with new candidate information */ + level = msg->data.candidate.level; + gsmsdp_set_ice_attribute (SDP_ATTR_ICE_CANDIDATE, level, + dcb->sdp->dest_sdp, (char *)msg->data.candidate.candidate); + vcm_res = vcmSetIceCandidate(dcb->peerconnection, (char *)msg->data.candidate.candidate, msg->data.candidate.level); if(vcm_res) { FSM_DEBUG_SM(DEB_F_PREFIX"failure setting ice candidate.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); } + /* Serialize the updated SDP and inform the PeerConnection of the + new SDP contents. */ - return (SM_RC_END); + remote_sdp = sipsdp_write_to_buf(dcb->sdp->dest_sdp, &remote_sdp_len); + + if (!remote_sdp) { + return (SM_RC_END); + } + + ui_update_remote_description(evUpdateRemoteDesc, line, call_id, + dcb->caller_id.call_instance_id, strlib_malloc(remote_sdp,-1)); + + free(remote_sdp); + return (SM_RC_END); } static void diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c index 53d442c89de7..71fa8ccb1203 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c @@ -1562,7 +1562,7 @@ gsmsdp_get_ice_attributes (sdp_attr_e sdp_attr, uint16_t level, void *sdp_p, cha } /* - * gsmsdp_set_attributes + * gsmsdp_set_ice_attribute * * Description: * @@ -1575,7 +1575,7 @@ gsmsdp_get_ice_attributes (sdp_attr_e sdp_attr, uint16_t level, void *sdp_p, cha * sdp_p - Pointer to the SDP to set the ice candidate attribute against. * ice_attrib - ice attribute to set */ -static void +void gsmsdp_set_ice_attribute (sdp_attr_e sdp_attr, uint16_t level, void *sdp_p, char *ice_attrib) { uint16_t a_instance = 0; @@ -5882,12 +5882,12 @@ gsmsdp_encode_sdp (cc_sdp_t *sdp_p, cc_msgbody_info_t *msg_body) cc_msgbody_t *part; uint32_t body_length; - if (msg_body == NULL) { + if (!msg_body || !sdp_p) { return CC_CAUSE_ERROR; } /* Support single SDP encoding for now */ - sdp_body = sipsdp_write_to_buf(sdp_p, &body_length); + sdp_body = sipsdp_write_to_buf(sdp_p->src_sdp, &body_length); if (sdp_body == NULL) { return CC_CAUSE_ERROR; diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/h/gsm_sdp.h b/media/webrtc/signaling/src/sipcc/core/gsm/h/gsm_sdp.h index 25ae4cfdb92b..1121699ca42b 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/h/gsm_sdp.h +++ b/media/webrtc/signaling/src/sipcc/core/gsm/h/gsm_sdp.h @@ -135,5 +135,9 @@ void gsmsdp_process_cap_constraints(fsmdef_dcb_t *dcb, const cc_media_constraint cc_causes_t gsmsdp_get_offered_media_types (fsm_fcb_t *fcb_p, cc_sdp_t *sdp_p, boolean *has_audio, boolean *has_video, boolean *has_data); fsmdef_media_t* gsmsdp_find_media_by_media_type(fsmdef_dcb_t *dcb, sdp_media_e media_type); + +extern void gsmsdp_set_ice_attribute (sdp_attr_e sdp_attr, uint16_t level, + void *sdp_p, char *ice_attrib); + #endif diff --git a/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h b/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h index a094c3d8672a..20fbc1735a05 100755 --- a/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h +++ b/media/webrtc/signaling/src/sipcc/core/includes/sessionConstants.h @@ -220,6 +220,8 @@ typedef enum { CREATE_ANSWER, SET_LOCAL_DESC, SET_REMOTE_DESC, + UPDATE_LOCAL_DESC, + UPDATE_REMOTE_DESC, REMOTE_STREAM_ADD } group_call_event_t; diff --git a/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h b/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h index 6604264eb15f..238f01627e97 100644 --- a/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h +++ b/media/webrtc/signaling/src/sipcc/core/includes/uiapi.h @@ -37,6 +37,8 @@ typedef enum { evCreateAnswerError = CREATEANSWERERROR, evSetLocalDesc = SETLOCALDESC, evSetRemoteDesc = SETREMOTEDESC, + evUpdateLocalDesc = UPDATELOCALDESC, + evUpdateRemoteDesc = UPDATEREMOTEDESC, evSetLocalDescError = SETLOCALDESCERROR, evSetRemoteDescError = SETREMOTEDESCERROR, evOnRemoteStreamAdd = REMOTESTREAMADD, @@ -150,13 +152,19 @@ void ui_call_start_ringer(vcm_ring_mode_t ringMode, short once, line_t line, cal void ui_BLF_notification (int request_id, cc_blf_state_t blf_state, int app_id); void ui_update_media_interface_change(line_t line, callid_t call_id, group_call_event_t event); void ui_create_offer(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp); + uint16_t call_instance_id, string_t sdp); void ui_create_answer(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp); + uint16_t call_instance_id, string_t sdp); void ui_set_local_description(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp, cc_int32_t status); + uint16_t call_instance_id, string_t sdp, cc_int32_t status); void ui_set_remote_description(call_events event, line_t nLine, callid_t nCallID, - uint16_t call_instance_id, char* sdp, cc_int32_t status); + uint16_t call_instance_id, string_t sdp, cc_int32_t status); + +void ui_update_local_description(call_events event, line_t nLine, callid_t nCallID, + uint16_t call_instance_id, string_t sdp); +void ui_update_remote_description(call_events event, line_t nLine, callid_t nCallID, + uint16_t call_instance_id, string_t sdp); + void ui_on_remote_stream_added(call_events event, line_t nLine, callid_t nCallID, uint16_t call_instance_id, cc_media_remote_track_table_t media_tracks); diff --git a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_attr.c b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_attr.c index 177628ff3d3f..b9be686af4de 100644 --- a/media/webrtc/signaling/src/sipcc/core/sdp/sdp_attr.c +++ b/media/webrtc/signaling/src/sipcc/core/sdp/sdp_attr.c @@ -517,6 +517,8 @@ sdp_result_e sdp_parse_attr_fmtp (sdp_t *sdp_p, sdp_attr_t *attr_p, /* END */ /* Once we move to RFC compliant video codec implementations, the above * patch should be removed */ + + src_ptr = temp_ptr; while (!done) { fmtp_ptr = sdp_getnextstrtok(fmtp_ptr, tmp, sizeof(tmp), "= \t", &result1); if (result1 == SDP_SUCCESS) { @@ -1026,7 +1028,7 @@ sdp_result_e sdp_parse_attr_fmtp (sdp_t *sdp_p, sdp_attr_t *attr_p, fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO; fmtp_p->level = (short) strtoul_result; codec_info_found = TRUE; - } if (cpr_strncasecmp(tmp,sdp_fmtp_codec_param[16].name, + } else if (cpr_strncasecmp(tmp,sdp_fmtp_codec_param[16].name, sdp_fmtp_codec_param[16].strlen) == 0) { fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO; fmtp_p->is_interlace = TRUE; diff --git a/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_sdp.c b/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_sdp.c index b0c951499f29..4bc58049df93 100644 --- a/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/sipstack/ccsip_sdp.c @@ -322,7 +322,7 @@ sipsdp_src_dest_create (const char *peerconnection, * and by examining SDP library error counters. */ char * -sipsdp_write_to_buf (cc_sdp_t *sdp_info, uint32_t *retbytes) +sipsdp_write_to_buf (sdp_t *sdp_info, uint32_t *retbytes) { flex_string fs; uint32_t sdp_len; @@ -330,12 +330,12 @@ sipsdp_write_to_buf (cc_sdp_t *sdp_info, uint32_t *retbytes) flex_string_init(&fs); - if (!sdp_info || !sdp_info->src_sdp) { + if (!sdp_info) { CCSIP_DEBUG_ERROR(SIP_F_PREFIX"NULL sdp_info or src_sdp\n", __FUNCTION__); return (NULL); } - if ((rc = sdp_build(sdp_info->src_sdp, &fs)) + if ((rc = sdp_build(sdp_info, &fs)) != SDP_SUCCESS) { CCSIP_DEBUG_TASK(DEB_F_PREFIX"sdp_build rc=%s\n", DEB_F_PREFIX_ARGS(SIP_SDP, __FUNCTION__), sdp_get_result_name(rc)); diff --git a/media/webrtc/signaling/src/sipcc/core/sipstack/h/ccsip_sdp.h b/media/webrtc/signaling/src/sipcc/core/sipstack/h/ccsip_sdp.h index b927a834601f..beeac0dc2b51 100644 --- a/media/webrtc/signaling/src/sipcc/core/sipstack/h/ccsip_sdp.h +++ b/media/webrtc/signaling/src/sipcc/core/sipstack/h/ccsip_sdp.h @@ -142,7 +142,7 @@ PMH_EXTERN void sipsdp_free(cc_sdp_t **sip_sdp); * Memory is allocated and should be freed by the user when done * Returns NULL on failure. */ -PMH_EXTERN char *sipsdp_write_to_buf(cc_sdp_t *, uint32_t *); +PMH_EXTERN char *sipsdp_write_to_buf(sdp_t *, uint32_t *); #define SIPSDP_FREE(x) \ if (x) \ diff --git a/media/webrtc/signaling/src/sipcc/cpr/include/cpr_types.h b/media/webrtc/signaling/src/sipcc/cpr/include/cpr_types.h index 33f1707e32a2..87a7b238a82b 100644 --- a/media/webrtc/signaling/src/sipcc/cpr/include/cpr_types.h +++ b/media/webrtc/signaling/src/sipcc/cpr/include/cpr_types.h @@ -102,6 +102,16 @@ extern const cpr_ip_addr_t ip_addr_invalid; #define CPR_IP_ADDR_INIT(a) a.type = CPR_IP_ADDR_INVALID; +/* + * !!! NOTE !!! + * + * The strings of type string_t are actually very special blocks + * of memory that have a "hidden" header block immediately preceding + * the pointer. You MUST use the functions in string_lib.c to + * create, manipulate, destroy, copy, or otherwise work with these + * strings. + */ + typedef const char *string_t; __END_DECLS diff --git a/media/webrtc/signaling/src/sipcc/include/cc_constants.h b/media/webrtc/signaling/src/sipcc/include/cc_constants.h index 8c96cd281e65..cc623d20155f 100644 --- a/media/webrtc/signaling/src/sipcc/include/cc_constants.h +++ b/media/webrtc/signaling/src/sipcc/include/cc_constants.h @@ -274,7 +274,7 @@ typedef enum { REMINUSE, HOLDREVERT, WHISPER, - PRESERVATION, + PRESERVATION, WAITINGFORDIGITS = 21, CREATEOFFER, CREATEANSWER, @@ -282,6 +282,8 @@ typedef enum { CREATEANSWERERROR, SETLOCALDESC, SETREMOTEDESC, + UPDATELOCALDESC, + UPDATEREMOTEDESC, SETLOCALDESCERROR, SETREMOTEDESCERROR, REMOTESTREAMADD, diff --git a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp index fb6c90abad47..23ba7a08f3ab 100644 --- a/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp +++ b/media/webrtc/signaling/src/softphonewrapper/CC_SIPCCCallInfo.cpp @@ -135,6 +135,12 @@ std::string CC_SIPCCCallInfo::callStateToString (cc_call_state_t state) case SETREMOTEDESC: statestr = "SETREMOTEDESC"; break; + case UPDATELOCALDESC: + statestr = "UPDATELOCALDESC"; + break; + case UPDATEREMOTEDESC: + statestr = "UPDATEREMOTEDESC"; + break; case SETLOCALDESCERROR: statestr = "SETLOCALDESCERROR"; break; @@ -418,7 +424,7 @@ bool CC_SIPCCCallInfo::isVideoMuted() string CC_SIPCCCallInfo::getSDP() { - return CCAPI_CallInfo_getSDP(callinfo_ref); + return CCAPI_CallInfo_getSDP(callinfo_ref); } cc_int32_t CC_SIPCCCallInfo::getStatusCode() diff --git a/media/webrtc/signaling/test/signaling_unittests.cpp b/media/webrtc/signaling/test/signaling_unittests.cpp index 30eb3d814a83..fb8a526d19b8 100644 --- a/media/webrtc/signaling/test/signaling_unittests.cpp +++ b/media/webrtc/signaling/test/signaling_unittests.cpp @@ -533,6 +533,24 @@ class SignalingAgent { char* offer() const { return offer_; } char* answer() const { return answer_; } + std::string getLocalDescription() const { + char *sdp = nullptr; + pc->GetLocalDescription(&sdp); + if (!sdp) { + return ""; + } + return sdp; + } + + std::string getRemoteDescription() const { + char *sdp = 0; + pc->GetRemoteDescription(&sdp); + if (!sdp) { + return ""; + } + return sdp; + } + void CreateOffer(sipcc::MediaConstraints& constraints, uint32_t offerFlags, uint32_t sdpCheck) { @@ -1432,6 +1450,53 @@ TEST_F(SignalingTest, OfferAllDynamicTypes) } +TEST_F(SignalingTest, OfferAnswerCheckDescriptions) +{ + sipcc::MediaConstraints constraints; + OfferAnswer(constraints, constraints, OFFER_AV | ANSWER_AV, true, + SHOULD_SENDRECV_AV, SHOULD_SENDRECV_AV); + + std::cout << "Caller's LocalDescription: " << std::endl << + a1_.getLocalDescription() << std::endl << std::endl; + std::cout << "Caller's Remote Description: " << std::endl << + a1_.getRemoteDescription() << std::endl << std::endl; + std::cout << "Callee's LocalDescription: " << std::endl << + a2_.getLocalDescription() << std::endl << std::endl; + std::cout << "Callee's Remote Description: " << std::endl << + a2_.getRemoteDescription() << std::endl << std::endl; + + ASSERT_EQ(a1_.getLocalDescription(),a2_.getRemoteDescription()); + ASSERT_EQ(a2_.getLocalDescription(),a1_.getRemoteDescription()); +} + +TEST_F(SignalingTest, CheckTrickleSdpChange) +{ + sipcc::MediaConstraints constraints; + OfferAnswerTrickle(constraints, constraints, + SHOULD_SENDRECV_AV, SHOULD_SENDRECV_AV); + std::cerr << "ICE handshake completed" << std::endl; + + PR_Sleep(kDefaultTimeout * 2); // Wait for some data to get written + a1_.CloseSendStreams(); + a2_.CloseReceiveStreams(); + + std::cout << "Caller's LocalDescription: " << std::endl << + a1_.getLocalDescription() << std::endl << std::endl; + std::cout << "Caller's Remote Description: " << std::endl << + a1_.getRemoteDescription() << std::endl << std::endl; + std::cout << "Callee's LocalDescription: " << std::endl << + a2_.getLocalDescription() << std::endl << std::endl; + std::cout << "Callee's Remote Description: " << std::endl << + a2_.getRemoteDescription() << std::endl << std::endl; + + ASSERT_NE(a1_.getLocalDescription().find("\r\na=candidate"), string::npos); + ASSERT_NE(a1_.getRemoteDescription().find("\r\na=candidate"), string::npos); + ASSERT_NE(a2_.getLocalDescription().find("\r\na=candidate"), string::npos); + ASSERT_NE(a2_.getRemoteDescription().find("\r\na=candidate"), string::npos); + ASSERT_EQ(a1_.getLocalDescription(),a2_.getRemoteDescription()); + ASSERT_EQ(a2_.getLocalDescription(),a1_.getRemoteDescription()); +} + } // End namespace test. int main(int argc, char **argv) {