aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-03 16:57:00 +0000
committermartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2004-02-03 16:57:00 +0000
commitf38bc8131c9eda8d0b0eabaafbaa53f4247989c4 (patch)
tree737412e9d633692be843c8429cc62df22fc5cfd7 /res
parent30674920f6b94533e355a87eaf823cf14bcba9ef (diff)
Add recording agent's calls patch. Basically the call starts recording when the agent picks up and the file is stamped with the agent's id and the timestamp. Also optionally a URL link to that file may be inserted in the userfield of the CDR record. By default the recorded file will be mixed if soxmix is available.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2121 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-xres/res_monitor.c51
-rwxr-xr-xres/res_parking.c12
2 files changed, 57 insertions, 6 deletions
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 7cf22e812..676cb3258 100755
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <libgen.h> //dirname()
#include <asterisk/lock.h>
#include <asterisk/channel.h>
@@ -48,6 +49,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
const char *fname_base, int need_lock )
{
int res = 0;
+ char tmp[256];
if( need_lock ) {
if (ast_mutex_lock(&chan->lock)) {
@@ -73,11 +75,19 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
/* Determine file names */
if( fname_base && strlen( fname_base ) ) {
+ int directory = strchr(fname_base, '/') ? 1 : 0;
+ /* try creating the directory just in case it doesn't exist */
+ if (directory) {
+ char *name = strdup(fname_base);
+ snprintf(tmp, sizeof(tmp), "mkdir -p %s",dirname(name));
+ free(name);
+ system(tmp);
+ }
snprintf( monitor->read_filename, FILENAME_MAX, "%s/%s-in",
- AST_MONITOR_DIR, fname_base );
+ directory ? "" : AST_MONITOR_DIR, fname_base );
snprintf( monitor->write_filename, FILENAME_MAX, "%s/%s-out",
- AST_MONITOR_DIR, fname_base );
- *monitor->filename_base = 0;
+ directory ? "" : AST_MONITOR_DIR, fname_base );
+ strncpy(monitor->filename_base, fname_base, sizeof(monitor->filename_base) - 1);
} else {
ast_mutex_lock( &monitorlock );
snprintf( monitor->read_filename, FILENAME_MAX, "%s/audio-in-%ld",
@@ -93,6 +103,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
}
snprintf( monitor->filename_base, FILENAME_MAX, "%s/%s",
AST_MONITOR_DIR, channel_name );
+ monitor->filename_changed = 1;
free( channel_name );
}
@@ -164,7 +175,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
ast_closestream( chan->monitor->write_stream );
}
- if(chan->monitor->filename_base&&strlen(chan->monitor->filename_base)) {
+ if(chan->monitor->filename_changed&&strlen(chan->monitor->filename_base)) {
if( ast_fileexists(chan->monitor->read_filename,NULL,NULL) > 0 ) {
snprintf( filename, FILENAME_MAX, "%s-in",
chan->monitor->filename_base );
@@ -191,7 +202,19 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
chan->monitor->write_filename );
}
}
-
+ if (chan->monitor->joinfiles && strlen(chan->monitor->filename_base)) {
+ char tmp[255];
+ char *format = !strcasecmp(chan->monitor->format,"wav49") ? "WAV" : chan->monitor->format;
+ char *name = chan->monitor->filename_base;
+ int directory = strchr(name, '/') ? 1 : 0;
+ char *dir = directory ? "" : AST_MONITOR_DIR;
+ snprintf(tmp, sizeof(tmp), "nice -n 19 soxmix %s/%s-in.%s %s/%s-out.%s %s/%s.%s && rm -rf %s/%s-* &", dir, name, format, dir, name, format, dir, name, format, dir, name);
+#if 0
+ ast_verbose("executing %s\n",tmp);
+#endif
+ if (system(tmp) == -1)
+ ast_log(LOG_WARNING, "You might not have the soxmix installed and available in the path, please check.\n");
+ }
free( chan->monitor->format );
free( chan->monitor );
chan->monitor = NULL;
@@ -207,6 +230,7 @@ int ast_monitor_stop( struct ast_channel *chan, int need_lock )
int ast_monitor_change_fname( struct ast_channel *chan,
const char *fname_base, int need_lock )
{
+ char tmp[256];
if( (!fname_base) || (!strlen(fname_base)) ) {
ast_log( LOG_WARNING,
"Cannot change monitor filename of channel %s to null",
@@ -222,8 +246,17 @@ int ast_monitor_change_fname( struct ast_channel *chan,
}
if( chan->monitor ) {
+ int directory = strchr(fname_base, '/') ? 1 : 0;
+ /* try creating the directory just in case it doesn't exist */
+ if (directory) {
+ char *name = strdup(fname_base);
+ snprintf(tmp, sizeof(tmp), "mkdir -p %s",dirname(name));
+ free(name);
+ system(tmp);
+ }
+
snprintf( chan->monitor->filename_base, FILENAME_MAX, "%s/%s",
- AST_MONITOR_DIR, fname_base );
+ directory ? "" : AST_MONITOR_DIR, fname_base );
} else {
ast_log( LOG_WARNING,
"Cannot change monitor filename of channel %s to %s, monitoring not started",
@@ -379,6 +412,12 @@ static int change_monitor_action(struct mansession *s, struct message *m)
return 0;
}
+void ast_monitor_setjoinfiles(struct ast_channel *chan, int turnon)
+{
+ if (chan->monitor)
+ chan->monitor->joinfiles = turnon;
+}
+
int load_module(void)
{
ast_register_application( "Monitor", start_monitor_exec, monitor_synopsis, monitor_descrip );
diff --git a/res/res_parking.c b/res/res_parking.c
index 0d0a714c9..5c8049822 100755
--- a/res/res_parking.c
+++ b/res/res_parking.c
@@ -234,6 +234,18 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allo
return -1;
peer->appl = "Bridged Call";
peer->data = chan->name;
+ /* copy the userfield from the B-leg to A-leg if applicable */
+ if (chan->cdr && peer->cdr && strlen(peer->cdr->userfield)) {
+ char tmp[256];
+ if (strlen(chan->cdr->userfield)) {
+ snprintf(tmp, sizeof(tmp), "%s;%s",chan->cdr->userfield, peer->cdr->userfield);
+ ast_cdr_appenduserfield(chan, tmp);
+ } else
+ ast_cdr_setuserfield(chan, peer->cdr->userfield);
+ /* free the peer's cdr without ast_cdr_free complaining */
+ free(peer->cdr);
+ peer->cdr = NULL;
+ }
for (;;) {
res = ast_channel_bridge(chan, peer, (allowdisconnect||allowredirect_out ? AST_BRIDGE_DTMF_CHANNEL_0 : 0) + (allowredirect_in ? AST_BRIDGE_DTMF_CHANNEL_1 : 0), &f, &who);
if (res < 0) {