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

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


Author: dvossel
Date: Thu Mar 24 16:56:40 2011
New Revision: 311673

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311673
Log:
CLI commands for starting/stopping a confbridge recording

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=311673&r1=311672&r2=311673
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Thu Mar 24 16:56:40 2011
@@ -1825,7 +1825,6 @@
 	return CLI_SUCCESS;
 }
 
-
 static char *handle_cli_confbridge_lock(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	switch (cmd) {
@@ -1876,6 +1875,94 @@
 	return CLI_SUCCESS;
 }
 
+static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	const char *rec_file = NULL;
+	struct conference_bridge *bridge = NULL;
+	struct conference_bridge tmp;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge record start";
+		e->usage =
+			"Usage: confbridge record start <conference> <file>\n"
+			"       <file> is optional, Otherwise the bridge profile\n"
+			"       record file will be used.  If the bridge profile\n"
+			"       has no record file specified, a file will automatically\n"
+			"       be generated in the monitor directory\n";
+		return NULL;
+	case CLI_GENERATE:
+		if (a->pos == 3) {
+			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+		}
+		return NULL;
+	}
+	if (a->argc < 4) {
+		return CLI_SHOWUSAGE;
+	}
+	if (a->argc == 5) {
+		rec_file = a->argv[4];
+	}
+
+	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	if (!bridge) {
+		ast_cli(a->fd, "Conference not found.\n");
+		return CLI_SUCCESS;
+	}
+	if (conf_is_recording(bridge)) {
+		ast_cli(a->fd, "Conference is already being recorded.\n");
+		ao2_ref(bridge, -1);
+		return CLI_SUCCESS;
+	}
+	if (!ast_strlen_zero(rec_file)) {
+		ao2_lock(bridge);
+		ast_copy_string(bridge->b_profile.rec_file, rec_file, sizeof(bridge->b_profile.rec_file));
+		ao2_unlock(bridge);
+	}
+	if (conf_start_record(bridge)) {
+		ast_cli(a->fd, "Could not start recording due to internal error.\n");
+		ao2_ref(bridge, -1);
+		return 0;
+	}
+	ast_cli(a->fd, "Recording started\n");
+	ao2_ref(bridge, -1);
+	return CLI_SUCCESS;
+}
+
+static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	struct conference_bridge *bridge = NULL;
+	struct conference_bridge tmp;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "confbridge record stop";
+		e->usage =
+			"Usage: confbridge record stop <conference>\n";
+		return NULL;
+	case CLI_GENERATE:
+		if (a->pos == 3) {
+			return complete_confbridge_name(a->line, a->word, a->pos, a->n);
+		}
+		return NULL;
+	}
+	if (a->argc != 4) {
+		return CLI_SHOWUSAGE;
+	}
+
+	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
+	bridge = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	if (!bridge) {
+		ast_cli(a->fd, "Conference not found.\n");
+		return CLI_SUCCESS;
+	}
+	conf_stop_record(bridge);
+	ast_cli(a->fd, "Recording stopped.\n");
+	ao2_ref(bridge, -1);
+	return CLI_SUCCESS;
+}
+
 static struct ast_cli_entry cli_confbridge[] = {
 	AST_CLI_DEFINE(handle_cli_confbridge_list, "List conference bridges and participants."),
 	AST_CLI_DEFINE(handle_cli_confbridge_kick, "Kick participants out of conference bridges."),
@@ -1883,6 +1970,8 @@
 	AST_CLI_DEFINE(handle_cli_confbridge_unmute, "Mute a participant."),
 	AST_CLI_DEFINE(handle_cli_confbridge_lock, "Lock a conference."),
 	AST_CLI_DEFINE(handle_cli_confbridge_unlock, "Unlock a conference."),
+	AST_CLI_DEFINE(handle_cli_confbridge_start_record, "Start recording a conference"),
+	AST_CLI_DEFINE(handle_cli_confbridge_stop_record, "Stop recording a conference."),
 };
 static struct ast_custom_function confbridge_function = {
 	.name = "CONFBRIDGE",




More information about the asterisk-commits mailing list