summaryrefslogtreecommitdiff
path: root/res/res_stasis_playback.c
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-07-03 17:58:45 +0000
committerDavid M. Lee <dlee@digium.com>2013-07-03 17:58:45 +0000
commita75fd32212c35b41143442bd757387fad636177a (patch)
tree461033acf36f4596d8fc9800a1195e12207b3ea2 /res/res_stasis_playback.c
parentc4adaf91067559dd5aa90577e181693abade0602 (diff)
ARI - channel recording support
This patch is the first step in adding recording support to the Asterisk REST Interface. Recordings are stored in /var/spool/recording. Since recordings may be destructive (overwriting existing files), the API rejects attempts to escape the recording directory (avoiding issues if someone attempts to record to ../../lib/sounds/greeting, for example). (closes issue ASTERISK-21594) (closes issue ASTERISK-21581) Review: https://reviewboard.asterisk.org/r/2612/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393550 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_stasis_playback.c')
-rw-r--r--res/res_stasis_playback.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c
index 3b092df2d..5b55ebc51 100644
--- a/res/res_stasis_playback.c
+++ b/res/res_stasis_playback.c
@@ -37,6 +37,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
+#include "asterisk/paths.h"
#include "asterisk/stasis_app_impl.h"
#include "asterisk/stasis_app_playback.h"
#include "asterisk/stasis_channels.h"
@@ -195,7 +196,7 @@ static void *play_uri(struct stasis_app_control *control,
RAII_VAR(struct stasis_app_playback *, playback, NULL,
playback_cleanup);
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
- const char *file;
+ RAII_VAR(char *, file, NULL, ast_free);
int res;
long offsetms;
@@ -225,16 +226,27 @@ static void *play_uri(struct stasis_app_control *control,
if (ast_begins_with(playback->media, SOUND_URI_SCHEME)) {
/* Play sound */
- file = playback->media + strlen(SOUND_URI_SCHEME);
+ file = ast_strdup(playback->media + strlen(SOUND_URI_SCHEME));
} else if (ast_begins_with(playback->media, RECORDING_URI_SCHEME)) {
/* Play recording */
- file = playback->media + strlen(RECORDING_URI_SCHEME);
+ const char *relname =
+ playback->media + strlen(RECORDING_URI_SCHEME);
+ if (relname[0] == '/') {
+ file = ast_strdup(relname);
+ } else {
+ ast_asprintf(&file, "%s/%s",
+ ast_config_AST_RECORDING_DIR, relname);
+ }
} else {
/* Play URL */
ast_log(LOG_ERROR, "Unimplemented\n");
return NULL;
}
+ if (!file) {
+ return NULL;
+ }
+
res = ast_control_streamfile_lang(chan, file, fwd, rev, stop, pause,
restart, playback->skipms, playback->language, &offsetms);