SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(_In_ switch_core_session_t *session,
_In_ const char *app, _In_opt_z_ const char *arg, _Out_opt_ int32_t *flags);
+SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg);
+
SWITCH_DECLARE(switch_status_t) switch_core_session_get_app_flags(const char *app, int32_t *flags);
/*!
if ((arg = strchr(app, ' '))) {
*arg++ = '\0';
}
- switch_core_session_execute_application(channel->session, app, arg);
+
+ if (switch_core_session_in_thread(channel->session)) {
+ switch_core_session_execute_application(channel->session, app, arg);
+ } else {
+ switch_core_session_execute_application_async(channel->session, app, arg);
+ }
}
return SWITCH_STATUS_SUCCESS;
if ((arg = strchr(app, ' '))) {
*arg++ = '\0';
}
- switch_core_session_execute_application(channel->session, app, arg);
+
+ if (switch_core_session_in_thread(channel->session)) {
+ switch_core_session_execute_application(channel->session, app, arg);
+ } else {
+ switch_core_session_execute_application_async(channel->session, app, arg);
+ }
}
if ((var = switch_channel_get_variable(channel, SWITCH_PASSTHRU_PTIME_MISMATCH_VARIABLE))) {
}
switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s execute on answer: %s(%s)\n", channel->name, app,
switch_str_nil(arg));
- switch_core_session_execute_application(channel->session, app, arg);
+
+ if (switch_core_session_in_thread(channel->session)) {
+ switch_core_session_execute_application(channel->session, app, arg);
+ } else {
+ switch_core_session_execute_application_async(channel->session, app, arg);
+ }
}
}
if (switch_queue_trypush(session->event_queue, *event) == SWITCH_STATUS_SUCCESS) {
*event = NULL;
status = SWITCH_STATUS_SUCCESS;
+
+ if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_test_flag(session->channel, CF_THREAD_SLEEPING)) {
+ switch_core_session_wake_session_thread(session);
+ }
}
}
}
+SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(switch_core_session_t *session, const char *app, const char *arg)
+{
+ switch_event_t *execute_event;
+
+ 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", app);
+
+ if (arg) {
+ switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
+ }
+
+ switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
+ switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ return SWITCH_STATUS_FALSE;
+}
+
+
SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(switch_core_session_t *session, const char *app,
const char *arg, int32_t *flags)
{
if (read_frame_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a)) {
if (exec_app) {
- switch_event_t *execute_event;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "%s Bridge execute app %s(%s)\n",
switch_channel_get_name(chan_a), exec_app, exec_data);
- 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", exec_app);
- if (exec_data) {
- switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", exec_data);
- }
- //switch_event_add_header(execute_event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
- switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
- switch_core_session_queue_private_event(session_a, &execute_event, SWITCH_FALSE);
- }
+ switch_core_session_execute_application_async(session_a, exec_app, exec_data);
exec_app = exec_data = NULL;
}