feat: add secure on-demand HLS playback plugin

This commit is contained in:
root
2026-09-04 20:23:10 +02:00
commit 6fae6a3a43
35 changed files with 2283 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace App\Entity;
final class Station
{
public function __construct(public int $id, private string $radioTempDirectory)
{
}
public function getRadioTempDir(): string
{
return $this->radioTempDirectory;
}
}
final class StationMedia
{
public function __construct(
public int $storage_location_id,
public string $unique_id,
public int $mtime,
public string $path,
) {
}
}
namespace App\Flysystem;
use App\Entity\Station;
final class StationFilesystems
{
public function __construct(private object $filesystem)
{
}
public function getMediaFilesystem(Station $station): object
{
return $this->filesystem;
}
}
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Plugin\AzuraCastOnDemandHls\Tests\Support;
use PHPUnit\Framework\TestCase;
abstract class TemporaryDirectoryTestCase extends TestCase
{
protected string $temporaryDirectory;
protected function setUp(): void
{
parent::setUp();
$this->temporaryDirectory = sys_get_temp_dir() . '/ondemand-hls-test-' . bin2hex(random_bytes(8));
mkdir($this->temporaryDirectory, 0700, true);
}
protected function tearDown(): void
{
$this->removeTree($this->temporaryDirectory);
parent::tearDown();
}
private function removeTree(string $path): void
{
if (is_link($path) || is_file($path)) {
@unlink($path);
return;
}
if (!is_dir($path)) {
return;
}
foreach (new \FilesystemIterator($path, \FilesystemIterator::SKIP_DOTS) as $item) {
$this->removeTree($item->getPathname());
}
@rmdir($path);
}
}