Skip to content

Commit

Permalink
[core] Update switch_ivr_record_session_event() to check event vars f…
Browse files Browse the repository at this point in the history
…or RECORD_STEREO, etc
  • Loading branch information
crienzo authored and andywolk committed Oct 23, 2021
1 parent a7fa9bf commit 60faf1a
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 62 deletions.
1 change: 1 addition & 0 deletions src/include/switch_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
/** @} */

SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix);
SWITCH_DECLARE(switch_status_t) switch_channel_execute_on_value(switch_channel_t *channel, const char *variable_value);
SWITCH_DECLARE(switch_status_t) switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix);
SWITCH_DECLARE(void) switch_channel_process_device_hangup(switch_channel_t *channel);
SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_queued_extension(switch_channel_t *channel);
Expand Down
1 change: 1 addition & 0 deletions src/include/test/switch_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char
switch_channel_set_variable(fst_channel, "send_silence_when_idle", "-1"); \
switch_channel_set_variable(fst_channel, "RECORD_STEREO", "true"); \
switch_ivr_record_session(fst_session, (char *)"/tmp/"#name".wav", 0, NULL); \
switch_channel_set_variable(fst_channel, "RECORD_STEREO", NULL); \
for(;;) {

/**
Expand Down
15 changes: 9 additions & 6 deletions src/switch_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3759,15 +3759,16 @@ SWITCH_DECLARE(switch_status_t) switch_channel_api_on(switch_channel_t *channel,
return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
}

static void do_execute_on(switch_channel_t *channel, const char *variable)
SWITCH_DECLARE(switch_status_t) switch_channel_execute_on_value(switch_channel_t *channel, const char *variable_value)
{
switch_status_t status;
char *arg = NULL;
char *p;
int bg = 0;
char *app;
char *expanded = NULL;

app = switch_core_session_strdup(channel->session, variable);
app = switch_core_session_strdup(channel->session, variable_value);

for(p = app; p && *p; p++) {
if (*p == ' ' || (*p == ':' && (*(p+1) != ':'))) {
Expand All @@ -3792,14 +3793,16 @@ static void do_execute_on(switch_channel_t *channel, const char *variable)
}

if (bg) {
switch_core_session_execute_application_async(channel->session, app, arg);
status = switch_core_session_execute_application_async(channel->session, app, arg);
} else {
switch_core_session_execute_application(channel->session, app, arg);
status = switch_core_session_execute_application(channel->session, app, arg);
}

if (expanded && expanded != arg) {
free(expanded);
}

return status;
}

SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
Expand All @@ -3821,11 +3824,11 @@ SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *chan
int i;
for (i = 0; i < hp->idx; i++) {
x++;
do_execute_on(channel, hp->array[i]);
switch_channel_execute_on_value(channel, hp->array[i]);
}
} else {
x++;
do_execute_on(channel, val);
switch_channel_execute_on_value(channel, val);
}
}
}
Expand Down
Loading

0 comments on commit 60faf1a

Please sign in to comment.