Quantcast
Channel: General Help - FreePBX Community Forums
Viewing all articles
Browse latest Browse all 12604

QueueMember Pausing Recording from Queue

$
0
0

@myauch wrote:

Hi folks,

The Story
My company uses a queue to ring our customer service team and QueueMetrics to monitor them. I was previously tasked with enabling recording for the queue. Simple enough, I turned on recording on the queue and everything worked. The original server is:
FreePBX 2.11.0.43
Call Recording 2.11.0.9
Asterisk 1.8.21.0
I was later tasked with allowing pausing of recordings for PCI compliance to take credit card numbers. My research led me to the fact that the Recording Module was rewritten and upgrading should allow this to work, and luckily enough we have a testbed VM of FreePBX running:
FreePBX 12.0.76.2
Call Recording 12.0.4
Asterisk 11.17.1

If it works correctly we will upgrade our main system to a newer version.

Setup and Issue
Testing on the FreePBX server I created a queue (805) and two extensions (2003, 2004). I set recording on the queue to Yes and placed extension 2004 in it as a static agent. Extension 2004 has Asterisk Dial Options overridden to TtrwWxX and On Demand Recording enabled. All other settings are pretty much default. When calling into the queue I found that:
1. Recordings were started successfully.
2. The first time pressing the *1 One Touch Recording feature code it would pause.
3. Pressing *1 again would resume.
4. All subsequent *1 presses would fail to pause the recording.

I have 12 text files full of debugging and various things I tested. I am NOT an Asterisk/FreePBX expert by any stretch, but it appeared based on my limited knowledge that:
1. The queue begins the recording on one channel
2. When the call is passed to a queue member that answers it and that member pauses and then restarts a recording, the recording is restarted on a different channel.
3. When again trying to pause subsequently, the One Touch Record feature does not pause the correct channel.

Debugging
FreePBX-SIP*CLI>
FreePBX-SIP*CLI>
FIRST PAUSE
-- Feature Found: apprecord exten: apprecord
-- Executing [s@macro-one-touch-record:1] Set("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS=") in new stack
-- Executing [s@macro-one-touch-record:2] System("SIP/2004-000061b2", "/var/lib/asterisk/bin/one_touch_record.php "SIP/2004-000061b2"") in new stack
== MixMonitor close filestream (mixed)
== End MixMonitor Recording SIP/2003-000061b1
-- Executing [s@macro-one-touch-record:3] NoOp("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS: [RECORDING_STOPPED]") in new stack
-- Executing [s@macro-one-touch-record:4] ExecIf("SIP/2004-000061b2", "0?Playback(beep)") in new stack
-- Executing [s@macro-one-touch-record:5] ExecIf("SIP/2004-000061b2", "1?Playback(beep&beep)") in new stack
-- Playing 'beep.ulaw' (language 'en')
-- Playing 'beep.ulaw' (language 'en')
-- Executing [s@macro-one-touch-record:6] ExecIf("SIP/2004-000061b2", "0?Playback(access-denied)") in new stack
-- Executing [s@macro-one-touch-record:7] MacroExit("SIP/2004-000061b2", "") in new stack
FreePBX-SIP*CLI>
FreePBX-SIP*CLI>
FIRST UNPAUSE
FreePBX-SIP*CLI>
-- Feature Found: apprecord exten: apprecord
-- Executing [s@macro-one-touch-record:1] Set("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS=") in new stack
-- Executing [s@macro-one-touch-record:2] System("SIP/2004-000061b2", "/var/lib/asterisk/bin/one_touch_record.php "SIP/2004-000061b2"") in new stack
== Begin MixMonitor Recording SIP/2003-000061b1
-- Executing [s@macro-one-touch-record:3] NoOp("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS: [RECORDING_STARTED]") in new stack
-- Executing [s@macro-one-touch-record:4] ExecIf("SIP/2004-000061b2", "1?Playback(beep)") in new stack
-- Playing 'beep.ulaw' (language 'en')
-- Executing [s@macro-one-touch-record:5] ExecIf("SIP/2004-000061b2", "0?Playback(beep&beep)") in new stack
-- Executing [s@macro-one-touch-record:6] ExecIf("SIP/2004-000061b2", "0?Playback(access-denied)") in new stack
-- Executing [s@macro-one-touch-record:7] MacroExit("SIP/2004-000061b2", "") in new stack
FreePBX-SIP*CLI>
SECOND PAUSE
FreePBX-SIP*CLI>
-- Feature Found: apprecord exten: apprecord
-- Executing [s@macro-one-touch-record:1] Set("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS=") in new stack
-- Executing [s@macro-one-touch-record:2] System("SIP/2004-000061b2", "/var/lib/asterisk/bin/one_touch_record.php "SIP/2004-000061b2"") in new stack
----> WHERE IS IT????? <-------
-- Executing [s@macro-one-touch-record:3] NoOp("SIP/2004-000061b2", "ONETOUCH_REC_SCRIPT_STATUS: [RECORDING_STOPPED]") in new stack
-- Executing [s@macro-one-touch-record:4] ExecIf("SIP/2004-000061b2", "0?Playback(beep)") in new stack
-- Executing [s@macro-one-touch-record:5] ExecIf("SIP/2004-000061b2", "1?Playback(beep&beep)") in new stack
-- Playing 'beep.ulaw' (language 'en')
-- Playing 'beep.ulaw' (language 'en')
-- Executing [s@macro-one-touch-record:6] ExecIf("SIP/2004-000061b2", "0?Playback(access-denied)") in new stack
-- Executing [s@macro-one-touch-record:7] MacroExit("SIP/2004-000061b2", "") in new stack
FreePBX-SIP*CLI>
FreePBX-SIP*CLI>

