Merge branch 'master' of dev.sourcefabric.org:airtime
Conflicts: python_apps/pypo/pypocli.py python_apps/pypo/pypofetch.py python_apps/pypo/pypopush.py
This commit is contained in:
commit
1a765e6cb9
|
@ -90,10 +90,6 @@ class DashboardController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
public function switchOffSource()
|
||||
{
|
||||
}
|
||||
|
||||
public function streamPlayerAction()
|
||||
{
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
|
|
|
@ -7,6 +7,8 @@ from media.monitor.pure import format_length, file_md5, is_airtime_recorded, \
|
|||
|
||||
defs_loaded = False
|
||||
|
||||
MAX_SIGNED_INT = 2**31-1
|
||||
|
||||
def is_defs_loaded():
|
||||
global defs_loaded
|
||||
return defs_loaded
|
||||
|
@ -37,11 +39,13 @@ def load_definitions():
|
|||
t.default(u'')
|
||||
t.depends('bitrate')
|
||||
t.translate(lambda k: k['bitrate'])
|
||||
t.max_value(MAX_SIGNED_INT)
|
||||
|
||||
with md.metadata('MDATA_KEY_SAMPLERATE') as t:
|
||||
t.default(u'0')
|
||||
t.depends('sample_rate')
|
||||
t.translate(lambda k: k['sample_rate'])
|
||||
t.max_value(MAX_SIGNED_INT)
|
||||
|
||||
with md.metadata('MDATA_KEY_FTYPE') as t:
|
||||
t.depends('ftype') # i don't think this field even exists
|
||||
|
@ -69,10 +73,11 @@ def load_definitions():
|
|||
|
||||
with md.metadata("MDATA_KEY_TRACKNUMBER") as t:
|
||||
t.depends("tracknumber")
|
||||
t.max_value(MAX_SIGNED_INT)
|
||||
|
||||
with md.metadata("MDATA_KEY_BPM") as t:
|
||||
t.depends("bpm")
|
||||
t.max_length(8)
|
||||
t.max_value(MAX_SIGNED_INT)
|
||||
|
||||
with md.metadata("MDATA_KEY_LABEL") as t:
|
||||
t.depends("organization")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from contextlib import contextmanager
|
||||
from media.monitor.pure import truncate_to_length, toposort
|
||||
from media.monitor.pure import truncate_to_value, truncate_to_length, toposort
|
||||
from os.path import normpath
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.log import Loggable
|
||||
|
@ -43,11 +43,15 @@ class MetadataElement(Loggable):
|
|||
self.__default = None
|
||||
self.__is_normalized = lambda _ : True
|
||||
self.__max_length = -1
|
||||
self.__max_value = -1
|
||||
self.__translator = None
|
||||
|
||||
def max_length(self,l):
|
||||
self.__max_length = l
|
||||
|
||||
def max_value(self,v):
|
||||
self.__max_value = v
|
||||
|
||||
def optional(self, setting):
|
||||
self.__optional = setting
|
||||
|
||||
|
@ -143,6 +147,8 @@ class MetadataElement(Loggable):
|
|||
r = self.__normalizer( self.__translator(full_deps) )
|
||||
if self.__max_length != -1:
|
||||
r = truncate_to_length(r, self.__max_length)
|
||||
if self.__max_value != -1:
|
||||
r = truncate_to_value(r, self.__max_value)
|
||||
return r
|
||||
|
||||
def normalize_mutagen(path):
|
||||
|
|
|
@ -465,6 +465,14 @@ def truncate_to_length(item, length):
|
|||
if len(item) > length: return item[0:length]
|
||||
else: return item
|
||||
|
||||
def truncate_to_value(item, value):
|
||||
""" Truncates 'item' to 'value' """
|
||||
if isinstance(item, basestring): item = int(item)
|
||||
if isinstance(item, int):
|
||||
item = abs(item)
|
||||
if item > value: item = value
|
||||
return str(item)
|
||||
|
||||
def format_length(mutagen_length):
|
||||
""" Convert mutagen length to airtime length """
|
||||
t = float(mutagen_length)
|
||||
|
|
|
@ -8,12 +8,10 @@ api_client_path="/usr/lib/airtime/"
|
|||
ls_path="/usr/bin/airtime-liquidsoap --verbose -f -d"
|
||||
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
|
||||
|
||||
exec 2>&1
|
||||
export PYTHONPATH=${api_client_path}
|
||||
|
||||
cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts
|
||||
python generate_liquidsoap_cfg.py
|
||||
|
||||
exec ${ls_path} ${ls_param}
|
||||
|
||||
exec ${ls_path} ${ls_param} 2>&1
|
||||
# EOF
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
if bitrate == 24 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 24, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 24, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 32 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 32, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 32, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 48 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 48, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 48, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 64, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 64, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 96, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 96, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 128, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 128, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 160, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 160, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 192, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 192, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 224, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 224, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 256, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 256, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aac(bitrate = 320, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aac(bitrate = 320, channels = 1), mean(!source)))
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
if bitrate == 24 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 24, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 24, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 32 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 32, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 32, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 48 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 48, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 48, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 64, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 64, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 96, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 96, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 128, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 128, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 160, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 160, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 192, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 192, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 224, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 224, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 256, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 256, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%aacplus(bitrate = 320, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%aacplus(bitrate = 320, channels = 1), mean(!source)))
|
||||
end
|
||||
end
|
||||
|
|
@ -123,133 +123,15 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
if type == "mp3" then
|
||||
if bitrate == 24 then
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
%include "mp3.liq"
|
||||
elsif type == "ogg" then
|
||||
%include "ogg.liq"
|
||||
elsif type == "opus" then
|
||||
%include "opus.liq"
|
||||
elsif type == "aac" then
|
||||
%include "aac.liq"
|
||||
else
|
||||
if not icecast_vorbis_metadata then
|
||||
source := add(normalize=false, [amplify(0.00001, noise()), !source])
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
%include "aacplus.liq"
|
||||
end
|
||||
else
|
||||
user_ref = ref user
|
||||
|
@ -257,7 +139,7 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
user_ref := "source"
|
||||
end
|
||||
|
||||
output.shoutcast_mono = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
output_mono = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
|
@ -269,7 +151,7 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
|
||||
output.shoutcast_stereo = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
output_stereo = output.shoutcast(id = "shoutcast_stream_#{stream}",
|
||||
host = host,
|
||||
port = port,
|
||||
password = pass,
|
||||
|
@ -281,73 +163,13 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
on_error = on_error,
|
||||
on_connect = on_connect)
|
||||
|
||||
if bitrate == 24 then
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
if type == "mp3" then
|
||||
%include "mp3.liq"
|
||||
elsif type == "aac" then
|
||||
%include "aac.liq"
|
||||
else
|
||||
%include "aacplus.liq"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
if bitrate == 24 then
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
if not icecast_vorbis_metadata then
|
||||
source := add(normalize=false, [amplify(0.00001, noise()), !source])
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
if bitrate == 24 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 24, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 24, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 32 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 32, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 32, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 48 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 48, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 48, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 64 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 64, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 64, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 96 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 96, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 96, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 128 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 128, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 128, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 160 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 160, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 160, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 192 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 192, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 192, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 224 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 224, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 224, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 256 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 256, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 256, channels = 1), mean(!source)))
|
||||
end
|
||||
elsif bitrate == 320 then
|
||||
if stereo then
|
||||
ignore(output_stereo(%opus(bitrate = 320, channels = 2), !source))
|
||||
else
|
||||
ignore(output_mono(%opus(bitrate = 320, channels = 1), mean(!source)))
|
||||
end
|
||||
end
|
||||
|
|
@ -23,6 +23,7 @@ from pypofile import PypoFile
|
|||
from recorder import Recorder
|
||||
from listenerstat import ListenerStat
|
||||
from pypomessagehandler import PypoMessageHandler
|
||||
from pypoliquidsoap import PypoLiquidsoap
|
||||
|
||||
from media.update.replaygainupdater import ReplayGainUpdater
|
||||
from media.update.silananalyzer import SilanAnalyzer
|
||||
|
@ -221,6 +222,9 @@ if __name__ == '__main__':
|
|||
recorder_q = Queue()
|
||||
pypoPush_q = Queue()
|
||||
|
||||
pypo_liquidsoap = PypoLiquidsoap(logger, telnet_lock,\
|
||||
ls_host, ls_port)
|
||||
|
||||
"""
|
||||
This queue is shared between pypo-fetch and pypo-file, where pypo-file
|
||||
is the consumer. Pypo-fetch will send every schedule it gets to pypo-file
|
||||
|
@ -237,11 +241,11 @@ if __name__ == '__main__':
|
|||
pfile.daemon = True
|
||||
pfile.start()
|
||||
|
||||
pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock, config)
|
||||
pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config)
|
||||
pf.daemon = True
|
||||
pf.start()
|
||||
|
||||
pp = PypoPush(pypoPush_q, telnet_lock)
|
||||
pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap)
|
||||
pp.daemon = True
|
||||
pp.start()
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
|||
POLL_INTERVAL = 1800
|
||||
|
||||
class PypoFetch(Thread):
|
||||
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, config):
|
||||
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config):
|
||||
Thread.__init__(self)
|
||||
self.api_client = api_client.AirtimeApiClient()
|
||||
self.fetch_queue = pypoFetch_q
|
||||
|
@ -49,7 +49,9 @@ class PypoFetch(Thread):
|
|||
|
||||
self.telnet_lock = telnet_lock
|
||||
|
||||
self.logger = logging.getLogger();
|
||||
self.logger = logging.getLogger()
|
||||
|
||||
self.pypo_liquidsoap = pypo_liquidsoap
|
||||
|
||||
self.cache_dir = os.path.join(config["cache_dir"], "scheduler")
|
||||
self.logger.debug("Cache dir %s", self.cache_dir)
|
||||
|
@ -562,6 +564,14 @@ class PypoFetch(Thread):
|
|||
# Bootstrap: since we are just starting up, we need to grab the
|
||||
# most recent schedule. After that we can just wait for updates.
|
||||
success = self.persistent_manual_schedule_fetch(max_attempts=5)
|
||||
|
||||
#Make sure all Liquidsoap queues are empty. This is important in the
|
||||
#case where we've just restarted the pypo scheduler, but Liquidsoap still
|
||||
#is playing tracks. In this case let's just restart everything from scratch
|
||||
#so that we can repopulate our dictionary that keeps track of what
|
||||
#Liquidsoap is playing much more easily.
|
||||
self.pypo_liquidsoap.clear_all_queues()
|
||||
|
||||
if success:
|
||||
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
||||
self.set_bootstrap_variables()
|
||||
|
|
|
@ -41,7 +41,7 @@ class PypoLiqQueue(Thread):
|
|||
except Empty, e:
|
||||
#Time to push a scheduled item.
|
||||
media_item = schedule_deque.popleft()
|
||||
self.pypo_liquidsoap.push_item(media_item)
|
||||
self.pypo_liquidsoap.play(media_item)
|
||||
if len(schedule_deque):
|
||||
time_until_next_play = \
|
||||
self.date_interval_to_seconds(
|
||||
|
|
|
@ -20,7 +20,8 @@ class PypoLiquidsoap():
|
|||
self.telnet_liquidsoap = TelnetLiquidsoap(telnet_lock, \
|
||||
logger,\
|
||||
host,\
|
||||
port)
|
||||
port,\
|
||||
self.liq_queue_tracker.keys())
|
||||
|
||||
|
||||
def play(self, media_item):
|
||||
|
@ -90,9 +91,6 @@ class PypoLiquidsoap():
|
|||
|
||||
return available_queue
|
||||
|
||||
def get_queues():
|
||||
return self.liq_queue_tracker
|
||||
|
||||
|
||||
def verify_correct_present_media(self, scheduled_now):
|
||||
#verify whether Liquidsoap is currently playing the correct files.
|
||||
|
@ -105,8 +103,6 @@ class PypoLiquidsoap():
|
|||
#get liquidsoap items for each queue. Since each queue can only have one
|
||||
#item, we should have a max of 8 items.
|
||||
|
||||
#TODO: Verify start, end, replay_gain is the same
|
||||
|
||||
#2013-03-21-22-56-00_0: {
|
||||
#id: 1,
|
||||
#type: "stream_output_start",
|
||||
|
@ -222,6 +218,9 @@ class PypoLiquidsoap():
|
|||
|
||||
return seconds
|
||||
|
||||
def clear_all_queues(self):
|
||||
self.telnet_liquidsoap.queue_clear_all()
|
||||
|
||||
|
||||
class UnknownMediaItemType(Exception):
|
||||
pass
|
||||
|
|
|
@ -14,7 +14,6 @@ import os
|
|||
|
||||
from pypofetch import PypoFetch
|
||||
from pypoliqqueue import PypoLiqQueue
|
||||
from pypoliquidsoap import PypoLiquidsoap
|
||||
|
||||
from Queue import Empty, Queue
|
||||
|
||||
|
@ -44,7 +43,7 @@ def is_file(media_item):
|
|||
return media_item['type'] == 'file'
|
||||
|
||||
class PypoPush(Thread):
|
||||
def __init__(self, q, telnet_lock, config):
|
||||
def __init__(self, q, telnet_lock, pypo_liquidsoap, config):
|
||||
Thread.__init__(self)
|
||||
self.api_client = api_client.AirtimeApiClient()
|
||||
self.queue = q
|
||||
|
|
|
@ -7,11 +7,12 @@ def create_liquidsoap_annotation(media):
|
|||
|
||||
class TelnetLiquidsoap:
|
||||
|
||||
def __init__(self, telnet_lock, logger, ls_host, ls_port):
|
||||
def __init__(self, telnet_lock, logger, ls_host, ls_port, queues):
|
||||
self.telnet_lock = telnet_lock
|
||||
self.ls_host = ls_host
|
||||
self.ls_port = ls_port
|
||||
self.logger = logger
|
||||
self.queues = queues
|
||||
self.current_prebuffering_stream_id = None
|
||||
|
||||
def __connect(self):
|
||||
|
@ -20,6 +21,23 @@ class TelnetLiquidsoap:
|
|||
def __is_empty(self, tn, queue_id):
|
||||
return True
|
||||
|
||||
def queue_clear_all(self):
|
||||
try:
|
||||
self.telnet_lock.acquire()
|
||||
tn = self.__connect()
|
||||
|
||||
for i in self.queues:
|
||||
msg = 'queues.%s_skip\n' % i
|
||||
self.logger.debug(msg)
|
||||
tn.write(msg)
|
||||
|
||||
tn.write("exit\n")
|
||||
self.logger.debug(tn.read_all())
|
||||
except Exception:
|
||||
raise
|
||||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
def queue_remove(self, queue_id):
|
||||
try:
|
||||
self.telnet_lock.acquire()
|
||||
|
|
Loading…
Reference in New Issue