Merge branch 'fix/live-stream-source' of https://github.com/Robbt/libretime into fix/live-stream-source
This commit is contained in:
commit
56dc67fe71
4 changed files with 57 additions and 168 deletions
|
@ -200,6 +200,49 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
|
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
|
||||||
$form->addElement($csrf_element);
|
$form->addElement($csrf_element);
|
||||||
|
|
||||||
|
$live_stream_subform = new Application_Form_LiveStreamingPreferences();
|
||||||
|
$form->addSubForm($live_stream_subform, "live_stream_subform");
|
||||||
|
|
||||||
|
// get predefined type and bitrate from pref table
|
||||||
|
$temp_types = Application_Model_Preference::GetStreamType();
|
||||||
|
$stream_types = array();
|
||||||
|
foreach ($temp_types as $type) {
|
||||||
|
$type = strtolower(trim($type));
|
||||||
|
if (isset($name_map[$type])) {
|
||||||
|
$name = $name_map[$type];
|
||||||
|
} else {
|
||||||
|
$name = $type;
|
||||||
|
}
|
||||||
|
$stream_types[$type] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp_bitrate = Application_Model_Preference::GetStreamBitrate();
|
||||||
|
$max_bitrate = intval(Application_Model_Preference::GetMaxBitrate());
|
||||||
|
$stream_bitrates = array();
|
||||||
|
foreach ($temp_bitrate as $type) {
|
||||||
|
if (intval($type) <= $max_bitrate) {
|
||||||
|
$stream_bitrates[trim($type)] = strtoupper(trim($type))." kbit/s";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get current settings
|
||||||
|
$setting = Application_Model_StreamSetting::getStreamSetting();
|
||||||
|
$form->setSetting($setting);
|
||||||
|
|
||||||
|
for ($i=1; $i<=$num_of_stream; $i++) {
|
||||||
|
$subform = new Application_Form_StreamSettingSubForm();
|
||||||
|
$subform->setPrefix($i);
|
||||||
|
$subform->setSetting($setting);
|
||||||
|
$subform->setStreamTypes($stream_types);
|
||||||
|
$subform->setStreamBitrates($stream_bitrates);
|
||||||
|
$subform->startForm();
|
||||||
|
$subform->toggleState();
|
||||||
|
$form->addSubForm($subform, "s".$i."_subform");
|
||||||
|
}
|
||||||
|
|
||||||
|
$live_stream_subform->updateVariables();
|
||||||
|
$form->startFrom();
|
||||||
|
|
||||||
if ($request->isPost()) {
|
if ($request->isPost()) {
|
||||||
$params = $request->getPost();
|
$params = $request->getPost();
|
||||||
/* Parse through post data and put in format
|
/* Parse through post data and put in format
|
||||||
|
@ -265,7 +308,7 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
// pulling this from the 2.5.x branch
|
// pulling this from the 2.5.x branch
|
||||||
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
|
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
|
||||||
$master_connection_url = "http://".$_SERVER['SERVER_NAME'].":".$values["master_source_port"].$values["master_source_mount"];
|
$master_connection_url = "http://".$_SERVER['SERVER_NAME'].":".$values["master_source_port"].$values["master_source_mount"];
|
||||||
if (empty($values["master_source_port"]) || empty($values["master_source_port"])) {
|
if (empty($values["master_source_port"]) || empty($values["master_source_mount"])) {
|
||||||
Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A');
|
Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A');
|
||||||
} else {
|
} else {
|
||||||
Application_Model_Preference::SetMasterDJSourceConnectionURL($master_connection_url);
|
Application_Model_Preference::SetMasterDJSourceConnectionURL($master_connection_url);
|
||||||
|
@ -291,12 +334,6 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
Application_Model_StreamSetting::setDjLiveStreamPort($values["show_source_port"]);
|
Application_Model_StreamSetting::setDjLiveStreamPort($values["show_source_port"]);
|
||||||
Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["show_source_mount"]);
|
Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["show_source_mount"]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Application_Model_StreamSetting::setOffAirMeta($values['offAirMeta']);
|
Application_Model_StreamSetting::setOffAirMeta($values['offAirMeta']);
|
||||||
|
|
||||||
// store stream update timestamp
|
// store stream update timestamp
|
||||||
|
@ -314,50 +351,6 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get predefined type and bitrate from pref table
|
|
||||||
$temp_types = Application_Model_Preference::GetStreamType();
|
|
||||||
$stream_types = array();
|
|
||||||
foreach ($temp_types as $type) {
|
|
||||||
$type = strtolower(trim($type));
|
|
||||||
if (isset($name_map[$type])) {
|
|
||||||
$name = $name_map[$type];
|
|
||||||
} else {
|
|
||||||
$name = $type;
|
|
||||||
}
|
|
||||||
$stream_types[$type] = $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$temp_bitrate = Application_Model_Preference::GetStreamBitrate();
|
|
||||||
$max_bitrate = intval(Application_Model_Preference::GetMaxBitrate());
|
|
||||||
$stream_bitrates = array();
|
|
||||||
foreach ($temp_bitrate as $type) {
|
|
||||||
if (intval($type) <= $max_bitrate) {
|
|
||||||
$stream_bitrates[trim($type)] = strtoupper(trim($type))." kbit/s";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get current settings
|
|
||||||
$setting = Application_Model_StreamSetting::getStreamSetting();
|
|
||||||
|
|
||||||
$form->setSetting($setting);
|
|
||||||
$form->startFrom();
|
|
||||||
|
|
||||||
$live_stream_subform = new Application_Form_LiveStreamingPreferences();
|
|
||||||
$form->addSubForm($live_stream_subform, "live_stream_subform");
|
|
||||||
|
|
||||||
for ($i=1; $i<=$num_of_stream; $i++) {
|
|
||||||
$subform = new Application_Form_StreamSettingSubForm();
|
|
||||||
$subform->setPrefix($i);
|
|
||||||
$subform->setSetting($setting);
|
|
||||||
$subform->setStreamTypes($stream_types);
|
|
||||||
$subform->setStreamBitrates($stream_bitrates);
|
|
||||||
$subform->startForm();
|
|
||||||
$subform->toggleState();
|
|
||||||
$form->addSubForm($subform, "s".$i."_subform");
|
|
||||||
}
|
|
||||||
|
|
||||||
$live_stream_subform->updateVariables();
|
|
||||||
|
|
||||||
$this->view->num_stream = $num_of_stream;
|
$this->view->num_stream = $num_of_stream;
|
||||||
$this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
|
$this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
|
@ -7,7 +7,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
$CC_CONFIG = Config::getConfig();
|
$CC_CONFIG = Config::getConfig();
|
||||||
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
||||||
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
|
|
||||||
|
|
||||||
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
|
|
||||||
// Master source connection url parameters
|
// Master source connection url parameters
|
||||||
$masterSourceHost = new Zend_Form_Element_Text('master_source_host');
|
$masterSourceHost = new Zend_Form_Element_Text('master_source_host');
|
||||||
$masterSourceHost->setLabel(_('Host:'))
|
$masterSourceHost->setLabel(_('Master Source Host:'))
|
||||||
->setAttrib('readonly', true)
|
->setAttrib('readonly', true)
|
||||||
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
->setValue(Application_Model_Preference::GetMasterDJSourceConnectionURL());
|
||||||
$this->addElement($masterSourceHost);
|
$this->addElement($masterSourceHost);
|
||||||
|
@ -97,7 +96,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
|
|
||||||
// Show source connection url parameters
|
// Show source connection url parameters
|
||||||
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
|
$showSourceHost = new Zend_Form_Element_Text('show_source_host');
|
||||||
$showSourceHost->setLabel(_('Host:'))
|
$showSourceHost->setLabel(_('Show Source Host:'))
|
||||||
->setAttrib('readonly', true)
|
->setAttrib('readonly', true)
|
||||||
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
->setValue(Application_Model_Preference::GetLiveDJSourceConnectionURL());
|
||||||
$this->addElement($showSourceHost);
|
$this->addElement($showSourceHost);
|
||||||
|
@ -146,12 +145,4 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function isValid($data)
|
|
||||||
{
|
|
||||||
$isValid = parent::isValid($data);
|
|
||||||
|
|
||||||
return $isValid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -141,9 +141,6 @@ function setLiveSourceConnectionOverrideListener(){
|
||||||
mount = ('/').concat(mount);
|
mount = ('/').concat(mount);
|
||||||
}
|
}
|
||||||
var url = "http://"+location.hostname+":"+port+mount;
|
var url = "http://"+location.hostname+":"+port+mount;
|
||||||
if (port == '' || mount == '') {
|
|
||||||
url = 'N/A';
|
|
||||||
}
|
|
||||||
live_dj_input.val(url);
|
live_dj_input.val(url);
|
||||||
live_dj_input.attr("readonly", "readonly");
|
live_dj_input.attr("readonly", "readonly");
|
||||||
live_dj_actions.hide();
|
live_dj_actions.hide();
|
||||||
|
@ -167,9 +164,6 @@ function setLiveSourceConnectionOverrideListener(){
|
||||||
mount = ('/').concat(mount);
|
mount = ('/').concat(mount);
|
||||||
}
|
}
|
||||||
var url = "http://"+location.hostname+":"+port+mount;
|
var url = "http://"+location.hostname+":"+port+mount;
|
||||||
if (port == '' || mount == '') {
|
|
||||||
url = 'N/A';
|
|
||||||
}
|
|
||||||
master_dj_input.val(url);
|
master_dj_input.val(url);
|
||||||
master_dj_input.attr("readonly", "readonly");
|
master_dj_input.attr("readonly", "readonly");
|
||||||
master_dj_actions.hide();
|
master_dj_actions.hide();
|
||||||
|
@ -484,11 +478,13 @@ $(document).ready(function() {
|
||||||
var url = baseUrl+'Preference/stream-setting';
|
var url = baseUrl+'Preference/stream-setting';
|
||||||
|
|
||||||
$.post(url, {format:"json", data: data}, function(json){
|
$.post(url, {format:"json", data: data}, function(json){
|
||||||
window.location.reload();
|
$('#content').empty().append(json.html);
|
||||||
//$('#content').empty().append(json.html);
|
if (json.valid) {
|
||||||
//setupEventListeners();
|
window.location.reload();
|
||||||
//setSliderForReplayGain();
|
}
|
||||||
//setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass);
|
setupEventListeners();
|
||||||
|
setSliderForReplayGain();
|
||||||
|
getAdminPasswordStatus();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (e.prop('checked')) {
|
if (e.prop('checked')) {
|
||||||
|
|
|
@ -205,102 +205,11 @@ class PypoFetch(Thread):
|
||||||
self.telnet_lock.release()
|
self.telnet_lock.release()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
TODO: This function needs to be way shorter, and refactored :/ - MK
|
NOTE: This function is quite short after it was refactored.
|
||||||
"""
|
"""
|
||||||
def regenerate_liquidsoap_conf(self, setting):
|
def regenerate_liquidsoap_conf(self, setting):
|
||||||
existing = {}
|
self.restart_liquidsoap()
|
||||||
|
self.update_liquidsoap_connection_status()
|
||||||
setting = sorted(setting.items())
|
|
||||||
try:
|
|
||||||
fh = open('/etc/airtime/liquidsoap.cfg', 'r')
|
|
||||||
except IOError, e:
|
|
||||||
#file does not exist
|
|
||||||
self.restart_liquidsoap()
|
|
||||||
return
|
|
||||||
|
|
||||||
self.logger.info("Reading existing config...")
|
|
||||||
# read existing conf file and build dict
|
|
||||||
while True:
|
|
||||||
line = fh.readline()
|
|
||||||
|
|
||||||
# empty line means EOF
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
|
|
||||||
line = line.strip()
|
|
||||||
|
|
||||||
if not len(line) or line[0] == "#":
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
key, value = line.split('=', 1)
|
|
||||||
except ValueError:
|
|
||||||
continue
|
|
||||||
key = key.strip()
|
|
||||||
value = value.strip()
|
|
||||||
value = value.replace('"', '')
|
|
||||||
if value == '' or value == "0":
|
|
||||||
value = ''
|
|
||||||
existing[key] = value
|
|
||||||
fh.close()
|
|
||||||
|
|
||||||
# dict flag for any change in config
|
|
||||||
change = {}
|
|
||||||
# this flag is to detect disable -> disable change
|
|
||||||
# in that case, we don't want to restart even if there are changes.
|
|
||||||
state_change_restart = {}
|
|
||||||
#restart flag
|
|
||||||
restart = False
|
|
||||||
|
|
||||||
self.logger.info("Looking for changes...")
|
|
||||||
# look for changes
|
|
||||||
for k, s in setting:
|
|
||||||
if "output_sound_device" in k or "icecast_vorbis_metadata" in k:
|
|
||||||
dump, stream = k.split('_', 1)
|
|
||||||
state_change_restart[stream] = False
|
|
||||||
# This is the case where restart is required no matter what
|
|
||||||
if (existing[k] != str(s)):
|
|
||||||
self.logger.info("'Need-to-restart' state detected for %s...", s)
|
|
||||||
restart = True;
|
|
||||||
elif "master_live_stream_port" in k or "master_live_stream_mp" in k or "dj_live_stream_port" in k or "dj_live_stream_mp" in k or "off_air_meta" in k:
|
|
||||||
if (existing[k] != s):
|
|
||||||
self.logger.info("'Need-to-restart' state detected for %s...", s)
|
|
||||||
restart = True;
|
|
||||||
else:
|
|
||||||
stream, dump = k.split('_', 1)
|
|
||||||
if "_output" in k:
|
|
||||||
if (existing[k] != s):
|
|
||||||
self.logger.info("'Need-to-restart' state detected for %s...", s)
|
|
||||||
restart = True;
|
|
||||||
state_change_restart[stream] = True
|
|
||||||
elif (k != 'disabled'):
|
|
||||||
state_change_restart[stream] = True
|
|
||||||
else:
|
|
||||||
state_change_restart[stream] = False
|
|
||||||
else:
|
|
||||||
# setting inital value
|
|
||||||
if stream not in change:
|
|
||||||
change[stream] = False
|
|
||||||
if not (s == existing[k]):
|
|
||||||
self.logger.info("Keyname: %s, Current value: %s, New Value: %s", k, existing[k], s)
|
|
||||||
change[stream] = True
|
|
||||||
|
|
||||||
# set flag change for sound_device alway True
|
|
||||||
self.logger.info("Change:%s, State_Change:%s...", change, state_change_restart)
|
|
||||||
|
|
||||||
for k, v in state_change_restart.items():
|
|
||||||
if k == "sound_device" and v:
|
|
||||||
restart = True
|
|
||||||
elif v and change[k]:
|
|
||||||
self.logger.info("'Need-to-restart' state detected for %s...", k)
|
|
||||||
restart = True
|
|
||||||
# rewrite
|
|
||||||
if restart:
|
|
||||||
self.restart_liquidsoap()
|
|
||||||
else:
|
|
||||||
self.logger.info("No change detected in setting...")
|
|
||||||
self.update_liquidsoap_connection_status()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ls_timeout
|
@ls_timeout
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue