CDR - Recording Playback: Fix seeking for chromium based browsers.

This commit is contained in:
fusionate 2024-10-18 18:58:44 -06:00
parent 7122ecc154
commit e0fe291da0
No known key found for this signature in database
5 changed files with 72 additions and 76 deletions

View File

@ -274,6 +274,7 @@ if (!class_exists('call_recordings')) {
case "ogg" : header("Content-Type: audio/ogg"); break; case "ogg" : header("Content-Type: audio/ogg"); break;
} }
} }
$call_recording_name = preg_replace('#[^a-zA-Z0-9_\-\.]#', '', $call_recording_name);
header('Content-Disposition: attachment; filename="'.$call_recording_name.'"'); header('Content-Disposition: attachment; filename="'.$call_recording_name.'"');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
@ -415,7 +416,7 @@ if (!class_exists('call_recordings')) {
} }
// If the range starts with an '-' we start from the beginning // If the range starts with an '-' we start from the beginning
// If not, we forward the file pointer // If not, we forward the file pointer
// And make sure to get the end byte if spesified // And make sure to get the end byte if specified
if ($range[0] == '-') { if ($range[0] == '-') {
// The n-number of the last bytes is requested // The n-number of the last bytes is requested
$c_start = $size - substr($range, 1); $c_start = $size - substr($range, 1);

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2017 Portions created by the Initial Developer are Copyright (C) 2017-2024
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -26,9 +26,9 @@
//includes files //includes files
require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
//check permisions //check permisions
require_once "resources/check_auth.php";
if (permission_exists('xml_cdr_view')) { if (permission_exists('xml_cdr_view')) {
//access granted //access granted
} }
@ -38,7 +38,11 @@
} }
//download //download
if (is_uuid($_GET['id'])) {
$obj = new xml_cdr; $obj = new xml_cdr;
$obj->download($_GET['id']); $obj->recording_uuid = $_GET['id'];
$obj->binary = isset($_GET['t']) && $_GET['t'] == 'bin' ? true : false;
$obj->download();
}
?> ?>

View File