For funsies I hacked the one_touch_record.php file and told ot_debug to also output to my own log file, since I didn't have a clue where it was putting this information. The RECORDING/STOPPED lines are the ACTUAL results based on listening to the recording.
RECORDING
2016-06-15 08:55:20 - Checking pickup extension
2016-06-15 08:55:20 - Checking this extension
2016-06-15 08:55:20 - Don't know what this exten is
2016-06-15 08:55:20 - Device is SIP/2004
2016-06-15 08:55:20 - Found SIP/2004 from DIALEDPEERNUMBER as 2004
2016-06-15 08:55:20 - This exten is 2004
2016-06-15 08:55:20 - Checking on demand setting
2016-06-15 08:55:20 - Found Master channel SIP/2003-000061b7
2016-06-15 08:55:20 - Checking if channel SIP/2003-000061b7 is already recording
2016-06-15 08:55:20 - Found SIP/2003-000061b7 as RECORDING
2016-06-15 08:55:20 - RPM is YES in SIP/2004-000061b8
2016-06-15 08:55:20 - Stopping
STOPPED
2016-06-15 08:55:22 - Checking pickup extension
2016-06-15 08:55:22 - Checking this extension
2016-06-15 08:55:22 - This exten is 2004
2016-06-15 08:55:22 - Checking on demand setting
2016-06-15 08:55:22 - Found Master channel SIP/2003-000061b7
2016-06-15 08:55:22 - Checking if channel SIP/2003-000061b7 is already recording
2016-06-15 08:55:22 - Found SIP/2003-000061b7, but it's not recording
2016-06-15 08:55:22 - Checking recording polcy NO
2016-06-15 08:55:22 - Recording Channel
2016-06-15 08:55:22 - Setting CDR info
RECORDING
2016-06-15 08:55:24 - Checking pickup extension
2016-06-15 08:55:24 - Checking this extension
2016-06-15 08:55:24 - This exten is 2004
2016-06-15 08:55:24 - Checking on demand setting
2016-06-15 08:55:24 - Found Master channel SIP/2004-000061b8
2016-06-15 08:55:24 - Checking if channel SIP/2004-000061b8 is already recording
2016-06-15 08:55:24 - Found SIP/2004-000061b8 as RECORDING
2016-06-15 08:55:24 - RPM is YES in SIP/2004-000061b8
2016-06-15 08:55:24 - Stopping
RECORDING
2016-06-15 08:55:26 - Checking pickup extension
2016-06-15 08:55:26 - Checking this extension
2016-06-15 08:55:26 - This exten is 2004
2016-06-15 08:55:26 - Checking on demand setting
2016-06-15 08:55:26 - Found Master channel SIP/2004-000061b8
2016-06-15 08:55:26 - Checking if channel SIP/2004-000061b8 is already recording
2016-06-15 08:55:26 - Found SIP/2004-000061b8, but it's not recording
2016-06-15 08:55:26 - Checking recording polcy NO
2016-06-15 08:55:26 - Recording Channel
2016-06-15 08:55:26 - Setting CDR info
RECORDING
2016-06-15 08:55:27 - Checking pickup extension
2016-06-15 08:55:27 - Checking this extension
2016-06-15 08:55:27 - This exten is 2004
2016-06-15 08:55:27 - Checking on demand setting
2016-06-15 08:55:27 - Found Master channel SIP/2004-000061b8
2016-06-15 08:55:27 - Checking if channel SIP/2004-000061b8 is already recording
2016-06-15 08:55:27 - Found SIP/2004-000061b8 as RECORDING
2016-06-15 08:55:27 - RPM is YES in SIP/2004-000061b8
2016-06-15 08:55:27 - Stopping
RECORDING

