Index: include/asterisk/monitor.h
===================================================================
--- include/asterisk/monitor.h	(révision 48530)
+++ include/asterisk/monitor.h	(copie de travail)
@@ -46,7 +46,7 @@
 
 /* Start monitoring a channel */
 int ast_monitor_start(struct ast_channel *chan, const char *format_spec,
-		      const char *fname_base, int need_lock );
+		      const char *fname_base, int need_lock, int stream_action);
 
 /* Stop monitoring a channel */
 int ast_monitor_stop(struct ast_channel *chan, int need_lock);
Index: res/res_monitor.c
===================================================================
--- res/res_monitor.c	(révision 48530)
+++ res/res_monitor.c	(copie de travail)
@@ -61,6 +61,11 @@
 		ast_channel_unlock(lock); \
 	} while (0)
 
+/* Streams recording control */
+#define X_REC_IN	1
+#define X_REC_OUT	2
+#define X_JOIN		4
+
 static unsigned long seq = 0;
 
 static char *monitor_synopsis = "Monitor a channel";
@@ -85,6 +90,10 @@
 "          administrator interface\n"
 "\n"
 "    b   - Don't begin recording unless a call is bridged to another channel\n"
+"\n"
+"    i   - Skip recording of input stream (disables m option)\n"
+"\n"
+"    o   - Skip recording of output stream (disables m option)\n"
 "\nReturns -1 if monitor files can't be opened or if the channel is already\n"
 "monitored, otherwise 0.\n"
 ;
@@ -125,7 +134,7 @@
 
 /* Start monitoring a channel */
 int ast_monitor_start(	struct ast_channel *chan, const char *format_spec,
-		const char *fname_base, int need_lock)
+		const char *fname_base, int need_lock, int stream_action)
 {
 	int res = 0;
 	char tmp[256];
@@ -192,31 +201,45 @@
 		}
 		
 		/* open files */
-		if (ast_fileexists(monitor->read_filename, NULL, NULL) > 0) {
-			ast_filedelete(monitor->read_filename, NULL);
-		}
-		if (!(monitor->read_stream = ast_writefile(monitor->read_filename,
+		if (stream_action & X_REC_IN) {
+			if (ast_fileexists(monitor->read_filename,
+						NULL, NULL) > 0)
+				ast_filedelete(monitor->read_filename, NULL);
+			if (!(monitor->read_stream = ast_writefile(
+						monitor->read_filename,
 						monitor->format, NULL,
-						O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
-			ast_log(LOG_WARNING, "Could not create file %s\n",
+						O_CREAT|O_TRUNC|O_WRONLY, 0,
+						0644))) {
+				ast_log(LOG_WARNING,
+						"Could not create file %s\n",
 						monitor->read_filename);
-			free(monitor);
-			UNLOCK_IF_NEEDED(chan, need_lock);
-			return -1;
-		}
-		if (ast_fileexists(monitor->write_filename, NULL, NULL) > 0) {
-			ast_filedelete(monitor->write_filename, NULL);
-		}
-		if (!(monitor->write_stream = ast_writefile(monitor->write_filename,
+				free(monitor);
+				UNLOCK_IF_NEEDED(chan, need_lock);
+				return -1;
+			}
+		} else
+			monitor->read_stream = NULL;
+
+		if (stream_action & X_REC_OUT) {
+			if (ast_fileexists(monitor->write_filename,
+						NULL, NULL) > 0)
+				ast_filedelete(monitor->write_filename, NULL);
+			if (!(monitor->write_stream = ast_writefile(
+						monitor->write_filename,
 						monitor->format, NULL,
-						O_CREAT|O_TRUNC|O_WRONLY, 0, 0644))) {
-			ast_log(LOG_WARNING, "Could not create file %s\n",
+						O_CREAT|O_TRUNC|O_WRONLY, 0,
+						0644))) {
+				ast_log(LOG_WARNING,
+						"Could not create file %s\n",
 						monitor->write_filename);
-			ast_closestream(monitor->read_stream);
-			free(monitor);
-			UNLOCK_IF_NEEDED(chan, need_lock);
-			return -1;
-		}
+				ast_closestream(monitor->read_stream);
+				free(monitor);
+				UNLOCK_IF_NEEDED(chan, need_lock);
+				return -1;
+			}
+		} else
+			monitor->write_stream = NULL;
+
 		chan->monitor = monitor;
 		ast_monitor_set_state(chan, AST_MONITOR_RUNNING);
 		/* so we know this call has been monitored in case we need to bill for it or something */
@@ -394,7 +417,7 @@
 	char *delay = NULL;
 	char *urlprefix = NULL;
 	char tmp[256];
-	int joinfiles = 0;
+	int stream_action = X_REC_IN | X_REC_OUT;
 	int waitforbridge = 0;
 	int res = 0;
 	
@@ -410,9 +433,13 @@
 				*options = 0;
 				options++;
 				if (strchr(options, 'm'))
-					joinfiles = 1;
+					stream_action |= X_JOIN;
 				if (strchr(options, 'b'))
 					waitforbridge = 1;
+				if (strchr(options, 'i'))
+					stream_action &= ~X_REC_IN;
+				if (strchr(options, 'o'))
+					stream_action &= ~X_REC_OUT;
 			}
 		}
 		arg = strchr(format,':');
@@ -445,11 +472,17 @@
 		return 0;
 	}
 
-	res = ast_monitor_start(chan, format, fname_base, 1);
+	res = ast_monitor_start(chan, format, fname_base, 1, stream_action);
 	if (res < 0)
 		res = ast_monitor_change_fname(chan, fname_base, 1);
-	ast_monitor_setjoinfiles(chan, joinfiles);
 
+	if (stream_action & X_JOIN) {
+		if ((stream_action & X_REC_IN) && (stream_action & X_REC_OUT))
+			ast_monitor_setjoinfiles(chan, 1);
+		else
+			ast_log(LOG_WARNING, "Won't mix streams if one of input or output streams is not recorded\n");
+	}
+
 	return res;
 }
 
@@ -485,7 +518,7 @@
 	char *format = astman_get_header(m, "Format");
 	char *mix = astman_get_header(m, "Mix");
 	char *d;
-	
+
 	if (ast_strlen_zero(name)) {
 		astman_send_error(s, m, "No channel specified");
 		return 0;
@@ -507,8 +540,8 @@
 		if ((d = strchr(fname, '/'))) 
 			*d = '-';
 	}
-	
-	if (ast_monitor_start(c, format, fname, 1)) {
+
+	if (ast_monitor_start(c, format, fname, 1, X_REC_IN | X_REC_OUT)) {
 		if (ast_monitor_change_fname(c, fname, 1)) {
 			astman_send_error(s, m, "Could not start monitoring channel");
 			ast_channel_unlock(c);
