static apt_bool_t mrcp_client_on_termination_subtract(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise(session,MRCP_SIG_STATUS_CODE_SUCCESS); } } else { /* channel termination */ mrcp_channel_t *channel = mrcp_client_channel_termination_find(session,mpf_message->termination); if(channel && channel->waiting_for_termination == TRUE) { channel->waiting_for_termination = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* raise app response */ mrcp_app_sig_response_raise(session,TRUE); } } } return TRUE; }
static apt_bool_t mrcp_client_on_termination_subtract(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Subtracted "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise(session,MRCP_SIG_STATUS_CODE_SUCCESS); } } else { /* channel termination */ mrcp_channel_t *channel = mrcp_client_channel_termination_find(session,mpf_message->termination); if(channel && channel->waiting_for_termination == TRUE) { channel->waiting_for_termination = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* raise app response */ mrcp_app_sig_response_raise(session,TRUE); } } } return TRUE; }
static apt_bool_t mrcp_client_on_termination_modify(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Modified "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; termination_slot->descriptor = mpf_message->descriptor;; if(mrcp_client_session_subrequest_remove(session) == TRUE) { if(session->state == SESSION_STATE_GENERATING_OFFER) { /* send offer to server */ mrcp_client_session_offer_send(session); } else if(session->state == SESSION_STATE_PROCESSING_ANSWER) { /* raise app response */ mrcp_app_sig_response_raise(session,TRUE); } } } return TRUE; }
static apt_bool_t mrcp_client_on_termination_modify(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; termination_slot->descriptor = mpf_message->descriptor;; if(mrcp_client_session_subrequest_remove(session) == TRUE) { if(session->state == SESSION_STATE_GENERATING_OFFER) { /* send offer to server */ mrcp_client_session_offer_send(session); } else if(session->state == SESSION_STATE_PROCESSING_ANSWER) { /* raise app response */ mrcp_app_sig_response_raise(session,TRUE); } } } return TRUE; }
apt_bool_t mrcp_client_session_terminate_response_process(mrcp_client_session_t *session) { apt_obj_log(APT_LOG_MARK,APT_PRIO_INFO,session->base.log_obj,"Session Terminated "APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise(session,MRCP_SIG_STATUS_CODE_SUCCESS); } return TRUE; }
apt_bool_t mrcp_client_session_terminate_response_process(mrcp_client_session_t *session) { apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Receive Terminate Response "APT_PTRSID_FMT, MRCP_SESSION_PTRSID(&session->base)); if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise(session,MRCP_SIG_STATUS_CODE_SUCCESS); } return TRUE; }
static apt_bool_t mrcp_client_on_termination_add(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Media Termination Added "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), mpf_termination_name_get(mpf_message->termination)); termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ mpf_rtp_termination_descriptor_t *rtp_descriptor; if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; rtp_descriptor = mpf_message->descriptor; if(rtp_descriptor->audio.local) { session->offer->ip = rtp_descriptor->audio.local->ip; session->offer->ext_ip = rtp_descriptor->audio.local->ext_ip; rtp_descriptor->audio.local->id = mrcp_session_audio_media_add(session->offer,rtp_descriptor->audio.local); rtp_descriptor->audio.local->mid = session->offer->audio_media_arr->nelts; termination_slot->id = session->offer->audio_media_arr->nelts - 1; } if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } } else { /* channel termination */ mrcp_channel_t *channel = mrcp_client_channel_termination_find(session,mpf_message->termination); if(channel && channel->waiting_for_termination == TRUE) { channel->waiting_for_termination = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } } } return TRUE; }
apt_bool_t mrcp_client_mpf_message_process(mpf_message_container_t *mpf_message_container) { apr_size_t i; mrcp_client_session_t *session; const mpf_message_t *mpf_message; for(i=0; i<mpf_message_container->count; i++) { mpf_message = &mpf_message_container->messages[i]; if(mpf_message->context) { session = mpf_engine_context_object_get(mpf_message->context); } else { session = NULL; } if(!session) { apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Received MPF Message: NULL session"); continue; } if(mpf_message->message_type == MPF_MESSAGE_TYPE_RESPONSE) { switch(mpf_message->command_id) { case MPF_ADD_TERMINATION: mrcp_client_on_termination_add(session,mpf_message); break; case MPF_MODIFY_TERMINATION: mrcp_client_on_termination_modify(session,mpf_message); break; case MPF_SUBTRACT_TERMINATION: mrcp_client_on_termination_subtract(session,mpf_message); break; case MPF_ADD_ASSOCIATION: case MPF_REMOVE_ASSOCIATION: case MPF_RESET_ASSOCIATIONS: case MPF_APPLY_TOPOLOGY: case MPF_DESTROY_TOPOLOGY: if(mrcp_client_session_subrequest_remove(session) == TRUE) { if(session->state == SESSION_STATE_GENERATING_OFFER) { /* send offer to server */ mrcp_client_session_offer_send(session); } else if(session->state == SESSION_STATE_PROCESSING_ANSWER) { /* raise app response */ mrcp_app_sig_response_raise(session,TRUE); } } break; default: break; } } else if(mpf_message->message_type == MPF_MESSAGE_TYPE_EVENT) { apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Process MPF Event " APT_NAMESID_FMT, MRCP_SESSION_NAMESID(session)); } } return TRUE; }
static apt_bool_t mrcp_client_on_termination_add(mrcp_client_session_t *session, const mpf_message_t *mpf_message) { rtp_termination_slot_t *termination_slot; if(!session) { return FALSE; } termination_slot = mrcp_client_rtp_termination_find(session,mpf_message->termination); if(termination_slot) { /* rtp termination */ mpf_rtp_termination_descriptor_t *rtp_descriptor; if(termination_slot->waiting == FALSE) { return FALSE; } termination_slot->waiting = FALSE; rtp_descriptor = mpf_message->descriptor; if(rtp_descriptor->audio.local) { session->offer->ip = rtp_descriptor->audio.local->ip; session->offer->ext_ip = rtp_descriptor->audio.local->ext_ip; rtp_descriptor->audio.local->id = mrcp_session_audio_media_add(session->offer,rtp_descriptor->audio.local); rtp_descriptor->audio.local->mid = session->offer->audio_media_arr->nelts; termination_slot->id = session->offer->audio_media_arr->nelts - 1; } if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } } else { /* channel termination */ mrcp_channel_t *channel = mrcp_client_channel_termination_find(session,mpf_message->termination); if(channel && channel->waiting_for_termination == TRUE) { channel->waiting_for_termination = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } } } return TRUE; }
apt_bool_t mrcp_client_on_channel_add(mrcp_channel_t *channel, mrcp_control_descriptor_t *descriptor, apt_bool_t status) { mrcp_client_session_t *session = (mrcp_client_session_t*)channel->session; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"On Control Channel Add "APT_PTRSID_FMT, MRCP_SESSION_PTRSID(&session->base)); if(!channel->waiting_for_channel) { return FALSE; } channel->waiting_for_channel = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } return TRUE; }
apt_bool_t mrcp_client_on_channel_remove(mrcp_channel_t *channel, apt_bool_t status) { mrcp_client_session_t *session = (mrcp_client_session_t*)channel->session; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"On Control Channel Remove "APT_PTRSID_FMT, MRCP_SESSION_PTRSID(&session->base)); if(!channel->waiting_for_channel) { return FALSE; } channel->waiting_for_channel = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise( session, status == TRUE ? MRCP_SIG_STATUS_CODE_SUCCESS : MRCP_SIG_STATUS_CODE_FAILURE); } return TRUE; }
apt_bool_t mrcp_client_on_channel_add(mrcp_channel_t *channel, mrcp_control_descriptor_t *descriptor, apt_bool_t status) { mrcp_client_session_t *session = (mrcp_client_session_t*)channel->session; apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Control Channel Added "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), channel->resource->name.buf); if(!channel->waiting_for_channel) { return FALSE; } channel->waiting_for_channel = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* send offer to server */ mrcp_client_session_offer_send(session); } return TRUE; }
apt_bool_t mrcp_client_on_channel_remove(mrcp_channel_t *channel, apt_bool_t status) { mrcp_client_session_t *session = (mrcp_client_session_t*)channel->session; apt_obj_log(APT_LOG_MARK,APT_PRIO_DEBUG,session->base.log_obj,"Control Channel Removed "APT_NAMESIDRES_FMT, MRCP_SESSION_NAMESID(session), channel->resource->name.buf); if(!channel->waiting_for_channel) { return FALSE; } channel->waiting_for_channel = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_session_terminate_raise( session, status == TRUE ? MRCP_SIG_STATUS_CODE_SUCCESS : MRCP_SIG_STATUS_CODE_FAILURE); } return TRUE; }
apt_bool_t mrcp_client_on_channel_modify(mrcp_channel_t *channel, mrcp_control_descriptor_t *descriptor, apt_bool_t status) { mrcp_client_session_t *session = (mrcp_client_session_t*)channel->session; apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"On Control Channel Modify "APT_PTRSID_FMT, MRCP_SESSION_PTRSID(&session->base)); if(!channel->waiting_for_channel) { return FALSE; } channel->waiting_for_channel = FALSE; if(mrcp_client_session_subrequest_remove(session) == TRUE) { /* raise app response */ if(status != TRUE) { session->status = MRCP_SIG_STATUS_CODE_FAILURE; } mrcp_app_sig_response_raise(session,TRUE); } return TRUE; }
apt_bool_t mrcp_client_session_discover_response_process(mrcp_client_session_t *session, mrcp_session_descriptor_t *descriptor) { apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Resources Discovered %s", session->base.name); if(!session->active_request) { return FALSE; } if(!descriptor) { /* raise app response */ session->status = MRCP_SIG_STATUS_CODE_FAILURE; return mrcp_app_sig_response_raise(session,TRUE); } if(mrcp_session_version_get(session) == MRCP_VERSION_1) { if(descriptor->resource_state == TRUE) { mrcp_control_descriptor_t *control_media; if(!session->answer) { session->answer = descriptor; } control_media = mrcp_control_descriptor_create(session->base.pool); control_media->id = mrcp_session_control_media_add(session->answer,control_media); control_media->resource_name = descriptor->resource_name; } } else { session->answer = descriptor; } if(mrcp_client_session_subrequest_remove(session) == TRUE) { mrcp_app_message_t *response; response = mrcp_client_app_response_create(session->active_request,MRCP_SIG_STATUS_CODE_SUCCESS,session->base.pool); response->descriptor = session->answer; session->answer = NULL; apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Raise App Resource Discovery Response %s", session->base.name); session->application->handler(response); session->active_request = apt_list_pop_front(session->request_queue); if(session->active_request) { mrcp_app_request_dispatch(session,session->active_request); } } return TRUE; }