diff --git a/config/forms/station.php b/config/forms/station.php index 05cd69932..7b42d9e8c 100644 --- a/config/forms/station.php +++ b/config/forms/station.php @@ -239,16 +239,6 @@ return [ 'elements' => [ - 'enable_streamers' => [ - 'radio', - [ - 'label' => __('Allow Streamers / DJs'), - 'description' => __('If this setting is turned on, streamers (or DJs) will be able to connect directly to your stream and broadcast live music that interrupts the AutoDJ stream.'), - 'default' => '0', - 'choices' => [0 => __('No'), 1 => __('Yes')], - ] - ], - 'enable_requests' => [ 'radio', [ @@ -259,21 +249,6 @@ return [ ] ], - 'charset' => [ - 'radio', - [ - 'label' => __('Character Set Encoding'), - 'description' => __('For most cases, use the default UTF-8 encoding. The older ISO-8859-1 encoding can be used if accepting connections from SHOUTcast 1 DJs or using other legacy software.'), - 'belongsTo' => 'backend_config', - 'default' => 'UTF-8', - 'choices' => [ - 'UTF-8' => 'UTF-8', - 'ISO-8859-1' => 'ISO-8859-1', - ], - 'class' => 'field-advanced', - ], - ], - 'request_delay' => [ 'number', [ @@ -296,19 +271,16 @@ return [ ] ], - 'crossfade' => [ - 'number', + 'enable_streamers' => [ + 'radio', [ - 'label' => __('Crossfade Duration (Seconds)'), - 'belongsTo' => 'backend_config', - 'description' => __('Number of seconds to overlap songs. Set to 0 to disable crossfade completely.'), - 'default' => 2, - 'min' => '0.0', - 'max' => '30.0', - 'step' => '0.1', + 'label' => __('Allow Streamers / DJs'), + 'description' => __('If this setting is turned on, streamers (or DJs) will be able to connect directly to your stream and broadcast live music that interrupts the AutoDJ stream.'), + 'default' => '0', + 'choices' => [0 => __('No'), 1 => __('Yes')], ] ], - + 'disconnect_deactivate_streamer' => [ 'number', [ @@ -320,18 +292,6 @@ return [ ] ], - 'use_manual_autodj' => [ - 'radio', - [ - 'label' => __('Manual AutoDJ Mode'), - 'label_class' => 'advanced', - 'description' => __('This mode disables App\'s AutoDJ management, using Liquidsoap itself to manage song playback. "Next Song" and some other features will not be available.'), - 'default' => '0', - 'choices' => [0 => __('No'), 1 => __('Yes')], - 'belongsTo' => 'backend_config', - ] - ], - 'dj_port' => [ 'text', [ @@ -343,6 +303,17 @@ return [ ] ], + 'dj_mount_point' => [ + 'text', + [ + 'label' => __('Customize DJ/Streamer Mount Point'), + 'label_class' => 'advanced', + 'description' => __('If your streaming software requires a specific mount point path, specify it here. Otherwise, use the default.'), + 'belongsTo' => 'backend_config', + 'default' => '/', + ], + ], + 'dj_buffer' => [ 'text', [ @@ -354,6 +325,46 @@ return [ ] ], + 'charset' => [ + 'radio', + [ + 'label' => __('Character Set Encoding'), + 'description' => __('For most cases, use the default UTF-8 encoding. The older ISO-8859-1 encoding can be used if accepting connections from SHOUTcast 1 DJs or using other legacy software.'), + 'belongsTo' => 'backend_config', + 'default' => 'UTF-8', + 'choices' => [ + 'UTF-8' => 'UTF-8', + 'ISO-8859-1' => 'ISO-8859-1', + ], + 'class' => 'field-advanced', + ], + ], + + 'crossfade' => [ + 'number', + [ + 'label' => __('Crossfade Duration (Seconds)'), + 'belongsTo' => 'backend_config', + 'description' => __('Number of seconds to overlap songs. Set to 0 to disable crossfade completely.'), + 'default' => 2, + 'min' => '0.0', + 'max' => '30.0', + 'step' => '0.1', + ] + ], + + 'use_manual_autodj' => [ + 'radio', + [ + 'label' => __('Manual AutoDJ Mode'), + 'label_class' => 'advanced', + 'description' => __('This mode disables App\'s AutoDJ management, using Liquidsoap itself to manage song playback. "Next Song" and some other features will not be available.'), + 'default' => '0', + 'choices' => [0 => __('No'), 1 => __('Yes')], + 'belongsTo' => 'backend_config', + ] + ], + 'telnet_port' => [ 'text', [ diff --git a/src/Controller/Stations/StreamersController.php b/src/Controller/Stations/StreamersController.php index c19f816dc..cec5d06aa 100644 --- a/src/Controller/Stations/StreamersController.php +++ b/src/Controller/Stations/StreamersController.php @@ -61,6 +61,8 @@ class StreamersController return $view->renderToResponse($response, 'stations/streamers/disabled'); } + $be_settings = (array)$station->getBackendConfig(); + /** @var Entity\Repository\SettingsRepository $settings_repo */ $settings_repo = $this->em->getRepository(Entity\Settings::class); @@ -68,6 +70,7 @@ class StreamersController 'server_url' => $settings_repo->getSetting('base_url', ''), 'stream_port' => $backend->getStreamPort($station), 'streamers' => $station->getStreamers(), + 'dj_mount_point' => $be_settings['dj_mount_point'] ?? '/', 'csrf' => $request->getSession()->getCsrf()->generate($this->csrf_namespace), ]); } diff --git a/src/Radio/Backend/Liquidsoap.php b/src/Radio/Backend/Liquidsoap.php index c59a2b1ab..828ce89d2 100644 --- a/src/Radio/Backend/Liquidsoap.php +++ b/src/Radio/Backend/Liquidsoap.php @@ -107,46 +107,6 @@ class Liquidsoap extends AbstractBackend implements EventSubscriberInterface '', 'set("tag.encodings",["UTF-8","ISO-8859-1"])', 'set("encoder.encoder.export",["artist","title","album","song"])', - '', - '# AutoDJ Next Song Script', - 'def azuracast_next_song() =', - ' uri = get_process_lines("'.$this->_getApiUrlCommand($station, 'nextsong').'")', - ' uri = list.hd(uri, default="")', - ' log("AzuraCast Raw Response: #{uri}")', - ' ', - ' if uri == "" or string.match(pattern="Error", uri) then', - ' log("AzuraCast Error: Delaying subsequent requests...")', - ' system("sleep 2")', - ' request.create("")', - ' else', - ' request.create(uri)', - ' end', - 'end', - '', - '# DJ Authentication', - 'def dj_auth(user,password) =', - ' log("Authenticating DJ: #{user}")', - ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'auth', ['dj_user' => '#{user}', 'dj_password' => '#{password}']).'")', - ' ret = list.hd(ret, default="")', - ' log("AzuraCast DJ Auth Response: #{ret}")', - ' bool_of_string(ret)', - 'end', - '', - 'live_enabled = ref false', - '', - 'def live_connected(header) =', - ' log("DJ Source connected! #{header}")', - ' live_enabled := true', - ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'djon').'")', - ' log("AzuraCast Live Connected Response: #{ret}")', - 'end', - '', - 'def live_disconnected() =', - ' log("DJ Source disconnected!")', - ' live_enabled := false', - ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'djoff').'")', - ' log("AzuraCast Live Disconnected Response: #{ret}")', - 'end', ]); } @@ -333,6 +293,23 @@ class Liquidsoap extends AbstractBackend implements EventSubscriberInterface $ls_config[] = 'requests = audio_to_stereo(request.queue(id="'.$this->_getVarName('requests', $station).'"))'; $fallbacks[] = 'requests'; } else { + $event->appendLines([ + '# AutoDJ Next Song Script', + 'def azuracast_next_song() =', + ' uri = get_process_lines("'.$this->_getApiUrlCommand($station, 'nextsong').'")', + ' uri = list.hd(uri, default="")', + ' log("AzuraCast Raw Response: #{uri}")', + ' ', + ' if uri == "" or string.match(pattern="Error", uri) then', + ' log("AzuraCast Error: Delaying subsequent requests...")', + ' system("sleep 2")', + ' request.create("")', + ' else', + ' request.create(uri)', + ' end', + 'end', + ]); + $ls_config[] = 'dynamic = audio_to_stereo(request.dynamic(id="'.$this->_getVarName('next_song', $station).'", timeout=20., azuracast_next_song))'; $ls_config[] = 'dynamic = cue_cut(id="'.$this->_getVarName('cue_cut', $station).'", dynamic)'; $fallbacks[] = 'dynamic'; @@ -349,11 +326,44 @@ class Liquidsoap extends AbstractBackend implements EventSubscriberInterface public function writeHarborConfiguration(WriteLiquidsoapConfiguration $event) { $station = $event->getStation(); + + if (!$station->getEnableStreamers()) { + return; + } + + $event->appendLines([ + '# DJ Authentication', + 'def dj_auth(user,password) =', + ' log("Authenticating DJ: #{user}")', + ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'auth', ['dj_user' => '#{user}', 'dj_password' => '#{password}']).'")', + ' ret = list.hd(ret, default="")', + ' log("AzuraCast DJ Auth Response: #{ret}")', + ' bool_of_string(ret)', + 'end', + '', + 'live_enabled = ref false', + '', + 'def live_connected(header) =', + ' log("DJ Source connected! #{header}")', + ' live_enabled := true', + ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'djon').'")', + ' log("AzuraCast Live Connected Response: #{ret}")', + 'end', + '', + 'def live_disconnected() =', + ' log("DJ Source disconnected!")', + ' live_enabled := false', + ' ret = get_process_lines("'.$this->_getApiUrlCommand($station, 'djoff').'")', + ' log("AzuraCast Live Disconnected Response: #{ret}")', + 'end', + ]); + $settings = (array)$station->getBackendConfig(); $charset = $settings['charset'] ?? 'UTF-8'; + $dj_mount = $settings['dj_mount_point'] ?? '/'; $harbor_params = [ - '"/"', + '"'.$this->_cleanUpString($dj_mount).'"', 'id="'.$this->_getVarName('input_streamer', $station).'"', 'port='.$this->getStreamPort($station), 'user="shoutcast"', diff --git a/templates/stations/streamers/index.phtml b/templates/stations/streamers/index.phtml index b7be8d82e..1cae5a9e3 100644 --- a/templates/stations/streamers/index.phtml +++ b/templates/stations/streamers/index.phtml @@ -60,7 +60,7 @@
:
-
/
+
e($dj_mount_point) ?>