Bug 797534: Update PeerConnectionImpl to use SDP from SIPCC, r=ehugg

This commit is contained in:
Adam Roach [:abr] 2012-12-19 09:25:51 -06:00
Родитель f194fd510a
Коммит e86ce73501
16 изменённых файлов: 378 добавлений и 71 удалений

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

@ -210,6 +210,7 @@ function PeerConnection() {
this.onstatechange = null; this.onstatechange = null;
this.ongatheringchange = null; this.ongatheringchange = null;
this.onicechange = null; this.onicechange = null;
this.localDescription = null;
this.remoteDescription = null; this.remoteDescription = null;
// Data channel. // Data channel.
@ -441,6 +442,11 @@ PeerConnection.prototype = {
break; break;
} }
this.localDescription = {
type: desc.type, sdp: desc.sdp,
__exposedProps__: { type: "rw", sdp: "rw"}
};
this.remoteDescription = { this.remoteDescription = {
type: desc.type, sdp: desc.sdp, type: desc.type, sdp: desc.sdp,
__exposedProps__: { type: "rw", sdp: "rw" } __exposedProps__: { type: "rw", sdp: "rw" }

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

@ -186,6 +186,12 @@ public:
} }
break; break;
} }
case UPDATELOCALDESC:
case UPDATEREMOTEDESC:
/* No action necessary */
break;
default: default:
CSFLogDebugS(logTag, ": **** UNHANDLED CALL STATE : " << mStateStr); CSFLogDebugS(logTag, ": **** UNHANDLED CALL STATE : " << mStateStr);
break; break;
@ -980,11 +986,15 @@ PeerConnectionImpl::onCallEvent(ccapi_call_event_e aCallEvent,
switch (event) { switch (event) {
case SETLOCALDESC: case SETLOCALDESC:
mLocalSDP = mLocalRequestedSDP; case UPDATELOCALDESC:
mLocalSDP = aInfo->getSDP();
break; break;
case SETREMOTEDESC: case SETREMOTEDESC:
mRemoteSDP = mRemoteRequestedSDP; case UPDATEREMOTEDESC:
mRemoteSDP = aInfo->getSDP();
break; break;
case CONNECTED: case CONNECTED:
CSFLogDebugS(logTag, "Setting PeerConnnection state to kActive"); CSFLogDebugS(logTag, "Setting PeerConnnection state to kActive");
ChangeReadyState(kActive); ChangeReadyState(kActive);

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

@ -983,6 +983,7 @@ 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);
calllogger_copy_call_log(&newData->call_log, &data->call_log); calllogger_copy_call_log(&newData->call_log, &data->call_log);
} else { } else {
newData->ref_count = 1; newData->ref_count = 1;
@ -1001,6 +1002,7 @@ 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();
calllogger_init_call_log(&newData->call_log); calllogger_init_call_log(&newData->call_log);
} }
@ -1045,6 +1047,8 @@ 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();
calllogger_free_call_log(&data->call_log); calllogger_free_call_log(&data->call_log);
} }
} }
@ -1296,7 +1300,11 @@ cc_call_handle_t ccappGetConnectedCall(){
static void ccappUpdateSessionData (session_update_t *sessUpd) static void ccappUpdateSessionData (session_update_t *sessUpd)
{ {
static const char fname[] = "ccappUpdateSessionData"; 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.
<adam@nostrum.com> */
session_data_t *data = (session_data_t *)findhash(sessUpd->sessionID);
session_data_t *sess_data_p;
boolean createdSessionData = TRUE; boolean createdSessionData = TRUE;
cc_deviceinfo_ref_t handle = 0; cc_deviceinfo_ref_t handle = 0;
boolean previouslyInConference = FALSE; boolean previouslyInConference = FALSE;
@ -1304,11 +1312,16 @@ static void ccappUpdateSessionData (session_update_t *sessUpd)
if ( data == NULL ) { if ( data == NULL ) {
cc_call_state_t call_state = sessUpd->update.ccSessionUpd.data.state_data.state; cc_call_state_t call_state = sessUpd->update.ccSessionUpd.data.state_data.state;
if ( ( sessUpd->eventID == CALL_INFORMATION ) || if ( sessUpd->eventID == CALL_INFORMATION ||
( sessUpd->eventID == CALL_STATE || sessUpd->eventID == CALL_NEWCALL sessUpd->eventID == CALL_STATE ||
|| sessUpd->eventID == CREATE_OFFER || sessUpd->eventID == CREATE_ANSWER sessUpd->eventID == CALL_NEWCALL ||
|| sessUpd->eventID == SET_LOCAL_DESC || sessUpd->eventID == SET_REMOTE_DESC sessUpd->eventID == CREATE_OFFER ||
|| sessUpd->eventID == REMOTE_STREAM_ADD)) { 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", 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, 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->sess_id = sessUpd->sessionID;
data->state = call_state; data->state = call_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 || sessUpd->eventID == CREATE_OFFER || if (sessUpd->eventID == CALL_NEWCALL ||
sessUpd->eventID == CREATE_ANSWER || sessUpd->eventID == SET_LOCAL_DESC || sessUpd->eventID == CREATE_OFFER ||
sessUpd->eventID == SET_REMOTE_DESC || sessUpd->eventID == REMOTE_STREAM_ADD ) { 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->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;
} }
@ -1365,15 +1383,28 @@ 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();
calllogger_init_call_log(&data->call_log); calllogger_init_call_log(&data->call_log);
if ( sessUpd->eventID == CREATE_OFFER || sessUpd->eventID == CREATE_ANSWER switch (sessUpd->eventID) {
|| sessUpd->eventID == SET_LOCAL_DESC || sessUpd->eventID == SET_REMOTE_DESC case CREATE_OFFER:
|| sessUpd->eventID == REMOTE_STREAM_ADD) { 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; data->sdp = sessUpd->update.ccSessionUpd.data.state_data.sdp;
data->cause = sessUpd->update.ccSessionUpd.data.state_data.cause; /* Fall through to the next case... */
data->media_stream_track_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_track_id; case REMOTE_STREAM_ADD:
data->media_stream_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_id; 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 CREATE_ANSWER:
case SET_LOCAL_DESC: case SET_LOCAL_DESC:
case SET_REMOTE_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; 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->cause = sessUpd->update.ccSessionUpd.data.state_data.cause;
data->state = sessUpd->update.ccSessionUpd.data.state_data.state; data->state = sessUpd->update.ccSessionUpd.data.state_data.state;
data->media_stream_track_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_track_id; data->media_stream_track_id = sessUpd->update.ccSessionUpd.data.state_data.media_stream_track_id;

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

@ -25,6 +25,7 @@
#include "platform_api.h" #include "platform_api.h"
#include "vcm.h" #include "vcm.h"
#include "ccapp_task.h" #include "ccapp_task.h"
#include "peer_connection_types.h"
/* /*
* Note: Do not include "msprovider.h" here unless the dependencies on * 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) ui_call_state (call_events event, line_t nLine, callid_t nCallID, cc_causes_t cause)
{ {
session_update_t msg; 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__), TNP_DEBUG(DEB_L_C_F_PREFIX"event=%d \n", DEB_L_C_F_PREFIX_ARGS(UI_API, nLine, nCallID, __FUNCTION__),
event); 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) int call_attr, uint16_t call_instance_id, boolean dialed_digits)
{ {
session_update_t msg; 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", 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"); 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) ui_set_call_attr (line_t line_id, callid_t call_id, call_attr_t attr)
{ {
session_update_t msg; 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); 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) ui_update_callref (line_t line, callid_t call_id, unsigned int callref)
{ {
session_update_t msg; 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); 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) ui_update_gcid (line_t line, callid_t call_id, char *gcid)
{ {
session_update_t msg; 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); 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) ui_update_video_avail (line_t line, callid_t call_id, int avail)
{ {
session_update_t msg; 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__)); 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) { void ui_update_media_interface_change(line_t line, callid_t call_id, group_call_event_t event) {
session_update_t msg; session_update_t msg;
memset( &msg, 0, sizeof(session_update_t));
if (event != MEDIA_INTERFACE_UPDATE_BEGIN && if (event != MEDIA_INTERFACE_UPDATE_BEGIN &&
event != MEDIA_INTERFACE_UPDATE_SUCCESSFUL && event != MEDIA_INTERFACE_UPDATE_SUCCESSFUL &&
@ -324,6 +332,7 @@ void
ui_call_stop_ringer (line_t line, callid_t call_id) ui_call_stop_ringer (line_t line, callid_t call_id)
{ {
session_update_t msg; 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__)); 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) ui_call_start_ringer (vcm_ring_mode_t ringMode, short once, line_t line, callid_t call_id)
{ {
session_update_t msg; 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__)); 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) ui_update_video_offered (line_t line, callid_t call_id, int avail)
{ {
session_update_t msg; 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__)); 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 lineName[MAX_LINE_NAME_SIZE];
char lineNumber[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", 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, 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) ui_cc_capability (line_t line, callid_t call_id, string_t recv_info_list)
{ {
session_update_t msg; session_update_t msg;
memset( &msg, 0, sizeof(session_update_t));
TNP_DEBUG(DEB_L_C_F_PREFIX"recv_info_list:%s\n", TNP_DEBUG(DEB_L_C_F_PREFIX"recv_info_list:%s\n",
DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__), 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) ui_set_call_status_display (string_t status, line_t line, callid_t callID, int timeout, char priority)
{ {
session_update_t msg; 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__), 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, status,
@ -1036,6 +1051,7 @@ ui_update_placed_call_info (line_t line, callid_t call_id, string_t cldName,
string_t cldNumber) string_t cldNumber)
{ {
session_update_t msg; session_update_t msg;
memset( &msg, 0, sizeof(session_update_t));
TNP_DEBUG(DEB_L_C_F_PREFIX"calledName:calledNumber %s:%s\n", 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); 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) ui_delete_last_digit (line_t line_id, callid_t call_id)
{ {
session_update_t msg; 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__)); 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) ui_control_featurekey_bksp (line_t line_id, callid_t call_id, boolean enable)
{ {
session_update_t msg; 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__), TNP_DEBUG(DEB_L_C_F_PREFIX"enable=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__),
enable); enable);
@ -1134,6 +1152,7 @@ void
ui_call_selected (line_t line_id, callid_t call_id, int selected) ui_call_selected (line_t line_id, callid_t call_id, int selected)
{ {
session_update_t msg; session_update_t msg;
memset( &msg, 0, sizeof(session_update_t));
TNP_DEBUG(DEB_L_C_F_PREFIX"selected=%d\n", TNP_DEBUG(DEB_L_C_F_PREFIX"selected=%d\n",
DEB_L_C_F_PREFIX_ARGS(UI_API, line_id, call_id, __FUNCTION__), selected); 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; int i;
session_update_t msg; 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__)); 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; return;
} }
memset( &msg, 0, sizeof(session_update_t));
msg.sessionID = createSessionId(line_id, call_id); msg.sessionID = createSessionId(line_id, call_id);
msg.eventID = CALL_SELECT_FEATURE_SET; 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) cc_security_e call_security)
{ {
session_update_t msg; 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__), TNP_DEBUG(DEB_L_C_F_PREFIX"security=%d\n", DEB_L_C_F_PREFIX_ARGS(UI_API, line, call_id, __FUNCTION__),
call_security); call_security);
@ -1338,6 +1357,7 @@ ui_terminate_feature (line_t line, callid_t call_id,
callid_t target_call_id) callid_t target_call_id)
{ {
session_update_t msg; 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__), 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); target_call_id);
@ -1486,6 +1506,7 @@ void ui_log_disposition (callid_t call_id, int logdisp)
{ {
session_update_t msg; session_update_t msg;
fsmdef_dcb_t *dcb = fsmdef_get_dcb_by_call_id(call_id); 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) { if (call_id == CC_NO_CALL_ID || dcb == NULL) {
@ -1532,10 +1553,11 @@ static void post_message_helper(
line_t nLine, line_t nLine,
callid_t nCallId, callid_t nCallId,
uint16_t call_instance_id, uint16_t call_instance_id,
char *sdp, string_t sdp,
cc_int32_t status) cc_int32_t status)
{ {
session_update_t msg; session_update_t msg;
memset( &msg, 0, sizeof(session_update_t));
if (nCallId == CC_NO_CALL_ID) { if (nCallId == CC_NO_CALL_ID) {
/* no operation when no call ID */ /* no operation when no call ID */
@ -1567,7 +1589,7 @@ static void post_message_helper(
* @return none * @return none
*/ */
void ui_create_offer(call_events event, line_t nLine, callid_t nCallID, 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", 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); 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 * @return none
*/ */
void ui_create_answer(call_events event, line_t nLine, callid_t nCallID, 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", 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); 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, 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", 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); 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, 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", 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); 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; 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 * 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; session_update_t msg;
fsmdef_dcb_t *dcb = fsmdef_get_dcb_by_call_id(nCallID); 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) { if (nCallID == CC_NO_CALL_ID || dcb == NULL) {
/* no operation when no call ID */ /* no operation when no call ID */

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

@ -2905,7 +2905,8 @@ fsmdef_ev_createoffer (sm_event_t *event) {
vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd);
if (!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)); 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); cause = gsmsdp_create_local_sdp(dcb, FALSE, TRUE, TRUE, TRUE, TRUE);
if (cause != CC_CAUSE_OK) { 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)); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
return (fsmdef_release(fcb, cause, FALSE)); return (fsmdef_release(fcb, cause, FALSE));
} }
cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body);
if (cause != CC_CAUSE_OK) { 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)); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
return (fsmdef_release(fcb, cause, FALSE)); return (fsmdef_release(fcb, cause, FALSE));
} }
/* Pass offer SDP back to UI */ /* 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); return (SM_RC_END);
} }
@ -3012,7 +3019,8 @@ fsmdef_ev_createanswer (sm_event_t *event) {
vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd); vcmGetIceParams(dcb->peerconnection, &ufrag, &ice_pwd);
if (!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)); 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); cause = gsmsdp_create_local_sdp(dcb, FALSE, has_audio, has_video, has_data, FALSE);
if (cause != CC_CAUSE_OK) { 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)); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
// Force clean up call without sending release // Force clean up call without sending release
return (fsmdef_release(fcb, cause, FALSE)); 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); cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, FALSE, TRUE);
if (cause != CC_CAUSE_OK) { 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)); return (fsmdef_release(fcb, cause, FALSE));
} }
cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body); cause = gsmsdp_encode_sdp_and_update_version(dcb, &msg_body);
if (cause != CC_CAUSE_OK) { 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)); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
return (fsmdef_release(fcb, cause, FALSE)); return (fsmdef_release(fcb, cause, FALSE));
} }
/* Pass SDP back to UI */ /* 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); return (SM_RC_END);
} }
@ -3099,12 +3114,16 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
callid_t call_id = msg->call_id; callid_t call_id = msg->call_id;
line_t line = msg->line; line_t line = msg->line;
cc_causes_t lsm_rc; 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__)); FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
if (!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); return (SM_RC_END);
} }
@ -3116,15 +3135,20 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
if (JSEP_OFFER == action) { if (JSEP_OFFER == action) {
cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body); cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
cc_free_msg_body_parts(&msg_body);
FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); 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); return (SM_RC_END);
} }
/* compare and fail if different: /* compare and fail if different:
* anant: Why? The JS should be able to modify the SDP. Commenting out for now (same for answer) * 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) { 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); return (SM_RC_END);
} }
*/ */
@ -3136,14 +3160,19 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
/* compare SDP generated from CreateAnswer */ /* compare SDP generated from CreateAnswer */
cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body); cause = gsmsdp_encode_sdp(dcb->sdp, &msg_body);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
cc_free_msg_body_parts(&msg_body);
FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); 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); return (SM_RC_END);
} }
/* compare and fail if different /* compare and fail if different
if (strcmp(msg_body.parts[0].body, sdp) != 0) { 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); return (SM_RC_END);
}*/ }*/
@ -3161,7 +3190,8 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
*/ */
cause = gsmsdp_install_peer_ice_attributes(fcb); cause = gsmsdp_install_peer_ice_attributes(fcb);
if (cause != CC_CAUSE_OK) { 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); return (SM_RC_END);
} }
@ -3183,8 +3213,20 @@ fsmdef_ev_setlocaldesc(sm_event_t *event) {
fsm_change_state(fcb, __LINE__, FSMDEF_S_CONNECTED); 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); return (SM_RC_END);
} }
@ -3211,13 +3253,16 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
boolean has_audio; boolean has_audio;
boolean has_video; boolean has_video;
boolean has_data; 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__)); FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
if (!sdpmode) { if (!sdpmode) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, 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); return (SM_RC_END);
} }
@ -3228,6 +3273,13 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
cc_initialize_msg_body_parts_info(&msg_body); 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.num_parts = 1;
msg_body.content_type = cc_content_type_SDP; msg_body.content_type = cc_content_type_SDP;
part = &msg_body.parts[0]; 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); cause = gsmsdp_process_offer_sdp(fcb, &msg_body, TRUE);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, 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); 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); cause = gsmsdp_create_local_sdp(dcb, TRUE, has_audio, has_video, has_data, FALSE);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, ui_set_remote_description(evSetRemoteDescError, line, call_id,
NULL, PC_SETREMOTEDESCERROR); dcb->caller_id.call_instance_id, strlib_empty(),
PC_SETREMOTEDESCERROR);
FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR)); FSM_DEBUG_SM(get_debug_string(FSM_DBG_SDP_BUILD_ERR));
// Force clean up call without sending release // Force clean up call without sending release
return (fsmdef_release(fcb, cause, FALSE)); 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); cause = gsmsdp_negotiate_media_lines(fcb, dcb->sdp, TRUE, TRUE, TRUE, FALSE);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, ui_set_remote_description(evSetRemoteDescError, line, call_id,
NULL, PC_SETREMOTEDESCERROR); dcb->caller_id.call_instance_id, strlib_empty(),
PC_SETREMOTEDESCERROR);
return (fsmdef_release(fcb, cause, FALSE)); 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); cause = gsmsdp_negotiate_answer_sdp(fcb, &msg_body);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, ui_set_remote_description(evSetRemoteDescError, line, call_id,
NULL, PC_SETREMOTEDESCERROR); dcb->caller_id.call_instance_id, strlib_empty(),
PC_SETREMOTEDESCERROR);
return (SM_RC_END); return (SM_RC_END);
} }
@ -3293,8 +3349,9 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
*/ */
cause = gsmsdp_install_peer_ice_attributes(fcb); cause = gsmsdp_install_peer_ice_attributes(fcb);
if (cause != CC_CAUSE_OK) { if (cause != CC_CAUSE_OK) {
ui_set_remote_description(evSetRemoteDescError, line, call_id, dcb->caller_id.call_instance_id, ui_set_remote_description(evSetRemoteDescError, line, call_id,
NULL, PC_SETREMOTEDESCERROR); dcb->caller_id.call_instance_id, strlib_empty(),
PC_SETREMOTEDESCERROR);
return (SM_RC_END); return (SM_RC_END);
} }
@ -3309,12 +3366,31 @@ fsmdef_ev_setremotedesc(sm_event_t *event) {
fsm_change_state(fcb, __LINE__, FSMDEF_S_CONNECTED); 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); return (SM_RC_END);
} }
/* TODO -- remove me. See bug 821066. */
static sm_rcs_t static sm_rcs_t
fsmdef_ev_localdesc(sm_event_t *event) { fsmdef_ev_localdesc(sm_event_t *event) {
fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; fsm_fcb_t *fcb = (fsm_fcb_t *) event->data;
@ -3342,6 +3418,7 @@ fsmdef_ev_localdesc(sm_event_t *event) {
return (SM_RC_END); return (SM_RC_END);
} }
/* TODO -- remove me. See bug 821066. */
static sm_rcs_t static sm_rcs_t
fsmdef_ev_remotedesc(sm_event_t *event) { fsmdef_ev_remotedesc(sm_event_t *event) {
fsm_fcb_t *fcb = (fsm_fcb_t *) event->data; fsm_fcb_t *fcb = (fsm_fcb_t *) event->data;
@ -3517,6 +3594,10 @@ fsmdef_ev_addcandidate(sm_event_t *event) {
int sdpmode = 0; int sdpmode = 0;
short vcm_res; short vcm_res;
uint16_t level; 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__)); FSM_DEBUG_SM(DEB_F_PREFIX"Entered.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__));
@ -3532,18 +3613,34 @@ fsmdef_ev_addcandidate(sm_event_t *event) {
return SM_RC_CLEANUP; return SM_RC_CLEANUP;
} }
/* Perform level lookup based on mid value */ /* Perform level lookup based on mid value */
/* comment until mid is properly updated /* comment until mid is properly updated
cause = gsmsdp_find_level_from_mid(dcb, (const char *)msg->data.candidate.mid, &level); 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); vcm_res = vcmSetIceCandidate(dcb->peerconnection, (char *)msg->data.candidate.candidate, msg->data.candidate.level);
if(vcm_res) { if(vcm_res) {
FSM_DEBUG_SM(DEB_F_PREFIX"failure setting ice candidate.\n", DEB_F_PREFIX_ARGS(FSM, __FUNCTION__)); 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. */
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); return (SM_RC_END);
} }

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

