Revision
16964
Author
anthm
Date
2010-03-10 17:40:14 -0600 (Wed, 10 Mar 2010)

Log Message

add record_fill_cng var

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_play_say.c (16963 => 16964)


--- freeswitch/trunk/src/switch_ivr_play_say.c	2010-03-10 20:44:36 UTC (rev 16963)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	2010-03-10 23:40:14 UTC (rev 16964)
@@ -364,7 +364,7 @@
 	time_t start = 0;
 	uint32_t org_silence_hits = 0;
 	int asis = 0;
-	int waste_resources = 0;
+	int waste_resources = 0, fill_cng = 0;
 	switch_codec_implementation_t read_impl = { 0 };
 	switch_frame_t write_frame = { 0 };
 	unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
@@ -415,7 +415,19 @@
 		}
 	}
 
+	
+	if ((vval = switch_channel_get_variable(channel, "record_fill_cng"))) {
 
+		if (switch_true(vval)) {
+			fill_cng = 1400;
+		} else {
+			if ((fill_cng = atoi(vval)) < 0) {
+				fill_cng = 0;
+			}
+		}
+	}
+	
+
 	if ((vval = switch_channel_get_variable(channel, "record_waste_resources"))) {
 
 		if (switch_true(vval)) {
@@ -425,7 +437,10 @@
 				waste_resources = 0;
 			}
 		}
+	}
 
+
+	if (fill_cng || waste_resources) {
 		if (switch_core_codec_init(&write_codec,
 								   "L16",
 								   NULL,
@@ -665,6 +680,11 @@
 			}
 		}
 
+		if (fill_cng || waste_resources) {
+			switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, waste_resources);
+		}
+
+
 		if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
 			int16_t *data = read_frame->data;
 			len = (switch_size_t) asis ? read_frame->datalen : read_frame->datalen / 2;
@@ -672,10 +692,14 @@
 			if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
+		} else if (switch_test_flag(read_frame, SFF_CNG)) {
+			len = write_frame.datalen;
+			if (switch_core_file_write(fh, write_frame.data, &len) != SWITCH_STATUS_SUCCESS) {
+				break;
+			}			
 		}
 
 		if (waste_resources) {
-			switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, waste_resources);
 			if (switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}