[asterisk-commits] dlee: branch dlee/ari-monitor2 r395937 - in /team/dlee/ari-monitor2: apps/ in...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 1 00:12:20 CDT 2013


Author: dlee
Date: Thu Aug  1 00:12:18 2013
New Revision: 395937

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395937
Log:
Compiles

Modified:
    team/dlee/ari-monitor2/apps/app_mixmonitor.c
    team/dlee/ari-monitor2/include/asterisk/mixmonitor.h
    team/dlee/ari-monitor2/main/mixmonitor.c
    team/dlee/ari-monitor2/res/res_stasis_recording.c
    team/dlee/ari-monitor2/res/stasis_recording/monitor.c
    team/dlee/ari-monitor2/res/stasis_recording/recording.h

Modified: team/dlee/ari-monitor2/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/apps/app_mixmonitor.c?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/apps/app_mixmonitor.c (original)
+++ team/dlee/ari-monitor2/apps/app_mixmonitor.c Thu Aug  1 00:12:18 2013
@@ -1181,6 +1181,13 @@
 	return CLI_SUCCESS;
 }
 
+static int mute_mixmonitor_callback(struct ast_channel *chan, enum ast_audiohook_flags dir, int enabled)
+{
+	int clear = !enabled; /* Seriously? */
+	dir &= (AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE);
+	return ast_audiohook_set_mute(chan, mixmonitor_spy_type, dir, clear);
+}
+
 /*! \brief  Mute / unmute  a MixMonitor channel */
 static int manager_mute_mixmonitor(struct mansession *s, const struct message *m)
 {
@@ -1226,7 +1233,7 @@
 		return AMI_SUCCESS;
 	}
 
