Merge pull request #3 from Robbt/Robbt-fix/live-stream-source
fixed default and override URL settings and removed unused validation
This commit is contained in:
commit
1a9daa52dd
|
@ -264,7 +264,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
|
||||
// pulling this from the 2.5.x branch
|
||||
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
|
||||
$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"])) {
|
||||
Application_Model_Preference::SetMasterDJSourceConnectionURL('N/A');
|
||||
} else {
|
||||
|
|
|
@ -77,6 +77,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
->setValue($m_port)
|
||||
->setValidators(array($betweenValidator))
|
||||
->addValidator('regex', false, array('pattern'=>'/^[0-9]+$/', 'messages'=>array('regexNotMatch'=>_('Only numbers are allowed.'))));
|
||||
|
||||
$this->addElement($masterSourcePort);
|
||||
|
||||
$m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
|
||||
|
@ -153,53 +154,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
|
||||
public function isValid($data)
|
||||
{
|
||||
$isValid = parent::isValid($data);
|
||||
$master_source_port = $data['master_source_port'];
|
||||
$show_source_port = $data['show_source_port'];
|
||||
|
||||
if ($master_source_port == $show_source_port && $master_source_port != "") {
|
||||
$element = $this->getElement('show_source_port');
|
||||
$element->addError(_("You cannot use same port as Master DJ port."));
|
||||
$isValid = false;
|
||||
}
|
||||
if ($master_source_port != "") {
|
||||
if (is_numeric($master_source_port)) {
|
||||
if ($master_source_port != Application_Model_StreamSetting::getMasterLiveStreamPort()) {
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
try {
|
||||
socket_bind($sock, 0, $master_source_port);
|
||||
} catch (Exception $e) {
|
||||
$element = $this->getElement("master_source_port");
|
||||
$element->addError(sprintf(_("Port %s is not available"), $master_source_port));
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
socket_close($sock);
|
||||
}
|
||||
} else {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if ($show_source_port != "") {
|
||||
if (is_numeric($show_source_port)) {
|
||||
if ($show_source_port != Application_Model_StreamSetting::getDjLiveStreamPort()) {
|
||||
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
||||
try {
|
||||
socket_bind($sock, 0, $show_source_port);
|
||||
} catch (Exception $e) {
|
||||
$element = $this->getElement("show_source_port");
|
||||
$element->addError(sprintf(_("Port %s is not available"), $show_source_port));
|
||||
$isValid = false;
|
||||
}
|
||||
socket_close($sock);
|
||||
}
|
||||
} else {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
|
||||
return $isValid = parent::isValid($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1102,7 +1102,13 @@ class Application_Model_Preference
|
|||
|
||||
public static function GetMasterDJSourceConnectionURL()
|
||||
{
|
||||
return self::getValue("master_dj_source_connection_url");
|
||||
$master_connection_url = self::getValue("master_dj_source_connection_url");
|
||||
if ($master_connection_url == "") {
|
||||
$master_connection_url = "http://".$_SERVER['SERVER_NAME'].":". Application_Model_StreamSetting::getMasterLiveStreamPort() . Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
|
||||
}
|
||||
|
||||
return $master_connection_url;
|
||||
|
||||
}
|
||||
|
||||
public static function SetLiveDJSourceConnectionURL($value)
|
||||
|
@ -1112,7 +1118,11 @@ class Application_Model_Preference
|
|||
|
||||
public static function GetLiveDJSourceConnectionURL()
|
||||
{
|
||||
return self::getValue("live_dj_source_connection_url");
|
||||
$livedj_connection_url = self::getValue("live_dj_source_connection_url");
|
||||
if ($livedj_connection_url == "") {
|
||||
$livedj_connection_url = "http://".$_SERVER['SERVER_NAME'].":". Application_Model_StreamSetting::getDjLiveStreamPort() . Application_Model_StreamSetting::getDjLiveStreamMountPoint();
|
||||
}
|
||||
return $livedj_connection_url;
|
||||
}
|
||||
|
||||
/* Source Connection URL override status starts */
|
||||
|
|
|
@ -129,7 +129,7 @@ function setLiveSourceConnectionOverrideListener(){
|
|||
live_dj_input.val(url);
|
||||
live_dj_input.attr("readonly", "readonly");
|
||||
live_dj_actions.hide();
|
||||
$.get(baseUrl+"Preference/set-source-connection-url/", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 1});
|
||||
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 1});
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
|
@ -137,7 +137,10 @@ function setLiveSourceConnectionOverrideListener(){
|
|||
event.preventDefault();
|
||||
var port = $("#show_source_port").val();
|
||||
var mount = $("#show_source_mount").val();
|
||||
var url = "http://"+location.hostname+":"+port+"/"+mount;
|
||||
if (mount.charAt(0) != '/') {
|
||||
mount = ('/').concat(mount);
|
||||
}
|
||||
var url = "http://"+location.hostname+":"+port+mount;
|
||||
if (port == '' || mount == '') {
|
||||
url = 'N/A';
|
||||
}
|
||||
|
@ -160,7 +163,10 @@ function setLiveSourceConnectionOverrideListener(){
|
|||
master_dj_actions.find("#reset").click(function(event){
|
||||
var port = $("#master_source_port").val();
|
||||
var mount = $("#master_source_mount").val();
|
||||
var url = "http://"+location.hostname+":"+port+"/"+mount;
|
||||
if (mount.charAt(0) != '/') {
|
||||
mount = ('/').concat(mount);
|
||||
}
|
||||
var url = "http://"+location.hostname+":"+port+mount;
|
||||
if (port == '' || mount == '') {
|
||||
url = 'N/A';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue