Member
Last active 8 years ago
I cannot get it to work. I deleted all the amportal.conf references in the recording_fop2.pl and I made sure that the config knows all the database variables. Still it records perfect. Only it won't combine the recordings and it won't show up in the fop2 interface.
Can you please help me? I don't know where to continu.
Below is my current recording_fop2.pl (I have the original file in backup)
#!/usr/bin/perl -w # Script to store recordings initiated by FOP2 inside a mysql table # and move it to a destination folder. Together with the recordings.php # aplication users will be allowed to browse/search/listen to recordings # initiated by themselves or by administrators (all or queuemanager # permission) # In order for this script to work it must be owned by the same user # asterisk is running as. # # You also have to check the locations of both sox and soxmix and # the fop2.cfg file # # In fop2.cfg you MUST set the monitor filename and configurations to be: # # monitor_filename=/var/spool/asterisk/monitor/${ORIG_EXTENSION}_${DEST_EXTENSION}_%h%i%s_${UNIQUEID} # monitor_format=wav # monitor_mix=true # monitor_exec=/usr/local/fop2/recording_fop2.pl # # The script must run on the same machine asterisk is installed. Be # sure the DESTFOLDER exists and it is owned by the asterisk user. # # The script will insert records to the fop2recordings table in the # fop2 database. # #CREATE TABLE `fop2recordings` ( # `id` int(11) NOT NULL auto_increment, # `uniqueid` varchar(50) default NULL, # `datetime` datetime default NULL, # `ownerextension` varchar(20) default NULL, # `targetextension` varchar(20) default NULL, # `filename` tinytext, # `duration` int(11) default '0', # `context` varchar(200) default NULL, # PRIMARY KEY (`id`), # UNIQUE KEY `uni` (`uniqueid`) #) use strict; use Fcntl; use File::Copy; use File::Basename; use File::Path qw(mkpath); use DBI; # database connection my $MYSQLUSER = "root"; my $MYSQLPASS = "Teij6boh"; my $MYSQLDBNAME = "fop2"; my $MYSQLTABLE = "fop2recordings"; my $MYSQLHOST = "192.168.1.4"; # configurable variables my $DESTFOLDER = "/var/spool/asterisk/monitor/fop2"; my $SOX = `which sox`; my $SOXMIX = `which soxmix`; chomp($SOX); chomp($SOXMIX); my $plainmix = 0; if($SOXMIX eq "") { $SOXMIX = "$SOX -m "; $plainmix=1; } my $dbh; # Remove trailing slash $DESTFOLDER =~ s|/\z||; if( $#ARGV < 2 ){ die("Not enough arguments\n\nUsage: recording_fop2.pl sound-in.wav sound-out.wav sound.wav\n"); } sub connect_db() { my $return = 0; my %attr = ( PrintError => 0, RaiseError => 0, ); my $dsn = "DBI:mysql:database=$MYSQLDBNAME;host=$MYSQLHOST"; $dbh->disconnect if $dbh; $dbh = DBI->connect( $dsn, $MYSQLUSER, $MYSQLPASS, \%attr ) or $return = 1; return $return; } # command line variables my $LEFT = shift(@ARGV); my $RIGHT = shift(@ARGV); my $OUT = shift(@ARGV); # do not edit below this line if ( !-f $SOX ) { die("No sox found $SOX"); exit 1; } my $SOXVERSION = `$SOX -h 2>&1 | head -n 1 | cut -d\. -f1 | awk '{print \$3}' | sed 's/[A-Za-z]//g'`; if ( !-f $LEFT ) { die("No left sound file found"); exit 1; } if ( !-f $RIGHT ) { die("No right sound file found"); exit 1; } my $time = localtime(time); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); my $newtime = sprintf ("%4d-%02d-%02d",$year+1900,$mon+1,$mday); if($SOXVERSION>12) { # New SOX system("$SOX $LEFT -c 2 $LEFT-tmp.wav remix 1 0"); system("$SOX $RIGHT -c 2 $RIGHT-tmp.wav remix 0 1"); } else { # Old SOX system("$SOX $LEFT -c 2 $LEFT-tmp.wav pan -1"); system("$SOX $RIGHT -c 2 $RIGHT-tmp.wav pan 1"); } if($plainmix==1) { system("$SOXMIX $LEFT-tmp.wav $RIGHT-tmp.wav $OUT"); } else { system("$SOXMIX -v 1 $LEFT-tmp.wav -v 1 $RIGHT-tmp.wav -v 1 $OUT"); } if ( -f $LEFT . "-tmp.wav" ) { unlink $LEFT . "-tmp.wav"; } if ( -f $RIGHT . "-tmp.wav" ) { unlink $RIGHT . "-tmp.wav"; } if ( -f $OUT ) { unlink $LEFT; unlink $RIGHT; } my $fnm = $OUT; my $basename = basename($OUT); my ( $exten, $targetexten, $fullmbox, $uniqueid, $context ) = split( /_/, $basename ); if(!defined($context)) { $context=""; } $uniqueid =~ s/\.wav//g; sub wavduration { sysopen WAV, $fnm, O_RDONLY; my $riff; sysread WAV, $riff, 12; my $fmt; sysread WAV, $fmt, 24; my $data; sysread WAV, $data, 8; my ( $r1, $r2, $r3 ) = unpack "A4VA4", $riff; my ( $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8 ) = unpack "A4VvvVVvv", $fmt; my ( $d1, $d2 ) = unpack "A4V", $data; my $playlength = int( $d2 / $f6 ); return $playlength; } ## MAIN ************************************** my $seconds = 0; my $finalrecording=$fnm; if ( -e $fnm ) { $seconds = wavduration($fnm); } if ( -e $fnm ) { mkpath("$DESTFOLDER/$newtime"); my $res = copy( $fnm, "$DESTFOLDER/$newtime" ); if($res == 1) { #print "borro $fnm porque copie en $DESTFOLDER/$newtime $basename\n"; $finalrecording = "$DESTFOLDER/$newtime/$basename"; unlink $fnm; } else { #print "preservo $fnm porque no pude copiar\n"; $finalrecording = $fnm; } } my $whorecorded = $exten; my $whomrecorded = $targetexten; my $duration = $seconds; &connect_db(); my $query = "DESC fop2recordings"; my $res = $dbh->do($query); if(defined($res)) { $query = "INSERT INTO $MYSQLTABLE VALUES ('','$uniqueid',now(),'$whorecorded','$whomrecorded','$finalrecording','$duration','$context');"; $dbh->do($query); $dbh->disconnect if $dbh; } else { $query="CREATE TABLE `fop2recordings` ( `id` int(11) NOT NULL auto_increment, `uniqueid` varchar(50) default NULL, `datetime` datetime default NULL, `ownerextension` varchar(20) default NULL, `targetextension` varchar(20) default NULL, `filename` tinytext, `duration` int(11) default '0', `context` varchar(200) default NULL, PRIMARY KEY (`id`), UNIQUE KEY `uni` (`uniqueid`) ) "; $dbh->do($query); $query = "INSERT INTO $MYSQLTABLE VALUES ('','$uniqueid',now(),'$whorecorded','$whomrecorded','$finalrecording','$duration','$context');"; $dbh->do($query); $dbh->disconnect if $dbh;
I am having a issue. The recording function works. It records in and out. I get two separate audio files.
Issue 1: They are not compiled into 1 mix. Can this be solved from within fop2 or should I solve this from within asterisk?
Do you have any tips helping me in the right direction?
Issue 2: The recording won't show up in the tab. I can see the recording tab but nothing shows up. Also the database table is there but there a 0 rows in it. I guess this has to do with configuration of FOP2, do you have any directions for setting this?
I am using Asterisk 11.0.1.. I enabled the fop 2 config like this (for readability all explanation has been removed):
[general] ; AMI definitions manager_host=192.168.1.4 manager_port=5038 manager_user=user1 manager_secret=secret10 ;event_mask=agent,call,command,system,user,dialplan ;listen_port = 4445 ;restrict_host = www.asternic.org web_dir = /var/www/fop2 poll_interval = 86400 poll_voicemail = 1 monitor_ipaddress = 0 blind_transfer = 1 ; supervised_transfer = 1 ; force_parameter_delimiter = "," ; use_agentlogin = 0 ;master_key = 5678 spy_options="bq" ;persistent_spy=0 ; monitor_filename=g${DEST_EXTENSION}-${UNIQUEID} monitor_filename=/var/spool/asterisk/monitor/${ORIG_EXTENSION}_${DEST_EXTENSION}_%h%i%s_${UNIQUEID} monitor_format=wav monitor_mix=true monitor_exec=/usr/local/fop2/recording_fop2.pl ; monitor_exec=/var/lib/asterisk/bin/postrecording-script.sh ; notify_on_ringing = 1 ; notify_on_connect = 1 ; no_pickupmark=1 ; use_pickupchan=1 voicemail_path=/var/spool/asterisk/voicemail ;voicemail_path=dbi:ODBC:asterisk!voicemessages ; save_chat_log=1 ; khomp_gsm=Khomp/b0 ; dongle_gsm=dongle01 ; sms_api_url=http://GATEWAY_ADDRESS/cgi-bin/exec?cmd=api_queue_sms&username=USER&password=PASSWORD&content=${MESSAGE}&destination=${NUMBER}&api_version=0.05&channel=1 ; sms_api_method=GET ; sms_api_user=USER ; sms_api_password=PASSWORD ; sms_api_url=http://api.smsified.com/v1/smsmessaging/outbound/SERVICENUMBER/requests?address=${NUMBER}&message=${MESSAGE} ; sms_api_method=POST ; sms_api_user=USER ; sms_api_password=PASSWORD ; sms_api_response_error=error user=1001:secret1:all user=1005:secret2:all user=5000:secret3:all user=5005:secret2:all user=9000:secret3:all user=9001:secret1:all buttonfile=buttons.cfg ;ssl_certificate_file=/etc/pki/tls/certs/localhost.crt ;ssl_certificate_key_file=/etc/pki/tls/private/localhost.key ;#exec autoconfig-users-freepbx.sh
[EDIT] I am not using FreePBX. I am on a Asterisk only server. Setup from Tarball. So maybe it goes wrong when calling the amportal.conf because that's not availble for me. I am now going to adapt the recording_fop2.pl to make this work [/EDIT]
If you need anything else, please let me know!
Indeed, yesterday when I posted my message, I thought the same thing . I went checking my context and I now know whats wrong. I used a sub context in which the external line was not included. I switch the the "main" context in which it was included and now it works like a charm.
Of course the problem with the phonebook is now also solved.
Only thing which I think to be weird, is that asterisk with option -rvvvvvvvvvv wouldn't show me any message until I tried with another extension. But that's not you fault, that's an asterisk "fail".
Thank you for your quick response!
Now I can let our reception work with it and if they like it I will get back to you ;)
I have two small problems in FOP2. I am evaluating this piece of software before buying.
This is a weird error for me. When using the dialpad I can call extensions in my context. Other context are included through includes in the config files (maybe that's the problem?) And I cannot reach the other context nor make outgoing calls. When I look in my asterisk log (full) it shows not even a sign of trying to call. Normally it would give a blocked number or whatsoever.
The Phonebook works now after some tweaking. Only when I click a number in the phonebook it also won't call. Maybe the same problem?
I have the user setup as : user=5000:'password':all
The extension works because I can call 5001, 5002 and so on.
Further I really like the software. It is really responsive and works like a charm.