@ -47,6 +47,8 @@ if (!class_exists('xml_cdr')) {
private $username; private $username;
private $password; private $password;
private $json; private $json;
public $recording_uuid;
public $binary;
/** /**
* user summary * user summary
@ -1830,45 +1832,30 @@ if (!class_exists('xml_cdr')) {
/** /**
* download the recordings * download the recordings
*/ */
public function download($uuid) { public function download() {
if (!permission_exists('xml_cdr_view')) { if (permission_exists('xml_cdr_view')) {
echo "permission denied";
return;
}
//get call recording from database //get call recording from database
if (!is_uuid($uuid)) { if (is_uuid($this->recording_uuid)) {
echo "invalid uuid";
return;
}
$sql = "select record_name, record_path from v_xml_cdr "; $sql = "select record_name, record_path from v_xml_cdr ";
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid "; $sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
//$sql .= "and domain_uuid = '".$domain_uuid."' \n"; $parameters['xml_cdr_uuid'] = $this->recording_uuid;
$parameters['xml_cdr_uuid'] = $uuid;
//$parameters['domain_uuid'] = $domain_uuid;
$row = $this->database->select($sql, $parameters, 'row'); $row = $this->database->select($sql, $parameters, 'row');
if (!empty($row) && is_array($row)) { if (!empty($row) && is_array($row)) {
$record_name = $row['record_name']; $record_name = $row['record_name'];
$record_path = $row['record_path']; $record_path = $row['record_path'];
} else {
echo "recording not found";
return;
} }
unset ($sql, $parameters, $row); unset ($sql, $parameters, $row);
}
//build full path //build full path
$record_file = $record_path.'/'.$record_name; $record_file = $record_path.'/'.$record_name;
//download the file //download the file
if (!file_exists($record_file) || $record_file == '/') { if ($record_file != '/' && file_exists($record_file)) {
echo "recording not found";
return;
}
ob_clean(); ob_clean();
$fd = fopen($record_file, "rb"); $fd = fopen($record_file, "rb");
if ($_GET['t'] == "bin") { if ($this->binary) {
header("Content-Type: application/force-download"); header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream"); header("Content-Type: application/octet-stream");
header("Content-Type: application/download"); header("Content-Type: application/download");
@ -1886,17 +1873,20 @@ if (!class_exists('xml_cdr')) {
header('Content-Disposition: attachment; filename="'.$record_name.'"'); header('Content-Disposition: attachment; filename="'.$record_name.'"');
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
if ($_GET['t'] == "bin") { if ($this->binary) {
header("Content-Length: ".filesize($record_file)); header("Content-Length: ".filesize($record_file));
} }
ob_clean(); ob_clean();
//content-range //content-range
if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") { if (isset($_SERVER['HTTP_RANGE']) && !$this->binary) {
$this->range_download($record_file); $this->range_download($record_file);
} }
fpassthru($fd); fpassthru($fd);
}
}
} //end download method } //end download method
@ -1922,7 +1912,7 @@ if (!class_exists('xml_cdr')) {
* (mediatype = mimetype) * (mediatype = mimetype)
* as well as a boundry header to indicate the various chunks of data. * as well as a boundry header to indicate the various chunks of data.
*/ */
header("Accept-Ranges: 0-$length"); header("Accept-Ranges: 0-".$length);
// header('Accept-Ranges: bytes'); // header('Accept-Ranges: bytes');
// multipart/byteranges // multipart/byteranges
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2 // http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
@ -1944,15 +1934,15 @@ if (!class_exists('xml_cdr')) {
} }
// If the range starts with an '-' we start from the beginning // If the range starts with an '-' we start from the beginning
// If not, we forward the file pointer // If not, we forward the file pointer
// And make sure to get the end byte if spesified // And make sure to get the end byte if specified
if ($range == '-') { if ($range[0] == '-') {
// The n-number of the last bytes is requested // The n-number of the last bytes is requested
$c_start = $size - substr($range, 1); $c_start = $size - substr($range, 1);
} }
else { else {
$range = explode('-', $range); $range = explode('-', $range);
$c_start = $range[0]; $c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric((int)$range[1])) ? $range[1] : $size; $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
} }
/* Check the range and make sure it's treated according to the specs. /* Check the range and make sure it's treated according to the specs.
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

View File

@ -932,7 +932,7 @@
if (!empty($record_path) || !empty($record_name)) { if (!empty($record_path) || !empty($record_name)) {
$content .= " <td class='middle button center no-link no-wrap'>"; $content .= " <td class='middle button center no-link no-wrap'>";
if ($permission['xml_cdr_recording_play']) { if ($permission['xml_cdr_recording_play']) {
$content .= "<audio id='recording_audio_".escape($row['xml_cdr_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['xml_cdr_uuid'])."')\" onended=\"recording_reset('".escape($row['xml_cdr_uuid'])."');\" src=\"download.php?id=".escape($row['xml_cdr_uuid']).(strpos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false ? "&t=record" : "&t=bin")."\" type='".escape($record_type)."'></audio>"; $content .= "<audio id='recording_audio_".escape($row['xml_cdr_uuid'])."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".escape($row['xml_cdr_uuid'])."')\" onended=\"recording_reset('".escape($row['xml_cdr_uuid'])."');\" src=\"download.php?id=".escape($row['xml_cdr_uuid'])."\" type='".escape($record_type)."'></audio>";
$content .= button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['xml_cdr_uuid']),'onclick'=>"recording_play('".escape($row['xml_cdr_uuid'])."')"]); $content .= button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$_SESSION['theme']['button_icon_play'],'id'=>'recording_button_'.escape($row['xml_cdr_uuid']),'onclick'=>"recording_play('".escape($row['xml_cdr_uuid'])."')"]);
} }
if ($permission['xml_cdr_recording_download']) { if ($permission['xml_cdr_recording_download']) {

View File

@ -802,9 +802,9 @@
if (recording_progress) { if (recording_progress) {
recording_progress.style.marginLeft = value + '%'; recording_progress.style.marginLeft = value + '%';
} }
if (recording_audio != null && parseInt(recording_audio.duration) > 30) { //seconds // if (recording_audio != null && parseInt(recording_audio.duration) > 30) { //seconds
clearInterval(audio_clock); // clearInterval(audio_clock);
} // }
} }
function recording_fast_forward() { function recording_fast_forward() {
@ -831,6 +831,7 @@
} }
recording_audio.currentTime = (event.offsetX / audio_player.offsetWidth) * recording_audio.duration; recording_audio.currentTime = (event.offsetX / audio_player.offsetWidth) * recording_audio.duration;
update_progress(recording_id_playing); update_progress(recording_id_playing);
document.getElementById('recording_button_' + player_id).focus();
} }
} }