/** * Send component start reply * @param component the component * @param iq the start request */ void rayo_component_send_start(struct rayo_component *component, iks *iq) { iks *response = iks_new_iq_result(iq); iks *ref = iks_insert(response, "ref"); iks_insert_attrib(ref, "xmlns", RAYO_NS); iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(component)); RAYO_SEND_REPLY(component, iks_find_attrib(response, "to"), response); }
/** * Stop execution of record component */ static iks *stop_call_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) { switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); if (session) { RECORD_COMPONENT(component)->stop = 1; switch_ivr_stop_record_session(session, RAYO_ID(component)); switch_core_session_rwunlock(session); } return iks_new_iq_result(iq); }
/** * Stop execution of fax component */ static iks *stop_fax_component(struct rayo_actor *component, struct rayo_message *msg, void *data) { iks *iq = msg->payload; switch_core_session_t *session = switch_core_session_locate(RAYO_COMPONENT(component)->parent->id); FAX_COMPONENT(component)->stop = 1; if (session) { switch_core_session_execute_application_async(session, "stopfax", ""); switch_core_session_rwunlock(session); } return iks_new_iq_result(iq); }
/** * Lower volume of output component */ static iks *volume_down_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data) { iks *iq = msg->payload; switch_stream_handle_t stream = { 0 }; char *command = switch_mprintf("%s volume:-", RAYO_JID(component)); SWITCH_STANDARD_STREAM(stream); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s lowering volume\n", RAYO_JID(component)); switch_api_execute("fileman", command, NULL, &stream); switch_safe_free(stream.data); switch_safe_free(command); return iks_new_iq_result(iq); }
/** * Stop execution of record component */ static iks *stop_mixer_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) { char *args; switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); RECORD_COMPONENT(component)->stop = 1; args = switch_mprintf("%s recording stop %s", RAYO_COMPONENT(component)->parent->id, RAYO_ID(component)); switch_api_execute("conference", args, NULL, &stream); switch_safe_free(args); switch_safe_free(stream.data); return iks_new_iq_result(iq); }
/** * Resume execution of record component */ static iks *resume_record_component(struct rayo_actor *client, struct rayo_actor *component, iks *iq, void *data) { struct record_component *record = RECORD_COMPONENT(component); switch_stream_handle_t stream = { 0 }; char *command = switch_mprintf("%s resume", record->local_file_path); SWITCH_STANDARD_STREAM(stream); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s resuming\n", RAYO_ID(component)); if (!record->start_time) { record->start_time = switch_micro_time_now(); } switch_api_execute("fileman", command, NULL, &stream); switch_safe_free(stream.data); switch_safe_free(command); return iks_new_iq_result(iq); }
/** * Stop execution of prompt component */ static iks *stop_call_prompt_component(struct rayo_actor *prompt, struct rayo_message *msg, void *data) { iks *iq = msg->payload; iks *reply = NULL; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) stop prompt\n", RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state)); switch (PROMPT_COMPONENT(prompt)->state) { case PCS_OUTPUT: /* input hasn't started yet */ PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT; PROMPT_COMPONENT(prompt)->complete = rayo_component_create_complete_event(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_STOP); rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid); break; case PCS_INPUT_OUTPUT: case PCS_INPUT: case PCS_STOP_OUTPUT: /* stopping input will trigger completion */ rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->input_jid); break; case PCS_START_INPUT: /* stop input as soon as it starts */ PROMPT_COMPONENT(prompt)->state = PCS_DONE; break; case PCS_DONE_STOP_OUTPUT: case PCS_DONE: /* already done */ break; case PCS_START_OUTPUT: case PCS_START_OUTPUT_BARGE: case PCS_START_INPUT_OUTPUT: case PCS_START_INPUT_TIMERS: /* ref hasn't been sent yet */ reply = iks_new_error(iq, STANZA_ERROR_UNEXPECTED_REQUEST); break; } if (!reply) { reply = iks_new_iq_result(iq); } return reply; }
/** * Seek output component */ static iks *seek_output_component(struct rayo_actor *component, struct rayo_message *msg, void *data) { iks *iq = msg->payload; iks *seek = iks_find(iq, "seek"); if (VALIDATE_RAYO_OUTPUT_SEEK(seek)) { int is_forward = !strcmp("forward", iks_find_attrib(seek, "direction")); int amount_ms = iks_find_int_attrib(seek, "amount"); char *command = switch_mprintf("%s seek:%s%i", RAYO_JID(component), is_forward ? "+" : "-", amount_ms); switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); switch_api_execute("fileman", command, NULL, &stream); switch_safe_free(stream.data); switch_safe_free(command); return iks_new_iq_result(iq); } return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST); }
/** * Stop execution of CPA component */ static iks *stop_cpa_component(struct rayo_actor *component, struct rayo_message *msg, void *data) { stop_cpa_detectors(CPA_COMPONENT(component)); rayo_component_send_complete(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP); return iks_new_iq_result(msg->payload); }