update
This commit is contained in:
parent
91e51e42f1
commit
c7b5d7d3c0
|
|
@ -162,7 +162,7 @@ EwIDAQAB
|
|||
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($zipFile) !== true) {
|
||||
error_log("zip unzip problem");
|
||||
error_log("zip unzip problem");
|
||||
fail('Unable to open ZIP');
|
||||
}
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
|
|
@ -214,13 +214,12 @@ EwIDAQAB
|
|||
unlink($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 'reboot':
|
||||
exec('sudo reboot');
|
||||
break;
|
||||
case 'backup':
|
||||
|
||||
$jsonFiles = [
|
||||
'input.json',
|
||||
'output.json',
|
||||
|
|
@ -230,16 +229,12 @@ EwIDAQAB
|
|||
];
|
||||
|
||||
$tmpZip = sys_get_temp_dir() . '/backup.zip';
|
||||
$outputFile = __DIR__ . '/universal_encoder_decoder.bin';
|
||||
|
||||
$publicKey = file_get_contents('/var/www/backup_private.pem');
|
||||
$publicKey = file_get_contents('/var/www/backup_public.pem');
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($tmpZip, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||
|
||||
|
||||
/* Add JSON files if exist */
|
||||
foreach ($jsonFiles as $json) {
|
||||
if (file_exists($json)) {
|
||||
$zip->addFile($json, basename($json));
|
||||
|
|
@ -249,11 +244,9 @@ EwIDAQAB
|
|||
$zip->close();
|
||||
$data = file_get_contents($tmpZip);
|
||||
|
||||
/* Generate AES key */
|
||||
$aesKey = random_bytes(32);
|
||||
$iv = random_bytes(16);
|
||||
|
||||
/* Encrypt ZIP */
|
||||
$encryptedData = openssl_encrypt(
|
||||
$data,
|
||||
'AES-256-CBC',
|
||||
|
|
@ -262,31 +255,28 @@ EwIDAQAB
|
|||
$iv
|
||||
);
|
||||
|
||||
/* Encrypt AES key using RSA public key */
|
||||
openssl_public_encrypt($aesKey, $encryptedKey, $publicKey);
|
||||
|
||||
/* Final binary format */
|
||||
$payload = json_encode([
|
||||
'key' => base64_encode($encryptedKey),
|
||||
'iv' => base64_encode($iv),
|
||||
'data' => base64_encode($encryptedData)
|
||||
]);
|
||||
$binary = pack('N', strlen($encryptedKey));
|
||||
$binary .= $encryptedKey;
|
||||
$binary .= $iv;
|
||||
$binary .= $encryptedData;
|
||||
|
||||
/* Headers */
|
||||
$filename = 'universal_encoder_decoder.bin';
|
||||
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Content-Length: ' . strlen($payload));
|
||||
header('Content-Length: ' . strlen($binary));
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
|
||||
echo $payload;
|
||||
echo $binary;
|
||||
flush();
|
||||
|
||||
unlink($tmpZip);
|
||||
|
||||
break;
|
||||
|
||||
case 'restore':
|
||||
|
|
|
|||
|
|
@ -375,18 +375,19 @@ function update_service($which_service)
|
|||
case "copy_input":
|
||||
switch ($input_source) {
|
||||
case "hdmi":
|
||||
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -f v4l2 -thread_queue_size 1024 -input_format mjpeg "
|
||||
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -hwaccel qsv -hwaccel_output_format qsv -f v4l2 -thread_queue_size 2048 -input_format mjpeg "
|
||||
. " -video_size " . $data['hdmi']['resolution']
|
||||
. " -framerate " . $data['hdmi']['framerate']
|
||||
. " -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source']
|
||||
. " -c:v h264_qsv -pix_fmt yuv420p -profile:v high -b:v 5M -maxrate 5M -bufsize 12M -c:a aac -b:a 265k -ar 48000 -tune zerolatency ";
|
||||
. " -c:v h264_qsv -profile:v high -level:v 4.2 -b:v 5M -maxrate 5M -bufsize 12M -tune zerolatency -muxrate 0 -pat_period 0.1 -pkt_size 1316 "
|
||||
. " -c:a aac -b:a 265k -ar 48000 ";
|
||||
if ($hdmi_delay_video != "")
|
||||
$input .= "-vf " . setptsFromMs($hdmi_delay_video);
|
||||
|
||||
if ($hdmi_delay_audio != "")
|
||||
$input .= adelayFromMs($hdmi_delay_audio, 2);
|
||||
|
||||
$input .= " -f mpegts " . ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"';
|
||||
$input .= " -f mpegts " . ' "udp://239.255.254.254:39000?reuse=1&localaddr=127.0.0.1"';
|
||||
break;
|
||||
case "url":
|
||||
$input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url'] . " -c:v copy -c:a copy -f mpegts " . ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"';
|
||||
|
|
@ -405,9 +406,9 @@ function update_service($which_service)
|
|||
case "use_common_backend":
|
||||
switch ($input_source) {
|
||||
case "hdmi":
|
||||
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -f v4l2 -thread_queue_size 1024 -input_format mjpeg -video_size " . $data['hdmi']['resolution']
|
||||
$input .= "ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -hwaccel qsv -hwaccel_output_format qsv -f v4l2 -thread_queue_size 2048 -input_format mjpeg -video_size " . $data['hdmi']['resolution']
|
||||
. " -framerate " . $data['hdmi']['framerate'] . " -i /dev/video0 -f alsa -thread_queue_size 1024 -i " . $data['hdmi']['audio_source']
|
||||
. " -c:v h264_qsv ";
|
||||
. " -c:v h264_qsv -profile:v high -level:v 4.2 ";
|
||||
if ($hdmi_delay_video != "")
|
||||
$input .= ' -vf "scale=' . $common_backend_resolution . ',' . setptsFromMs($hdmi_delay_video) . '"';
|
||||
else
|
||||
|
|
@ -425,8 +426,8 @@ function update_service($which_service)
|
|||
$input .= ' -af "volume=' . $common_backend_audio_db_gain . ',' . adelayFromMs($hdmi_delay_audio, 2) . '"';
|
||||
else
|
||||
$input .= ' -af "volume=' . $common_backend_audio_db_gain . '"';
|
||||
$input .= " -tune zerolatency -pkt_size 1316 -f mpegts "
|
||||
. ' "udp://@239.255.254.254:39000?localaddr=127.0.0.1"';
|
||||
$input .= " -tune zerolatency -muxrate 0 -pat_period 0.1 -pkt_size 1316 -f mpegts "
|
||||
. ' "udp://239.255.254.254:39000?reuse=1&localaddr=127.0.0.1"';
|
||||
break;
|
||||
case "url":
|
||||
$input .= "ffmpeg -hwaccel auto -hide_banner -stream_loop -1 -re -i " . $data['url']
|
||||
|
|
|
|||
1
setup.sh
1
setup.sh
|
|
@ -4,4 +4,5 @@ sudo cp users.json /var/www/users.json
|
|||
sudo cp attempts.json /var/www/attempts.json
|
||||
DEVICE_ID="$(sudo cat /sys/class/dmi/id/product_uuid | tr -d '\n')"
|
||||
sudo sed -i 's/certificatecertificatecertificatecertificate/'$DEVICE_ID'/g' /var/www/html/certification.html
|
||||
sudo chown -R www-data:www-data /var/www/*
|
||||
sudo reboot
|
||||
Loading…
Reference in New Issue