Revision
17396
Author
mike
Date
2010-04-26 03:19:51 -0500 (Mon, 26 Apr 2010)

Log Message

core: add sound_prefix support in uuid_displace (FSCORE-550)

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_async.c (17395 => 17396)


--- freeswitch/trunk/src/switch_ivr_async.c	2010-04-26 08:14:57 UTC (rev 17395)
+++ freeswitch/trunk/src/switch_ivr_async.c	2010-04-26 08:19:51 UTC (rev 17396)
@@ -353,10 +353,15 @@
 	switch_media_bug_t *bug;
 	switch_status_t status;
 	time_t to = 0;
+	char *ext;
+	const char *prefix;
 	displace_helper_t *dh;
 	switch_codec_implementation_t read_impl = { 0 };
 	switch_core_session_get_read_impl(session, &read_impl);
 
+	if (zstr(file)) {
+		return SWITCH_STATUS_FALSE;
+	}
 
 	if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
@@ -376,7 +381,35 @@
 		return SWITCH_STATUS_MEMERR;
 	}
 
+	if (!(prefix = switch_channel_get_variable(channel, "sound_prefix"))) {
+		prefix = SWITCH_GLOBAL_dirs.base_dir;
+	}
 
+	if (!strstr(file, SWITCH_URL_SEPARATOR)) {
+		if (!switch_is_file_path(file)) {
+			char *tfile = NULL;
+			char *e;
+
+			if (*file == '[') {
+				tfile = switch_core_session_strdup(session, file);
+				if ((e = switch_find_end_paren(tfile, '[', ']'))) {
+					*e = '\0';
+					file = e + 1;
+				} else {
+					tfile = NULL;
+				}
+			}
+
+			file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", prefix, SWITCH_PATH_SEPARATOR, file);
+		}
+		if ((ext = strrchr(file, '.'))) {
+			ext++;
+		} else {
+			ext = read_impl.iananame;
+			file = switch_core_session_sprintf(session, "%s.%s", file, ext);
+		}
+	}
+
 	dh->fh.channels = read_impl.number_of_channels;
 	dh->fh.samplerate = read_impl.actual_samples_per_second;
 	dh->file = switch_core_session_strdup(session, file);