Tony Mountifield
2007-Nov-06 11:49 UTC
[asterisk-users] Recording just first part of call?
I know that I can record the contents of a call by calling Monitor() or MixMonitor() from the dialplan just before invoking Dial(). I have a potential customer who wants only the first minute of each call recorded (for identification purposes, without the storage overhead of keeping the complete call). Can anyone here think of the easiest way to do this? The only possibilities I can think of are: a) Add a new option to Monitor() or MixMonitor() to stop recording after a specified length of time. b) Record the whole call and post-process the recording file to discard all except the required first part. Any better ideas? Thanks in advance! Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
Anselm Martin Hoffmeister
2007-Nov-06 12:39 UTC
[asterisk-users] Recording just first part of call?
Am Dienstag, den 06.11.2007, 11:49 +0000 schrieb Tony Mountifield:> I know that I can record the contents of a call by calling Monitor() > or MixMonitor() from the dialplan just before invoking Dial(). > > I have a potential customer who wants only the first minute of each > call recorded (for identification purposes, without the storage overhead > of keeping the complete call). > > Can anyone here think of the easiest way to do this? The only possibilities > I can think of are: > > a) Add a new option to Monitor() or MixMonitor() to stop recording after > a specified length of time. > > b) Record the whole call and post-process the recording file to discard > all except the required first part.The asterisk manager API seems to offer a "StopMonitor" command, which is basically the same as the StopMonitor() extensions.conf command, afaik. A quick ugly hack (and well, I did not have my coffee yet, so caveat emptor): Before calling the "Monitor()" in extensions.conf, call an AGI that kind of starts a timer. This AGI would have to know about the Channel used (you surely figure how to do that, I am to lazy to look it up right now). Something like 8<===#!/usr/bin/php -q GLOBAL $stdin, $stdout; ob_implicit_flush(false); set_time_limit(30); error_reporting(0); $stdin = fopen( 'php://stdin', 'r' ); $stdout = fopen( 'php://stdout', 'w' ); while ( !feof($stdin) ) { $temp = fgets( $stdin ); $temp = str_replace( "\n", "", $temp ); $s = explode( ":", $temp ); $agivar[$s[0]] = trim( $s[1] ); if ( ( $temp == "") || ($temp == "\n") ) { break; } } $channel = $agivar[agi_channel]; system ("screen -d -m /usr/local/bin/stop-recording ".$channel); exit(0); ====>8 The script at /usr/local/bin/stop-recording could be a bash script: 8<===#!/bin/bash sleep 60 # Before Stopping the monitor, you want to make sure that # about 60 seconds went past # Perhaps add some leeway if the other party answered # after ring no. 5 or so # The following should all be on one line, but emails tend to break... ( echo -e "Action: login\nUsername: foo\nSecret: bar\nEvents: off\n\n" ; sleep 1 ; echo -e "Action: StopMonitor\nChannel: $1\n\n" ; sleep 1 ) | netcat localhost 5038 >/dev/null 2>/dev/null ====>8 You would want to add a check that the original call is the one to be StopMonitored() - e.g. if the caller hangs up and redials within a few seconds, the second call would possibly be terminated. You could manage this by writing the "channel" to a temporary file in the AGI, removing the file after call termination. The Bash script would then read the channel from the file, or just silently terminate if the file is not there. This is just an idea. It needs some tweaking here and there, and there probably are way more elegant methods for solving the task... :-) BR Anselm
If you're up to using the Manager interface and your programming language of choice, you could poll the list of active calls and stop recording when their duration exceeds a minute. According to my docs, res/res_monitor.c implements manager commands that could be used to halt current recordings. The Asterisk-Java library has a "StatusAction" and "StopMonitorAction," if Java is a language candidate for an application you might write. Martin Smith, Systems Developer martins at bebr.ufl.edu Bureau of Economic and Business Research University of Florida (352) 392-0171 Ext. 221> -----Original Message----- > From: asterisk-users-bounces at lists.digium.com > [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of > Tony Mountifield > Sent: Tuesday, November 06, 2007 6:50 AM > To: asterisk-users at lists.digium.com > Subject: [asterisk-users] Recording just first part of call? > > I know that I can record the contents of a call by calling Monitor() > or MixMonitor() from the dialplan just before invoking Dial(). > > I have a potential customer who wants only the first minute of each > call recorded (for identification purposes, without the > storage overhead > of keeping the complete call). > > Can anyone here think of the easiest way to do this? The only > possibilities > I can think of are: > > a) Add a new option to Monitor() or MixMonitor() to stop > recording after > a specified length of time. > > b) Record the whole call and post-process the recording file > to discard > all except the required first part. > > Any better ideas? > > Thanks in advance! > > Tony > > -- > Tony Mountifield > Work: tony at softins.co.uk - http://www.softins.co.uk > Play: tony at mountifield.org - http://tony.mountifield.org > > _______________________________________________ > --Bandwidth and Colocation Provided by http://www.api-digital.com-- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >