Merge remote-tracking branch 'origin/saas-stream-settings' into saas-dev

This commit is contained in:
Albert Santoni 2015-08-05 14:50:31 -04:00
commit e49d337db0
14 changed files with 240 additions and 170 deletions

View File

@ -11,6 +11,7 @@ class ProvisioningHelper
private $dbuser, $dbpass, $dbname, $dbhost, $dbowner, $apikey;
private $instanceId;
private $stationName, $description;
private $defaultIcecastPassword;
public function __construct($apikey)
{
@ -118,6 +119,9 @@ class ProvisioningHelper
if (isset($_POST['description'])) {
$this->description = $_POST['description'];
}
if (isset($_POST['icecast_pass'])) {
$this->defaultIcecastPassword = $_POST['icecast_pass'];
}
}
/**
@ -208,6 +212,9 @@ class ProvisioningHelper
if ($this->description) {
Application_Model_Preference::SetStationDescription($this->description);
}
if (isset($this->defaultIcecastPassword)) {
Application_Model_Preference::setDefaultIcecastPassword($this->defaultIcecastPassword);
}
}
}

View File

@ -32,6 +32,8 @@ define('DEFAULT_LOGO_PLACEHOLDER', 1);
define('DEFAULT_LOGO_FILE', 'images/airtime_logo.png');
define('DEFAULT_TIMESTAMP_FORMAT', 'Y-m-d H:i:s');
define('DEFAULT_MICROTIME_FORMAT', 'Y-m-d H:i:s.u');
define('DEFAULT_ICECAST_PORT', 8000);
define('DEFAULT_ICECAST_PASS', 'hackme');
// Metadata Keys for files
define('MDATA_KEY_FILEPATH' , 'filepath');

View File

@ -171,8 +171,7 @@ class LocaleController extends Zend_Controller_Action
"Check this box to automatically switch on Master/Show source upon source connection." => _("Check this box to automatically switch on Master/Show source upon source connection."),
"If your Icecast server expects a username of 'source', this field can be left blank." => _("If your Icecast server expects a username of 'source', this field can be left blank."),
"If your live streaming client does not ask for a username, this field should be 'source'." => _("If your live streaming client does not ask for a username, this field should be 'source'."),
"If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted."
=> _("If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If Airtime is recording, and if the change causes a playout engine restart, the recording will be interrupted."),
"WARNING: This will restart your stream and may cause a short dropout for your listeners!" => _("WARNING: This will restart your stream and may cause a short dropout for your listeners!"),
"This is the admin username and password for Icecast/SHOUTcast to get listener statistics." => _("This is the admin username and password for Icecast/SHOUTcast to get listener statistics."),
//preferences/support-setting.js
"Image must be one of jpg, jpeg, png, or gif" => _("Image must be one of jpg, jpeg, png, or gif"),

View File

@ -149,9 +149,6 @@ class PreferenceController extends Zend_Controller_Action
session_start(); //Open session for writing.
// get current settings
$setting = Application_Model_StreamSetting::getStreamSetting();
$name_map = array(
'ogg' => 'Ogg Vorbis',
'fdkaac' => 'AAC+',
@ -160,55 +157,14 @@ class PreferenceController extends Zend_Controller_Action
'mp3' => 'MP3',
);
// 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";
}
}
$num_of_stream = intval(Application_Model_Preference::GetNumOfStreams());
$form = new Application_Form_StreamSetting();
// $form->addElement('hash', 'csrf', array(
// 'salt' => 'unique'
// ));
$csrf_namespace = new Zend_Session_Namespace('csrf_namespace');
$csrf_element = new Zend_Form_Element_Hidden('csrf');
$csrf_element->setValue($csrf_namespace->authtoken)->setRequired('true')->removeDecorator('HtmlTag')->removeDecorator('Label');
$form->addElement($csrf_element);
$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();
$form->addSubForm($subform, "s".$i."_subform");
}
if ($request->isPost()) {
$params = $request->getPost();
/* Parse through post data and put in format
@ -246,7 +202,6 @@ class PreferenceController extends Zend_Controller_Action
$values["s3_data"] = $s3_data;
$values["s4_data"] = $s4_data;
$error = false;
if ($form->isValid($values)) {
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
@ -263,13 +218,8 @@ class PreferenceController extends Zend_Controller_Action
$s4_set_admin_pass = !empty($values["s4_data"]["admin_pass"]);
// this goes into cc_pref table
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]);
Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]);
Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
$this->setStreamPreferences($values);
// compare new values with current value
$changeRGenabled = Application_Model_Preference::GetEnableReplayGain() != $values["enableReplayGain"];
$changeRGmodifier = Application_Model_Preference::getReplayGainModifier() != $values["replayGainModifier"];
@ -294,34 +244,86 @@ class PreferenceController extends Zend_Controller_Action
}
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
$live_stream_subform->updateVariables();
$this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form;
$this->view->num_stream = $num_of_stream;
$this->view->statusMsg = "<div class='success'>"._("Stream Setting Updated.")."</div>";
$this->_helper->json->sendJson(array(
"valid"=>"true",
"html"=>$this->view->render('preference/stream-setting.phtml'),
"s1_set_admin_pass"=>$s1_set_admin_pass,
"s2_set_admin_pass"=>$s2_set_admin_pass,
"s3_set_admin_pass"=>$s3_set_admin_pass,
"s4_set_admin_pass"=>$s4_set_admin_pass,
));
} else {
$live_stream_subform->updateVariables();
$this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form;
$this->view->num_stream = $num_of_stream;
$this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml')));
}
}
// 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->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form;
if ($request->isPost()) {
if ($form->isValid($values)) {
$this->_helper->json->sendJson(array(
"valid" => "true",
"html" => $this->view->render('preference/stream-setting.phtml'),
"s1_set_admin_pass" => $s1_set_admin_pass,
"s2_set_admin_pass" => $s2_set_admin_pass,
"s3_set_admin_pass" => $s3_set_admin_pass,
"s4_set_admin_pass" => $s4_set_admin_pass,
));
} else {
$this->_helper->json->sendJson(array("valid" => "false", "html" => $this->view->render('preference/stream-setting.phtml')));
}
}
}
/**
* Set stream settings preferences
*
* @param array $values stream setting preference values
*/
private function setStreamPreferences($values) {
Application_Model_Preference::setUsingCustomStreamSettings($values['customStreamSettings']);
Application_Model_Preference::SetStreamLabelFormat($values['streamFormat']);
Application_Model_Preference::SetLiveStreamMasterUsername($values["master_username"]);
Application_Model_Preference::SetLiveStreamMasterPassword($values["master_password"]);
Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
}
public function serverBrowseAction()

View File

@ -41,6 +41,9 @@ class ProvisioningController extends Zend_Controller_Action
if (isset($_POST['provisioning_status'])) {
Application_Model_Preference::setProvisioningStatus($_POST['provisioning_status']);
}
if (isset($_POST['icecast_pass'])) {
Application_Model_Preference::setDefaultIcecastPassword($_POST['icecast_pass']);
}
} catch (Exception $e) {
$this->getResponse()
->setHttpResponseCode(400)

View File

@ -7,7 +7,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
{
$CC_CONFIG = Config::getConfig();
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
@ -103,7 +102,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($showSourceMount);
// demo only code
if (!$isStreamConfigable) {
if ($isDemo) {
$elements = $this->getElements();
foreach ($elements as $element) {
if ($element->getType() != 'Zend_Form_Element_Hidden') {

View File

@ -16,6 +16,10 @@ class Application_Form_StreamSetting extends Zend_Form
public function startFrom()
{
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'preference/stream-setting.phtml'))
));
$setting = $this->setting;
$icecast_vorbis_metadata = new Zend_Form_Element_Checkbox('icecast_vorbis_metadata');
@ -55,6 +59,13 @@ class Application_Form_StreamSetting extends Zend_Form
->setAttribs(array('style' => "border: 0; color: #f6931f; font-weight: bold;"))
->setDecorators(array('ViewHelper'));
$this->addElement($replay_gain);
$custom = Application_Model_Preference::getUsingCustomStreamSettings();
$customSettings = new Zend_Form_Element_Radio('customStreamSettings');
$customSettings->setLabel(_('Streaming Server:'));
$customSettings->setMultiOptions(array(_("Airtime Pro Streaming"), _("Custom / 3rd Party Streaming")));
$customSettings->setValue(!empty($custom) ? $custom : 0);
$this->addElement($customSettings);
}
public function isValid($data)

View File

@ -6,6 +6,8 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
private $stream_types;
private $stream_bitrates;
static $customizable;
public function init()
{
@ -39,54 +41,49 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
$stream_types = $this->stream_types;
$stream_bitrates = $this->stream_bitrates;
$streamDefaults = Application_Model_StreamSetting::getDefaults($prefix);
// If we're not using custom stream settings, use the defaults
$useDefaults = !Application_Model_Preference::getUsingCustomStreamSettings();
$this->setIsArray(true);
$this->setElementsBelongTo($prefix."_data");
$disable_all = Application_Model_Preference::GetEnableStreamConf() == "false";
$enable = new Zend_Form_Element_Checkbox('enable');
$enable->setLabel(_('Enabled:'))
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$enable->setAttrib("disabled", "disabled");
}
$this->addElement($enable);
static::$customizable[] = $enable->getName();
$mobile = new Zend_Form_Element_Checkbox('mobile');
$mobile->setLabel(_('Mobile:'));
$mobile->setValue($setting[$prefix.'_mobile']);
$mobile->setDecorators(array('ViewHelper'));
$this->addElement($mobile);
static::$customizable[] = $mobile->getName();
$type = new Zend_Form_Element_Select('type');
$type->setLabel(_("Stream Type:"))
->setMultiOptions($stream_types)
->setValue(isset($setting[$prefix.'_type'])?$setting[$prefix.'_type']:0)
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$type->setAttrib("disabled", "disabled");
}
$this->addElement($type);
static::$customizable[] = $type->getName();
$bitrate = new Zend_Form_Element_Select('bitrate');
$bitrate->setLabel(_("Bit Rate:"))
->setMultiOptions($stream_bitrates)
->setValue(isset($setting[$prefix.'_bitrate'])?$setting[$prefix.'_bitrate']:0)
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$bitrate->setAttrib("disabled", "disabled");
}
$this->addElement($bitrate);
static::$customizable[] = $bitrate->getName();
$output = new Zend_Form_Element_Select('output');
$output->setLabel(_("Service Type:"))
->setMultiOptions(array("icecast"=>"Icecast", "shoutcast"=>"SHOUTcast"))
->setValue(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast")
->setValue($useDefaults ? $streamDefaults['output'] :
(isset($setting[$prefix.'_output'])?$setting[$prefix.'_output']:"icecast"))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$output->setAttrib("disabled", "disabled");
}
$this->addElement($output);
$channels = new Zend_Form_Element_Select('channels');
@ -94,43 +91,35 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
->setMultiOptions(array("mono"=>_("1 - Mono"), "stereo"=>_("2 - Stereo")))
->setValue(isset($setting[$prefix.'_channels']) ? $setting[$prefix.'_channels'] : "stereo")
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$channels->setAttrib("disabled", "disabled");
}
$this->addElement($channels);
static::$customizable[] = $channels->getName();
$host = new Zend_Form_Element_Text('host');
$host->setLabel(_("Server"))
->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"")
->setValue($useDefaults ? $streamDefaults['host'] :
(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:""))
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$host->setAttrib("disabled", "disabled");
}
$host->setAttrib('alt', 'domain');
$this->addElement($host);
$port = new Zend_Form_Element_Text('port');
$port->setLabel(_("Port"))
->setValue(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:"")
->setValue($useDefaults ? $streamDefaults['port'] :
(isset($setting[$prefix.'_port'])?$setting[$prefix.'_port']:""))
->setValidators(array(new Zend_Validate_Between(array('min'=>0, 'max'=>99999))))
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$port->setAttrib("disabled", "disabled");
}
$this->addElement($port);
$pass = new Zend_Form_Element_Text('pass');
$pass->setLabel(_("Password"))
->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"")
->setValue($useDefaults ? $streamDefaults['pass'] :
(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:""))
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$pass->setAttrib("disabled", "disabled");
}
$pass->setAttrib('alt', 'regular_text');
$this->addElement($pass);
@ -138,9 +127,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
$genre->setLabel(_("Genre"))
->setValue(isset($setting[$prefix.'_genre'])?$setting[$prefix.'_genre']:"")
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$genre->setAttrib("disabled", "disabled");
}
$this->addElement($genre);
$url = new Zend_Form_Element_Text('url');
@ -149,9 +135,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$url->setAttrib("disabled", "disabled");
}
$url->setAttrib('alt', 'url');
$this->addElement($url);
@ -159,41 +142,31 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
$name->setLabel(_("Name"))
->setValue(isset($setting[$prefix.'_name'])?$setting[$prefix.'_name']:"")
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$name->setAttrib("disabled", "disabled");
}
$this->addElement($name);
$description = new Zend_Form_Element_Text('description');
$description->setLabel(_("Description"))
->setValue(isset($setting[$prefix.'_description'])?$setting[$prefix.'_description']:"")
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$description->setAttrib("disabled", "disabled");
}
$this->addElement($description);
$mount = new Zend_Form_Element_Text('mount');
$mount->setLabel(_("Mount Point"))
->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"")
->setValue($useDefaults ? $streamDefaults['mount'] :
(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:""))
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$mount->setAttrib("disabled", "disabled");
}
$mount->setAttrib('alt', 'regular_text');
$this->addElement($mount);
$user = new Zend_Form_Element_Text('user');
$user->setLabel(_("Username"))
->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"")
->setValue($useDefaults ? $streamDefaults['user'] :
(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:""))
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$user->setAttrib("disabled", "disabled");
}
$user->setAttrib('alt', 'regular_text');
$this->addElement($user);
@ -203,9 +176,6 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$adminUser->setAttrib("disabled", "disabled");
}
$adminUser->setAttrib('alt', 'regular_text');
$this->addElement($adminUser);
@ -215,16 +185,16 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => _('Invalid character entered')))))
->setDecorators(array('ViewHelper'));
if ($disable_all) {
$adminPass->setAttrib("disabled", "disabled");
}
$adminPass->setAttrib('alt', 'regular_text');
$this->addElement($adminPass);
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$liquidsoap_error_msg = '<div class="stream-status status-info"><h3>'._('Getting information from the server...').'</h3></div>';
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml', "stream_number"=>$stream_number, "enabled"=>$enable->getValue(), "liquidsoap_error_msg"=>$liquidsopa_error_msg))
array('ViewScript', array('viewScript' => 'form/stream-setting-form.phtml',
"stream_number"=>$stream_number,
"enabled"=>$enable->getValue(),
"liquidsoap_error_msg"=>$liquidsoap_error_msg))
));
}
@ -232,26 +202,42 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
{
$f_data = $data['s'.$this->prefix."_data"];
$isValid = parent::isValid($f_data);
if ($f_data['enable'] == 1) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError(_("Server cannot be empty."));
$isValid = false;
}
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError(_("Port cannot be empty."));
$isValid = false;
}
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError(_("Mount cannot be empty with Icecast server."));
// XXX: A couple of ugly workarounds here, but I guess that's what you get when you
// combine an already-complex POST and GET into a single action...
if (Application_Model_Preference::getUsingCustomStreamSettings() && $f_data) {
if ($f_data['enable'] == 1 && isset($f_data["host"])) {
if ($f_data['host'] == '') {
$element = $this->getElement("host");
$element->addError(_("Server cannot be empty."));
$isValid = false;
}
if ($f_data['port'] == '') {
$element = $this->getElement("port");
$element->addError(_("Port cannot be empty."));
$isValid = false;
}
if ($f_data['output'] == 'icecast') {
if ($f_data['mount'] == '') {
$element = $this->getElement("mount");
$element->addError(_("Mount cannot be empty with Icecast server."));
$isValid = false;
}
}
}
}
return $isValid;
}
public function toggleState() {
$elements = $this->getElements();
foreach ($elements as $element) {
if (Application_Model_Preference::getUsingCustomStreamSettings()) {
$element->setAttrib('disabled', null);
} else if (!(in_array($element->getName(), static::$customizable)
|| $element->getType() == 'Zend_Form_Element_Hidden')) {
$element->setAttrib('disabled', 'disabled');
}
}
}
}

View File

@ -1512,6 +1512,28 @@ class Application_Model_Preference
self::setValue("task_manager_lock", $value);
}
// SAAS-876 - Toggle indicating whether user is using custom stream settings
public static function getUsingCustomStreamSettings() {
return self::getValue("using_custom_stream_settings");
}
public static function setUsingCustomStreamSettings($value) {
self::setValue("using_custom_stream_settings", $value);
}
// SAAS-876 - Store the default Icecast password to restore when switching
// back to Airtime Pro streaming settings
public static function getDefaultIcecastPassword() {
$val = self::getValue("default_icecast_password");
return empty($val) ? DEFAULT_ICECAST_PASS : $val;
}
public static function setDefaultIcecastPassword($value) {
self::setValue("default_icecast_password", $value);
}
public static function getRadioPageDisplayLoginButton()
{
return self::getValue("radio_page_display_login_button");

View File

@ -246,6 +246,10 @@ class Application_Model_StreamSetting
} elseif (is_array($d)) {
$temp = explode('_', $key);
$prefix = $temp[0];
// SAAS-876 - If we're using Airtime Pro streaming, set the stream to use the default settings
if (!Application_Model_Preference::getUsingCustomStreamSettings()) {
$d = array_merge($d, static::getDefaults($prefix));
}
foreach ($d as $k => $v) {
$keyname = $prefix . "_" . $k;
if ($k == 'enable') {
@ -265,8 +269,28 @@ class Application_Model_StreamSetting
}
}
/**
* SAAS-876 - Get the default stream settings values for Airtime Pro streaming
*
* @param int $prefix
*
* @return array array of default stream setting values
*/
public static function getDefaults($prefix) {
$config = Config::getConfig();
return array(
'host' => $config['baseUrl'],
'port' => DEFAULT_ICECAST_PORT,
'output' => 'icecast',
'user' => $config['stationId'],
'pass' => Application_Model_Preference::getDefaultIcecastPassword(),
// Kind of ugly... convert prefix int to ascii char
'mount' => $config['stationId'] . '_' . chr($prefix[1] + 96),
);
}
/*
* Sets indivisual stream setting.
* Sets individual stream setting.
*
* $data - data array. $data is [].
* TODO: Make this SQL a prepared statement!

View File

@ -1,7 +1,7 @@
<?php
$s_name = "s".$this->stream_number;
?>
<h3 class="collapsible-header <?php echo $this->stream_number == '1'?"closed":""?>"><span class="arrow-icon"></span><?php echo _("Stream "); ?><?php echo $this->stream_number?></h3>
<h3 class="collapsible-header <?php echo $this->enabled == 0?"closed":""?>"><span class="arrow-icon"></span><?php echo _("Stream "); ?><?php echo $this->stream_number?></h3>
<div class="stream-setting-content" <?php echo $this->enabled == 0?'style="display: none;':''?> id="<?php echo $s_name?>-config">
<fieldset class="padded">
<dl class="zend_form clearfix">

View File

@ -1,12 +1,10 @@
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong stream-config">
<h2 <?php if($this->enable_stream_conf == "true"){?>style="float:left"<?php }?>><?php echo _("Stream Settings") ?></h2>
<h2 style="float:left"><?php echo _("Stream Settings") ?></h2>
<?php $baseUrl = Application_Common_OsPath::getBaseDir(); ?>
<?php if($this->enable_stream_conf == "true"){?>
<form method="post" id="stream_form" enctype="application/x-www-form-urlencoded">
<button name="stream_save" id="stream_save" type="button" class="btn btn-small right-floated"><?php echo _("Save") ?></button>
<button name="stream_save" id="stream_save_top" type="button" class="btn btn-small right-floated"><?php echo _("Save") ?></button>
<?php echo $this->form->getElement('csrf') ?>
<div style="clear:both"></div>
<?php }?>
<?php echo $this->statusMsg;?>
<div style="float: left; margin-right: 10px; width: 490px; overflow: auto;">
<fieldset class="padded stream-setting-global">
@ -39,6 +37,7 @@
<dd id="vorbisMetadata-element">
<?php echo $this->form->getElement('icecast_vorbis_metadata') ?>
</dd>
<dt id="streamFormat-label">
<label class="optional"><?php echo $this->form->getElement('streamFormat')->getLabel() ?></label>
</dt>
@ -105,16 +104,16 @@
<div style="float: left; width: 600px;">
<fieldset class="padded">
<legend><?php echo _("Output Stream Settings") ?></legend>
<?php
for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform");
}
?>
<?php
// TODO: replace this with something that looks good
echo $this->form->getElement('customStreamSettings')->render();
for($i=1;$i<=$this->num_stream;$i++){
echo $this->form->getSubform("s".$i."_subform");
}
?>
</fieldset>
<?php if($this->enable_stream_conf == "true"){?>
<br />
<button name="stream_save" id="stream_save" type="button" class="btn btn-small right-floated"><?php echo _("Save") ?></button>
<?php }?>
<button name="stream_save" id="stream_save_bottom" type="button" class="btn btn-small right-floated"><?php echo _("Save") ?></button>
</div>
</form>
</div>

View File

@ -1888,6 +1888,7 @@ span.errors.sp-errors{
margin:8px 0 0 0;
cursor:pointer;
position:relative;
clear: both;
}
.collapsible-content {
margin-top:-1px;
@ -2234,6 +2235,10 @@ span.errors.sp-errors{
width: 1100px;
}
#stream_save_bottom {
bottom: 0;
}
.preferences .padded {
margin-top: 5px; /* Firefox needs this */
}

