CC-3301: Add ability to switch stereo/mono stream in stream settings
-fixed
This commit is contained in:
parent
8b5f94fa9f
commit
859445c766
|
@ -163,7 +163,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
foreach ($temp as $t) {
|
||||
$setting[$t['keyname']] = $t['value'];
|
||||
}
|
||||
|
||||
// get predefined type and bitrate from pref table
|
||||
$temp_types = Application_Model_Preference::GetStreamType();
|
||||
$stream_types = array();
|
||||
|
@ -204,12 +203,11 @@ class PreferenceController extends Zend_Controller_Action
|
|||
$form->addSubForm($subform, "s".$i."_subform");
|
||||
}
|
||||
if ($request->isPost()) {
|
||||
$post_data = $request->getPost();
|
||||
$values = $request->getPost();
|
||||
|
||||
$error = false;
|
||||
$values = $post_data;
|
||||
|
||||
if ($form->isValid($post_data)) {
|
||||
if ($form->isValid($values)) {
|
||||
if (!$isSaas) {
|
||||
$values['output_sound_device'] = $form->getValue('output_sound_device');
|
||||
$values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
|
||||
|
@ -264,7 +262,7 @@ class PreferenceController extends Zend_Controller_Action
|
|||
$data = array();
|
||||
$info = Application_Model_StreamSetting::getStreamSetting();
|
||||
$data['setting'] = $info;
|
||||
for ($i=1;$i<=$num_of_stream;$i++) {
|
||||
for ($i=1; $i<=$num_of_stream; $i++) {
|
||||
Application_Model_StreamSetting::setLiquidsoapError($i, "waiting");
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,16 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm
|
|||
}
|
||||
$this->addElement($output);
|
||||
|
||||
$channels = new Zend_Form_Element_Select('channels');
|
||||
$channels->setLabel("Channels:")
|
||||
->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);
|
||||
|
||||
$host = new Zend_Form_Element_Text('host');
|
||||
$host->setLabel("Server")
|
||||
->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"")
|
||||
|
|
|
@ -183,11 +183,13 @@ class Application_Model_StreamSetting
|
|||
}
|
||||
$v = trim($v);
|
||||
|
||||
#escape double single quotes CC-3926
|
||||
$v = str_replace("'", "''", $v);
|
||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||
$stream_setting = CcStreamSettingQuery::create()->filterByDbKeyName($keyname)->findOne();
|
||||
if (is_null($stream_setting)) {
|
||||
throw new Exception("Keyname $keyname does not exist!");
|
||||
}
|
||||
|
||||
$con->exec($sql);
|
||||
$stream_setting->setDbValue($v);
|
||||
$stream_setting->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,14 @@
|
|||
<dd id="<?php echo $s_name?>Output-element">
|
||||
<?php echo $this->element->getElement('output')?>
|
||||
</dd>
|
||||
|
||||
|
||||
<dt id="<?php echo $s_name?>Channels-label">
|
||||
<label for="<?php echo $s_name?>Channels"><?php echo $this->element->getElement('channels')->getLabel()?></label>
|
||||
</dt>
|
||||
<dd id="<?php echo $s_name?>Channels-element">
|
||||
<?php echo $this->element->getElement('channels')?>
|
||||
</dd>
|
||||
|
||||
<fieldset class="padded top-margin display_field toggle closed" id="output_setting">
|
||||
<legend style="cursor: pointer;">
|
||||
<span class="ui-icon ui-icon-triangle-2-n-s"></span>
|
||||
|
|
|
@ -302,3 +302,9 @@ INSERT INTO cc_country (isocode, name) VALUES ('ESH', 'Western Sahara ');
|
|||
INSERT INTO cc_country (isocode, name) VALUES ('YEM', 'Yemen ');
|
||||
INSERT INTO cc_country (isocode, name) VALUES ('ZMB', 'Zambia ');
|
||||
INSERT INTO cc_country (isocode, name) VALUES ('ZWE', 'Zimbabwe ');
|
||||
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_channels', 'stereo', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_channels', 'stereo', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_channels', 'stereo', 'string');
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
DELETE FROM cc_pref WHERE keystr = 'system_version';
|
||||
INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '2.2.0');
|
||||
|
||||
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s1_channels', 'stereo', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s2_channels', 'stereo', 'string');
|
||||
INSERT INTO cc_stream_setting (keyname, value, type) VALUES ('s3_channels', 'stereo', 'string');
|
||||
|
||||
ALTER TABLE cc_files
|
||||
DROP CONSTRAINT cc_files_gunid_idx;
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ def to_live(old,new) =
|
|||
end
|
||||
|
||||
|
||||
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream, connected, name) =
|
||||
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream, connected, name, channels) =
|
||||
source = ref s
|
||||
def on_error(msg)
|
||||
connected := "false"
|
||||
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{!time} &")
|
||||
|
@ -86,12 +87,28 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{!time} &")
|
||||
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{!time} &")
|
||||
end
|
||||
|
||||
stereo = (channels == "stereo")
|
||||
|
||||
if output_type == "icecast" then
|
||||
user_ref = ref user
|
||||
if user == "" then
|
||||
user_ref := "source"
|
||||
end
|
||||
output = output.icecast(host = host,
|
||||
output_mono = output.icecast(host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
mount = mount_point,
|
||||
fallible = true,
|
||||
url = url,
|
||||
description = description,
|
||||
name = name,
|
||||
genre = genre,
|
||||
user = !user_ref,
|
||||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
|
||||
output_stereo = output.icecast(host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
mount = mount_point,
|
||||
|
@ -105,55 +122,131 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
on_connect = on_connect)
|
||||
if type == "mp3" then
|
||||
if bitrate == 24 then
|
||||
ignore(output(%mp3(bitrate = 24),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 24, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 24, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 32 then
|
||||
ignore(output(%mp3(bitrate = 32),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 32, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 32, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 48 then
|
||||
ignore(output(%mp3(bitrate = 48),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 48, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 48, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
ignore(output(%mp3(bitrate = 64),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 64, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 64, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
ignore(output(%mp3(bitrate = 96),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 96, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 96, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
ignore(output(%mp3(bitrate = 128),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 128, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 128, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
ignore(output(%mp3(bitrate = 160),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 160, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 160, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
ignore(output(%mp3(bitrate = 192),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 192, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 192, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
ignore(output(%mp3(bitrate = 224),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 224, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 224, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
ignore(output(%mp3(bitrate = 256),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 256, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 256, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
ignore(output(%mp3(bitrate = 320),s))
|
||||
if stereo then
|
||||
ignore(output_stereo(%mp3(bitrate = 320, stereo = true), !source))
|
||||
else
|
||||
ignore(output_mono(%mp3(bitrate = 320, stereo = false), mean(!source)))
|
||||
end
|
||||
end
|
||||
else
|
||||
source = ref s
|
||||
if not icecast_vorbis_metadata then
|
||||
source := add(normalize=false, [amplify(0.00001, noise()),s])
|
||||
source := add(normalize=false, [amplify(0.00001, noise()), !source])
|
||||
end
|
||||
if bitrate == 24 then
|
||||
ignore(output(%vorbis(quality=-0.1),!source))
|
||||
elsif bitrate == 32 then
|
||||
ignore(output(%vorbis(quality=-0.1),!source))
|
||||
elsif bitrate == 48 then
|
||||
ignore(output(%vorbis(quality=-0.1),!source))
|
||||
|
||||
if bitrate == 24 or bitrate == 32 or bitrate == 48 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=-0.1, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=-0.1, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
ignore(output(%vorbis(quality=0),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
ignore(output(%vorbis(quality=0.2),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.2, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.2, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
ignore(output(%vorbis(quality=0.4),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.4, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.4, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
ignore(output(%vorbis(quality=0.5),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.5, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.5, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
ignore(output(%vorbis(quality=0.6),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.6, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.6, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
ignore(output(%vorbis(quality=0.7),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.7, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.7, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
ignore(output(%vorbis(quality=0.8),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.8, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.8, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
ignore(output(%vorbis(quality=0.9),!source))
|
||||
if stereo then
|
||||
ignore(output_stereo(%vorbis(quality=0.9, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%vorbis(quality=0.9, channels = 1), mean(!source)))
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -176,7 +269,7 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
if url == "" then
|
||||
url_ref := "N/A"
|
||||
end
|
||||
output.shoutcast = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
output.shoutcast_mono = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
|
@ -187,28 +280,85 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
user = !user_ref,
|
||||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
|
||||
output.shoutcast_stereo = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
fallible = true,
|
||||
url = !url_ref,
|
||||
genre = !genre_ref,
|
||||
name = !description_ref,
|
||||
user = !user_ref,
|
||||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
|
||||
if bitrate == 24 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 24),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 24, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 24, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 32 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 32),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 32, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 32, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 48 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 48),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 48, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 48, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 64),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 64, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 64, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 96),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 96, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 96, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 128),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 128, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 128, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 160),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 160, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 160, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 192),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 192, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 192, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 224),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 224, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 224, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 256),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 256, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 256, stereo = false), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
ignore(output.shoutcast(%mp3(bitrate = 320),s))
|
||||
if stereo then
|
||||
ignore(output.shoutcast_stereo(%mp3(bitrate = 320, stereo = true), !source))
|
||||
else
|
||||
ignore(output.shoutcast_mono(%mp3(bitrate = 320, stereo = false), mean(!source)))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -299,7 +299,9 @@ if s1_enable == true then
|
|||
s1_namespace := s1_mount
|
||||
end
|
||||
server.register(namespace=!s1_namespace, "connected", fun (s) -> begin log("#{!s1_namespace}.connected") !s1_connected end)
|
||||
output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass, s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1", s1_connected, s1_description)
|
||||
output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass,
|
||||
s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1",
|
||||
s1_connected, s1_name, s1_channels)
|
||||
end
|
||||
|
||||
if s2_enable == true then
|
||||
|
@ -309,7 +311,9 @@ if s2_enable == true then
|
|||
s2_namespace := s2_mount
|
||||
end
|
||||
server.register(namespace=!s2_namespace, "connected", fun (s) -> begin log("#{!s2_namespace}.connected") !s2_connected end)
|
||||
output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass, s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2", s2_connected, s2_description)
|
||||
output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass,
|
||||
s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2",
|
||||
s2_connected, s2_name, s2_channels)
|
||||
|
||||
end
|
||||
|
||||
|
@ -320,7 +324,9 @@ if s3_enable == true then
|
|||
s3_namespace := s3_mount
|
||||
end
|
||||
server.register(namespace=!s3_namespace, "connected", fun (s) -> begin log("#{!s3_namespace}.connected") !s3_connected end)
|
||||
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected, s3_description)
|
||||
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass,
|
||||
s3_mount, s3_url, s3_name, s3_genre, s3_user, s, "3",
|
||||
s3_connected, s3_description, s3_channels)
|
||||
end
|
||||
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --liquidsoap-started &"
|
||||
|
|
Loading…
Reference in New Issue