Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
17884dbe49
15 changed files with 110 additions and 59 deletions
|
@ -772,15 +772,17 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$error_msg = $request->getParam('error_msg');
|
||||
$stream_id = $request->getParam('stream_id');
|
||||
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg);
|
||||
$boot_time = $request->getParam('boot_time');
|
||||
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg, $boot_time);
|
||||
}
|
||||
|
||||
public function updateLiquidsoapConnectionAction(){
|
||||
$request = $this->getRequest();
|
||||
|
||||
$stream_id = $request->getParam('stream_id');
|
||||
$boot_time = $request->getParam('boot_time');
|
||||
// setting error_msg as "" when there is no error_msg
|
||||
Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK");
|
||||
Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK", $boot_time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -203,6 +203,11 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_StreamSetting::setStreamSetting($values);
|
||||
$data = array();
|
||||
$data['setting'] = Application_Model_StreamSetting::getStreamSetting();
|
||||
for($i=1;$i<=$num_of_stream;$i++){
|
||||
Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
|
||||
}
|
||||
// store stream update timestamp
|
||||
Application_Model_Preference::SetStreamUpdateTimestamp();
|
||||
Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data);
|
||||
$this->view->statusMsg = "<div class='success'>Stream Setting Updated.</div>";
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
|
|||
|
||||
$enable = new Zend_Form_Element_Checkbox('enable');
|
||||
$enable->setLabel('Enabled:')
|
||||
->setValue($setting[$prefix.'_output'] != 'disabled'?1:0)
|
||||
->setValue($setting[$prefix.'_enable'] == 'true' ? 1 : 0)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
if($disable_all){
|
||||
$enable->setAttrib("disabled", "disabled");
|
||||
|
|
|
@ -573,6 +573,25 @@ class Application_Model_Preference
|
|||
return $val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the last timestamp of user updating stream setting
|
||||
*/
|
||||
public static function SetStreamUpdateTimestamp() {
|
||||
$now = time();
|
||||
self::SetValue("stream_update_timestamp", $now);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last timestamp of user updating stream setting
|
||||
*/
|
||||
public static function GetStreamUpdateTimestemp() {
|
||||
$update_time = self::GetValue("stream_update_timestamp");
|
||||
if($update_time == null){
|
||||
$update_time = 0;
|
||||
}
|
||||
return $update_time;
|
||||
}
|
||||
|
||||
/* User specific preferences start */
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ class Application_Model_StreamSetting {
|
|||
global $CC_DBC;
|
||||
$sql = "SELECT * "
|
||||
."FROM cc_stream_setting "
|
||||
."WHERE keyname LIKE '%_output' "
|
||||
."AND value != 'disabled'";
|
||||
."WHERE keyname LIKE '%_enable' "
|
||||
."AND value == true";
|
||||
|
||||
$rows = $CC_DBC->getAll($sql);
|
||||
$ids = array();
|
||||
|
@ -75,21 +75,18 @@ class Application_Model_StreamSetting {
|
|||
*/
|
||||
public static function setStreamSetting($data){
|
||||
global $CC_DBC;
|
||||
foreach($data as $key=>$d){
|
||||
if($key == "output_sound_device" || $key == "icecast_vorbis_metadata"){
|
||||
foreach ($data as $key=>$d) {
|
||||
if ($key == "output_sound_device" || $key == "icecast_vorbis_metadata") {
|
||||
$v = $d == 1?"true":"false";
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$temp = explode('_', $key);
|
||||
$prefix = $temp[0];
|
||||
foreach($d as $k=>$v){
|
||||
$keyname = $prefix."_".$k;
|
||||
if( $k == 'output'){
|
||||
if( $d["enable"] == 0){
|
||||
$v = 'disabled';
|
||||
}
|
||||
foreach ($d as $k=>$v) {
|
||||
$keyname = $prefix . "_" . $k;
|
||||
if ($k == 'enable') {
|
||||
$v = $d['enable'] == 1 ? 'true' : 'false';
|
||||
}
|
||||
$v = trim($v);
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||
|
@ -113,22 +110,29 @@ class Application_Model_StreamSetting {
|
|||
}
|
||||
}
|
||||
|
||||
public static function setLiquidsoapError($stream_id, $msg){
|
||||
/*
|
||||
* Stores liquidsoap status if $boot_time > save time.
|
||||
* save time is the time that user clicked save on stream setting page
|
||||
*/
|
||||
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null){
|
||||
global $CC_DBC;
|
||||
|
||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if ($result == 1){
|
||||
$sql = "UPDATE cc_stream_setting"
|
||||
." SET value = '$msg'"
|
||||
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
|
||||
if($boot_time == null || $boot_time > $update_time ){
|
||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
}else{
|
||||
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||
." VALUES ('$keyname', '$msg', 'string')";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if ($result == 1){
|
||||
$sql = "UPDATE cc_stream_setting"
|
||||
." SET value = '$msg'"
|
||||
." WHERE keyname = '$keyname'";
|
||||
}else{
|
||||
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||
." VALUES ('$keyname', '$msg', 'string')";
|
||||
}
|
||||
$res = $CC_DBC->query($sql);
|
||||
}
|
||||
$res = $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public static function getLiquidsoapError($stream_id){
|
||||
|
@ -145,17 +149,15 @@ class Application_Model_StreamSetting {
|
|||
public static function getStreamEnabled($stream_id){
|
||||
global $CC_DBC;
|
||||
|
||||
$keyname = "s".$stream_id."_output";
|
||||
$keyname = "s" . $stream_id . "_enable";
|
||||
$sql = "SELECT value FROM cc_stream_setting"
|
||||
." WHERE keyname = '$keyname'";
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
|
||||
if($result == 'disabled'){
|
||||
if ($result == 'false') {
|
||||
$result = false;
|
||||
}else{
|
||||
} else {
|
||||
$result = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ INSERT INTO cc_pref("keystr", "valstr") VALUES('plan_level', 'disabled');
|
|||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
|
||||
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_enable', 'true', 'boolean');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_type', 'ogg', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_bitrate', '128', 'integer');
|
||||
|
@ -22,7 +23,8 @@ INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_url', 'ht
|
|||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_description', 'Airtime Radio! Stream #1', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s1_genre', 'genre', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_enable', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_host', '', 'string');
|
||||
|
@ -34,7 +36,8 @@ INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_url', '',
|
|||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_description', '', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s2_genre', '', 'string');
|
||||
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_output', 'disabled', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_enable', 'false', 'boolean');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_output', 'icecast', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_type', '', 'string');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_bitrate', '', 'integer');
|
||||
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('s3_host', '', 'string');
|
||||
|
|
|
@ -96,6 +96,8 @@ function checkLiquidsoapStatus(){
|
|||
html = '<div class="stream-status status-good"><h3>Connected to the streaming server</h3></div>'
|
||||
}else if(status == "N/A"){
|
||||
html = '<div class="stream-status status-disabled"><h3>The stream is disabled</h3></div>'
|
||||
}else if(status == "waiting"){
|
||||
html = '<div class="stream-status status-info"><h3>Getting information from the server...</h3></div>'
|
||||
}else{
|
||||
html = '<div class="stream-status status-error"><h3>Can not connect to the streaming server</h3><p>'+status+'</p></div>'
|
||||
}
|
||||
|
@ -163,6 +165,6 @@ $(document).ready(function() {
|
|||
})
|
||||
|
||||
showErrorSections()
|
||||
setInterval('checkLiquidsoapStatus()', 7000)
|
||||
setInterval('checkLiquidsoapStatus()', 1000)
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue