Project "FreeSWITCH Source" received a push.

branch: master updated

       via: bc397ab6000d8e8acaeecf351a3281428226d0d9 (commit)
      from: 687d39f259cf62bea5c6508acd76d8732dcc0e11 (commit)


= COMMIT LOG ===========================================================
committer: Anthony Minessale
comments: 
FS-2971

diff --git a/libs/esl/src/esl_event.c b/libs/esl/src/esl_event.c
index db7c581..9bd78a8 100644
--- a/libs/esl/src/esl_event.c
+++ b/libs/esl/src/esl_event.c
@@ -131,6 +131,8 @@ static const char *EVENT_NAMES[] = {
 	"NAT",
 	"RECORD_START",
 	"RECORD_STOP",
+	"PLAYBACK_START",
+	"PLAYBACK_STOP",
 	"CALL_UPDATE",
 	"FAILURE",
 	"SOCKET_DATA",
diff --git a/libs/esl/src/include/esl_event.h b/libs/esl/src/include/esl_event.h
index 0e6d3e3..7e619f4 100644
--- a/libs/esl/src/include/esl_event.h
+++ b/libs/esl/src/include/esl_event.h
@@ -119,6 +119,8 @@ typedef enum {
 	ESL_EVENT_NAT,
 	ESL_EVENT_RECORD_START,
 	ESL_EVENT_RECORD_STOP,
+	ESL_EVENT_PLAYBACK_START,
+	ESL_EVENT_PLAYBACK_STOP,
 	ESL_EVENT_CALL_UPDATE,
 	ESL_EVENT_FAILURE,
 	ESL_EVENT_SOCKET_DATA,
diff --git a/src/include/switch_types.h b/src/include/switch_types.h
index 3972404..4253d0e 100644
--- a/src/include/switch_types.h
+++ b/src/include/switch_types.h
@@ -1504,6 +1504,8 @@ typedef enum {
 	SWITCH_EVENT_NAT,
 	SWITCH_EVENT_RECORD_START,
 	SWITCH_EVENT_RECORD_STOP,
+	SWITCH_EVENT_PLAYBACK_START,
+	SWITCH_EVENT_PLAYBACK_STOP,
 	SWITCH_EVENT_CALL_UPDATE,
 	SWITCH_EVENT_FAILURE,
 	SWITCH_EVENT_SOCKET_DATA,
diff --git a/src/switch_channel.c b/src/switch_channel.c
index 9e3064b..179f63d 100644
--- a/src/switch_channel.c
+++ b/src/switch_channel.c
@@ -2042,10 +2042,13 @@ SWITCH_DECLARE(void) switch_channel_event_set_extended_data(switch_channel_t *ch
 		event->event_id == SWITCH_EVENT_REQUEST_PARAMS ||
 		event->event_id == SWITCH_EVENT_CHANNEL_DATA ||
 		event->event_id == SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE ||
+		event->event_id == SWITCH_EVENT_CHANNEL_DESTROY ||
 		event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
 		event->event_id == SWITCH_EVENT_API ||
 		event->event_id == SWITCH_EVENT_RECORD_START ||
 		event->event_id == SWITCH_EVENT_RECORD_STOP || 
+		event->event_id == SWITCH_EVENT_PLAYBACK_START ||
+		event->event_id == SWITCH_EVENT_PLAYBACK_STOP ||
 		event->event_id == SWITCH_EVENT_CALL_UPDATE || 
 		event->event_id == SWITCH_EVENT_MEDIA_BUG_START || 
 		event->event_id == SWITCH_EVENT_MEDIA_BUG_STOP || 
diff --git a/src/switch_event.c b/src/switch_event.c
index b626d5b..56ee9e9 100644
--- a/src/switch_event.c
+++ b/src/switch_event.c
@@ -189,6 +189,8 @@ static char *EVENT_NAMES[] = {
 	"NAT",
 	"RECORD_START",
 	"RECORD_STOP",
+	"PLAYBACK_START",
+	"PLAYBACK_STOP",
 	"CALL_UPDATE",
 	"FAILURE",
 	"SOCKET_DATA",
diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c
index dc263e9..98dfd0f 100644
--- a/src/switch_ivr_play_say.c
+++ b/src/switch_ivr_play_say.c
@@ -746,12 +746,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
 
 	}
 
-	if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
-		switch_channel_event_set_data(channel, event);
-		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file);
-		switch_event_fire(&event);
-	}
-
 	if (fill_cng || waste_resources) {
 		switch_core_codec_destroy(&write_codec);
 	}
@@ -766,6 +760,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
 
 	switch_channel_set_variable_printf(channel, "record_samples", "%d", fh->samples_out);
 
+	if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(channel, event);
+		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", file);
+		switch_event_fire(&event);
+	}
+
 	switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
 	return status;
 }
@@ -951,6 +951,38 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_sessi
 #define FILE_BLOCKSIZE 1024 * 8
 #define FILE_BUFSIZE 1024 * 64
 
+static void add_playback_vars_to_event(switch_core_session_t *session, switch_event_t *event, char *vars)
+{
+	char *tmp;
+
+	if (!session || !event || !vars)
+		return;
+
+	if ((tmp = switch_core_session_strdup(session, vars))) {
+		char *argv[128] = { 0 };
+		int argc, i;
+
+		if (!(argc = switch_separate_string(tmp, ',', argv, (sizeof(argv) / sizeof(argv[0])))))
+			return;
+
+		for (i = 0; i < argc; i++) {
+			char *var, *val;
+
+			if ((var = strchr(argv[i], '='))) {
+				*var = '\0';
+				val = var+1;
+				var = argv[i];
+
+				if (var && *var && val && *val) {
+					if ((var = switch_core_session_sprintf(session, "playback_variable_%s", var))) {
+						switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val);
+					}
+				}
+			}
+		}
+	}
+}
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
@@ -990,6 +1022,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 	int timeout_samples = 0;
 	const char *var;
 	int more_data = 0;
+	char *playback_vars, *tmp;
+	switch_event_t *event;
 
 	if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
@@ -1138,6 +1172,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 			}
 		}
 
+		/* Try to parse extra parameters for this playback (parameters within {} at the end of the filename */
+		playback_vars = NULL;
+		if ((tmp = strchr(file, '{'))) {
+			char *tfile, *e;
+			
+			if ((tfile = switch_core_session_strdup(session, tmp))) {
+				if ((e = switch_find_end_paren(tfile, '{', '}')) && *(e + 1) == '\0') {
+					*tmp = '\0';
+					*e = '\0';
+					playback_vars = tfile+1;
+				}
+			}
+		}
 
 		if (!fh) {
 			fh = &lfh;
@@ -1293,6 +1340,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 
 		ilen = samples;
 
+		if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_START) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file);
+			add_playback_vars_to_event(session, event, playback_vars); 
+			switch_event_fire(&event);
+		}
+
 		for (;;) {
 			int do_speed = 1;
 			int last_speed = -1;
@@ -1586,6 +1640,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 		}
 		switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_in);
 
+		if (switch_event_create(&event, SWITCH_EVENT_PLAYBACK_STOP) == SWITCH_STATUS_SUCCESS) {
+			switch_channel_event_set_data(channel, event);
+			switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-File-Path", file);
+			if (status == SWITCH_STATUS_BREAK) {
+				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "break");
+			} else {
+				switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Playback-Status", "done");
+			}
+			add_playback_vars_to_event(session, event, playback_vars); 
+			switch_event_fire(&event);
+		}
+
 		switch_core_session_io_write_lock(session);
 		switch_channel_set_private(channel, "__fh", NULL);
 		switch_core_session_io_rwunlock(session);
========================================================================

Summary of changes:
 libs/esl/src/esl_event.c         |    2 +
 libs/esl/src/include/esl_event.h |    2 +
 src/include/switch_types.h       |    2 +
 src/switch_channel.c             |    3 +
 src/switch_event.c               |    2 +
 src/switch_ivr_play_say.c        |   78 +++++++++++++++++++++++++++++++++++---
 6 files changed, 83 insertions(+), 6 deletions(-)

this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630 --
FreeSWITCH Source