#define RAYO_CAUSE_BUSY SWITCH_CAUSE_USER_BUSY
#define RAYO_CAUSE_ERROR SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE
-#define RAYO_END_REASON_HANGUP "hangup"
-#define RAYO_END_REASON_ERROR "error"
-#define RAYO_END_REASON_BUSY "busy"
-#define RAYO_END_REASON_REJECT "reject"
+#define RAYO_END_REASON_HANGUP "hungup"
+#define RAYO_END_REASON_HANGUP_LOCAL "hangup-command"
#define RAYO_END_REASON_TIMEOUT "timeout"
+#define RAYO_END_REASON_BUSY "busy"
+#define RAYO_END_REASON_REJECT "rejected"
+#define RAYO_END_REASON_ERROR "error"
#define RAYO_SIP_REQUEST_HEADER "sip_r_"
#define RAYO_SIP_RESPONSE_HEADER "sip_rh_"
{
struct rayo_call *call = RAYO_CALL(actor);
switch_event_t *event = call->end_event;
- char *cause_str;
- switch_call_cause_t cause = SWITCH_CAUSE_NONE;
int no_offered_clients = 1;
switch_hash_index_t *hi = NULL;
iks *revent;
return;
}
- cause_str = switch_event_get_header(event, "variable_hangup_cause");
revent = iks_new_presence("end", RAYO_NS,
RAYO_JID(call),
rayo_call_get_dcp_jid(call));
iks_insert_attrib(revent, "type", "unavailable");
end = iks_find(revent, "end");
- if (cause_str) {
- cause = switch_channel_str2cause(cause_str);
+ if (switch_true(switch_event_get_header(event, "variable_rayo_local_hangup"))) {
+ iks_insert(end, RAYO_END_REASON_HANGUP_LOCAL);
+ } else {
+ /* remote hangup... translate to specific rayo reason */
+ switch_call_cause_t cause = SWITCH_CAUSE_NONE;
+ char *cause_str = switch_event_get_header(event, "variable_hangup_cause");
+ if (cause_str) {
+ cause = switch_channel_str2cause(cause_str);
+ }
+ iks_insert(end, switch_cause_to_rayo_cause(cause));
}
- iks_insert(end, switch_cause_to_rayo_cause(cause));
#if 0
{
/* do hangup */
if (!response) {
+ switch_channel_set_variable(switch_core_session_get_channel(session), "rayo_local_hangup", "true");
add_signaling_headers(session, hangup, RAYO_SIP_REQUEST_HEADER);
add_signaling_headers(session, hangup, RAYO_SIP_RESPONSE_HEADER);
switch_ivr_kill_uuid(rayo_call_get_uuid(call), hangup_cause);
} else {
RAYO_UNLOCK(b_call);
- /* bridge this call to call-id */
+ /* bridge this call to call-uri */
switch_channel_set_variable(switch_core_session_get_channel(session), "bypass_media", bypass);
if (switch_false(bypass)) {
switch_channel_pre_answer(switch_core_session_get_channel(session));
goto done;
}
mixer_name = iks_find_attrib(join, "mixer-name");
- call_id = iks_find_attrib(join, "call-id");
+ call_id = iks_find_attrib(join, "call-uri");
/* can't join both mixer and call */
if (!zstr(mixer_name) && !zstr(call_id)) {
- response = iks_new_error_detailed(node, STANZA_ERROR_BAD_REQUEST, "mixer-name and call-id are mutually exclusive");
+ response = iks_new_error_detailed(node, STANZA_ERROR_BAD_REQUEST, "mixer-name and call-uri are mutually exclusive");
goto done;
}
/* need to join *something* */
if (zstr(mixer_name) && zstr(call_id)) {
- response = iks_new_error_detailed(node, STANZA_ERROR_BAD_REQUEST, "mixer-name or call-id is required");
+ response = iks_new_error_detailed(node, STANZA_ERROR_BAD_REQUEST, "mixer-name or call-uri is required");
goto done;
}
switch_core_session_t *session = (switch_core_session_t *)session_data;
iks *response = NULL;
iks *unjoin = iks_find(node, "unjoin");
- const char *call_id = iks_find_attrib(unjoin, "call-id");
+ const char *call_id = iks_find_attrib(unjoin, "call-uri");
const char *mixer_name = iks_find_attrib(unjoin, "mixer-name");
if (!zstr(call_id) && !zstr(mixer_name)) {
if (join) {
/* check join args */
- const char *call_id = iks_find_attrib(join, "call-id");
+ const char *call_id = iks_find_attrib(join, "call-uri");
const char *mixer_name = iks_find_attrib(join, "mixer-name");
if (!zstr(call_id) && !zstr(mixer_name)) {
/* broadcast member unjoined event to subscribers */
delete_member_event = iks_new_presence("unjoined", RAYO_NS, RAYO_JID(mixer), "");
x = iks_find(delete_member_event, "unjoined");
- iks_insert_attrib(x, "call-id", uuid);
+ iks_insert_attrib(x, "call-uri", uuid);
broadcast_mixer_event(mixer, delete_member_event);
iks_delete(delete_member_event);
/* broadcast member joined event to subscribers */
add_member_event = iks_new_presence("joined", RAYO_NS, RAYO_JID(mixer), "");
x = iks_find(add_member_event, "joined");
- iks_insert_attrib(x, "call-id", uuid);
+ iks_insert_attrib(x, "call-uri", uuid);
broadcast_mixer_event(mixer, add_member_event);
iks_delete(add_member_event);
}
iks_insert_attrib(response, "type", "result");
ref = iks_insert(response, "ref");
iks_insert_attrib(ref, "xmlns", RAYO_NS);
- iks_insert_attrib(ref, "id", uuid);
- iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(call));
+
+#ifdef RAYO_UUID_IN_REF_URI
+ iks_insert_attrib(ref, "uri", uuid);
+#else
+ iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(call));
+#endif
RAYO_SEND(call, rclient, rayo_message_create(response));
call->dial_id = NULL;
}
switch_event_get_header(event, "variable_rayo_call_jid"),
switch_event_get_header(event, "variable_rayo_dcp_jid"));
iks *joined = iks_find(revent, "joined");
- iks_insert_attrib(joined, "call-id", b_uuid);
+ iks_insert_attrib(joined, "call-uri", b_uuid);
call->joined = 1;
if (b_call) {
revent = iks_new_presence("joined", RAYO_NS, RAYO_JID(b_call), rayo_call_get_dcp_jid(b_call));
joined = iks_find(revent, "joined");
- iks_insert_attrib(joined, "call-id", a_uuid);
+ iks_insert_attrib(joined, "call-uri", a_uuid);
b_call->joined = 1;
switch_event_get_header(event, "variable_rayo_call_jid"),
switch_event_get_header(event, "variable_rayo_dcp_jid"));
iks *joined = iks_find(revent, "unjoined");
- iks_insert_attrib(joined, "call-id", b_uuid);
+ iks_insert_attrib(joined, "call-uri", b_uuid);
RAYO_SEND(call, rclient, rayo_message_create(revent));
call->joined = 0;
if (b_call) {
revent = iks_new_presence("unjoined", RAYO_NS, RAYO_JID(b_call), rayo_call_get_dcp_jid(b_call));
joined = iks_find(revent, "unjoined");
- iks_insert_attrib(joined, "call-id", a_uuid);
+ iks_insert_attrib(joined, "call-uri", a_uuid);
RAYO_SEND_BY_JID(b_call, rayo_call_get_dcp_jid(b_call), rayo_message_create(revent));
b_call->joined = 0;
#define RAYO_NS RAYO_BASE RAYO_VERSION
#define RAYO_CLIENT_NS RAYO_BASE "client:" RAYO_VERSION
+#define RAYO_CALL_NS RAYO_BASE "call:" RAYO_VERSION
+#define RAYO_MIXER_NS RAYO_BASE "mixer:" RAYO_VERSION
+
+/* this is to support punchblock.. undefine once punchblock is fixed */
+#define RAYO_UUID_IN_REF_URI
struct rayo_actor;
struct rayo_call;
iks *response = iks_new_iq_result(iq);
iks *ref = iks_insert(response, "ref");
iks_insert_attrib(ref, "xmlns", RAYO_NS);
- iks_insert_attrib(ref, "id", component->ref);
+#ifdef RAYO_UUID_IN_REF_URI
+ iks_insert_attrib(ref, "uri", component->ref);
+#else
iks_insert_attrib_printf(ref, "uri", "xmpp:%s", RAYO_JID(component));
+#endif
RAYO_SEND_BY_JID(component, iks_find_attrib(response, "to"), rayo_message_create(response));
}
* <input> component validation
*/
ELEMENT(RAYO_INPUT)
- STRING_ATTRIB(mode, any, "any,dtmf,speech");
+ STRING_ATTRIB(mode, any, "any,dtmf,voice")
ATTRIB(terminator,, any)
- ATTRIB(recognizer, en-US, any)
+ ATTRIB(recognizer,, any)
+ ATTRIB(language, en-US, any)
ATTRIB(initial-timeout, -1, positive_or_neg_one)
ATTRIB(inter-digit-timeout, -1, positive_or_neg_one)
ATTRIB(sensitivity, 0.5, decimal_between_zero_and_one)
ATTRIB(min-confidence, 0, decimal_between_zero_and_one)
ATTRIB(max-silence, -1, positive_or_neg_one)
+ /* for now, only NLSML */
+ STRING_ATTRIB(match-content-type, application/nlsml+xml, "application/nlsml+xml")
/* internal attribs for prompt support */
ATTRIB(barge-event, false, bool)
ATTRIB(start-timers, true, bool)
ATTRIB(start-offset, 0, not_negative)
ATTRIB(start-paused, false, bool)
ATTRIB(repeat-interval, 0, not_negative)
- ATTRIB(repeat-times, 1, positive)
+ ATTRIB(repeat-times, 1, not_negative)
ATTRIB(max-time, -1, positive_or_neg_one)
ATTRIB(renderer,, any)
+ ATTRIB(voice,, any)
ELEMENT_END
/**
* <output><seek> validation
*/
ELEMENT(RAYO_OUTPUT_SEEK)
- STRING_ATTRIB(direction,, "forward,back");
+ STRING_ATTRIB(direction,, "forward,back")
ATTRIB(amount,-1, positive)
ELEMENT_END
ATTRIB(max-duration, -1, positive_or_neg_one)
ATTRIB(initial-timeout, -1, positive_or_neg_one)
ATTRIB(final-timeout, -1, positive_or_neg_one)
- STRING_ATTRIB(direction, duplex, "duplex,send,recv");
+ STRING_ATTRIB(direction, duplex, "duplex,send,recv")
ATTRIB(mix, false, bool)
ELEMENT_END
STRING_ATTRIB(direction, duplex, "send,recv,duplex"); */
STRING_ATTRIB(direction, duplex, "duplex")
STRING_ATTRIB(media, bridge, "bridge,direct")
- ATTRIB(call-id,, any)
+ ATTRIB(call-uri,, any)
ATTRIB(mixer-name,, any)
ELEMENT_END
#define MAX_DTMF 64
-#define INPUT_INITIAL_TIMEOUT "initial-timeout", RAYO_INPUT_COMPLETE_NS
-#define INPUT_INTER_DIGIT_TIMEOUT "inter-digit-timeout", RAYO_INPUT_COMPLETE_NS
-#define INPUT_MAX_SILENCE "max-silence", RAYO_INPUT_COMPLETE_NS
-#define INPUT_MIN_CONFIDENCE "min-confidence", RAYO_INPUT_COMPLETE_NS
-#define INPUT_MATCH "match", RAYO_INPUT_COMPLETE_NS
+#define INPUT_MATCH_TAG "match"
+#define INPUT_MATCH INPUT_MATCH_TAG, RAYO_INPUT_COMPLETE_NS
+#define INPUT_NOINPUT "noinput", RAYO_INPUT_COMPLETE_NS
#define INPUT_NOMATCH "nomatch", RAYO_INPUT_COMPLETE_NS
#define RAYO_INPUT_COMPONENT_PRIVATE_VAR "__rayo_input_component"
return digit_mask;
}
+/**
+ * Send match event to client
+ */
+static void send_match_event(struct rayo_component *component, iks *result)
+{
+ iks *event = rayo_component_create_complete_event_with_metadata(RAYO_COMPONENT(component), INPUT_MATCH, result, 0);
+ /* add content-type to <match>... */
+ iks *match = iks_find(iks_find(event, "complete"), INPUT_MATCH_TAG);
+ iks_insert_attrib(match, "content-type", "application/nlsml+xml");
+ rayo_component_send_complete_event(component, event);
+}
+
/**
* Send barge-in event to client
*/
handler->component = NULL;
switch_core_media_bug_remove(session, &handler->bug);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits);
- rayo_component_send_complete_with_metadata(RAYO_COMPONENT(component), INPUT_MATCH, result, 0);
+ send_match_event(RAYO_COMPONENT(component), result);
iks_delete(result);
break;
}
iks *result = nlsml_create_dtmf_match(component->digits);
/* notify of match */
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "MATCH = %s\n", component->digits);
- rayo_component_send_complete_with_metadata(RAYO_COMPONENT(component), INPUT_MATCH, result, 0);
+ send_match_event(RAYO_COMPONENT(component), result);
iks_delete(result);
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "inter-digit-timeout\n");
- rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_INTER_DIGIT_TIMEOUT);
+ rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOMATCH);
}
} else if (!component->num_digits && component->initial_timeout > 0 && elapsed_ms > component->initial_timeout) {
handler->component = NULL;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "initial-timeout\n");
- rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_INITIAL_TIMEOUT);
+ rayo_component_send_complete(RAYO_COMPONENT(component), INPUT_NOINPUT);
}
}
switch_core_media_bug_set_read_replace_frame(bug, rframe);
component->min_confidence = (int)ceil(iks_find_decimal_attrib(input, "min-confidence") * 100.0);
component->barge_event = iks_find_bool_attrib(input, "barge-event");
component->start_timers = iks_find_bool_attrib(input, "start-timers");
+ /* TODO this should just be a single digit terminator? */
component->term_digit_mask = digit_mask_set_from_digits(0, iks_find_attrib_soft(input, "terminator"));
+ /* TODO recognizer ignored */
+ /* TODO language ignored */
component->handler = handler;
/* parse the grammar */
enum nlsml_match_type match_type = nlsml_parse(result, uuid);
switch (match_type) {
case NMT_NOINPUT:
- rayo_component_send_complete(component, INPUT_INITIAL_TIMEOUT);
+ rayo_component_send_complete(component, INPUT_NOINPUT);
break;
case NMT_MATCH: {
iks *result_xml = nlsml_normalize(result);
- rayo_component_send_complete_with_metadata(component, INPUT_MATCH, result_xml, 0);
+ send_match_event(RAYO_COMPONENT(component), result_xml);
iks_delete(result_xml);
break;
}
/* done? */
if (!context->cur_doc) {
- if (++context->play_count < output->repeat_times) {
+ if (output->repeat_times == 0 || ++context->play_count < output->repeat_times) {
/* repeat all document(s) */
if (!output->repeat_interval) {
goto top;