mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-15 15:54:13 +00:00
Merge branch 'master' into smgmaster
This commit is contained in:
commit
2b8d96a301
364 files changed
+122942
-1699
No files matched your search
@@ -1918,6 +1918,101 @@ SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_m
|
||||
}
|
||||
}
|
||||
|
||||
struct switch_say_file_handle {
|
||||
char *ext;
|
||||
int cnt;
|
||||
struct switch_stream_handle stream;
|
||||
switch_event_t *param_event;
|
||||
};
|
||||
|
||||
SWITCH_DECLARE(char *) switch_say_file_handle_get_variable(switch_say_file_handle_t *sh, const char *var)
|
||||
{
|
||||
char *ret = NULL;
|
||||
|
||||
if (sh->param_event) {
|
||||
ret = switch_event_get_header(sh->param_event, var);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) switch_say_file_handle_get_path(switch_say_file_handle_t *sh)
|
||||
{
|
||||
return (char *) sh->stream.data;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) switch_say_file_handle_detach_path(switch_say_file_handle_t *sh)
|
||||
{
|
||||
char *path;
|
||||
|
||||
switch_assert(sh);
|
||||
path = (char *) sh->stream.data;
|
||||
sh->stream.data = NULL;
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(void) switch_say_file_handle_destroy(switch_say_file_handle_t **sh)
|
||||
{
|
||||
switch_assert(sh);
|
||||
|
||||
switch_safe_free((*sh)->stream.data);
|
||||
switch_safe_free((*sh)->ext);
|
||||
|
||||
if ((*sh)->param_event) {
|
||||
switch_event_destroy(&(*sh)->param_event);
|
||||
}
|
||||
free(*sh);
|
||||
*sh = NULL;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_say_file_handle_create(switch_say_file_handle_t **sh, const char *ext, switch_event_t **var_event)
|
||||
{
|
||||
switch_assert(sh);
|
||||
|
||||
if (zstr(ext)) {
|
||||
ext = "wav";
|
||||
}
|
||||
|
||||
*sh = malloc(sizeof(**sh));
|
||||
memset(*sh, 0, sizeof(**sh));
|
||||
|
||||
SWITCH_STANDARD_STREAM((*sh)->stream);
|
||||
|
||||
if (var_event) {
|
||||
(*sh)->param_event = *var_event;
|
||||
*var_event = NULL;
|
||||
}
|
||||
|
||||
(*sh)->ext = strdup(ext);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *fmt, ...)
|
||||
{
|
||||
char buf[256] = "";
|
||||
int ret;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
if ((ret = switch_vsnprintf(buf, sizeof(buf), fmt, ap)) > 0) {
|
||||
if (!sh->cnt++) {
|
||||
sh->stream.write_function(&sh->stream, "file_string://%s.%s", buf, sh->ext);
|
||||
} else {
|
||||
sh->stream.write_function(&sh->stream, "!%s.%s", buf, sh->ext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
Reference in new issue
Block a user