[Freeswitch-svn] [commit] r5236 - in freeswitch/trunk/src: . include include/private mod/applications/mod_commands mod/applications/mod_playback
Freeswitch SVN
anthm at freeswitch.org
Thu May 31 10:42:23 EDT 2007
Author: anthm
Date: Thu May 31 10:42:23 2007
New Revision: 5236
Modified:
freeswitch/trunk/src/include/private/switch_core_pvt.h
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c
freeswitch/trunk/src/switch_caller.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_core_media_bug.c
freeswitch/trunk/src/switch_ivr_async.c
Log:
add timout to record and time tables to all the channel events
Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h (original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h Thu May 31 10:42:23 2007
@@ -136,6 +136,7 @@
void *user_data;
uint32_t flags;
uint8_t ready;
+ time_t stop_time;
struct switch_media_bug *next;
};
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Thu May 31 10:42:23 2007
@@ -130,7 +130,7 @@
*/
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
switch_media_bug_callback_t callback,
- void *user_data, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
+ void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug);
/*!
\brief Obtain private data from a media bug
\param bug the bug to get the data from
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Thu May 31 10:42:23 2007
@@ -198,7 +198,7 @@
\param fh file handle to use (NULL for builtin one)
\return SWITCH_STATUS_SUCCESS if all is well
*/
-SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh);
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh);
/*!
\brief Stop Recording a session
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 Thu May 31 10:42:23 2007
@@ -550,6 +550,7 @@
char *mycmd = NULL, *argv[4] = { 0 };
char *uuid = NULL, *action = NULL, *path = NULL;
int argc = 0;
+ uint32_t limit = 0;
if (session) {
return SWITCH_STATUS_FALSE;
@@ -570,7 +571,8 @@
uuid = argv[0];
action = argv[1];
path = argv[2];
-
+ limit = argv[3] ? atoi(argv[3]) : 0;
+
if (!(rsession = switch_core_session_locate(uuid))) {
stream->write_function(stream, "-Error Cannot locate session!\n");
return SWITCH_STATUS_SUCCESS;
@@ -581,7 +583,7 @@
}
if (!strcasecmp(action, "start")) {
- switch_ivr_record_session(rsession, path, NULL);
+ switch_ivr_record_session(rsession, path, limit, NULL);
} else if (!strcasecmp(action, "stop")) {
switch_ivr_stop_record_session(rsession, path);
} else {
@@ -1230,7 +1232,7 @@
/*.interface_name */ "session_record",
/*.desc */ "session record",
/*.function */ session_record_function,
- /*.syntax */ "<uuid> [start|stop] <path>",
+ /*.syntax */ "<uuid> [start|stop] <path> [<limit>]",
/*.next */ &broadcast_api_interface
};
Modified: freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_playback/mod_playback.c Thu May 31 10:42:23 2007
@@ -142,6 +142,11 @@
path = switch_core_session_strdup(session, data);
if ((p = strchr(path, '+'))) {
+ char *q = p - 1;
+ while(q && *q == ' ') {
+ *q = '\0';
+ q--;
+ }
*p++ = '\0';
limit = atoi(p);
}
@@ -158,10 +163,24 @@
static void record_session_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel;
+ char *p, *path = NULL;
+ uint32_t limit = 0;
+
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
- switch_ivr_record_session(session, data, NULL);
+ path = switch_core_session_strdup(session, data);
+ if ((p = strchr(path, '+'))) {
+ char *q = p - 1;
+ while(q && *q == ' ') {
+ *q = '\0';
+ q--;
+ }
+ *p++ = '\0';
+ limit = atoi(p);
+ }
+
+ switch_ivr_record_session(session, path, limit, NULL);
}
Modified: freeswitch/trunk/src/switch_caller.c
==============================================================================
--- freeswitch/trunk/src/switch_caller.c (original)
+++ freeswitch/trunk/src/switch_caller.c Thu May 31 10:42:23 2007
@@ -193,6 +193,16 @@
snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->chan_name);
}
+ if (caller_profile->times) {
+ snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
+ snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
+ snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
+ snprintf(header_name, sizeof(header_name), "%s-Channel-Transfer-Time", prefix);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
+ }
snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "yes" : "no");
@@ -203,7 +213,7 @@
snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
-
+
}
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu May 31 10:42:23 2007
@@ -232,7 +232,7 @@
switch_mutex_lock(bp->read_mutex);
switch_buffer_write(bp->raw_read_buffer, read_frame->data, read_frame->datalen);
if (bp->callback) {
- if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE) {
+ if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ) == SWITCH_FALSE || (bp->stop_time && bp->stop_time >= time(NULL))) {
bp->ready = 0;
if (last) {
last->next = bp->next;
@@ -505,6 +505,11 @@
}
}
+ if (bp->stop_time && bp->stop_time >= time(NULL)) {
+ ok = SWITCH_FALSE;
+ }
+
+
if (ok == SWITCH_FALSE) {
bp->ready = 0;
if (last) {
Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c (original)
+++ freeswitch/trunk/src/switch_core_media_bug.c Thu May 31 10:42:23 2007
@@ -144,7 +144,7 @@
#define MAX_BUG_BUFFER 1024 * 512
SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *session,
switch_media_bug_callback_t callback,
- void *user_data, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
+ void *user_data, time_t stop_time, switch_media_bug_flag_t flags, switch_media_bug_t **new_bug)
{
switch_media_bug_t *bug, *bp;
switch_size_t bytes;
@@ -170,6 +170,7 @@
bug->session = session;
bug->flags = flags;
bug->ready = 1;
+ bug->stop_time = stop_time;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
bytes = session->read_codec->implementation->bytes_per_frame;
Modified: freeswitch/trunk/src/switch_ivr_async.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_async.c (original)
+++ freeswitch/trunk/src/switch_ivr_async.c Thu May 31 10:42:23 2007
@@ -147,7 +147,7 @@
}
-SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, switch_file_handle_t *fh)
+SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t *session, char *file, uint32_t limit, switch_file_handle_t *fh)
{
switch_channel_t *channel;
switch_codec_t *read_codec;
@@ -155,6 +155,7 @@
const char *vval;
switch_media_bug_t *bug;
switch_status_t status;
+ time_t to = 0;
if (!fh) {
if (!(fh = switch_core_session_alloc(session, sizeof(*fh)))) {
@@ -220,9 +221,11 @@
switch_channel_set_variable(channel, "RECORD_DATE", NULL);
}
+ if (limit) {
+ to = time(NULL) + limit;
+ }
-
- if ((status = switch_core_media_bug_add(session, record_callback, fh, SMBF_BOTH, &bug)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = switch_core_media_bug_add(session, record_callback, fh, to, SMBF_BOTH, &bug)) != SWITCH_STATUS_SUCCESS) {
switch_core_file_close(fh);
return status;
}
@@ -312,7 +315,7 @@
switch_channel_answer(channel);
- if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = switch_core_media_bug_add(session, inband_dtmf_callback, pvt, 0, SMBF_READ_STREAM, &bug)) != SWITCH_STATUS_SUCCESS) {
return status;
}
@@ -597,7 +600,7 @@
sth->session = session;
sth->ah = ah;
- if ((status = switch_core_media_bug_add(session, speech_callback, sth, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) {
+ if ((status = switch_core_media_bug_add(session, speech_callback, sth, 0, SMBF_READ_STREAM, &sth->bug)) != SWITCH_STATUS_SUCCESS) {
switch_core_asr_close(ah, &flags);
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return status;
More information about the Freeswitch-svn
mailing list