#1115 -- Make DJ mount point configurable.

This commit is contained in:
Buster "Silver Eagle" Neece 2019-01-29 18:25:41 -06:00
parent ea160925af
commit 72c4d3ab44
4 changed files with 113 additions and 89 deletions

View File

@ -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',
[

View File

@ -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),
]);
}

View File

@ -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"',

View File

@ -60,7 +60,7 @@
<dd><?=(int)$stream_port ?></dd>
<dt><?=__('Mount Name') ?>:</dt>
<dd>/</dd>
<dd><?=$this->e($dj_mount_point) ?></dd>
</dl>
<h3 class="card-subtitle mt-3"><?=__('ShoutCast v1 Clients') ?></h3>