2015-01-02 08:16:54 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2018-08-04 22:05:14 +00:00
|
|
|
namespace App\Entity;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
use App\Annotations\AuditLog;
|
2020-12-03 04:18:06 +00:00
|
|
|
use App\Environment;
|
2020-02-12 01:18:41 +00:00
|
|
|
use App\File;
|
2020-11-10 03:06:48 +00:00
|
|
|
use App\Normalizer\Annotation\DeepNormalize;
|
2019-08-07 04:33:55 +00:00
|
|
|
use App\Radio\Adapters;
|
|
|
|
use App\Validator\Constraints as AppAssert;
|
2020-10-05 06:27:12 +00:00
|
|
|
use DateTimeZone;
|
2018-12-22 00:01:04 +00:00
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2020-11-10 03:06:48 +00:00
|
|
|
use League\Flysystem\Adapter\Local;
|
|
|
|
use League\Flysystem\AdapterInterface;
|
2019-08-07 04:33:55 +00:00
|
|
|
use OpenApi\Annotations as OA;
|
2020-11-10 03:06:48 +00:00
|
|
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
2019-08-07 04:33:55 +00:00
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
2015-01-02 08:16:54 +00:00
|
|
|
|
|
|
|
/**
|
2020-04-17 08:25:10 +00:00
|
|
|
* @ORM\Table(name="station", indexes={
|
|
|
|
* @ORM\Index(name="idx_short_name", columns={"short_name"})
|
|
|
|
* })
|
2019-09-29 07:50:24 +00:00
|
|
|
* @ORM\Entity()
|
2018-12-22 00:01:04 +00:00
|
|
|
* @ORM\HasLifecycleCallbacks
|
2018-12-22 17:27:41 +00:00
|
|
|
*
|
2019-08-14 23:50:53 +00:00
|
|
|
* @AuditLog\Auditable
|
|
|
|
*
|
2018-12-22 17:27:41 +00:00
|
|
|
* @OA\Schema(type="object", schema="Station")
|
2019-04-09 09:06:44 +00:00
|
|
|
* @AppAssert\StationPortChecker()
|
2015-01-02 08:16:54 +00:00
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
class Station
|
2015-01-02 08:16:54 +00:00
|
|
|
{
|
2020-10-14 22:19:31 +00:00
|
|
|
use Traits\TruncateStrings;
|
|
|
|
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_REQUEST_DELAY = 5;
|
|
|
|
public const DEFAULT_REQUEST_THRESHOLD = 15;
|
2018-10-27 00:14:32 +00:00
|
|
|
public const DEFAULT_DISCONNECT_DEACTIVATE_STREAMER = 0;
|
2018-09-09 18:23:03 +00:00
|
|
|
public const DEFAULT_API_HISTORY_ITEMS = 5;
|
2018-08-18 23:01:03 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="id", type="integer")
|
|
|
|
* @ORM\Id
|
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY")
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=1)
|
2019-04-09 09:06:44 +00:00
|
|
|
* @var int|null
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="name", type="string", length=100, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="AzuraTest Radio")
|
2019-04-10 04:46:51 +00:00
|
|
|
*
|
|
|
|
* @Assert\NotBlank()
|
2017-12-08 09:51:08 +00:00
|
|
|
* @var string|null The full display name of the station.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $name;
|
|
|
|
|
2017-12-08 09:51:08 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="short_name", type="string", length=100, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="azuratest_radio")
|
2019-04-10 04:46:51 +00:00
|
|
|
*
|
|
|
|
* @Assert\NotBlank()
|
2017-12-08 09:51:08 +00:00
|
|
|
* @var string|null The URL-friendly name for the station, typically auto-generated from the full station name.
|
|
|
|
*/
|
|
|
|
protected $short_name;
|
|
|
|
|
2018-03-24 07:38:27 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="is_enabled", type="boolean", nullable=false)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool If set to "false", prevents the station from broadcasting but leaves it in the database.
|
2018-03-24 07:38:27 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $is_enabled = true;
|
2018-03-24 07:38:27 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="frontend_type", type="string", length=100, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="icecast")
|
2019-04-10 04:46:51 +00:00
|
|
|
*
|
|
|
|
* @Assert\Choice(choices={Adapters::FRONTEND_ICECAST, Adapters::FRONTEND_REMOTE, Adapters::FRONTEND_SHOUTCAST})
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var string|null The frontend adapter (icecast,shoutcast,remote,etc)
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2019-08-05 16:34:58 +00:00
|
|
|
protected $frontend_type = Adapters::FRONTEND_ICECAST;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-18 04:15:54 +00:00
|
|
|
* @ORM\Column(name="frontend_config", type="json", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(@OA\Items())
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var array|null An array containing station-specific frontend configuration
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $frontend_config;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="backend_type", type="string", length=100, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
2019-04-10 04:46:51 +00:00
|
|
|
* @Assert\Choice(choices={Adapters::BACKEND_LIQUIDSOAP, Adapters::BACKEND_NONE})
|
2019-04-08 05:09:53 +00:00
|
|
|
* @OA\Property(example="liquidsoap")
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var string|null The backend adapter (liquidsoap,etc)
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2019-08-05 16:34:58 +00:00
|
|
|
protected $backend_type = Adapters::BACKEND_LIQUIDSOAP;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-18 04:15:54 +00:00
|
|
|
* @ORM\Column(name="backend_config", type="json", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(@OA\Items())
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var array|null An array containing station-specific backend configuration
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
|
|
|
protected $backend_config;
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="adapter_api_key", type="string", length=150, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
2019-08-15 19:01:00 +00:00
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2020-10-14 22:19:31 +00:00
|
|
|
* @var string|null An internal API key used for container-to-container communications from Liquidsoap to AzuraCast
|
2017-09-07 03:53:25 +00:00
|
|
|
*/
|
|
|
|
protected $adapter_api_key;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="description", type="text", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="A sample radio station.")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $description;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="url", type="string", length=255, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="https://demo.azuracast.com/")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $url;
|
|
|
|
|
2018-11-26 08:16:55 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="genre", type="string", length=150, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="Various")
|
2018-11-26 08:16:55 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $genre;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="radio_base_dir", type="string", length=255, nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example="/var/azuracast/stations/azuratest_radio")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
protected $radio_base_dir;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="nowplaying", type="array", nullable=true)
|
2019-08-14 23:50:53 +00:00
|
|
|
*
|
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var mixed|null
|
|
|
|
*/
|
|
|
|
protected $nowplaying;
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="nowplaying_timestamp", type="integer", nullable=true)
|
2019-08-14 23:50:53 +00:00
|
|
|
*
|
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2017-09-07 03:53:25 +00:00
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $nowplaying_timestamp;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2020-08-18 04:15:54 +00:00
|
|
|
* @ORM\Column(name="automation_settings", type="json", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(@OA\Items())
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var array|null
|
|
|
|
*/
|
|
|
|
protected $automation_settings;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="automation_timestamp", type="integer", nullable=true)
|
2019-08-14 23:50:53 +00:00
|
|
|
*
|
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var int|null The UNIX timestamp when station automation was most recently run.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $automation_timestamp = 0;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="enable_requests", type="boolean", nullable=false)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether listeners can request songs to play on this station.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_requests = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="request_delay", type="integer", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=5)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var int|null
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $request_delay = self::DEFAULT_REQUEST_DELAY;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="request_threshold", type="integer", nullable=true)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=15)
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var int|null
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $request_threshold = self::DEFAULT_REQUEST_THRESHOLD;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="disconnect_deactivate_streamer", type="integer", nullable=true, options={"default":0})
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=0)
|
2018-10-27 00:14:32 +00:00
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $disconnect_deactivate_streamer = self::DEFAULT_DISCONNECT_DEACTIVATE_STREAMER;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="enable_streamers", type="boolean", nullable=false)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether streamers are allowed to broadcast to this station at all.
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_streamers = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="is_streamer_live", type="boolean", nullable=false)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
2019-08-14 23:50:53 +00:00
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2019-04-08 05:09:53 +00:00
|
|
|
* @OA\Property(example=false)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether a streamer is currently active on the station.
|
2018-02-03 21:54:12 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $is_streamer_live = false;
|
2018-02-03 21:54:12 +00:00
|
|
|
|
2017-09-18 03:27:32 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="enable_public_page", type="boolean", nullable=false)
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=true)
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether this station is visible as a public page and in a now-playing API response.
|
2017-09-18 03:27:32 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $enable_public_page = true;
|
2017-09-18 03:27:32 +00:00
|
|
|
|
2020-05-15 10:13:47 +00:00
|
|
|
/**
|
|
|
|
* @ORM\Column(name="enable_on_demand", type="boolean", nullable=false)
|
|
|
|
*
|
|
|
|
* @OA\Property(example=true)
|
|
|
|
* @var bool Whether this station has a public "on-demand" streaming and download page.
|
|
|
|
*/
|
|
|
|
protected $enable_on_demand = false;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="needs_restart", type="boolean")
|
2019-08-14 23:50:53 +00:00
|
|
|
*
|
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2018-08-18 23:01:03 +00:00
|
|
|
* @var bool Whether to show the "Restart station to apply changes" sidebar for this station
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $needs_restart = false;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="has_started", type="boolean")
|
2019-08-14 23:50:53 +00:00
|
|
|
*
|
|
|
|
* @AuditLog\AuditIgnore()
|
|
|
|
*
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var bool
|
|
|
|
*/
|
2018-08-18 23:01:03 +00:00
|
|
|
protected $has_started = false;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="api_history_items", type="smallint")
|
2019-04-08 05:09:53 +00:00
|
|
|
*
|
|
|
|
* @OA\Property(example=5)
|
2020-10-14 22:19:31 +00:00
|
|
|
* @var int|null The number of "last played" history items to show for a station in the Now Playing API responses.
|
2018-08-18 23:01:03 +00:00
|
|
|
*/
|
|
|
|
protected $api_history_items = self::DEFAULT_API_HISTORY_ITEMS;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
/**
|
|
|
|
* @ORM\Column(name="timezone", type="string", length=100, nullable=true)
|
|
|
|
*
|
|
|
|
* @OA\Property(example="UTC")
|
|
|
|
* @var string|null The time zone that station operations should take place in.
|
|
|
|
*/
|
|
|
|
protected $timezone = 'UTC';
|
|
|
|
|
2020-05-03 01:28:08 +00:00
|
|
|
/**
|
|
|
|
* @ORM\Column(name="default_album_art_url", type="string", length=255, nullable=true)
|
|
|
|
*
|
|
|
|
* @OA\Property(example="https://example.com/image.jpg")
|
|
|
|
* @var string|null The station-specific default album artwork URL.
|
|
|
|
*/
|
|
|
|
protected $default_album_art_url = null;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="SongHistory", mappedBy="station")
|
2019-02-17 06:58:48 +00:00
|
|
|
* @ORM\OrderBy({"timestamp_start" = "DESC"})
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $history;
|
|
|
|
|
|
|
|
/**
|
2020-11-10 03:06:48 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="StorageLocation")
|
|
|
|
* @ORM\JoinColumns({
|
|
|
|
* @ORM\JoinColumn(name="media_storage_location_id", referencedColumnName="id", onDelete="SET NULL")
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* @DeepNormalize(true)
|
|
|
|
* @Serializer\MaxDepth(1)
|
|
|
|
*
|
|
|
|
* @var StorageLocation
|
|
|
|
*/
|
|
|
|
protected $media_storage_location;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="StorageLocation")
|
|
|
|
* @ORM\JoinColumns({
|
|
|
|
* @ORM\JoinColumn(name="recordings_storage_location_id", referencedColumnName="id", onDelete="SET NULL")
|
|
|
|
* })
|
|
|
|
*
|
|
|
|
* @DeepNormalize(true)
|
|
|
|
* @Serializer\MaxDepth(1)
|
|
|
|
*
|
|
|
|
* @var StorageLocation
|
2017-08-17 18:28:48 +00:00
|
|
|
*/
|
2020-11-10 03:06:48 +00:00
|
|
|
protected $recordings_storage_location;
|
2017-08-17 18:28:48 +00:00
|
|
|
|
|
|
|
/**
|
2019-05-03 11:55:48 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="StationStreamer", mappedBy="station")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $streamers;
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\Column(name="current_streamer_id", type="integer", nullable=true)
|
2020-11-10 03:06:48 +00:00
|
|
|
* @var int|null
|
2018-02-03 21:54:12 +00:00
|
|
|
*/
|
|
|
|
protected $current_streamer_id;
|
|
|
|
|
|
|
|
/**
|
2018-12-20 11:33:49 +00:00
|
|
|
* @ORM\ManyToOne(targetEntity="StationStreamer")
|
2018-12-22 00:01:04 +00:00
|
|
|
* @ORM\JoinColumns({
|
|
|
|
* @ORM\JoinColumn(name="current_streamer_id", referencedColumnName="id", onDelete="SET NULL")
|
2018-02-03 21:54:12 +00:00
|
|
|
* })
|
|
|
|
* @var StationStreamer|null
|
|
|
|
*/
|
|
|
|
protected $current_streamer;
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
/**
|
2019-05-03 11:55:48 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="RolePermission", mappedBy="station")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $permissions;
|
|
|
|
|
|
|
|
/**
|
2019-05-03 11:55:48 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="StationPlaylist", mappedBy="station")
|
2018-12-22 00:01:04 +00:00
|
|
|
* @ORM\OrderBy({"type" = "ASC","weight" = "DESC"})
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $playlists;
|
|
|
|
|
|
|
|
/**
|
2019-05-03 11:55:48 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="StationMount", mappedBy="station")
|
2017-08-17 18:28:48 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $mounts;
|
|
|
|
|
2018-09-09 18:23:03 +00:00
|
|
|
/**
|
2019-05-03 11:55:48 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="StationRemote", mappedBy="station")
|
2018-09-09 18:23:03 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $remotes;
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
/**
|
2019-05-03 08:40:47 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="StationWebhook", mappedBy="station", fetch="EXTRA_LAZY", cascade={"persist"})
|
2018-02-12 12:46:03 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
|
|
|
protected $webhooks;
|
|
|
|
|
2020-01-05 21:29:56 +00:00
|
|
|
/**
|
2020-01-08 19:24:33 +00:00
|
|
|
* @ORM\OneToMany(targetEntity="SftpUser", mappedBy="station")
|
2020-01-05 21:29:56 +00:00
|
|
|
* @var Collection
|
|
|
|
*/
|
2020-02-24 16:22:07 +00:00
|
|
|
protected $sftp_users;
|
2020-01-05 21:29:56 +00:00
|
|
|
|
2017-01-24 00:17:50 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2020-10-14 22:19:31 +00:00
|
|
|
$this->history = new ArrayCollection();
|
|
|
|
$this->playlists = new ArrayCollection();
|
|
|
|
$this->mounts = new ArrayCollection();
|
|
|
|
$this->remotes = new ArrayCollection();
|
|
|
|
$this->webhooks = new ArrayCollection();
|
|
|
|
$this->streamers = new ArrayCollection();
|
|
|
|
$this->sftp_users = new ArrayCollection();
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-04-09 09:06:44 +00:00
|
|
|
public function getId(): ?int
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getName(): ?string
|
|
|
|
{
|
|
|
|
return $this->name;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setName(?string $name = null): void
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->name = $this->truncateString($name, 100);
|
2017-12-08 09:51:08 +00:00
|
|
|
|
|
|
|
if (empty($this->short_name) && !empty($name)) {
|
2020-03-05 14:37:35 +00:00
|
|
|
$this->setShortName($name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getShortName(): ?string
|
|
|
|
{
|
|
|
|
return (!empty($this->short_name))
|
|
|
|
? $this->short_name
|
|
|
|
: self::getStationShortName($this->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setShortName(?string $short_name): void
|
|
|
|
{
|
|
|
|
$short_name = trim($short_name);
|
|
|
|
if (!empty($short_name)) {
|
|
|
|
$short_name = self::getStationShortName($short_name);
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->short_name = $this->truncateString($short_name, 100);
|
2017-12-08 09:51:08 +00:00
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 21:54:09 +00:00
|
|
|
public static function getStationShortName(string $str): string
|
2018-03-24 07:38:27 +00:00
|
|
|
{
|
2019-12-02 21:54:09 +00:00
|
|
|
return File::sanitizeFileName($str);
|
2018-03-24 07:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsEnabled(bool $is_enabled): void
|
|
|
|
{
|
|
|
|
$this->is_enabled = $is_enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getFrontendType(): ?string
|
|
|
|
{
|
|
|
|
return $this->frontend_type;
|
|
|
|
}
|
|
|
|
|
2020-03-29 07:16:41 +00:00
|
|
|
public function setFrontendType(?string $frontend_type = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->frontend_type = $frontend_type;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
public function getFrontendConfig(): StationFrontendConfiguration
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
return new StationFrontendConfiguration((array)$this->frontend_config);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
/**
|
|
|
|
* @param array|StationFrontendConfiguration $frontend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
|
|
|
public function setFrontendConfig($frontend_config, bool $force_overwrite = false): void
|
2017-08-04 11:46:30 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
if (!($frontend_config instanceof StationFrontendConfiguration)) {
|
|
|
|
$config = new StationFrontendConfiguration(
|
|
|
|
($force_overwrite) ? [] : (array)$this->frontend_config,
|
|
|
|
);
|
2020-07-11 05:38:20 +00:00
|
|
|
|
|
|
|
foreach ($frontend_config as $key => $val) {
|
|
|
|
$config->set($key, $val);
|
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
$frontend_config = $config;
|
2017-08-04 11:46:30 +00:00
|
|
|
}
|
2018-05-01 14:37:52 +00:00
|
|
|
|
2020-07-11 05:38:20 +00:00
|
|
|
$config = $frontend_config->toArray();
|
2020-08-16 14:54:01 +00:00
|
|
|
|
2019-03-02 00:34:06 +00:00
|
|
|
if ($this->frontend_config != $config) {
|
2018-05-01 14:37:52 +00:00
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
2017-08-04 11:46:30 +00:00
|
|
|
$this->frontend_config = $config;
|
|
|
|
}
|
|
|
|
|
2018-03-10 15:37:35 +00:00
|
|
|
/**
|
|
|
|
* Set frontend configuration but do not overwrite existing values.
|
|
|
|
*
|
2019-01-31 17:54:17 +00:00
|
|
|
* @param array $default_config
|
2018-03-10 15:37:35 +00:00
|
|
|
*/
|
2019-01-31 17:54:17 +00:00
|
|
|
public function setFrontendConfigDefaults(array $default_config): void
|
2018-03-10 15:37:35 +00:00
|
|
|
{
|
|
|
|
$frontend_config = (array)$this->frontend_config;
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
foreach ($default_config as $config_key => $config_value) {
|
2018-03-10 15:37:35 +00:00
|
|
|
if (empty($frontend_config[$config_key])) {
|
|
|
|
$frontend_config[$config_key] = $config_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->frontend_config = $frontend_config;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getBackendType(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->backend_type;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setBackendType(string $backend_type = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->backend_type = $backend_type;
|
|
|
|
}
|
2015-02-17 12:23:21 +00:00
|
|
|
|
2019-05-19 15:30:44 +00:00
|
|
|
/**
|
|
|
|
* Clear all port assignments for the station (useful after cloning).
|
|
|
|
*/
|
|
|
|
public function clearPorts(): void
|
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
$fe_config = $this->getFrontendConfig();
|
|
|
|
$fe_config->setPort(null);
|
|
|
|
$this->setFrontendConfig($fe_config);
|
|
|
|
|
|
|
|
$be_config = $this->getBackendConfig();
|
|
|
|
$be_config->setDjPort(null);
|
|
|
|
$be_config->setTelnetPort(null);
|
|
|
|
$this->setBackendConfig($be_config);
|
2019-05-19 15:30:44 +00:00
|
|
|
}
|
|
|
|
|
2018-05-01 07:32:31 +00:00
|
|
|
/**
|
|
|
|
* Whether the station uses AzuraCast to directly manage the AutoDJ or lets the backend handle it.
|
|
|
|
*/
|
|
|
|
public function useManualAutoDJ(): bool
|
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
$settings = $this->getBackendConfig();
|
|
|
|
return $settings->useManualAutoDj();
|
2018-05-01 07:32:31 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
public function getBackendConfig(): StationBackendConfiguration
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
return new StationBackendConfiguration((array)$this->backend_config);
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 07:58:59 +00:00
|
|
|
/**
|
|
|
|
* @param array|StationBackendConfiguration $backend_config
|
|
|
|
* @param bool $force_overwrite
|
|
|
|
*/
|
|
|
|
public function setBackendConfig($backend_config, bool $force_overwrite = false): void
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
2020-05-02 07:58:59 +00:00
|
|
|
if (!($backend_config instanceof StationBackendConfiguration)) {
|
|
|
|
$config = new StationBackendConfiguration(
|
|
|
|
($force_overwrite) ? [] : (array)$this->backend_config
|
|
|
|
);
|
2020-07-11 05:38:20 +00:00
|
|
|
|
|
|
|
foreach ($backend_config as $key => $val) {
|
|
|
|
$config->set($key, $val);
|
|
|
|
}
|
2020-05-02 07:58:59 +00:00
|
|
|
|
|
|
|
$backend_config = $config;
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2020-07-11 05:38:20 +00:00
|
|
|
$config = $backend_config->toArray();
|
2020-05-02 07:58:59 +00:00
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
if ($this->backend_config != $config) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->backend_config = $config;
|
|
|
|
}
|
|
|
|
|
2017-09-07 03:53:25 +00:00
|
|
|
public function getAdapterApiKey(): ?string
|
|
|
|
{
|
|
|
|
return $this->adapter_api_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a random new adapter API key.
|
|
|
|
*/
|
2019-01-28 20:47:19 +00:00
|
|
|
public function generateAdapterApiKey(): void
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
|
|
|
$this->adapter_api_key = bin2hex(random_bytes(50));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticate the supplied adapter API key.
|
|
|
|
*
|
2019-01-31 17:54:17 +00:00
|
|
|
* @param string $api_key
|
2017-09-07 03:53:25 +00:00
|
|
|
*/
|
2019-01-28 20:47:19 +00:00
|
|
|
public function validateAdapterApiKey($api_key): bool
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
|
|
|
return hash_equals($api_key, $this->adapter_api_key);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getDescription(): ?string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->description;
|
|
|
|
}
|
2017-01-24 00:35:16 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setDescription(string $description = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->description = $description;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->url;
|
|
|
|
}
|
2016-05-06 08:57:34 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setUrl(string $url = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->url = $this->truncateString($url);
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2017-04-23 20:37:10 +00:00
|
|
|
|
2018-11-26 08:16:55 +00:00
|
|
|
public function getGenre(): ?string
|
|
|
|
{
|
|
|
|
return $this->genre;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setGenre(?string $genre): void
|
|
|
|
{
|
2020-03-29 07:16:41 +00:00
|
|
|
$this->genre = $this->truncateString($genre, 150);
|
2018-11-26 08:16:55 +00:00
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getRadioBaseDir(): ?string
|
|
|
|
{
|
|
|
|
return $this->radio_base_dir;
|
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
|
2020-03-29 07:29:29 +00:00
|
|
|
public function setRadioBaseDir(?string $newDir = null): void
|
2017-05-10 09:01:38 +00:00
|
|
|
{
|
2020-03-29 07:29:29 +00:00
|
|
|
$newDir = $this->truncateString(trim($newDir));
|
|
|
|
|
|
|
|
if (empty($newDir)) {
|
2020-12-03 04:18:06 +00:00
|
|
|
$stationsBaseDir = Environment::getInstance()->getStationDirectory();
|
2020-03-29 07:29:29 +00:00
|
|
|
$newDir = $stationsBaseDir . '/' . $this->getShortName();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->radio_base_dir = $newDir;
|
2017-05-10 09:01:38 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function ensureDirectoriesExist(): void
|
2018-12-05 07:15:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
if (null === $this->radio_base_dir) {
|
|
|
|
$this->setRadioBaseDir(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flysystem adapters will automatically create the main directory.
|
|
|
|
$this->getRadioBaseDirAdapter();
|
|
|
|
$this->getRadioPlaylistsDirAdapter();
|
|
|
|
$this->getRadioConfigDirAdapter();
|
|
|
|
$this->getRadioTempDirAdapter();
|
|
|
|
|
|
|
|
if (null === $this->media_storage_location) {
|
|
|
|
$storageLocation = new StorageLocation(
|
|
|
|
StorageLocation::TYPE_STATION_MEDIA,
|
|
|
|
StorageLocation::ADAPTER_LOCAL
|
|
|
|
);
|
|
|
|
$storageLocation->setPath($this->getRadioBaseDir() . '/media');
|
|
|
|
|
|
|
|
$this->media_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (null === $this->recordings_storage_location) {
|
|
|
|
$storageLocation = new StorageLocation(
|
|
|
|
StorageLocation::TYPE_STATION_RECORDINGS,
|
|
|
|
StorageLocation::ADAPTER_LOCAL
|
|
|
|
);
|
|
|
|
$storageLocation->setPath($this->getRadioBaseDir() . '/recordings');
|
|
|
|
|
|
|
|
$this->recordings_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->getRadioMediaDirAdapter();
|
|
|
|
$this->getRadioRecordingsDirAdapter();
|
2018-12-05 07:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioBaseDirAdapter(?string $suffix = null): AdapterInterface
|
2020-05-12 00:32:41 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
$path = $this->radio_base_dir . $suffix;
|
|
|
|
return new Local($path);
|
2020-05-12 00:32:41 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioPlaylistsDir(): string
|
2018-12-05 07:15:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/playlists';
|
2018-12-05 07:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioPlaylistsDirAdapter(): AdapterInterface
|
2020-01-29 02:23:55 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return new Local($this->getRadioPlaylistsDir());
|
2020-01-29 02:23:55 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioConfigDir(): string
|
2018-11-02 18:44:01 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/config';
|
2018-11-02 18:44:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioConfigDirAdapter(): AdapterInterface
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return new Local($this->getRadioConfigDir());
|
2017-08-17 18:28:48 +00:00
|
|
|
}
|
2017-01-24 00:17:50 +00:00
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioTempDir(): string
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->radio_base_dir . '/temp';
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioTempDirAdapter(): AdapterInterface
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return new Local($this->getRadioTempDir());
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioMediaDirAdapter(): AdapterInterface
|
2019-09-04 18:00:51 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->getMediaStorageLocation()->getStorageAdapter();
|
2019-09-04 18:00:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getRadioRecordingsDirAdapter(): AdapterInterface
|
2020-05-12 00:32:41 +00:00
|
|
|
{
|
2020-11-10 03:06:48 +00:00
|
|
|
return $this->getRecordingsStorageLocation()->getStorageAdapter();
|
2020-05-12 00:32:41 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
public function getNowplaying(): ?Api\NowPlaying
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2018-02-12 12:46:03 +00:00
|
|
|
if ($this->nowplaying instanceof Api\NowPlaying) {
|
|
|
|
return $this->nowplaying;
|
|
|
|
}
|
|
|
|
return null;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setNowplaying(Api\NowPlaying $nowplaying = null): void
|
2017-05-10 09:27:22 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->nowplaying = $nowplaying;
|
2018-02-12 12:46:03 +00:00
|
|
|
|
|
|
|
if ($nowplaying instanceof Api\NowPlaying) {
|
|
|
|
$this->nowplaying_timestamp = time();
|
|
|
|
}
|
2017-09-07 03:53:25 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function getNowplayingTimestamp(): int
|
2019-03-01 00:46:01 +00:00
|
|
|
{
|
2019-09-04 18:00:51 +00:00
|
|
|
return (int)$this->nowplaying_timestamp;
|
2019-03-01 00:46:01 +00:00
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function setNowPlayingTimestamp(int $nowplaying_timestamp): void
|
2017-09-07 03:53:25 +00:00
|
|
|
{
|
2019-09-04 18:00:51 +00:00
|
|
|
$this->nowplaying_timestamp = $nowplaying_timestamp;
|
2017-05-10 09:27:22 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 22:19:31 +00:00
|
|
|
/**
|
|
|
|
* @return mixed[]|null
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getAutomationSettings(): ?array
|
2017-01-24 00:17:50 +00:00
|
|
|
{
|
2017-08-17 18:28:48 +00:00
|
|
|
return $this->automation_settings;
|
2017-01-24 00:17:50 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setAutomationSettings(array $automation_settings = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->automation_settings = $automation_settings;
|
|
|
|
}
|
2016-05-19 14:56:21 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getAutomationTimestamp(): ?int
|
|
|
|
{
|
|
|
|
return $this->automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setAutomationTimestamp(int $automation_timestamp = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->automation_timestamp = $automation_timestamp;
|
|
|
|
}
|
2016-08-30 06:28:56 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getEnableRequests(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_requests;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnableRequests(bool $enable_requests): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->enable_requests = $enable_requests;
|
|
|
|
}
|
2016-09-04 23:24:53 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getRequestDelay(): ?int
|
|
|
|
{
|
|
|
|
return $this->request_delay;
|
|
|
|
}
|
2017-04-14 21:03:59 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setRequestDelay(int $request_delay = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->request_delay = $request_delay;
|
|
|
|
}
|
2016-09-01 18:22:23 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function getRequestThreshold(): ?int
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
return $this->request_threshold;
|
|
|
|
}
|
2016-11-20 04:00:25 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setRequestThreshold(int $request_threshold = null): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->request_threshold = $request_threshold;
|
|
|
|
}
|
2017-06-06 18:07:18 +00:00
|
|
|
|
2018-10-27 00:14:32 +00:00
|
|
|
public function getDisconnectDeactivateStreamer(): int
|
|
|
|
{
|
|
|
|
return $this->disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setDisconnectDeactivateStreamer(int $disconnect_deactivate_streamer): void
|
2018-10-27 00:14:32 +00:00
|
|
|
{
|
|
|
|
$this->disconnect_deactivate_streamer = $disconnect_deactivate_streamer;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getEnableStreamers(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnableStreamers(bool $enable_streamers): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
2019-03-02 00:34:06 +00:00
|
|
|
if ($this->enable_streamers !== $enable_streamers) {
|
|
|
|
$this->setNeedsRestart(true);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
$this->enable_streamers = $enable_streamers;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
public function getIsStreamerLive(): bool
|
|
|
|
{
|
|
|
|
return $this->is_streamer_live;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsStreamerLive(bool $is_streamer_live): void
|
|
|
|
{
|
|
|
|
$this->is_streamer_live = $is_streamer_live;
|
|
|
|
}
|
|
|
|
|
2018-02-01 11:49:40 +00:00
|
|
|
public function getEnablePublicPage(): bool
|
2017-09-18 03:27:32 +00:00
|
|
|
{
|
2018-03-24 07:38:27 +00:00
|
|
|
return (bool)$this->enable_public_page && $this->isEnabled();
|
2017-09-18 03:27:32 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setEnablePublicPage(bool $enable_public_page): void
|
2017-09-18 03:27:32 +00:00
|
|
|
{
|
|
|
|
$this->enable_public_page = $enable_public_page;
|
|
|
|
}
|
|
|
|
|
2020-05-15 10:13:47 +00:00
|
|
|
public function getEnableOnDemand(): bool
|
|
|
|
{
|
|
|
|
return $this->enable_on_demand;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEnableOnDemand(bool $enable_on_demand): void
|
|
|
|
{
|
|
|
|
$this->enable_on_demand = $enable_on_demand;
|
|
|
|
}
|
|
|
|
|
2019-09-04 18:00:51 +00:00
|
|
|
public function isEnabled(): bool
|
|
|
|
{
|
|
|
|
return $this->is_enabled;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getNeedsRestart(): bool
|
|
|
|
{
|
|
|
|
return $this->needs_restart;
|
|
|
|
}
|
2016-09-02 00:34:08 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setNeedsRestart(bool $needs_restart): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->needs_restart = $needs_restart;
|
|
|
|
}
|
2017-05-11 05:48:38 +00:00
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getHasStarted(): bool
|
|
|
|
{
|
|
|
|
return $this->has_started;
|
|
|
|
}
|
2015-01-02 08:16:54 +00:00
|
|
|
|
2019-01-28 20:47:19 +00:00
|
|
|
public function setHasStarted(bool $has_started): void
|
2017-08-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
$this->has_started = $has_started;
|
|
|
|
}
|
|
|
|
|
2018-08-18 23:01:03 +00:00
|
|
|
public function getApiHistoryItems(): int
|
|
|
|
{
|
|
|
|
return $this->api_history_items ?? self::DEFAULT_API_HISTORY_ITEMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setApiHistoryItems(?int $api_history_items): void
|
|
|
|
{
|
|
|
|
$this->api_history_items = $api_history_items;
|
|
|
|
}
|
2019-01-28 20:47:19 +00:00
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
public function getTimezone(): string
|
|
|
|
{
|
|
|
|
if (!empty($this->timezone)) {
|
|
|
|
return $this->timezone;
|
|
|
|
}
|
|
|
|
|
2020-10-09 21:31:48 +00:00
|
|
|
return 'UTC';
|
2019-05-13 21:25:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 06:27:12 +00:00
|
|
|
public function getTimezoneObject(): DateTimeZone
|
2020-08-16 14:54:01 +00:00
|
|
|
{
|
2020-10-05 06:27:12 +00:00
|
|
|
return new DateTimeZone($this->getTimezone());
|
2020-08-16 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-13 21:25:36 +00:00
|
|
|
public function setTimezone(?string $timezone): void
|
|
|
|
{
|
|
|
|
$this->timezone = $timezone;
|
|
|
|
}
|
|
|
|
|
2020-05-03 01:28:08 +00:00
|
|
|
public function getDefaultAlbumArtUrl(): ?string
|
|
|
|
{
|
|
|
|
return $this->default_album_art_url;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $default_album_art_url
|
|
|
|
*/
|
|
|
|
public function setDefaultAlbumArtUrl(?string $default_album_art_url): void
|
|
|
|
{
|
|
|
|
$this->default_album_art_url = $default_album_art_url;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getHistory(): Collection
|
|
|
|
{
|
|
|
|
return $this->history;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStreamers(): Collection
|
|
|
|
{
|
|
|
|
return $this->streamers;
|
|
|
|
}
|
|
|
|
|
2018-02-03 21:54:12 +00:00
|
|
|
public function getCurrentStreamer(): ?StationStreamer
|
|
|
|
{
|
|
|
|
return $this->current_streamer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCurrentStreamer(?StationStreamer $current_streamer = null): void
|
|
|
|
{
|
2020-02-12 01:18:41 +00:00
|
|
|
if (null !== $this->current_streamer || null !== $current_streamer) {
|
|
|
|
$this->current_streamer = $current_streamer;
|
|
|
|
}
|
2018-02-03 21:54:12 +00:00
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
public function getMediaStorageLocation(): StorageLocation
|
|
|
|
{
|
|
|
|
return $this->media_storage_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMediaStorageLocation(StorageLocation $storageLocation): void
|
|
|
|
{
|
|
|
|
if (StorageLocation::TYPE_STATION_MEDIA !== $storageLocation->getType()) {
|
|
|
|
throw new \InvalidArgumentException('Storage location must be for station media.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->media_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRecordingsStorageLocation(): StorageLocation
|
|
|
|
{
|
|
|
|
return $this->recordings_storage_location;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRecordingsStorageLocation(StorageLocation $storageLocation): void
|
|
|
|
{
|
|
|
|
if (StorageLocation::TYPE_STATION_RECORDINGS !== $storageLocation->getType()) {
|
|
|
|
throw new \InvalidArgumentException('Storage location must be for station live recordings.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->recordings_storage_location = $storageLocation;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getPermissions(): Collection
|
|
|
|
{
|
|
|
|
return $this->permissions;
|
|
|
|
}
|
|
|
|
|
2020-11-10 03:06:48 +00:00
|
|
|
/**
|
|
|
|
* @return StationMedia[]|Collection
|
|
|
|
*/
|
|
|
|
public function getMedia(): Collection
|
|
|
|
{
|
|
|
|
return $this->media_storage_location->getMedia();
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationPlaylist[]|Collection
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getPlaylists(): Collection
|
|
|
|
{
|
|
|
|
return $this->playlists;
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationMount[]|Collection
|
|
|
|
*/
|
2017-08-17 18:28:48 +00:00
|
|
|
public function getMounts(): Collection
|
|
|
|
{
|
|
|
|
return $this->mounts;
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:41:15 +00:00
|
|
|
/**
|
|
|
|
* @return StationRemote[]|Collection
|
|
|
|
*/
|
2018-09-09 18:23:03 +00:00
|
|
|
public function getRemotes(): Collection
|
|
|
|
{
|
|
|
|
return $this->remotes;
|
|
|
|
}
|
|
|
|
|
2018-02-12 12:46:03 +00:00
|
|
|
public function getWebhooks(): Collection
|
|
|
|
{
|
|
|
|
return $this->webhooks;
|
|
|
|
}
|
|
|
|
|
2020-01-14 03:49:50 +00:00
|
|
|
public function getSftpUsers(): Collection
|
2020-01-05 21:29:56 +00:00
|
|
|
{
|
2020-02-24 16:22:07 +00:00
|
|
|
return $this->sftp_users;
|
2020-01-05 21:29:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 14:54:01 +00:00
|
|
|
public function clearCache(): void
|
|
|
|
{
|
|
|
|
$this->nowplaying = null;
|
|
|
|
$this->nowplaying_timestamp = 0;
|
|
|
|
}
|
2018-08-04 22:05:14 +00:00
|
|
|
}
|