[Freeswitch-svn] [commit] r6389 - in freeswitch/trunk/src: . include

Freeswitch SVN anthm at freeswitch.org
Fri Nov 23 13:35:38 EST 2007


Author: anthm
Date: Fri Nov 23 13:35:38 2007
New Revision: 6389

Modified:
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch_core_media_bug.c
   freeswitch/trunk/src/switch_ivr_async.c

Log:
add RECORD_ANSWER_REQ var

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Fri Nov 23 13:35:38 2007
@@ -158,6 +158,14 @@
 SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_read_replace_frame(switch_media_bug_t *bug);
 
 /*!
+  \brief Obtain the session from a media bug
+  \param bug the bug to get the data from
+*/
+SWITCH_DECLARE(switch_core_session_t *) switch_core_media_bug_get_session(switch_media_bug_t *bug);
+
+SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag);
+
+/*!
   \brief Set a return replace frame
   \param bug the bug to set the frame on
   \param frame the frame to set

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Fri Nov 23 13:35:38 2007
@@ -783,6 +783,8 @@
 SMBF_WRITE_STREAM - Include the Write Stream
 SMBF_WRITE_REPLACE - Replace the Write Stream
 SMBF_READ_REPLACE - Replace the Read Stream
+SMBF_STEREO - Record in stereo
+SMBF_ANSWER_RECORD_REQ - Don't record until the channel is answered
 </pre>
 */
 typedef enum {
@@ -791,7 +793,8 @@
 	SMBF_WRITE_STREAM = (1 << 1),
 	SMBF_WRITE_REPLACE = (1 << 2),
 	SMBF_READ_REPLACE = (1 << 3),
-	SMBF_STEREO = (1 << 4)
+	SMBF_STEREO = (1 << 4),
+	SMBF_RECORD_ANSWER_REQ = (1 << 5)
 } switch_media_bug_flag_t;
 
 /*!

Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c	(original)
+++ freeswitch/trunk/src/switch_core_media_bug.c	Fri Nov 23 13:35:38 2007
@@ -40,6 +40,15 @@
 	switch_buffer_destroy(&bug->raw_write_buffer);
 }
 
+SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag)
+{
+	return switch_test_flag(bug, flag);
+}
+
+SWITCH_DECLARE(switch_core_session_t *) switch_core_media_bug_get_session(switch_media_bug_t *bug)
+{
+	return bug->session;
+}
 
 SWITCH_DECLARE(switch_frame_t *) switch_core_media_bug_get_write_replace_frame(switch_media_bug_t *bug)
 {

Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c	(original)
+++ freeswitch/trunk/src/switch_ivr_async.c	Fri Nov 23 13:35:38 2007
@@ -262,10 +262,24 @@
 	case SWITCH_ABC_TYPE_READ:
 		if (fh) {
 			switch_size_t len;
-
+			switch_core_session_t *session;
+			switch_channel_t *channel;
+			
+			session = switch_core_media_bug_get_session(bug);
+			assert(session != NULL);
+			channel = switch_core_session_get_channel(session);
+			assert(channel != NULL);
+			
 			if (switch_core_media_bug_read(bug, &frame) == SWITCH_STATUS_SUCCESS) {
-				len = (switch_size_t) frame.datalen / 2;
-				switch_core_file_write(fh, frame.data, &len);
+				int doit = 1;
+				if (!switch_channel_test_flag(channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bug, SMBF_RECORD_ANSWER_REQ)) {
+					doit = 0;
+				}
+
+				if (doit) {
+					len = (switch_size_t) frame.datalen / 2;
+					switch_core_file_write(fh, frame.data, &len);
+				}
 			}
 		}
 		break;
@@ -327,6 +341,10 @@
 		flags |= SMBF_STEREO;
 		channels = 2;
 	}
+
+	if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
+		flags |= SMBF_RECORD_ANSWER_REQ;
+	}
 	
 	fh->channels = channels;
 	fh->samplerate = read_codec->implementation->actual_samples_per_second;



More information about the Freeswitch-svn mailing list