static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) { mrcp_profile_t *profile; mrcp_channel_t *channel; rtp_termination_slot_t *slot; int i; if(!session->offer) { return FALSE; } apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Session <%s>", mrcp_session_str(session)); profile = session->profile; /* remove existing control channels */ for(i=0; i<session->channels->nelts; i++) { /* get existing channel */ channel = *((mrcp_channel_t**)session->channels->elts + i); if(!channel) continue; if(channel->control_channel) { /* remove channel */ apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Remove Control Channel"); if(mrcp_client_control_channel_remove(channel->control_channel) == TRUE) { channel->waiting_for_channel = TRUE; session->terminate_flag_count++; } } if(channel->termination) { /* send subtract termination request */ if(channel->termination) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Subtract Channel Termination"); if(mrcp_client_mpf_request_send(profile->media_engine,MPF_COMMAND_SUBTRACT,session->context,channel->termination,NULL) == TRUE) { channel->waiting_for_termination = TRUE; session->terminate_flag_count++; } } } } /* subtract existing terminations */ for(i=0; i<session->terminations->nelts; i++) { /* get existing termination */ slot = &((rtp_termination_slot_t*)session->terminations->elts)[i]; if(!slot || !slot->termination) continue; /* send subtract termination request */ apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Subtract Termination"); if(mrcp_client_mpf_request_send(profile->media_engine,MPF_COMMAND_SUBTRACT,session->context,slot->termination,NULL) == TRUE) { slot->waiting = TRUE; session->terminate_flag_count++; } } session->terminate_flag_count++; mrcp_session_terminate_request(&session->base); return TRUE; }
static apt_bool_t mrcp_client_session_terminate(mrcp_client_session_t *session) { mrcp_profile_t *profile; mrcp_channel_t *channel; rtp_termination_slot_t *slot; int i; apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Terminate Session "APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); profile = session->profile; mrcp_client_session_state_set(session,SESSION_STATE_TERMINATING); if(session->context) { /* first destroy existing topology */ if(mpf_engine_topology_message_add( session->profile->media_engine, MPF_DESTROY_TOPOLOGY,session->context, &session->mpf_task_msg) == TRUE){ mrcp_client_session_subrequest_add(session); } } /* remove existing control channels */ for(i=0; i<session->channels->nelts; i++) { /* get existing channel */ channel = APR_ARRAY_IDX(session->channels,i,mrcp_channel_t*); if(!channel) continue; if(channel->control_channel) { /* remove channel */ apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Remove Control Channel "APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); if(mrcp_client_control_channel_remove(channel->control_channel) == TRUE) { channel->waiting_for_channel = TRUE; mrcp_client_session_subrequest_add(session); } } /* send subtract termination request */ if(channel->termination) { apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Subtract Media Termination "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(channel->termination)); if(mpf_engine_termination_message_add( profile->media_engine, MPF_SUBTRACT_TERMINATION,session->context,channel->termination,NULL, &session->mpf_task_msg) == TRUE) { channel->waiting_for_termination = TRUE; mrcp_client_session_subrequest_add(session); } } } if(session->context) { /* subtract existing terminations */ for(i=0; i<session->terminations->nelts; i++) { /* get existing termination */ slot = &APR_ARRAY_IDX(session->terminations,i,rtp_termination_slot_t); if(!slot || !slot->termination) continue; /* send subtract termination request */ apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Subtract Media Termination "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(slot->termination)); if(mpf_engine_termination_message_add( profile->media_engine, MPF_SUBTRACT_TERMINATION,session->context,slot->termination,NULL, &session->mpf_task_msg) == TRUE) { slot->waiting = TRUE; mrcp_client_session_subrequest_add(session); } } mpf_engine_message_send(profile->media_engine,&session->mpf_task_msg); } mrcp_client_session_subrequest_add(session); mrcp_session_terminate_request(&session->base); return TRUE; }