mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
add uuid_fileman <uuid> <cmd>:<val> <-- same vals as the callbacks in js and lua to control the currently playing file of a channel from the cli or ESL (for the people who were ignoring me on the conference call so I decided to implement it instead of try to explain it )
This commit is contained in:
118
src/switch_ivr.c
118
src/switch_ivr.c
@@ -2563,6 +2563,124 @@ SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_exists(const char *uuid)
|
||||
return exists;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
|
||||
{
|
||||
if (zstr(cmd)) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (fhp) {
|
||||
if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (!strncasecmp(cmd, "speed", 5)) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(cmd, ':'))) {
|
||||
p++;
|
||||
if (*p == '+' || *p == '-') {
|
||||
int step;
|
||||
if (!(step = atoi(p))) {
|
||||
step = 1;
|
||||
}
|
||||
fhp->speed += step;
|
||||
} else {
|
||||
int speed = atoi(p);
|
||||
fhp->speed = speed;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
} else if (!strncasecmp(cmd, "volume", 6)) {
|
||||
char *p;
|
||||
|
||||
if ((p = strchr(cmd, ':'))) {
|
||||
p++;
|
||||
if (*p == '+' || *p == '-') {
|
||||
int step;
|
||||
if (!(step = atoi(p))) {
|
||||
step = 1;
|
||||
}
|
||||
fhp->vol += step;
|
||||
} else {
|
||||
int vol = atoi(p);
|
||||
fhp->vol = vol;
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (fhp->vol) {
|
||||
switch_normalize_volume(fhp->vol);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else if (!strcasecmp(cmd, "pause")) {
|
||||
if (switch_test_flag(fhp, SWITCH_FILE_PAUSE)) {
|
||||
switch_clear_flag(fhp, SWITCH_FILE_PAUSE);
|
||||
} else {
|
||||
switch_set_flag(fhp, SWITCH_FILE_PAUSE);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strcasecmp(cmd, "stop")) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
} else if (!strcasecmp(cmd, "truncate")) {
|
||||
switch_core_file_truncate(fhp, 0);
|
||||
} else if (!strcasecmp(cmd, "restart")) {
|
||||
unsigned int pos = 0;
|
||||
fhp->speed = 0;
|
||||
switch_core_file_seek(fhp, &pos, 0, SEEK_SET);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strncasecmp(cmd, "seek", 4)) {
|
||||
switch_codec_t *codec;
|
||||
unsigned int samps = 0;
|
||||
unsigned int pos = 0;
|
||||
char *p;
|
||||
codec = switch_core_session_get_read_codec(session);
|
||||
|
||||
if ((p = strchr(cmd, ':'))) {
|
||||
p++;
|
||||
if (*p == '+' || *p == '-') {
|
||||
int step;
|
||||
int32_t target;
|
||||
if (!(step = atoi(p))) {
|
||||
step = 1000;
|
||||
}
|
||||
|
||||
samps = step * (codec->implementation->samples_per_second / 1000);
|
||||
target = (int32_t)fhp->pos + samps;
|
||||
|
||||
if (target < 0) {
|
||||
target = 0;
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", target);
|
||||
switch_core_file_seek(fhp, &pos, target, SEEK_SET);
|
||||
|
||||
} else {
|
||||
samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
|
||||
if (samps < 0) {
|
||||
samps = 0;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "seek to position %d\n", samps);
|
||||
switch_core_file_seek(fhp, &pos, samps, SEEK_SET);
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(cmd, "true") || !strcmp(cmd, "undefined")) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
|
Reference in New Issue
Block a user