[Freeswitch-svn] [commit] r3951 - freeswitch/trunk/src/mod/applications/mod_commands

Freeswitch SVN anthm at freeswitch.org
Fri Jan 12 11:05:49 EST 2007


Author: anthm
Date: Fri Jan 12 11:05:49 2007
New Revision: 3951

Modified:
   freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c

Log:
add session_record api command

Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c	Fri Jan 12 11:05:49 2007
@@ -39,6 +39,7 @@
 static const char modname[] = "mod_commands";
 static switch_api_interface_t ctl_api_interface;
 static switch_api_interface_t uuid_bridge_api_interface;
+static switch_api_interface_t session_record_api_interface;
 static switch_api_interface_t status_api_interface;
 static switch_api_interface_t show_api_interface;
 static switch_api_interface_t pause_api_interface;
@@ -362,6 +363,62 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
+static switch_status_t session_record_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+    switch_core_session_t *session = NULL;
+	char *argv[4] = {0};
+    char *uuid = NULL, *action = NULL, *path = NULL;
+	int argc = 0;
+
+	if (isession) {
+		return SWITCH_STATUS_FALSE;
+	}
+	
+	if (switch_strlen_zero(cmd)) {
+        goto usage;
+    }
+
+	if ((argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) != 3) {
+        goto usage;
+    }
+
+    uuid = argv[0];
+    action = argv[1];
+    action = argv[2];
+    
+    if (!(session = switch_core_session_locate(uuid))) {
+		stream->write_function(stream, "-Error Cannot locate session!\n");
+        return SWITCH_STATUS_SUCCESS;
+    }
+    
+    if (switch_strlen_zero(action) || switch_strlen_zero(path)) {
+        goto usage;
+    }
+
+    if (!strcasecmp(action, "start")) {
+        switch_ivr_record_session(session, path, NULL);
+    } else if (!strcasecmp(action, "stop")) {
+        switch_ivr_stop_record_session(session, path);
+    } else {
+        goto usage;
+    }
+
+    goto done;
+
+ usage:
+
+    stream->write_function(stream, "USAGE: %s\n", session_record_api_interface.syntax);
+    return SWITCH_STATUS_SUCCESS;
+
+ done:
+
+    if (session) {
+        switch_core_session_rwunlock(session);
+    }
+
+    return SWITCH_STATUS_SUCCESS;
+}
+
 static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
 {
 	switch_core_session_t *session = NULL;
@@ -694,12 +751,20 @@
 	/*.next */ &hold_api_interface
 };
 
+static switch_api_interface_t session_record_api_interface = {
+	/*.interface_name */ "session_record",
+	/*.desc */ "session record",
+	/*.function */ session_record_function,
+	/*.syntax */ "<uuid> [start|stop] <path>",
+	/*.next */ &broadcast_api_interface
+};
+
 static switch_api_interface_t uuid_bridge_api_interface = {
 	/*.interface_name */ "uuid_bridge",
 	/*.desc */ "uuid_bridge",
 	/*.function */ uuid_bridge_function,
 	/*.syntax */ "<uuid> <other_uuid>",
-	/*.next */ &broadcast_api_interface
+	/*.next */ &session_record_api_interface
 };
 
 static switch_api_interface_t status_api_interface = {



More information about the Freeswitch-svn mailing list