no boom boom boom

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15300 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-10-31 00:22:59 +00:00
parent fffc68bfd1
commit e0f76a3c6b
1 changed files with 13 additions and 7 deletions

View File

@ -136,7 +136,7 @@ static switch_status_t start_capture(switch_core_session_t *session, unsigned in
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
static void do_snap(switch_core_session_t *session) static switch_status_t do_snap(switch_core_session_t *session)
{ {
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_media_bug_t *bug = switch_channel_get_private(channel, "snapshot"); switch_media_bug_t *bug = switch_channel_get_private(channel, "snapshot");
@ -153,7 +153,7 @@ static void do_snap(switch_core_session_t *session)
struct cap_cb *cb = (struct cap_cb *) switch_core_media_bug_get_user_data(bug); struct cap_cb *cb = (struct cap_cb *) switch_core_media_bug_get_user_data(bug);
if (!cb) { if (!cb) {
return; return SWITCH_STATUS_FALSE;
} }
switch_time_exp_lt(&tm, switch_time_make(switch_epoch_time_now(NULL), 0)); switch_time_exp_lt(&tm, switch_time_make(switch_epoch_time_now(NULL), 0));
@ -174,7 +174,7 @@ static void do_snap(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE); switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
return; return SWITCH_STATUS_FALSE;
} }
switch_mutex_lock(cb->mutex); switch_mutex_lock(cb->mutex);
@ -191,6 +191,8 @@ static void do_snap(switch_core_session_t *session)
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Wrote %s\n", file); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Wrote %s\n", file);
} }
return SWITCH_STATUS_SUCCESS;
} }
#define SNAP_SYNTAX "start <sec> <read|write>" #define SNAP_SYNTAX "start <sec> <read|write>"
@ -200,12 +202,14 @@ SWITCH_STANDARD_APP(snapshot_app_function)
int argc = 0; int argc = 0;
char *lbuf = NULL; char *lbuf = NULL;
switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING; switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING;
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))) { if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))) {
argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
} }
if (argc < 1) { if (argc < 1) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SNAP_SYNTAX); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SNAP_SYNTAX);
return;
} }
if (!strcasecmp(argv[0], "start")) { if (!strcasecmp(argv[0], "start")) {
@ -243,7 +247,6 @@ SWITCH_STANDARD_APP(snapshot_app_function)
do_snap(session); do_snap(session);
return; return;
} }
} }
@ -260,12 +263,13 @@ SWITCH_STANDARD_API(snapshot_function)
if (zstr(cmd) || argc < 1 || zstr(argv[0])) { if (zstr(cmd) || argc < 1 || zstr(argv[0])) {
stream->write_function(stream, "-USAGE: %s\n", SNAP_API_SYNTAX); stream->write_function(stream, "-USAGE: %s\n", SNAP_API_SYNTAX);
goto done;
} else { } else {
switch_core_session_t *lsession = NULL; switch_core_session_t *lsession = NULL;
if ((lsession = switch_core_session_locate(argv[0]))) { if ((lsession = switch_core_session_locate(argv[0]))) {
if (!strcasecmp(argv[1], "snap")) { if (!strcasecmp(argv[1], "snap")) {
do_snap(lsession); status = do_snap(lsession);
} else if (!strcasecmp(argv[1], "start")) { } else if (!strcasecmp(argv[1], "start")) {
char *sec = argv[1]; char *sec = argv[1];
char *fl = argv[2]; char *fl = argv[2];
@ -293,8 +297,8 @@ SWITCH_STANDARD_API(snapshot_function)
if (!base) { if (!base) {
base = "mod_snapshot"; base = "mod_snapshot";
} }
start_capture(lsession, seconds, flags, base); status = start_capture(lsession, seconds, flags, base);
} }
switch_core_session_rwunlock(lsession); switch_core_session_rwunlock(lsession);
@ -307,6 +311,8 @@ SWITCH_STANDARD_API(snapshot_function)
stream->write_function(stream, "-ERR Operation Failed\n"); stream->write_function(stream, "-ERR Operation Failed\n");
} }
done:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }