[asterisk-commits] dvossel: branch dvossel/hd_confbridge r311668 - /team/dvossel/hd_confbridge/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 24 16:12:35 CDT 2011


Author: dvossel
Date: Thu Mar 24 16:12:31 2011
New Revision: 311668

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311668
Log:
AMI actions for starting and stopping conference recordings

Modified:
    team/dvossel/hd_confbridge/apps/app_confbridge.c

Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=311668&r1=311667&r2=311668
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Thu Mar 24 16:12:31 2011
@@ -195,6 +195,30 @@
 		<description>
 		</description>
 	</manager>
+	<manager name="ConfbridgeStartRecord" language="en_US">
+		<synopsis>
+			Start recording a Confbridge conference.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Conference" required="true" />
+			<parameter name="RecordFile" required="false" />
+		</syntax>
+		<description>
+			<para>Start recording a conference. If recording is already present an error will be returned. If RecordFile is not provided, the default record file specified in the conference's bridge profile will be used, if that is not present either a file will automatically be generated in the monitor directory.</para>
+		</description>
+	</manager>
+	<manager name="ConfbridgeStopRecord" language="en_US">
+		<synopsis>
+			Stop recording a Confbridge conference.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+			<parameter name="Conference" required="true" />
+		</syntax>
+		<description>
+		</description>
+	</manager>
 ***/
 
 /*!
@@ -364,6 +388,23 @@
 
 /*!
  * \internal
+ * \brief Returns whether or not conference is being recorded.
+ * \retval 1, conference is recording.
+ * \retval 0, conference is NOT recording.
+ */
+static int conf_is_recording(struct conference_bridge *conference_bridge)
+{
+	int res = 0;
+	ao2_lock(conference_bridge);
+	if (conference_bridge->record_chan || conference_bridge->record_thread != AST_PTHREADT_NULL) {
+		res = 1;
+	}
+	ao2_unlock(conference_bridge);
+	return res;
+}
+
+/*!
+ * \internal
  * \brief Stops the confbridge recording thread.
  *
  * \note do not call this function with any locks
@@ -404,7 +445,7 @@
 	ao2_lock(conference_bridge);
 	if (conference_bridge->record_chan || conference_bridge->record_thread != AST_PTHREADT_NULL) {
 		ao2_unlock(conference_bridge);
-		return 0; /* already recording */
+		return -1; /* already recording */
 	}
 	if (!cap) {
 		ao2_unlock(conference_bridge);
@@ -771,9 +812,7 @@
 		/* Link it into the conference bridges container */
 		ao2_link(conference_bridges, conference_bridge);
 
-		if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_RECORD_CONFERENCE)) {
-			start_record = 1;
-		}
+
 		send_conf_start_event(conference_bridge->name);
 		ast_debug(1, "Created conference bridge '%s' and linked to container '%p'\n", name, conference_bridges);
 	}
@@ -806,6 +845,11 @@
 		post_join_marked(conference_bridge, conference_bridge_user);
 	} else {
 		post_join_unmarked(conference_bridge, conference_bridge_user);
+	}
+
+	/* check to see if recording needs to be started or not */
+	if (ast_test_flag(&conference_bridge->b_profile, BRIDGE_OPT_RECORD_CONFERENCE) && !conf_is_recording(conference_bridge)) {
+		start_record = 1;
 	}
 
 	ao2_unlock(conference_bridge);
@@ -2075,6 +2119,86 @@
 	return 0;
 }
 
+static int action_confbridgestartrecord(struct mansession *s, const struct message *m)
+{
+	const char *conference = astman_get_header(m, "Conference");
+	const char *recordfile = astman_get_header(m, "RecordFile");
+	struct conference_bridge *bridge = NULL;
+	struct conference_bridge tmp;
+
+	if (ast_strlen_zero(conference)) {
+		astman_send_error(s, m, "No Conference name provided.");
+		return 0;
+	}
+	if (!ao2_container_count(conference_bridges)) {
+		astman_send_error(s, m, "No active conferences.");
+		return 0;
+	}
+
+	ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	if (!bridge) {
+		astman_send_error(s, m, "No Conference by that name found.");
+		return 0;
+	}
+
+	if (conf_is_recording(bridge)) {
+		astman_send_error(s, m, "Conference is already being recorded.");
+		ao2_ref(bridge, -1);
+		return 0;
+	}
+
+	if (!ast_strlen_zero(recordfile)) {
+		ao2_lock(bridge);
+		ast_copy_string(bridge->b_profile.rec_file, recordfile, sizeof(bridge->b_profile.rec_file));
+		ao2_unlock(bridge);
+	}
+
+	if (conf_start_record(bridge)) {
+		astman_send_error(s, m, "Internal error starting conference recording.");
+		ao2_ref(bridge, -1);
+		return 0;
+	}
+
+	ao2_ref(bridge, -1);
+	astman_send_ack(s, m, "Conference Recording Started.");
+	return 0;
+}
+static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
+{
+	const char *conference = astman_get_header(m, "Conference");
+	struct conference_bridge *bridge = NULL;
+	struct conference_bridge tmp;
+
+	if (ast_strlen_zero(conference)) {
+		astman_send_error(s, m, "No Conference name provided.");
+		return 0;
+	}
+	if (!ao2_container_count(conference_bridges)) {
+		astman_send_error(s, m, "No active conferences.");
+		return 0;
+	}
+
+	ast_copy_string(tmp.name, conference, sizeof(tmp.name));
+	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	if (!bridge) {
+		astman_send_error(s, m, "No Conference by that name found.");
+		return 0;
+	}
+
+	if (conf_stop_record(bridge)) {
+		astman_send_error(s, m, "Internal error while stopping recording.");
+		ao2_ref(bridge, -1);
+		return 0;
+	}
+
+	ao2_ref(bridge, -1);
+	astman_send_ack(s, m, "Conference Recording Stopped.");
+	return 0;
+}
+
+
+
 /*! \brief Called when module is being unloaded */
 static int unload_module(void)
 {
@@ -2099,6 +2223,8 @@
 	res |= ast_manager_unregister("ConfbridgeKick");
 	res |= ast_manager_unregister("ConfbridgeUnlock");
 	res |= ast_manager_unregister("ConfbridgeLock");
+	res |= ast_manager_unregister("ConfbridgeStartRecord");
+	res |= ast_manager_unregister("ConfbridgeStopRecord");
 
 	return res;
 }
@@ -2135,6 +2261,8 @@
 	res |= ast_manager_register_xml("ConfbridgeKick", EVENT_FLAG_CALL, action_confbridgekick);
 	res |= ast_manager_register_xml("ConfbridgeUnlock", EVENT_FLAG_CALL, action_confbridgeunlock);
 	res |= ast_manager_register_xml("ConfbridgeLock", EVENT_FLAG_CALL, action_confbridgelock);
+	res |= ast_manager_register_xml("ConfbridgeStartRecord", EVENT_FLAG_CALL, action_confbridgestartrecord);
+	res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord);
 
 	conf_load_config(0);
 	return res;




More information about the asterisk-commits mailing list