mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user