-	if (ast_audiohook_set_mute(c, mixmonitor_spy_type, flag, clearmute)) {
+	if (mute_mixmonitor_callback(c, flag, clearmute)) {
 		ast_channel_unref(c);
 		astman_send_error(s, m, "Cannot set mute flag");
 		return AMI_SUCCESS;
@@ -1375,6 +1382,7 @@
 	struct ast_mixmonitor_methods mixmonitor_methods = {
 		.start = start_mixmonitor_callback,
 		.stop = stop_mixmonitor_callback,
+		.mute = mute_mixmonitor_callback,
 	};
 
 	return ast_set_mixmonitor_methods(&mixmonitor_methods);

Modified: team/dlee/ari-monitor2/include/asterisk/mixmonitor.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/include/asterisk/mixmonitor.h?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/include/asterisk/mixmonitor.h (original)
+++ team/dlee/ari-monitor2/include/asterisk/mixmonitor.h Thu Aug  1 00:12:18 2013
@@ -16,12 +16,17 @@
  * at the top of the source tree.
  */
 
+#ifndef _ASTERISK_MIXMONITOR_H
+#define _ASTERISK_MIXMONITOR_H
+
 /*! \file
  *
  * \brief loadable MixMonitor functionality
  *
  * \author Jonathan Rose <jrose at digium.com>
  */
+
+#include "asterisk/audiohook.h"
 
 /*!
  * \brief Start a mixmonitor on a channel.
@@ -49,12 +54,26 @@
 typedef int (*ast_mixmonitor_stop_fn)(struct ast_channel *chan, const char *mixmon_id);
 
 /*!
+ * \brief Mute/unmute a mixmonitor on a channel.
+ * \since 12.0.0
+ *
+ * \param chan Which channel to mute/unmute MixMonitor
+ * \param dir Direction in which to mute/unmute
+ * \param enabled If true (non-zero), mute. If false (zero), unmute.
+ *
+ * \retval 0 on success
+ * \retval non-zero on failure
+ */
+typedef int (*ast_mixmonitor_mute_fn)(struct ast_channel *chan, enum ast_audiohook_flags dir, int enabled);
+
+/*!
  * \brief MixMonitor virtual methods table definition
  * \since 12.0.0
  */
 struct ast_mixmonitor_methods {
 	ast_mixmonitor_start_fn start;
 	ast_mixmonitor_stop_fn stop;
+	ast_mixmonitor_mute_fn mute;
 };
 
 /*!
@@ -103,3 +122,18 @@
  * \retval non-zero on failure
  */
 int ast_stop_mixmonitor(struct ast_channel *chan, const char *mixmon_id);
+
+/*!
+ * \brief Mute/unmute a mixmonitor on a channel.
+ * \since 12.0.0
+ *
+ * \param chan Which channel to mute/unmute MixMonitor
+ * \param dir Direction in which to mute/unmute
+ * \param enabled If true (non-zero), mute. If false (zero), unmute.
+ *
+ * \retval 0 on success
+ * \retval non-zero on failure
+ */
+int ast_mute_mixmonitor(struct ast_channel *chan, enum ast_audiohook_flags dir, int enabled);
+
+#endif /* _ASTERISK_MIXMONITOR_H */

Modified: team/dlee/ari-monitor2/main/mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/main/mixmonitor.c?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/main/mixmonitor.c (original)
+++ team/dlee/ari-monitor2/main/mixmonitor.c Thu Aug  1 00:12:18 2013
@@ -96,3 +96,15 @@
 
 	return mixmonitor_methods.stop(chan, mixmon_id);
 }
+
+int ast_mute_mixmonitor(struct ast_channel *chan, enum ast_audiohook_flags dir, int enabled)
+{
+	SCOPED_RDLOCK(lock, &mixmonitor_lock);
+
+	if (!mixmonitor_methods.mute) {
+		ast_log(LOG_ERROR, "No loaded module currently provides MixMonitor muting functionality.\n");
+		return -1;
+	}
+
+	return mixmonitor_methods.mute(chan, dir, enabled);
+}

Modified: team/dlee/ari-monitor2/res/res_stasis_recording.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/res/res_stasis_recording.c?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/res/res_stasis_recording.c (original)
+++ team/dlee/ari-monitor2/res/res_stasis_recording.c Thu Aug  1 00:12:18 2013
@@ -34,6 +34,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/file.h"
+#include "asterisk/mixmonitor.h"
 #include "asterisk/module.h"
 #include "asterisk/paths.h"
 #include "asterisk/stasis_app_impl.h"
@@ -439,8 +440,12 @@
 {
 	int res = 0;
 	recording->state = STASIS_APP_RECORDING_STATE_CANCELED;
-	res |= stasis_app_control_queue_control(recording->control,
-		AST_CONTROL_RECORD_CANCEL);
+	if (recording->mixmonitor) {
+		res |= ast_stop_mixmonitor(recording->channel, NULL);
+	} else {
+		res |= stasis_app_control_queue_control(recording->control,
+			AST_CONTROL_RECORD_CANCEL);
+	}
 	res |= ast_filedelete(recording->absolute_name, NULL);
 	return res;
 }
@@ -448,12 +453,22 @@
 static int recording_stop(struct stasis_app_recording *recording)
 {
 	recording->state = STASIS_APP_RECORDING_STATE_COMPLETE;
+
+	if (recording->mixmonitor) {
+		return ast_stop_mixmonitor(recording->channel, NULL);
+	}
+
 	return stasis_app_control_queue_control(recording->control,
 		AST_CONTROL_RECORD_STOP);
 }
 
 static int recording_pause(struct stasis_app_recording *recording)
 {
+	if (recording->mixmonitor) {
+		errno = ENOSYS;
+		return -1;
+	}
+
 	recording->state = STASIS_APP_RECORDING_STATE_PAUSED;
 	return stasis_app_control_queue_control(recording->control,
 		AST_CONTROL_RECORD_SUSPEND);
@@ -461,6 +476,11 @@
 
 static int recording_unpause(struct stasis_app_recording *recording)
 {
+	if (recording->mixmonitor) {
+		errno = ENOSYS;
+		return -1;
+	}
+
 	recording->state = STASIS_APP_RECORDING_STATE_RECORDING;
 	return stasis_app_control_queue_control(recording->control,
 		AST_CONTROL_RECORD_SUSPEND);
@@ -474,6 +494,12 @@
 	}
 
 	recording->muted = 1;
+
+	if (recording->mixmonitor) {
+		return ast_mute_mixmonitor(recording->channel,
+			AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE, 1);
+	}
+
 	return stasis_app_control_queue_control(recording->control,
 		AST_CONTROL_RECORD_MUTE);
 }
@@ -483,6 +509,13 @@
 	if (!recording->muted) {
 		/* already unmuted */
 		return 0;
+	}
+
+	recording->muted = 0;
+
+	if (recording->mixmonitor) {
+		return ast_mute_mixmonitor(recording->channel,
+			AST_AUDIOHOOK_MUTE_READ | AST_AUDIOHOOK_MUTE_WRITE, 0);
 	}
 
 	return stasis_app_control_queue_control(recording->control,

Modified: team/dlee/ari-monitor2/res/stasis_recording/monitor.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/res/stasis_recording/monitor.c?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/res/stasis_recording/monitor.c (original)
+++ team/dlee/ari-monitor2/res/stasis_recording/monitor.c Thu Aug  1 00:12:18 2013
@@ -46,6 +46,7 @@
 	const char *app_args = "";
 
 	ao2_lock(recording);
+	recording->channel = chan;
 	recording->state = STASIS_APP_RECORDING_STATE_RECORDING;
 	recording_publish(recording);
 	ao2_unlock(recording);

Modified: team/dlee/ari-monitor2/res/stasis_recording/recording.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-monitor2/res/stasis_recording/recording.h?view=diff&rev=395937&r1=395936&r2=395937
==============================================================================
--- team/dlee/ari-monitor2/res/stasis_recording/recording.h (original)
+++ team/dlee/ari-monitor2/res/stasis_recording/recording.h Thu Aug  1 00:12:18 2013
@@ -38,10 +38,14 @@
 	/*! Control object for the channel we're playing back to */
 	struct stasis_app_control *control;
 
+	/*! Channel being recorded; only set for mixmonitor. */
+	struct ast_channel *channel;
 	/*! Current state of the recording. */
 	enum stasis_app_recording_state state;
 	/*! Indicates whether the recording is currently muted */
 	int muted:1;
+	/*! If true, recording is using mixmonitor */
+	int mixmonitor:1;
 };
 
 /*!




More information about the asterisk-commits mailing list