@ -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: * 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. * sdp_p - Pointer to the SDP to set the ice candidate attribute against.
* ice_attrib - ice attribute to set * 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) gsmsdp_set_ice_attribute (sdp_attr_e sdp_attr, uint16_t level, void *sdp_p, char *ice_attrib)
{ {
uint16_t a_instance = 0; 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; cc_msgbody_t *part;
uint32_t body_length; uint32_t body_length;
if (msg_body == NULL) { if (!msg_body || !sdp_p) {
return CC_CAUSE_ERROR; return CC_CAUSE_ERROR;
} }
/* Support single SDP encoding for now */ /* 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) { if (sdp_body == NULL) {
return CC_CAUSE_ERROR; return CC_CAUSE_ERROR;

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

@ -135,5 +135,9 @@ void gsmsdp_process_cap_constraints(fsmdef_dcb_t *dcb, const cc_media_constraint
cc_causes_t 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); 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); 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 #endif

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

@ -220,6 +220,8 @@ typedef enum {
CREATE_ANSWER, CREATE_ANSWER,
SET_LOCAL_DESC, SET_LOCAL_DESC,
SET_REMOTE_DESC, SET_REMOTE_DESC,
UPDATE_LOCAL_DESC,
UPDATE_REMOTE_DESC,
REMOTE_STREAM_ADD REMOTE_STREAM_ADD
} group_call_event_t; } group_call_event_t;

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

@ -37,6 +37,8 @@ typedef enum {
evCreateAnswerError = CREATEANSWERERROR, evCreateAnswerError = CREATEANSWERERROR,
evSetLocalDesc = SETLOCALDESC, evSetLocalDesc = SETLOCALDESC,
evSetRemoteDesc = SETREMOTEDESC, evSetRemoteDesc = SETREMOTEDESC,
evUpdateLocalDesc = UPDATELOCALDESC,
evUpdateRemoteDesc = UPDATEREMOTEDESC,
evSetLocalDescError = SETLOCALDESCERROR, evSetLocalDescError = SETLOCALDESCERROR,
evSetRemoteDescError = SETREMOTEDESCERROR, evSetRemoteDescError = SETREMOTEDESCERROR,
evOnRemoteStreamAdd = REMOTESTREAMADD, 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_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);
void ui_create_offer(call_events event, line_t nLine, callid_t nCallID, 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, 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, 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, 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, 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); uint16_t call_instance_id, cc_media_remote_track_table_t media_tracks);

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

@ -517,6 +517,8 @@ sdp_result_e sdp_parse_attr_fmtp (sdp_t *sdp_p, sdp_attr_t *attr_p,
/* END */ /* END */
/* Once we move to RFC compliant video codec implementations, the above /* Once we move to RFC compliant video codec implementations, the above
* patch should be removed */ * patch should be removed */
src_ptr = temp_ptr;
while (!done) { while (!done) {
fmtp_ptr = sdp_getnextstrtok(fmtp_ptr, tmp, sizeof(tmp), "= \t", &result1); fmtp_ptr = sdp_getnextstrtok(fmtp_ptr, tmp, sizeof(tmp), "= \t", &result1);
if (result1 == SDP_SUCCESS) { 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->fmtp_format = SDP_FMTP_CODEC_INFO;
fmtp_p->level = (short) strtoul_result; fmtp_p->level = (short) strtoul_result;
codec_info_found = TRUE; 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) { sdp_fmtp_codec_param[16].strlen) == 0) {
fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO; fmtp_p->fmtp_format = SDP_FMTP_CODEC_INFO;
fmtp_p->is_interlace = TRUE; fmtp_p->is_interlace = TRUE;

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

@ -322,7 +322,7 @@ sipsdp_src_dest_create (const char *peerconnection,
* and by examining SDP library error counters. * and by examining SDP library error counters.
*/ */
char * 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; flex_string fs;
uint32_t sdp_len; uint32_t sdp_len;
@ -330,12 +330,12 @@ sipsdp_write_to_buf (cc_sdp_t *sdp_info, uint32_t *retbytes)
flex_string_init(&fs); 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__); CCSIP_DEBUG_ERROR(SIP_F_PREFIX"NULL sdp_info or src_sdp\n", __FUNCTION__);
return (NULL); return (NULL);
} }
if ((rc = sdp_build(sdp_info->src_sdp, &fs)) if ((rc = sdp_build(sdp_info, &fs))
!= SDP_SUCCESS) { != SDP_SUCCESS) {
CCSIP_DEBUG_TASK(DEB_F_PREFIX"sdp_build rc=%s\n", DEB_F_PREFIX_ARGS(SIP_SDP, __FUNCTION__), CCSIP_DEBUG_TASK(DEB_F_PREFIX"sdp_build rc=%s\n", DEB_F_PREFIX_ARGS(SIP_SDP, __FUNCTION__),
sdp_get_result_name(rc)); sdp_get_result_name(rc));

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

@ -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 * Memory is allocated and should be freed by the user when done
* Returns NULL on failure. * 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) \ #define SIPSDP_FREE(x) \
if (x) \ if (x) \

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

@ -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; #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; typedef const char *string_t;
__END_DECLS __END_DECLS

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

@ -282,6 +282,8 @@ typedef enum {
CREATEANSWERERROR, CREATEANSWERERROR,
SETLOCALDESC, SETLOCALDESC,
SETREMOTEDESC, SETREMOTEDESC,
UPDATELOCALDESC,
UPDATEREMOTEDESC,
SETLOCALDESCERROR, SETLOCALDESCERROR,
SETREMOTEDESCERROR, SETREMOTEDESCERROR,
REMOTESTREAMADD, REMOTESTREAMADD,

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

@ -135,6 +135,12 @@ std::string CC_SIPCCCallInfo::callStateToString (cc_call_state_t state)
case SETREMOTEDESC: case SETREMOTEDESC:
statestr = "SETREMOTEDESC"; statestr = "SETREMOTEDESC";
break; break;
case UPDATELOCALDESC:
statestr = "UPDATELOCALDESC";
break;
case UPDATEREMOTEDESC:
statestr = "UPDATEREMOTEDESC";
break;
case SETLOCALDESCERROR: case SETLOCALDESCERROR:
statestr = "SETLOCALDESCERROR"; statestr = "SETLOCALDESCERROR";
break; break;

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

@ -533,6 +533,24 @@ class SignalingAgent {
char* offer() const { return offer_; } char* offer() const { return offer_; }
char* answer() const { return answer_; } 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, void CreateOffer(sipcc::MediaConstraints& constraints,
uint32_t offerFlags, uint32_t sdpCheck) { 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. } // End namespace test.
int main(int argc, char **argv) { int main(int argc, char **argv) {