switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
}
+ if (!switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
+ switch_channel_set_flag(session->channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
+ }
+
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
switch_goto_status(SWITCH_STATUS_FALSE, done);
}
} else {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
- "Cannot execute app '%s' media required on an outbound channel that does not have media established\n", app);
- switch_goto_status(SWITCH_STATUS_FALSE, done);
+ uint32_t ready = 0, sanity = 2000;
+
+ do {
+ sanity--;
+ ready = switch_channel_media_ready(session->channel);
+ switch_cond_next();
+ } while(!ready && sanity);
+
+ if (!ready) {
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+ "Cannot execute app '%s' media required on an outbound channel that does not have media established\n", app);
+ switch_goto_status(SWITCH_STATUS_FALSE, done);
+ }
}
}
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
{
int x = 0;
-
+ switch_channel_t *channel;
switch_ivr_parse_all_messages(session);
- while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS)
+ channel = switch_core_session_get_channel(session);
+
+ if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA)) {
+ if (switch_channel_media_ready(channel)) {
+ switch_channel_clear_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
+ } else {
+ return SWITCH_STATUS_SUCCESS;
+ }
+ }
+
+ while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS) {
x++;
+ }
if (x) {
switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);