[asterisk-commits] dlee: branch dlee/record r390040 - in /team/dlee/record: ./ include/asterisk/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 29 14:25:31 CDT 2013


Author: dlee
Date: Wed May 29 14:25:27 2013
New Revision: 390040

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390040
Log:
Put recordings in the spool directory

Modified:
    team/dlee/record/Makefile
    team/dlee/record/include/asterisk/paths.h
    team/dlee/record/main/asterisk.c
    team/dlee/record/res/res_stasis_recording.c

Modified: team/dlee/record/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/Makefile?view=diff&rev=390040&r1=390039&r2=390040
==============================================================================
--- team/dlee/record/Makefile (original)
+++ team/dlee/record/Makefile Wed May 29 14:25:27 2013
@@ -535,7 +535,8 @@
 INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
 	"$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
 	"$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
-	"$(ASTSPOOLDIR)/voicemail" "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
+	"$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
+	"$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
 	"$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
 	"$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
 	"$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \

Modified: team/dlee/record/include/asterisk/paths.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/paths.h?view=diff&rev=390040&r1=390039&r2=390040
==============================================================================
--- team/dlee/record/include/asterisk/paths.h (original)
+++ team/dlee/record/include/asterisk/paths.h Wed May 29 14:25:27 2013
@@ -23,6 +23,7 @@
 extern const char *ast_config_AST_MODULE_DIR;
 extern const char *ast_config_AST_SPOOL_DIR;
 extern const char *ast_config_AST_MONITOR_DIR;
+extern const char *ast_config_AST_RECORDING_DIR;
 extern const char *ast_config_AST_VAR_DIR;
 extern const char *ast_config_AST_DATA_DIR;
 extern const char *ast_config_AST_LOG_DIR;

Modified: team/dlee/record/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/asterisk.c?view=diff&rev=390040&r1=390039&r2=390040
==============================================================================
--- team/dlee/record/main/asterisk.c (original)
+++ team/dlee/record/main/asterisk.c Wed May 29 14:25:27 2013
@@ -372,6 +372,7 @@
 	char module_dir[PATH_MAX];
 	char spool_dir[PATH_MAX];
 	char monitor_dir[PATH_MAX];
+	char recording_dir[PATH_MAX];
 	char var_dir[PATH_MAX];
 	char data_dir[PATH_MAX];
 	char log_dir[PATH_MAX];
@@ -396,6 +397,7 @@
 const char *ast_config_AST_MODULE_DIR	= cfg_paths.module_dir;
 const char *ast_config_AST_SPOOL_DIR	= cfg_paths.spool_dir;
 const char *ast_config_AST_MONITOR_DIR	= cfg_paths.monitor_dir;
+const char *ast_config_AST_RECORDING_DIR	= cfg_paths.recording_dir;
 const char *ast_config_AST_VAR_DIR	= cfg_paths.var_dir;
 const char *ast_config_AST_DATA_DIR	= cfg_paths.data_dir;
 const char *ast_config_AST_LOG_DIR	= cfg_paths.log_dir;
@@ -3329,6 +3331,7 @@
 	ast_copy_string(cfg_paths.spool_dir, DEFAULT_SPOOL_DIR, sizeof(cfg_paths.spool_dir));
 	ast_copy_string(cfg_paths.module_dir, DEFAULT_MODULE_DIR, sizeof(cfg_paths.module_dir));
 	snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", cfg_paths.spool_dir);
+	snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", cfg_paths.spool_dir);
 	ast_copy_string(cfg_paths.var_dir, DEFAULT_VAR_DIR, sizeof(cfg_paths.var_dir));
 	ast_copy_string(cfg_paths.data_dir, DEFAULT_DATA_DIR, sizeof(cfg_paths.data_dir));
 	ast_copy_string(cfg_paths.log_dir, DEFAULT_LOG_DIR, sizeof(cfg_paths.log_dir));
@@ -3364,6 +3367,7 @@
 		} else if (!strcasecmp(v->name, "astspooldir")) {
 			ast_copy_string(cfg_paths.spool_dir, v->value, sizeof(cfg_paths.spool_dir));
 			snprintf(cfg_paths.monitor_dir, sizeof(cfg_paths.monitor_dir), "%s/monitor", v->value);
+			snprintf(cfg_paths.recording_dir, sizeof(cfg_paths.recording_dir), "%s/recording", v->value);
 		} else if (!strcasecmp(v->name, "astvarlibdir")) {
 			ast_copy_string(cfg_paths.var_dir, v->value, sizeof(cfg_paths.var_dir));
 			if (!found.dbdir)

Modified: team/dlee/record/res/res_stasis_recording.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/res_stasis_recording.c?view=diff&rev=390040&r1=390039&r2=390040
==============================================================================
--- team/dlee/record/res/res_stasis_recording.c (original)
+++ team/dlee/record/res/res_stasis_recording.c Wed May 29 14:25:27 2013
@@ -57,6 +57,8 @@
 struct stasis_app_recording {
 	/*! Recording options. */
 	struct stasis_app_recording_options *options;
+	/*! Absolute path (minus extension) of the recording */
+	char *absolute_name;
 	/*! Control object for the channel we're playing back to */
 	struct stasis_app_control *control;
 
@@ -303,7 +305,7 @@
 			ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
 	}
 
-	s = ast_writefile(recording->options->name, recording->options->format,
+	s = ast_writefile(recording->absolute_name, recording->options->format,
 		RECORDING_COMMENT, ioflags, RECORDING_CHECK, AST_FILE_MODE);
 	if (s == NULL) {
 		ast_log(LOG_WARNING, "%s: Could not record to file %s.%s: %s\n",
@@ -428,6 +430,7 @@
 	struct stasis_app_recording_options *options)
 {
 	RAII_VAR(struct stasis_app_recording *, recording, NULL, ao2_cleanup);
+	char *last_slash;
 
 	errno = 0;
 
@@ -450,9 +453,30 @@
 		return NULL;
 	}
 
-	recording->control = control;
+	if (options->name[0] == '/') {
+		recording->absolute_name = ast_strdup(options->name);
+	} else {
+		ast_asprintf(&recording->absolute_name, "%s/%s",
+			ast_config_AST_RECORDING_DIR, options->name);
+	}
+
+	if (recording->absolute_name == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+
+	if ((last_slash = strrchr(recording->absolute_name, '/'))) {
+		*last_slash = '\0';
+		if (ast_mkdir(recording->absolute_name, 0777) != 0) {
+			/* errno set by ast_mkdir */
+			return NULL;
+		}
+		*last_slash = '/';
+	}
+
 	ao2_ref(options, +1);
 	recording->options = options;
+	recording->control = control;
 	recording->state = STASIS_APP_RECORDING_STATE_QUEUED;
 
 	{




More information about the asterisk-commits mailing list