CC-2706: Streams should have a username field

- adding "User" field on stream setting form
- change key name from "output_s1" to "s1_output" format to be consistent
- changed order of inserting in default.sql file
- hiding username field on shoutcast selection
- liquidsoap and pypo takes care of user field input
This commit is contained in:
James 2011-08-24 17:13:56 -04:00
parent 9eb21cb327
commit 58837ff89b
8 changed files with 136 additions and 89 deletions

View file

@ -37,9 +37,13 @@ def to_live(old,new) =
end
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s) =
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s) =
if output_type == "icecast" then
output.icecast = output.icecast(host = host,
user_ref = ref user
if user == "" then
user_ref := "source"
end
output = output.icecast(host = host,
port = port,
password = pass,
mount = mount_point,
@ -48,30 +52,31 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
restart_delay = 5,
url = url,
description = description,
genre = genre)
genre = genre,
user = !user_ref)
if type == "mp3" then
if bitrate == 24 then
ignore(output.icecast(%mp3(bitrate = 24),s))
ignore(output(%mp3(bitrate = 24),s))
elsif bitrate == 32 then
ignore(output.icecast(%mp3(bitrate = 32),s))
ignore(output(%mp3(bitrate = 32),s))
elsif bitrate == 48 then
ignore(output.icecast(%mp3(bitrate = 48),s))
ignore(output(%mp3(bitrate = 48),s))
elsif bitrate == 64 then
ignore(output.icecast(%mp3(bitrate = 64),s))
ignore(output(%mp3(bitrate = 64),s))
elsif bitrate == 96 then
ignore(output.icecast(%mp3(bitrate = 96),s))
ignore(output(%mp3(bitrate = 96),s))
elsif bitrate == 128 then
ignore(output.icecast(%mp3(bitrate = 128),s))
ignore(output(%mp3(bitrate = 128),s))
elsif bitrate == 160 then
ignore(output.icecast(%mp3(bitrate = 160),s))
ignore(output(%mp3(bitrate = 160),s))
elsif bitrate == 192 then
ignore(output.icecast(%mp3(bitrate = 192),s))
ignore(output(%mp3(bitrate = 192),s))
elsif bitrate == 224 then
ignore(output.icecast(%mp3(bitrate = 224),s))
ignore(output(%mp3(bitrate = 224),s))
elsif bitrate == 256 then
ignore(output.icecast(%mp3(bitrate = 256),s))
ignore(output(%mp3(bitrate = 256),s))
elsif bitrate == 320 then
ignore(output.icecast(%mp3(bitrate = 320),s))
ignore(output(%mp3(bitrate = 320),s))
end
else
source = ref s
@ -79,30 +84,34 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
source := add(normalize=false, [amplify(0.00001, noise()),s])
end
if bitrate == 24 then
ignore(output.icecast(%vorbis.cbr(bitrate = 24),!source))
ignore(output(%vorbis.cbr(bitrate = 24),!source))
elsif bitrate == 32 then
ignore(output.icecast(%vorbis.cbr(bitrate = 32),!source))
ignore(output(%vorbis.cbr(bitrate = 32),!source))
elsif bitrate == 48 then
ignore(output.icecast(%vorbis.cbr(bitrate = 48),!source))
ignore(output(%vorbis.cbr(bitrate = 48),!source))
elsif bitrate == 64 then
ignore(output.icecast(%vorbis.cbr(bitrate = 64),!source))
ignore(output(%vorbis.cbr(bitrate = 64),!source))
elsif bitrate == 96 then
ignore(output.icecast(%vorbis.cbr(bitrate = 96),!source))
ignore(output(%vorbis.cbr(bitrate = 96),!source))
elsif bitrate == 128 then
ignore(output.icecast(%vorbis.cbr(bitrate = 128),!source))
ignore(output(%vorbis.cbr(bitrate = 128),!source))
elsif bitrate == 160 then
ignore(output.icecast(%vorbis.cbr(bitrate = 160),!source))
ignore(output(%vorbis.cbr(bitrate = 160),!source))
elsif bitrate == 192 then
ignore(output.icecast(%vorbis.cbr(bitrate = 192),!source))
ignore(output(%vorbis.cbr(bitrate = 192),!source))
elsif bitrate == 224 then
ignore(output.icecast(%vorbis.cbr(bitrate = 224),!source))
ignore(output(%vorbis.cbr(bitrate = 224),!source))
elsif bitrate == 256 then
ignore(output.icecast(%vorbis.cbr(bitrate = 256),!source))
ignore(output(%vorbis.cbr(bitrate = 256),!source))
elsif bitrate == 320 then
ignore(output.icecast(%vorbis.cbr(bitrate = 320),!source))
ignore(output(%vorbis.cbr(bitrate = 320),!source))
end
end
else
user_ref = ref user
if user == "" then
user_ref := "source"
end
output.shoutcast = output.shoutcast(host = host,
port = port,
password = pass,
@ -111,7 +120,8 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
restart_delay = 5,
url = url,
genre = genre,
name = description)
name = description,
user = !user_ref)
if bitrate == 24 then
ignore(output.shoutcast(%mp3(bitrate = 24),s))
elsif bitrate == 32 then

View file

@ -56,18 +56,18 @@ if output_sound_device then
ignore(output.alsa(s))
end
if output_s1 != "disabled" then
if s1_output != "disabled" then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(output_s1, s1_type, s1_bitrate, s1_host, s1_port, s1_pass, s1_mount, s1_url, s1_description, s1_genre, s)
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)
end
if output_s2 != "disabled" then
if s2_output != "disabled" then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(output_s2, s2_type, s2_bitrate, s2_host, s2_port, s2_pass, s2_mount, s2_url, s2_description, s2_genre, s)
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)
end
if output_s3 != "disabled" then
if s3_output != "disabled" then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(output_s3, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s)
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)
end

View file

@ -139,25 +139,22 @@ class PypoFetch(Thread):
# look for changes
for s in setting:
if "output_" in s[u'keyname'] and s[u'keyname'] != "output_icecast_vorbis_metadata" and s[u'keyname'] != "output_sound_device":
if "output_sound_device" in s[u'keyname']:
dump, stream = s[u'keyname'].split('_', 1)
state_change_restart[stream] = False
# This is the case where restart is required no matter what
if (existing[s[u'keyname']] != s[u'value']):
logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
restart = True;
# This is the case where we need further checking
if s[u'value'] != 'disabled':
state_change_restart[stream] = True
else:
if s[u'keyname'] == "output_sound_device":
dump, stream = s[u'keyname'].split('_',1)
state_change_restart[stream] = False
if not (s[u'value'] == existing[s[u'keyname']]):
stream, dump = s[u'keyname'].split('_',1)
if "_output" in s[u'keyname']:
if (existing[s[u'keyname']] != s[u'value']):
logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
restart = True;
elif ( s[u'value'] != 'disabled'):
state_change_restart[stream] = True
elif s[u'keyname'] != "output_icecast_vorbis_metadata" and s[u'keyname'] != "log_file":
stream, dump = s[u'keyname'].split('_',1)
else:
# setting inital value
if stream not in change:
change[stream] = False
@ -195,6 +192,8 @@ class PypoFetch(Thread):
buffer += temp
buffer += "\n"
fh.write(buffer)
fh.write("output_icecast_vorbis_metadata = false\n");
fh.write("log_file = \"/var/log/airtime/pypo-liquidsoap/<script>.log\"\n");
fh.close()
# restarting pypo.
# we could just restart liquidsoap but it take more time somehow.