View File

@ -28,7 +28,7 @@ function rebuildStreamURL(ele){
}else{
streamurl = "http://"+host+":"+port+"/"
}
div.find("#stream_url").text(streamurl)
div.find("#stream_url").html('<a href="' + streamurl + '" target="_blank">' + streamurl + '</a>')
}
function restrictOggBitrate(ele, on){
var div = ele.closest("div")
@ -468,19 +468,30 @@ $(document).ready(function() {
setupEventListeners();
setSliderForReplayGain();
getAdminPasswordStatus();
$('#stream_save').live('click', function(){
var confirm_pypo_restart_text = sprintf($.i18n._("If you change the username or password values for an enabled stream the playout engine will be rebooted and your listeners will hear silence for 5-10 seconds. Changing the following fields will NOT cause a reboot: Stream Label (Global Settings), and Switch Transition Fade(s), Master Username, and Master Password (Input Stream Settings). If %s is recording, and if the change causes a playout engine restart, the recording will be interrupted."), PRODUCT_NAME);
var s = $("[name^='customStreamSettings']:checked");
$("[id^='stream_save'], [name^='customStreamSettings']").live('click', function() {
var e = $(this);
if (e[0] == s[0]) { return; }
var confirm_pypo_restart_text = $.i18n._("WARNING: This will restart your stream and may cause a short dropout for your listeners!");
if (confirm(confirm_pypo_restart_text)) {
var data = $('#stream_form').serialize();
var url = baseUrl+'Preference/stream-setting';
$.post(url, {format:"json", data: data}, function(json){
$('#content').empty().append(json.html);
setupEventListeners();
setSliderForReplayGain();
setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass);
window.location.reload();
//$('#content').empty().append(json.html);
//setupEventListeners();
//setSliderForReplayGain();
//setPseudoAdminPassword(json.s1_set_admin_pass, json.s2_set_admin_pass, json.s3_set_admin_pass, json.s4_set_admin_pass);
});
} else {
if (e.prop('checked')) {
if (e[0] != s[0]) {
e.prop('checked', false);
s.prop('checked', true);
}
}
}
});
});