本文整理汇总了C++中RAYO_JID函数的典型用法代码示例。如果您正苦于以下问题:C++ RAYO_JID函数的具体用法?C++ RAYO_JID怎么用?C++ RAYO_JID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RAYO_JID函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rayo_component_send_start
/**
* Start execution of call output component
* @param component to start
* @param session the session to output to
* @param output the output request
* @param iq the original request
*/
static iks *start_call_output(struct rayo_component *component, switch_core_session_t *session, iks *output, iks *iq)
{
switch_stream_handle_t stream = { 0 };
/* acknowledge command */
rayo_component_send_start(component, iq);
/* build playback command */
SWITCH_STANDARD_STREAM(stream);
stream.write_function(&stream, "{id=%s,session=%s,pause=%s",
RAYO_JID(component), switch_core_session_get_uuid(session),
OUTPUT_COMPONENT(component)->start_paused ? "true" : "false");
if (OUTPUT_COMPONENT(component)->max_time > 0) {
stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time * 1000);
}
stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component));
if (switch_ivr_displace_session(session, stream.data, 0, "m") == SWITCH_STATUS_SUCCESS) {
RAYO_UNLOCK(component);
} else {
if (OUTPUT_COMPONENT(component)->document) {
iks_delete(OUTPUT_COMPONENT(component)->document);
}
if (switch_channel_get_state(switch_core_session_get_channel(session)) >= CS_HANGUP) {
rayo_component_send_complete(component, COMPONENT_COMPLETE_HANGUP);
component = NULL;
} else {
rayo_component_send_complete(component, COMPONENT_COMPLETE_ERROR);
component = NULL;
}
}
switch_safe_free(stream.data);
return NULL;
}
示例2: switch_log_printf
/**
* Pass output component command
*/
static iks *forward_output_component_request(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{
iks *iq = msg->payload;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) %s prompt\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state), iks_name(iks_first_tag(iq)));
switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_OUTPUT:
case PCS_START_INPUT_OUTPUT:
case PCS_INPUT_OUTPUT: {
/* forward request to output component */
iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", PROMPT_COMPONENT(prompt)->output_jid);
RAYO_SEND_MESSAGE_DUP(prompt, PROMPT_COMPONENT(prompt)->output_jid, iq);
return NULL;
}
case PCS_START_INPUT_TIMERS:
case PCS_START_OUTPUT:
case PCS_START_OUTPUT_BARGE:
/* ref hasn't been sent yet */
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "too soon");
break;
case PCS_START_INPUT:
case PCS_STOP_OUTPUT:
case PCS_DONE_STOP_OUTPUT:
case PCS_INPUT:
case PCS_DONE:
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "output is finished");
}
return NULL;
}
示例3: iks_find
/**
* Handle input failure.
*/
static iks *prompt_component_handle_input_error(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{
iks *iq = msg->payload;
iks *error = iks_find(iq, "error");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s (%s) input error\n",
RAYO_JID(prompt), prompt_component_state_to_string(PROMPT_COMPONENT(prompt)->state));
switch (PROMPT_COMPONENT(prompt)->state) {
case PCS_START_INPUT_TIMERS:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, <input> error: %s\n", RAYO_JID(prompt), iks_string(iks_stack(iq), iq));
PROMPT_COMPONENT(prompt)->state = PCS_DONE;
/* forward IQ error to client */
iq = PROMPT_COMPONENT(prompt)->iq;
iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent));
iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid);
iks_insert_node(iq, iks_copy_within(error, iks_stack(iq)));
RAYO_SEND_REPLY(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
/* done */
RAYO_UNLOCK(prompt);
RAYO_DESTROY(prompt);
break;
case PCS_START_INPUT:
/* send presence error to client */
PROMPT_COMPONENT(prompt)->state = PCS_DONE;
iks_delete(PROMPT_COMPONENT(prompt)->iq);
rayo_component_send_complete(RAYO_COMPONENT(prompt), COMPONENT_COMPLETE_ERROR);
break;
case PCS_START_INPUT_OUTPUT:
PROMPT_COMPONENT(prompt)->state = PCS_DONE_STOP_OUTPUT;
/* forward IQ error to client */
iq = PROMPT_COMPONENT(prompt)->iq;
iks_insert_attrib(iq, "from", RAYO_JID(RAYO_COMPONENT(prompt)->parent));
iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid);
iks_insert_node(iq, iks_copy_within(error, iks_stack(iq)));
PROMPT_COMPONENT(prompt)->complete = iq;
rayo_component_send_stop(prompt, PROMPT_COMPONENT(prompt)->output_jid);
break;
case PCS_START_OUTPUT:
case PCS_START_OUTPUT_BARGE:
case PCS_INPUT_OUTPUT:
case PCS_STOP_OUTPUT:
case PCS_INPUT:
case PCS_OUTPUT:
case PCS_DONE_STOP_OUTPUT:
case PCS_DONE:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s, unexpected start input error event\n", RAYO_JID(prompt));
break;
}
return NULL;
}
示例4: switch_mprintf
/**
* 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);
}
示例5: iks_find
/**
* Start execution of mixer output component
*/
static iks *start_mixer_output_component(struct rayo_actor *mixer, struct rayo_message *msg, void *data)
{
iks *iq = msg->payload;
struct rayo_component *component = NULL;
iks *output = iks_find(iq, "output");
iks *document = NULL;
switch_stream_handle_t stream = { 0 };
/* validate output attributes */
if (!VALIDATE_RAYO_OUTPUT(output)) {
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
}
/* check if <document> exists */
document = iks_find(output, "document");
if (!document) {
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
}
component = create_output_component(mixer, RAT_MIXER_COMPONENT, output, iks_find_attrib(iq, "from"));
if (!component) {
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create output entity");
}
/* build conference command */
SWITCH_STANDARD_STREAM(stream);
stream.write_function(&stream, "%s play ", rayo_mixer_get_name(RAYO_MIXER(mixer)), RAYO_ID(component));
stream.write_function(&stream, "{id=%s,pause=%s",
RAYO_JID(component),
OUTPUT_COMPONENT(component)->start_paused ? "true" : "false");
if (OUTPUT_COMPONENT(component)->max_time_ms > 0) {
stream.write_function(&stream, ",timeout=%i", OUTPUT_COMPONENT(component)->max_time_ms);
}
if (OUTPUT_COMPONENT(component)->start_offset_ms > 0) {
stream.write_function(&stream, ",start_offset_ms=%i", OUTPUT_COMPONENT(component)->start_offset_ms);
}
stream.write_function(&stream, "}fileman://rayo://%s", RAYO_JID(component));
/* acknowledge command */
rayo_component_send_start(component, iq);
rayo_component_api_execute_async(component, "conference", stream.data);
switch_safe_free(stream.data);
RAYO_RELEASE(component);
return NULL;
}
示例6: start_input
/**
* Start input component
*/
static void start_input(struct prompt_component *prompt, int start_timers, int barge_event)
{
iks *iq = iks_new("iq");
iks *input = iks_find(PROMPT_COMPONENT(prompt)->iq, "prompt");
input = iks_find(input, "input");
iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", RAYO_JID(RAYO_COMPONENT(prompt)->parent));
iks_insert_attrib_printf(iq, "id", "mod_rayo-prompt-%d", RAYO_SEQ_NEXT(prompt));
iks_insert_attrib(iq, "type", "set");
input = iks_copy_within(input, iks_stack(iq));
iks_insert_attrib(input, "start-timers", start_timers ? "true" : "false");
iks_insert_attrib(input, "barge-event", barge_event ? "true" : "false");
iks_insert_node(iq, input);
RAYO_SEND_MESSAGE(prompt, RAYO_JID(RAYO_COMPONENT(prompt)->parent), iq);
}
示例7: start_input_timers
/**
* Start input component timers
*/
static void start_input_timers(struct prompt_component *prompt)
{
iks *x;
iks *iq = iks_new("iq");
iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", prompt->input_jid);
iks_insert_attrib(iq, "type", "set");
iks_insert_attrib_printf(iq, "id", "mod_rayo-prompt-%d", RAYO_SEQ_NEXT(prompt));
x = iks_insert(iq, "start-timers");
iks_insert_attrib(x, "xmlns", RAYO_INPUT_NS);
RAYO_SEND_MESSAGE(prompt, prompt->input_jid, iq);
}
示例8: rayo_component_send_stop
/**
* Send stop to component
*/
static void rayo_component_send_stop(struct rayo_actor *from, const char *to)
{
iks *stop = iks_new("iq");
iks *x;
iks_insert_attrib(stop, "from", RAYO_JID(from));
iks_insert_attrib(stop, "to", to);
iks_insert_attrib(stop, "type", "set");
iks_insert_attrib_printf(stop, "id", "mod_rayo-prompt-%d", RAYO_SEQ_NEXT(from));
x = iks_insert(stop, "stop");
iks_insert_attrib(x, "xmlns", RAYO_EXT_NS);
RAYO_SEND_MESSAGE(from, to, stop);
}
示例9: iks_insert_attrib
/**
* Forward result
*/
static iks *prompt_component_handle_result(struct rayo_actor *prompt, struct rayo_message *msg, void *data)
{
iks *iq = msg->payload;
/* forward all results, except for internal ones... */
if (strncmp("mod_rayo-prompt", iks_find_attrib_soft(iq, "id"), 15)) {
iks_insert_attrib(iq, "from", RAYO_JID(prompt));
iks_insert_attrib(iq, "to", RAYO_COMPONENT(prompt)->client_jid);
RAYO_SEND_REPLY_DUP(prompt, RAYO_COMPONENT(prompt)->client_jid, iq);
}
return NULL;
}
示例10: rayo_cpa_detector_event
/**
* Forward CPA signal to client
*/
static void rayo_cpa_detector_event(const char *jid, void *user_data)
{
struct rayo_actor *component = RAYO_LOCATE(jid);
if (component) {
if (CPA_COMPONENT(component)->ready) {
switch_event_t *event = (switch_event_t *)user_data;
const char *signal_type = switch_event_get_header(event, "signal-type");
struct cpa_signal *cpa_signal = switch_core_hash_find(CPA_COMPONENT(component)->signals, signal_type);
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_COMPONENT(component)->parent->id), SWITCH_LOG_DEBUG, "Handling CPA event\n");
if (cpa_signal) {
const char *value = switch_event_get_header(event, "value");
const char *duration = switch_event_get_header(event, "duration");
if (cpa_signal->terminate) {
iks *complete_event;
iks *signal_xml;
stop_cpa_detectors(CPA_COMPONENT(component));
/* send complete event to client */
complete_event = rayo_component_create_complete_event(RAYO_COMPONENT(component), "signal", RAYO_CPA_NS);
signal_xml = iks_find(complete_event, "complete");
signal_xml = iks_find(signal_xml, "signal");
iks_insert_attrib(signal_xml, "type", signal_type);
if (!zstr(value)) {
iks_insert_attrib(signal_xml, "value", value);
}
if (!zstr(duration)) {
iks_insert_attrib(signal_xml, "duration", duration);
}
rayo_component_send_complete_event(RAYO_COMPONENT(component), complete_event);
} else {
/* send event to client */
iks *signal_event = iks_new_presence("signal", RAYO_CPA_NS, RAYO_JID(component), RAYO_COMPONENT(component)->client_jid);
iks *signal_xml = iks_find(signal_event, "signal");
iks_insert_attrib(signal_xml, "type", signal_type);
if (!zstr(value)) {
iks_insert_attrib(signal_xml, "value", value);
}
if (!zstr(duration)) {
iks_insert_attrib(signal_xml, "duration", duration);
}
RAYO_SEND_REPLY(component, RAYO_COMPONENT(component)->client_jid, signal_event);
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(RAYO_COMPONENT(component)->parent->id), SWITCH_LOG_DEBUG, "Skipping CPA event\n");
}
RAYO_UNLOCK(component);
}
}
示例11: stop_cpa_detectors
/**
* Stop all CPA detectors
*/
static void stop_cpa_detectors(struct cpa_component *cpa)
{
if (cpa->signals) {
switch_hash_index_t *hi = NULL;
for (hi = switch_core_hash_first(cpa->signals); hi; hi = switch_core_hash_next(hi)) {
const void *signal_type;
void *cpa_signal = NULL;
switch_core_hash_this(hi, &signal_type, NULL, &cpa_signal);
if (cpa_signal) {
rayo_cpa_detector_stop(RAYO_COMPONENT(cpa)->parent->id, ((struct cpa_signal *)cpa_signal)->name);
unsubscribe(RAYO_COMPONENT(cpa)->parent->id, ((struct cpa_signal *)cpa_signal)->name, RAYO_JID(cpa));
}
}
switch_core_hash_destroy(&cpa->signals);
cpa->signals = NULL;
}
unsubscribe(RAYO_COMPONENT(cpa)->parent->id, "hangup", RAYO_JID(cpa));
}
示例12: iks_find
/**
* Start execution of call receivefax component
* @param call the call to receive fax from
* @param msg the original request
* @param session_data the call's session
*/
static iks *start_receivefax_component(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data;
struct receivefax_component *receivefax_component = NULL;
iks *receivefax = iks_find(iq, "receivefax");
iks *response = NULL;
switch_event_t *execute_event = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_memory_pool_t *pool;
int file_no;
/* validate attributes */
if (!VALIDATE_RAYO_RECEIVEFAX(receivefax)) {
return iks_new_error(iq, STANZA_ERROR_BAD_REQUEST);
}
/* fax is only allowed if the call is not currently joined */
if (rayo_call_is_joined(RAYO_CALL(call))) {
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "can't receive fax on a joined call");
}
if (rayo_call_is_faxing(RAYO_CALL(call))) {
return iks_new_error_detailed(iq, STANZA_ERROR_UNEXPECTED_REQUEST, "fax already in progress");
}
/* create receivefax component */
switch_core_new_memory_pool(&pool);
receivefax_component = switch_core_alloc(pool, sizeof(*receivefax_component));
rayo_component_init((struct rayo_component *)receivefax_component, pool, RAT_CALL_COMPONENT, "receivefax", NULL, call, iks_find_attrib(iq, "from"));
file_no = rayo_actor_seq_next(call);
receivefax_component->filename = switch_core_sprintf(pool, "%s%s%s-%d.tif",
globals.file_prefix, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no);
if (!strncmp(receivefax_component->filename, "http://", 7) || !strncmp(receivefax_component->filename, "https://", 8)) {
/* This is an HTTP URL, need to PUT after fax is received */
receivefax_component->local_filename = switch_core_sprintf(pool, "%s%s%s-%d",
SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, switch_core_session_get_uuid(session), file_no);
receivefax_component->http_put_after_receive = 1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to HTTP URL\n", RAYO_JID(receivefax_component));
} else {
/* assume file.. */
receivefax_component->local_filename = receivefax_component->filename;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s save fax to local file\n", RAYO_JID(receivefax_component));
}
/* add channel variable so that fax component can be located from fax events */
switch_channel_set_variable(channel, "rayo_fax_jid", RAYO_JID(receivefax_component));
/* clear fax result variables */
switch_channel_set_variable(channel, "fax_success", NULL);
switch_channel_set_variable(channel, "fax_result_code", NULL);
switch_channel_set_variable(channel, "fax_result_text", NULL);
switch_channel_set_variable(channel, "fax_document_transferred_pages", NULL);
switch_channel_set_variable(channel, "fax_document_total_pages", NULL);
switch_channel_set_variable(channel, "fax_image_resolution", NULL);
switch_channel_set_variable(channel, "fax_image_size", NULL);
switch_channel_set_variable(channel, "fax_bad_rows", NULL);
switch_channel_set_variable(channel, "fax_transfer_rate", NULL);
switch_channel_set_variable(channel, "fax_ecm_used", NULL);
switch_channel_set_variable(channel, "fax_local_station_id", NULL);
switch_channel_set_variable(channel, "fax_remote_station_id", NULL);
/* clear fax interrupt variable */
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
rayo_call_set_faxing(RAYO_CALL(call), 1);
/* execute rxfax APP */
if (switch_event_create(&execute_event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "call-command", "execute");
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-name", "rxfax");
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", receivefax_component->local_filename);
if (!switch_channel_test_flag(channel, CF_PROXY_MODE)) {
switch_channel_set_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
}
if (switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to rxfax (queue event failed)");
if (execute_event) {
switch_event_destroy(&execute_event);
}
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
} else {
/* component starting... */
rayo_component_send_start(RAYO_COMPONENT(receivefax_component), iq);
}
} else {
response = iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "failed to create rxfax event");
rayo_call_set_faxing(RAYO_CALL(call), 0);
RAYO_UNLOCK(receivefax_component);
}
return response;
//.........这里部分代码省略.........
示例13: on_execute_complete_event
/**
* Handle fax completion event from FreeSWITCH core
* @param event received from FreeSWITCH core. It will be destroyed by the core after this function returns.
*/
static void on_execute_complete_event(switch_event_t *event)
{
const char *application = switch_event_get_header(event, "Application");
if (!zstr(application) && (!strcmp(application, "rxfax") || !strcmp(application, "txfax"))) {
int is_rxfax = !strcmp(application, "rxfax");
const char *uuid = switch_event_get_header(event, "Unique-ID");
const char *fax_jid = switch_event_get_header(event, "variable_rayo_fax_jid");
struct rayo_actor *component;
if (!zstr(fax_jid) && (component = RAYO_LOCATE(fax_jid))) {
iks *result;
iks *complete;
iks *fax;
int have_fax_document = 1;
switch_core_session_t *session;
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Got result for %s\n", fax_jid);
/* clean up channel */
session = switch_core_session_locate(uuid);
if (session) {
switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_read_frame_interrupt", NULL);
switch_core_session_rwunlock(session);
}
/* RX only: transfer HTTP document and delete local copy */
if (is_rxfax && RECEIVEFAX_COMPONENT(component)->http_put_after_receive && switch_file_exists(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component)) == SWITCH_STATUS_SUCCESS) {
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename);
switch_api_execute("http_put", RECEIVEFAX_COMPONENT(component)->filename, NULL, &stream);
/* check if successful */
if (!zstr(stream.data) && strncmp(stream.data, "+OK", 3)) {
/* PUT failed */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s PUT fax to %s failed: %s\n", RAYO_JID(component), RECEIVEFAX_COMPONENT(component)->filename, (char *)stream.data);
have_fax_document = 0;
}
switch_safe_free(stream.data)
switch_file_remove(RECEIVEFAX_COMPONENT(component)->local_filename, RAYO_POOL(component));
}
/* successful fax? */
if (have_fax_document && switch_true(switch_event_get_header(event, "variable_fax_success"))) {
result = rayo_component_create_complete_event(RAYO_COMPONENT(component), FAX_FINISH);
} else if (have_fax_document && FAX_COMPONENT(component)->stop) {
result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_STOP);
} else {
result = rayo_component_create_complete_event(RAYO_COMPONENT(component), COMPONENT_COMPLETE_ERROR);
}
complete = iks_find(result, "complete");
/* RX only: add fax document information */
if (is_rxfax && have_fax_document) {
const char *pages = switch_event_get_header(event, "variable_fax_document_transferred_pages");
if (!zstr(pages) && switch_is_number(pages) && atoi(pages) > 0) {
const char *resolution = switch_event_get_header(event, "variable_fax_file_image_resolution");
const char *size = switch_event_get_header(event, "variable_fax_image_size");
fax = iks_insert(complete, "fax");
iks_insert_attrib(fax, "xmlns", RAYO_FAX_COMPLETE_NS);
if (RECEIVEFAX_COMPONENT(component)->http_put_after_receive) {
iks_insert_attrib(fax, "url", RECEIVEFAX_COMPONENT(component)->filename);
} else {
/* convert absolute path to file:// URI */
iks_insert_attrib_printf(fax, "url", "file://%s", RECEIVEFAX_COMPONENT(component)->filename);
}
if (!zstr(resolution)) {
iks_insert_attrib(fax, "resolution", resolution);
}
if (!zstr(size)) {
iks_insert_attrib(fax, "size", size);
}
iks_insert_attrib(fax, "pages", pages);
}
}
/* add metadata from event */
insert_fax_metadata(event, "fax_success", complete);
insert_fax_metadata(event, "fax_result_code", complete);
insert_fax_metadata(event, "fax_result_text", complete);
insert_fax_metadata(event, "fax_document_transferred_pages", complete);
insert_fax_metadata(event, "fax_document_total_pages", complete);
insert_fax_metadata(event, "fax_image_resolution", complete);
insert_fax_metadata(event, "fax_image_size", complete);
insert_fax_metadata(event, "fax_bad_rows", complete);
insert_fax_metadata(event, "fax_transfer_rate", complete);
insert_fax_metadata(event, "fax_ecm_used", complete);
insert_fax_metadata(event, "fax_local_station_id", complete);
insert_fax_metadata(event, "fax_remote_station_id", complete);
/* flag faxing as done */
rayo_call_set_faxing(RAYO_CALL(RAYO_COMPONENT(component)->parent), 0);
rayo_component_send_complete_event(RAYO_COMPONENT(component), result);
//.........这里部分代码省略.........
示例14: iks_find
/**
* Start CPA
*/
iks *rayo_cpa_component_start(struct rayo_actor *call, struct rayo_message *msg, void *session_data)
{
iks *iq = msg->payload;
switch_core_session_t *session = (switch_core_session_t *)session_data;
iks *input = iks_find(iq, "input");
switch_memory_pool_t *pool = NULL;
struct cpa_component *component = NULL;
int have_grammar = 0;
iks *grammar = NULL;
/* create CPA component */
switch_core_new_memory_pool(&pool);
component = switch_core_alloc(pool, sizeof(*component));
component = CPA_COMPONENT(rayo_component_init((struct rayo_component *)component, pool, RAT_CALL_COMPONENT, "cpa", NULL, call, iks_find_attrib(iq, "from")));
if (!component) {
switch_core_destroy_memory_pool(&pool);
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, "Failed to create CPA entity");
}
switch_core_hash_init(&component->signals);
/* start CPA detectors */
for (grammar = iks_find(input, "grammar"); grammar; grammar = iks_next_tag(grammar)) {
if (!strcmp("grammar", iks_name(grammar))) {
const char *error_str = "";
const char *url = iks_find_attrib_soft(grammar, "url");
char *url_dup;
char *url_params;
if (zstr(url)) {
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Missing grammar URL");
}
have_grammar = 1;
url_dup = strdup(url);
if ((url_params = strchr(url_dup, '?'))) {
*url_params = '\0';
url_params++;
}
if (switch_core_hash_find(component->signals, url)) {
free(url_dup);
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "Duplicate URL");
}
/* start detector */
/* TODO return better reasons... */
if (rayo_cpa_detector_start(switch_core_session_get_uuid(session), url_dup, &error_str)) {
struct cpa_signal *cpa_signal = switch_core_alloc(pool, sizeof(*cpa_signal));
cpa_signal->terminate = !zstr(url_params) && strstr(url_params, "terminate=true");
cpa_signal->name = switch_core_strdup(pool, url_dup);
switch_core_hash_insert(component->signals, cpa_signal->name, cpa_signal);
subscribe(switch_core_session_get_uuid(session), cpa_signal->name, RAYO_JID(component));
} else {
free(url_dup);
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_INTERNAL_SERVER_ERROR, error_str);
}
free(url_dup);
}
}
if (!have_grammar) {
stop_cpa_detectors(component);
RAYO_UNLOCK(component);
RAYO_DESTROY(component);
return iks_new_error_detailed(iq, STANZA_ERROR_BAD_REQUEST, "No grammar defined");
}
/* acknowledge command */
rayo_component_send_start(RAYO_COMPONENT(component), iq);
/* TODO hangup race condition */
subscribe(switch_core_session_get_uuid(session), "hangup", RAYO_JID(component));
/* ready to forward detector events */
component->ready = 1;
return NULL;
}