2020-05-02 07:58:59 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
namespace App\Entity;
|
|
|
|
|
2022-02-22 23:44:08 +00:00
|
|
|
use App\Entity\Enums\StationBackendPerformanceModes;
|
2022-05-23 04:50:55 +00:00
|
|
|
use App\Radio\Enums\AudioProcessingMethods;
|
2022-01-07 08:26:40 +00:00
|
|
|
use App\Radio\Enums\StreamFormats;
|
2020-07-10 08:18:10 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2022-05-08 18:05:02 +00:00
|
|
|
use InvalidArgumentException;
|
2020-05-02 07:58:59 +00:00
|
|
|
|
2022-05-31 11:41:35 +00:00
|
|
|
/**
|
|
|
|
* @extends ArrayCollection<string, mixed>
|
|
|
|
*/
|
2020-07-10 08:18:10 +00:00
|
|
|
class StationBackendConfiguration extends ArrayCollection
|
2020-05-02 07:58:59 +00:00
|
|
|
{
|
|
|
|
public const CHARSET = 'charset';
|
|
|
|
|
|
|
|
public function getCharset(): string
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return $this->get(self::CHARSET) ?? 'UTF-8';
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setCharset(?string $charset): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::CHARSET, $charset);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const DJ_PORT = 'dj_port';
|
|
|
|
|
|
|
|
public function getDjPort(): ?int
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$port = $this->get(self::DJ_PORT);
|
2020-05-02 08:32:41 +00:00
|
|
|
return is_numeric($port) ? (int)$port : null;
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDjPort(?int $port): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::DJ_PORT, $port);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const TELNET_PORT = 'telnet_port';
|
|
|
|
|
|
|
|
public function getTelnetPort(): ?int
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$port = $this->get(self::TELNET_PORT);
|
2020-05-02 08:32:41 +00:00
|
|
|
return is_numeric($port) ? (int)$port : null;
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setTelnetPort(?int $port): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::TELNET_PORT, $port);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const RECORD_STREAMS = 'record_streams';
|
|
|
|
|
|
|
|
public function recordStreams(): bool
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return (bool)($this->get(self::RECORD_STREAMS) ?? false);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setRecordStreams(?bool $recordStreams): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::RECORD_STREAMS, $recordStreams);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const RECORD_STREAMS_FORMAT = 'record_streams_format';
|
|
|
|
|
|
|
|
public function getRecordStreamsFormat(): ?string
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return $this->get(self::RECORD_STREAMS_FORMAT);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
2022-01-07 08:26:40 +00:00
|
|
|
public function getRecordStreamsFormatEnum(): ?StreamFormats
|
|
|
|
{
|
|
|
|
$recordStreamsFormat = $this->getRecordStreamsFormat();
|
2022-01-07 23:56:59 +00:00
|
|
|
return StreamFormats::tryFrom(strtolower($recordStreamsFormat ?? ''));
|
2022-01-07 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
public function setRecordStreamsFormat(?string $format): void
|
|
|
|
{
|
2022-01-07 08:26:40 +00:00
|
|
|
if (null !== $format) {
|
|
|
|
$format = strtolower($format);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null !== $format && null === StreamFormats::tryFrom($format)) {
|
2022-05-08 18:05:02 +00:00
|
|
|
throw new InvalidArgumentException('Invalid recording type specified.');
|
2022-01-07 08:26:40 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::RECORD_STREAMS_FORMAT, $format);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const USE_MANUAL_AUTODJ = 'use_manual_autodj';
|
|
|
|
|
|
|
|
public function useManualAutoDj(): bool
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return (bool)($this->get(self::USE_MANUAL_AUTODJ) ?? false);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUseManualAutoDj(?bool $useManualAutoDj): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::USE_MANUAL_AUTODJ, $useManualAutoDj);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const AUTODJ_QUEUE_LENGTH = 'autodj_queue_length';
|
|
|
|
public const DEFAULT_QUEUE_LENGTH = 3;
|
|
|
|
|
|
|
|
public function getAutoDjQueueLength(): int
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return (int)($this->get(self::AUTODJ_QUEUE_LENGTH) ?? self::DEFAULT_QUEUE_LENGTH);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setAutoDjQueueLength(?int $queueLength): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::AUTODJ_QUEUE_LENGTH, $queueLength);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const DJ_MOUNT_POINT = 'dj_mount_point';
|
|
|
|
|
|
|
|
public function getDjMountPoint(): string
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return $this->get(self::DJ_MOUNT_POINT) ?? '/';
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDjMountPoint(?string $mountPoint): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::DJ_MOUNT_POINT, $mountPoint);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 04:50:55 +00:00
|
|
|
public const AUDIO_PROCESSING_METHOD = 'audio_processing_method';
|
2020-05-02 07:58:59 +00:00
|
|
|
|
2022-05-23 04:50:55 +00:00
|
|
|
public function getAudioProcessingMethod(): ?string
|
2020-05-02 07:58:59 +00:00
|
|
|
{
|
2022-05-23 04:50:55 +00:00
|
|
|
return $this->getAudioProcessingMethodEnum()->value;
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 04:50:55 +00:00
|
|
|
public function getAudioProcessingMethodEnum(): AudioProcessingMethods
|
2020-05-02 07:58:59 +00:00
|
|
|
{
|
2022-05-23 04:50:55 +00:00
|
|
|
return AudioProcessingMethods::tryFrom($this->get(self::AUDIO_PROCESSING_METHOD) ?? '')
|
|
|
|
?? AudioProcessingMethods::default();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setAudioProcessingMethod(?string $method): void
|
|
|
|
{
|
|
|
|
if (null !== $method) {
|
|
|
|
$method = strtolower($method);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null !== $method && null === AudioProcessingMethods::tryFrom($method)) {
|
|
|
|
throw new \InvalidArgumentException('Invalid audio processing method specified.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->set(self::AUDIO_PROCESSING_METHOD, $method);
|
|
|
|
}
|
|
|
|
|
|
|
|
public const STEREO_TOOL_LICENSE_KEY = 'stereo_tool_license_key';
|
|
|
|
|
|
|
|
public function getStereoToolLicenseKey(): ?string
|
|
|
|
{
|
|
|
|
return $this->get(self::STEREO_TOOL_LICENSE_KEY) ?? null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setStereoToolLicenseKey(?string $licenseKey): void
|
|
|
|
{
|
|
|
|
$this->set(self::STEREO_TOOL_LICENSE_KEY, $licenseKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
public const STEREO_TOOL_CONFIGURATION_PATH = 'stereo_tool_configuration_path';
|
|
|
|
|
|
|
|
public function getStereoToolConfigurationPath(): ?string
|
|
|
|
{
|
|
|
|
return $this->get(self::STEREO_TOOL_CONFIGURATION_PATH) ?? null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setStereoToolConfigurationPath(?string $stereoToolConfigurationPath): void
|
|
|
|
{
|
|
|
|
$this->set(self::STEREO_TOOL_CONFIGURATION_PATH, $stereoToolConfigurationPath);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public const USE_REPLAYGAIN = 'enable_replaygain_metadata';
|
|
|
|
|
|
|
|
public function useReplayGain(): bool
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
return $this->get(self::USE_REPLAYGAIN) ?? false;
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUseReplayGain(?bool $useReplayGain): void
|
|
|
|
{
|
2020-07-10 08:18:10 +00:00
|
|
|
$this->set(self::USE_REPLAYGAIN, $useReplayGain);
|
2020-05-02 07:58:59 +00:00
|
|
|
}
|
2020-08-02 17:32:55 +00:00
|
|
|
|
|
|
|
public const CROSSFADE_TYPE = 'crossfade_type';
|
|
|
|
|
|
|
|
public const CROSSFADE_NORMAL = 'normal';
|
|
|
|
public const CROSSFADE_DISABLED = 'none';
|
|
|
|
public const CROSSFADE_SMART = 'smart';
|
|
|
|
|
|
|
|
public function getCrossfadeType(): string
|
|
|
|
{
|
|
|
|
return $this->get(self::CROSSFADE_TYPE) ?? self::CROSSFADE_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCrossfadeType(string $crossfadeType): void
|
|
|
|
{
|
|
|
|
$this->set(self::CROSSFADE_TYPE, $crossfadeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public const CROSSFADE = 'crossfade';
|
|
|
|
|
|
|
|
public const DEFAULT_CROSSFADE_DURATION = 2;
|
|
|
|
|
|
|
|
public function getCrossfade(): float
|
|
|
|
{
|
2021-10-24 02:16:45 +00:00
|
|
|
return round((float)($this->get(self::CROSSFADE) ?? self::DEFAULT_CROSSFADE_DURATION), 1);
|
2020-08-02 17:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setCrossfade(?float $crossfade): void
|
|
|
|
{
|
|
|
|
$this->set(self::CROSSFADE, $crossfade);
|
|
|
|
}
|
2020-08-23 21:18:40 +00:00
|
|
|
|
2020-08-31 22:32:30 +00:00
|
|
|
public function getCrossfadeDuration(): float
|
2020-08-23 21:18:40 +00:00
|
|
|
{
|
|
|
|
$crossfade = $this->getCrossfade();
|
|
|
|
$crossfadeType = $this->getCrossfadeType();
|
|
|
|
|
|
|
|
if (self::CROSSFADE_DISABLED !== $crossfadeType && $crossfade > 0) {
|
|
|
|
return round($crossfade * 1.5, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-09-14 00:03:04 +00:00
|
|
|
|
2021-12-17 07:19:49 +00:00
|
|
|
public function isCrossfadeEnabled(): bool
|
|
|
|
{
|
|
|
|
return $this->getCrossfadeDuration() > 0;
|
|
|
|
}
|
|
|
|
|
2020-09-14 00:03:04 +00:00
|
|
|
public const DUPLICATE_PREVENTION_TIME_RANGE = 'duplicate_prevention_time_range';
|
|
|
|
|
|
|
|
public const DEFAULT_DUPLICATE_PREVENTION_TIME_RANGE = 120;
|
|
|
|
|
|
|
|
public function getDuplicatePreventionTimeRange(): int
|
|
|
|
{
|
2021-10-24 02:16:45 +00:00
|
|
|
return (int)(
|
|
|
|
$this->get(self::DUPLICATE_PREVENTION_TIME_RANGE) ?? self::DEFAULT_DUPLICATE_PREVENTION_TIME_RANGE
|
|
|
|
);
|
2020-09-14 00:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setDuplicatePreventionTimeRange(?int $duplicatePreventionTimeRange): void
|
|
|
|
{
|
|
|
|
$this->set(self::DUPLICATE_PREVENTION_TIME_RANGE, $duplicatePreventionTimeRange);
|
|
|
|
}
|
2022-02-22 23:44:08 +00:00
|
|
|
|
|
|
|
public const PERFORMANCE_MODE = 'performance_mode';
|
|
|
|
|
|
|
|
public function getPerformanceMode(): string
|
|
|
|
{
|
|
|
|
return $this->getPerformanceModeEnum()->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPerformanceModeEnum(): StationBackendPerformanceModes
|
|
|
|
{
|
|
|
|
return StationBackendPerformanceModes::tryFrom($this->get(self::PERFORMANCE_MODE) ?? '')
|
|
|
|
?? StationBackendPerformanceModes::default();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPerformanceMode(?string $performanceMode): void
|
|
|
|
{
|
|
|
|
$perfModeEnum = StationBackendPerformanceModes::tryFrom($performanceMode ?? '');
|
|
|
|
if (null === $perfModeEnum) {
|
|
|
|
$this->set(self::PERFORMANCE_MODE, null);
|
|
|
|
} else {
|
|
|
|
$this->set(self::PERFORMANCE_MODE, $perfModeEnum->value);
|
|
|
|
}
|
|
|
|
}
|
2020-09-14 00:03:04 +00:00
|
|
|
}
|