As you can see, after listing the master channel as SIP/2003-000061b7 and restarting after the first pause, the next time through it sees the master channel as SIP/2004-000061b8 and recording. It says it's stopping it, however the recording is not stopped. It appears to be noticing when it should be starting/stopping correctly, but not actually stopping. The secret appeared to be that REC_STATUS is updated to STOPPED for multiple channels, but $astman->stopmixmonitor was only being run on one channel.

My Solution
Based upon the following code in
/var/www/html/admin/modules/callrecording/bin/one_touch_record.php
lines 119-122 on mine

foreach (array($channel, $myMaster, $bridgePeer, $theirMaster) as $c) {
$rid = getVariable($c, "RECORD_ID");
if (!empty($rid)) {
ot_debug("Found Master channel $rid");

It appears that it is looking for the recording ID/master channel in a specific order, but not necessarily checking if there could possibly have been two valid recordings? Question mark? Again, I am not an expert and my understanding of 'channels' has come from just playing with this.

My line of reasoning was, well, if it doesn't know which of those channels it should ACTUALLY be pausing, I'll just tell it to pause all of them just in case. I used the variable names in the foreach(array()) statement to just stop all of those channels via stopmixmonitor.

I changed this section (the bolded is my final result), lines 155 through 195 in my one_touch_record.php.

ot_debug("Checking if channel $masterChannel is already recording");
$rid = getVariable($masterChannel, 'RECORD_ID');
if (!empty($rid)) {
// This channel, previously, has been recording things.
$recStatus = getVariable($rid, 'REC_STATUS');
if ($recStatus == "RECORDING") {
ot_debug("Found $rid as RECORDING");
// We're recording. Are we allowed to stop it? The CURRENT channel will have the
// latest, correct, policy mode.
$rpm = getVariable($channel, "REC_POLICY_MODE");
ot_debug("RPM is $rpm in $channel");
if ($rpm == "FORCE" && $onDemand != "override") {
ot_debug("Denied policymode - $onDemand and $rpm");
setVariable($channel, "ONETOUCH_REC_SCRIPT_STATUS", "DENIED-POLICYMODE");
exit(0);
}

ot_debug("Stopping ".$rid);
$astman->stopmixmonitor($rid, rand());
$astman->stopmixmonitor($channel, rand());
$astman->stopmixmonitor($bridgePeer, rand());
$astman->stopmixmonitor($myMaster, rand());
$astman->stopmixmonitor($theirMaster, rand());
setVariable($rid, "REC_STATUS", "STOPPED");
setVariable($channel, "REC_STATUS", "STOPPED");
setVariable($bridgePeer, "REC_STATUS", "STOPPED");
setVariable($myMaster, "REC_STATUS", "STOPPED");
setVariable($theirMaster, "REC_STATUS", "STOPPED");
setVariable($channel, "ONETOUCH_REC_SCRIPT_STATUS", "RECORDING_STOPPED");
exit(0);

}
// Ah, it's not recording. So we just want to keep that Recording ID, as we're
// going to use it later as our master channel. However, we do know what the
// filename should be, so we'll update that
ot_debug("Found $rid, but it's not recording");
$masterChannel = $rid;
$cfn = getVariable($masterChannel, "CALLFILENAME");
if (!empty($cfn)) {
$callFileName = $cfn;
}
}

This now works exactly as I want it to, starting a recording on a queue, transferring the call to a queue member, and then allowing the queue member to pause the recording multiple times. Hacky and not elegant at all, but it got the results I wanted without understanding the actual logic behind how the channels are being created and identified. It has a strange side effect that all pauses after the first include the "beep" sound in the final recording, but the first does not.

Could an expert weigh in on this issue? Is this a bug or some sort of intended functionality? Does not seem like expected behavior for a non-technical end-user to have to tangle with.

Thanks for your time.

Edit:
Also, it should be noted I attempted to just change the order it checks the channels from:
foreach (array($channel, $myMaster, $bridgePeer, $theirMaster) as $c) {
to
foreach (array($bridgePeer, $theirMaster, $channel, $myMaster) as $c) {
and that just made the recording bizarre. It wiped out all of the audio after the first pause and instead repeated the last unpaused section a bunch of times. I.E. Instead of 'a b c d e f g' it sounded like 'a g g g g g g'

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 12604

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>