METROPOLIS: Bug fix for BFCP

This commit is contained in:
bossiel 2014-07-28 01:05:02 +00:00
parent e1faefeecd
commit 4c85552471
2 changed files with 41 additions and 24 deletions

View File

@ -51,6 +51,7 @@ typedef struct tdav_session_bfcp_s
tsk_bool_t b_use_ipv6;
tsk_bool_t b_revoked_handled;
tsk_bool_t b_conf_idf_changed;
tsk_bool_t b_stop_to_reconf;
char* p_local_ip;
//uint16_t local_port;
@ -110,6 +111,12 @@ static int _tdav_session_bfcp_set(tmedia_session_t* p_self, const tmedia_param_t
p_bfcp->p_natt_ctx = tsk_object_ref(param->value);
}
}
else if (param->value_type == tmedia_pvt_int32) {
if (tsk_striequals(param->key, "stop-to-reconf")) {
p_bfcp->b_stop_to_reconf = TSK_TO_INT32((uint8_t*)param->value) ? tsk_true : tsk_false;
}
}
return ret;
}
@ -232,14 +239,18 @@ static int _tdav_session_bfcp_stop(tmedia_session_t* p_self)
p_bfcp = (tdav_session_bfcp_t*)p_self;
if (p_bfcp->b_started) {
#if 0 // Must not ... because could be caused by an incoming reINVITE.
if (p_bfcp->p_pkt_FloorRelease) {
if ((ret = tbfcp_session_send_pkt(p_bfcp->p_bfcp_s, p_bfcp->p_pkt_FloorRelease))) {
if (!p_bfcp->b_stop_to_reconf) { // If stop-to-reconf then do not release the FloorRequest but reuse it
if (p_bfcp->b_started) {
/*if (p_bfcp->p_bfcp_s)*/ {
/*if (!p_bfcp->p_pkt_FloorRelease) {
ret = tbfcp_session_create_pkt_FloorRelease(p_bfcp->p_bfcp_s, &p_bfcp->p_pkt_FloorRelease);
}
if (ret == 0 && p_bfcp->p_pkt_FloorRelease && (ret = tbfcp_session_send_pkt(p_bfcp->p_bfcp_s, p_bfcp->p_pkt_FloorRelease))) {
//!\ do not exit
}*/
}
}
#endif
tsk_strupdate(&p_bfcp->rfc4583.confid, "");
}
if (p_bfcp->p_bfcp_s) {
@ -247,6 +258,7 @@ static int _tdav_session_bfcp_stop(tmedia_session_t* p_self)
}
p_bfcp->b_started = tsk_false;
p_bfcp->b_stop_to_reconf = tsk_false; // reset
return ret;
}
@ -485,7 +497,7 @@ static int _tdav_session_bfcp_notif(const struct tbfcp_session_event_xs *e)
TSK_OBJECT_SAFE_FREE(p_bfcp->p_pkt_Hello);
if (e->pc_pkt->hdr.primitive == tbfcp_primitive_HelloAck) {
if (!p_bfcp->p_pkt_FloorRequest) {
if (p_bfcp->b_conf_idf_changed) {
if (p_bfcp->b_conf_idf_changed || 0) {
// Create the "FloorRelease" for this "FloorRequest"
TSK_OBJECT_SAFE_FREE(p_bfcp->p_pkt_FloorRelease);
if ((ret = tbfcp_session_create_pkt_FloorRelease(p_bfcp->p_bfcp_s, &p_bfcp->p_pkt_FloorRelease))) {
@ -510,7 +522,7 @@ static int _tdav_session_bfcp_notif(const struct tbfcp_session_event_xs *e)
}
else if(p_bfcp->p_pkt_FloorRequest /*&& p_bfcp->p_pkt_FloorRequest->hdr.transac_id == e->pc_pkt->hdr.transac_id*/ && p_bfcp->p_pkt_FloorRequest->hdr.user_id == e->pc_pkt->hdr.user_id && p_bfcp->p_pkt_FloorRequest->hdr.conf_id == e->pc_pkt->hdr.conf_id) {
tsk_bool_t transac_id_matched = (p_bfcp->p_pkt_FloorRequest->hdr.transac_id == e->pc_pkt->hdr.transac_id);
if (e->pc_pkt->hdr.primitive == tbfcp_primitive_FloorRequestStatus) {
if (e->pc_pkt->hdr.primitive == tbfcp_primitive_FloorRequestStatus || e->pc_pkt->hdr.primitive == tbfcp_primitive_FloorStatus) {
tsk_size_t u_index0, u_index1, u_index2, u_index3;
const tbfcp_attr_grouped_t *pc_attr_FloorRequestInformation = tsk_null,
*pc_attr_FloorRequestStatus = tsk_null,
@ -583,13 +595,15 @@ static int _tdav_session_bfcp_notif(const struct tbfcp_session_event_xs *e)
// Status from old FloorRequest
tbfcp_pkt_t* p_pkt = tsk_null;
TSK_DEBUG_INFO("Status from old Request");
if ((ret = tbfcp_pkt_create_FloorRelease_2(e->pc_pkt->hdr.conf_id, e->pc_pkt->hdr.transac_id, e->pc_pkt->hdr.user_id, pc_attr_FloorRequestStatus->extra_hdr.FloorID, &p_pkt))) {
goto raise_err;
}
ret = tbfcp_session_send_pkt(p_bfcp->p_bfcp_s, p_pkt);
TSK_OBJECT_SAFE_FREE(p_pkt);
if (ret) {
goto raise_err;
if (u_status == tbfcp_reqstatus_Pending || u_status == tbfcp_reqstatus_Accepted || u_status == tbfcp_reqstatus_Granted) {
if ((ret = tbfcp_pkt_create_FloorRelease_2(e->pc_pkt->hdr.conf_id, e->pc_pkt->hdr.transac_id, e->pc_pkt->hdr.user_id, pc_attr_FloorRequestStatus->extra_hdr.FloorID, &p_pkt))) {
goto raise_err;
}
ret = tbfcp_session_send_pkt(p_bfcp->p_bfcp_s, p_pkt);
TSK_OBJECT_SAFE_FREE(p_pkt);
if (ret) {
goto raise_err;
}
}
}
}

View File

@ -1136,7 +1136,7 @@ int tmedia_session_mgr_set_ro(tmedia_session_mgr_t* self, const tsdp_message_t*
tsk_bool_t is_ro_media_lines_changed = tsk_false;
tsk_bool_t is_ice_active = tsk_false;
tsk_bool_t had_ro_sdp, had_ro_provisional, is_ro_provisional_final_matching = tsk_false;
tsk_bool_t new_mediatype_striped = tsk_false;
tsk_bool_t is_new_mediatype_striped = tsk_false;
tmedia_qos_stype_t qos_type = tmedia_qos_stype_none;
tmedia_type_t new_mediatype = tmedia_none;
tmedia_sessions_L_t *list_tmp_sessions;
@ -1162,15 +1162,15 @@ int tmedia_session_mgr_set_ro(tmedia_session_mgr_t* self, const tsdp_message_t*
// Remove BFCP offer if not locally enabled. Only the client can init BFCP session.
if ((ro_type & tmedia_ro_type_offer)) {
if (!(self->type & tmedia_bfcp_video)) {
new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
is_new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
new_mediatype &= ~tmedia_bfcp_video;
}
if (!(self->type & tmedia_bfcp_audio)) {
new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
is_new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
new_mediatype &= ~tmedia_bfcp_audio;
}
if (!(self->type & tmedia_bfcp)) {
new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
is_new_mediatype_striped |= (new_mediatype & tmedia_bfcp_video);
new_mediatype &= ~tmedia_bfcp;
}
}
@ -1293,8 +1293,8 @@ int tmedia_session_mgr_set_ro(tmedia_session_mgr_t* self, const tsdp_message_t*
* For initial offer we don't need to check anything
*/
if (self->sdp.lo) {
if ((is_media_type_changed = (new_mediatype != self->type)) || new_mediatype_striped) {
tsk_bool_t force = !!new_mediatype_striped;
if ((is_media_type_changed = (new_mediatype != self->type)) || is_new_mediatype_striped) {
tsk_bool_t force = !!is_new_mediatype_striped;
tmedia_session_mgr_set_media_type_2(self, new_mediatype, force);
TSK_DEBUG_INFO("media type has changed");
}
@ -1328,13 +1328,16 @@ int tmedia_session_mgr_set_ro(tmedia_session_mgr_t* self, const tsdp_message_t*
* loopback address won't work on embedded devices such as iOS and Android.
*
*/
if((self->started && !is_ro_loopback_address) && (is_ro_codecs_changed || is_ro_network_info_changed || is_ro_media_lines_changed || is_media_type_changed)){
if ((self->started && !is_ro_loopback_address) && (is_ro_codecs_changed || is_ro_network_info_changed || is_ro_media_lines_changed || is_media_type_changed)){
TSK_DEBUG_INFO("stopped_to_reconf=true,is_ice_active=%s", is_ice_active?"true":"false");
stopped_to_reconf = tsk_true;
tmedia_session_mgr_set(self,
TMEDIA_SESSION_SET_INT32(self->type, "stop-to-reconf", stopped_to_reconf),
TMEDIA_SESSION_SET_NULL());
if((ret = tmedia_session_mgr_stop(self))){
TSK_DEBUG_ERROR("Failed to stop session manager");
goto bail;
}
stopped_to_reconf = tsk_true;
}
/* update remote offer */
@ -1459,7 +1462,7 @@ end_of_sessions_update:
}
/* signal that ro has changed (will be used to update lo) unless there was no ro_sdp */
self->ro_changed = (had_ro_sdp && (is_ro_hold_resume_changed || is_ro_network_info_changed || is_ro_media_lines_changed || is_ro_codecs_changed));
self->ro_changed = (had_ro_sdp && (is_ro_hold_resume_changed || is_ro_network_info_changed || is_ro_media_lines_changed || is_ro_codecs_changed /*|| is_media_type_changed || is_new_mediatype_striped*/));
/* update "provisional" info */
self->ro_provisional = ((ro_type & tmedia_ro_type_provisional) == tmedia_ro_type_provisional);