forked from Mirrors/freeswitch
update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5465 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4c98a5d5ea
commit
fdf9a8f052
|
@ -23,7 +23,7 @@ $o = $fs->call_command("answer");
|
|||
#to turn on events when in async mode
|
||||
$o = $fs->raw_command("myevents");
|
||||
$o = $fs->call_command("playback", "/ram/swimp.raw");
|
||||
$o = $fs->call_command("hangup");
|
||||
|
||||
|
||||
#comment exit in async mode
|
||||
#exit;
|
||||
|
@ -36,7 +36,11 @@ while(my $r = $fs->readhash(undef)) {
|
|||
if ($r->{has_event}) {
|
||||
print Dumper $r->{event};
|
||||
}
|
||||
|
||||
if ($r->{event}->{'event-name'} !~ /execute/i) {
|
||||
printf "wtf $data->{'unique-id'}\n";
|
||||
$o = $fs->call_command("break");
|
||||
$o = $fs->call_command("hangup");
|
||||
}
|
||||
}
|
||||
|
||||
$fs->disconnect();
|
||||
|
|
|
@ -573,6 +573,7 @@ CF_BREAK = (1 << 19) - Channel should stop what it's doing
|
|||
CF_BROADCAST = (1 << 20) - Channel is broadcasting
|
||||
CF_UNICAST = (1 << 21) - Channel has a unicast connection
|
||||
CF_VIDEO = (1 << 22) - Channel has video
|
||||
CF_EVENT_LOCK = (1 << 23) - Don't parse events
|
||||
</pre>
|
||||
*/
|
||||
|
||||
|
@ -599,7 +600,8 @@ typedef enum {
|
|||
CF_BREAK = (1 << 19),
|
||||
CF_BROADCAST = (1 << 20),
|
||||
CF_UNICAST = (1 << 21),
|
||||
CF_VIDEO = (1 << 22)
|
||||
CF_VIDEO = (1 << 22),
|
||||
CF_EVENT_LOCK = (1 << 23)
|
||||
} switch_channel_flag_t;
|
||||
|
||||
|
||||
|
|
|
@ -94,6 +94,14 @@ SWITCH_STANDARD_APP(ring_ready_function)
|
|||
switch_channel_ring_ready(channel);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(break_function)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
switch_channel_set_flag(channel, CF_BREAK);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_APP(queue_dtmf_function)
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
|
@ -1134,6 +1142,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
|||
SWITCH_ADD_APP(app_interface, "set", "Set a channel varaible", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "unset", "Unset a channel varaible", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
|
||||
SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>", SAF_SUPPORT_NOMEDIA);
|
||||
|
|
|
@ -513,11 +513,6 @@ SWITCH_DECLARE(uint8_t) switch_channel_ready(switch_channel_t *channel)
|
|||
ret++;
|
||||
}
|
||||
|
||||
if (switch_test_flag(channel, CF_BREAK)) {
|
||||
switch_clear_flag_locked(channel, CF_BREAK);
|
||||
ret = (uint8_t) 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -567,11 +567,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch
|
|||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_EVENT_PARSE)) {
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
if (session->private_event_queue) {
|
||||
if ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
|
||||
*event = (switch_event_t *) pop;
|
||||
|
@ -913,6 +913,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
|||
const switch_application_interface_t *application_interface, char *arg) {
|
||||
switch_app_log_t *log, *lp;
|
||||
switch_event_t *event;
|
||||
switch_channel_t *channel;
|
||||
|
||||
log = switch_core_session_alloc(session, sizeof(*log));
|
||||
|
||||
|
@ -932,10 +933,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
|||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_channel_event_set_data(session->channel, event);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "%s", application_interface->interface_name);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", "%s", arg);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", arg);
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
application_interface->application_function(session, arg);
|
||||
|
||||
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
|
||||
|
|
|
@ -684,7 +684,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, ch
|
|||
}
|
||||
}
|
||||
|
||||
snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, encode_buf);
|
||||
snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, switch_strlen_zero(encode_buf) ? "_undef_" : encode_buf);
|
||||
len = strlen(buf);
|
||||
|
||||
}
|
||||
|
|
|
@ -272,7 +272,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
|||
unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
|
||||
unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
|
||||
char *lead_frames = switch_event_get_header(event, "lead-frames");
|
||||
|
||||
char *event_lock = switch_event_get_header(event, "event-lock");
|
||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||
|
||||
assert(channel != NULL);
|
||||
assert(event != NULL);
|
||||
|
||||
|
@ -286,15 +288,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
|||
|
||||
switch_channel_set_flag(channel, CF_EVENT_PARSE);
|
||||
|
||||
if (switch_true(event_lock)) {
|
||||
switch_channel_set_flag(channel, CF_EVENT_LOCK);
|
||||
}
|
||||
|
||||
|
||||
if (lead_frames) {
|
||||
switch_frame_t *read_frame;
|
||||
int frame_count = atoi(lead_frames);
|
||||
switch_status_t status;
|
||||
|
||||
while(frame_count > 0) {
|
||||
status = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
return status;
|
||||
goto done;
|
||||
}
|
||||
if (!switch_test_flag(read_frame, SFF_CNG)) {
|
||||
frame_count--;
|
||||
|
@ -308,12 +314,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
|||
char *app_arg = switch_event_get_header(event, "execute-app-arg");
|
||||
char *loop_h = switch_event_get_header(event, "loops");
|
||||
int loops = 1;
|
||||
|
||||
|
||||
if (loop_h) {
|
||||
loops = atoi(loop_h);
|
||||
}
|
||||
|
||||
if (app_name && app_arg) {
|
||||
|
||||
if (app_name) {
|
||||
if ((application_interface = switch_loadable_module_get_application_interface(app_name))) {
|
||||
if (application_interface->application_function) {
|
||||
int x;
|
||||
|
@ -368,9 +374,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
|||
switch_ivr_nomedia(uuid, SMF_REBRIDGE);
|
||||
}
|
||||
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
||||
done:
|
||||
switch_channel_clear_flag(channel, CF_EVENT_PARSE);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
switch_channel_clear_flag(channel, CF_EVENT_LOCK);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
|
@ -906,6 +916,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
|
|||
|
||||
switch_channel_set_caller_profile(channel, new_profile);
|
||||
switch_channel_set_flag(channel, CF_TRANSFER);
|
||||
|
||||
switch_channel_set_state(channel, CS_RING);
|
||||
|
||||
msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSFER;
|
||||
|
|
|
@ -1179,6 +1179,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
|
||||
if ((flags & SMF_LOOP)) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
|
||||
}
|
||||
|
@ -1197,6 +1198,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "%s", app);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", path);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
|
||||
if ((flags & SMF_LOOP)) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
|
||||
}
|
||||
|
@ -1209,6 +1211,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
|
|||
if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "nomedia");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "nomedia-uuid", "%s", uuid);
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
|
||||
switch_core_session_queue_private_event(master, &event);
|
||||
}
|
||||
}
|
||||
|
@ -1218,7 +1221,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_broadcast(char *uuid, char *path, swi
|
|||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "call-command", "execute");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-name", "hangup");
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "execute-app-arg", "%s", cause);
|
||||
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event-lock", "%s", "true");
|
||||
switch_core_session_queue_private_event(session, &event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,6 +274,7 @@ static switch_status_t uuid_bridge_on_transmit(switch_core_session_t *session)
|
|||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
|
||||
switch_channel_clear_state_handler(channel, NULL);
|
||||
|
||||
switch_channel_set_flag(channel, CF_BREAK);
|
||||
|
||||
if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -656,6 +657,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(char *originator_uuid, ch
|
|||
switch_channel_set_flag(originatee_channel, CF_TAGGED);
|
||||
switch_channel_set_private(originator_channel, SWITCH_UUID_BRIDGE, originatee_session);
|
||||
|
||||
switch_channel_set_flag(originator_channel, CF_BREAK);
|
||||
switch_channel_set_flag(originatee_channel, CF_BREAK);
|
||||
|
||||
/* switch_channel_set_state_flag sets flags you want to be set when the next state change happens */
|
||||
switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
|
||||
switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);
|
||||
|
|
|
@ -395,6 +395,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
|
|||
while (switch_channel_ready(channel)) {
|
||||
switch_size_t len;
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_core_session_private_event_count(session)) {
|
||||
switch_ivr_parse_all_events(session);
|
||||
}
|
||||
|
@ -537,6 +542,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
|
|||
while(switch_channel_ready(channel)) {
|
||||
switch_status_t status = switch_core_session_read_frame(session, &read_frame, 1000, 0);
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||
break;
|
||||
}
|
||||
|
@ -782,6 +792,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
int do_speed = 1;
|
||||
int last_speed = -1;
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_core_session_private_event_count(session)) {
|
||||
switch_ivr_parse_all_events(session);
|
||||
}
|
||||
|
@ -1150,6 +1165,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text_handle(switch_core_session
|
|||
while (switch_channel_ready(channel)) {
|
||||
switch_event_t *event;
|
||||
|
||||
if (switch_channel_test_flag(channel, CF_BREAK)) {
|
||||
switch_channel_clear_flag(channel, CF_BREAK);
|
||||
break;
|
||||
}
|
||||
|
||||
if (switch_core_session_dequeue_private_event(session, &event) == SWITCH_STATUS_SUCCESS) {
|
||||
switch_ivr_parse_event(session, event);
|
||||
switch_event_destroy(&event);
|
||||
|
|
Loading…
Reference in New Issue