CC-3224: "On-the-fly" stream rebroadcasting
- frond-end implementation for master dj and live dj - db implementation - liquidsoap is broken on this commit
This commit is contained in:
parent
96c4462adc
commit
128a497059
16 changed files with 304 additions and 99 deletions
|
@ -102,5 +102,5 @@ get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
|
|||
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
|
||||
|
||||
#URL to check live stream auth
|
||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%'
|
||||
check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%/username/%%username%%/password/%%password%%/djtype/%%djtype%%'
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
return response
|
||||
|
||||
def check_live_stream_auth(self, username, password):
|
||||
def check_live_stream_auth(self, username, password, dj_type):
|
||||
#logger = logging.getLogger()
|
||||
response = ''
|
||||
try:
|
||||
|
@ -373,6 +373,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
url = url.replace("%%username%%", username)
|
||||
url = url.replace("%%djtype%%", dj_type)
|
||||
url = url.replace("%%password%%", password)
|
||||
|
||||
req = urllib2.Request(url)
|
||||
|
|
|
@ -12,8 +12,16 @@ except Exception, e:
|
|||
|
||||
api_clients = api_client.api_client_factory(config)
|
||||
|
||||
username = sys.argv[1]
|
||||
password = sys.argv[2]
|
||||
response = api_clients.check_live_stream_auth(username, password)
|
||||
dj_type = sys.argv[1]
|
||||
username = sys.argv[2]
|
||||
password = sys.argv[3]
|
||||
|
||||
type = ''
|
||||
if dj_type == '--master':
|
||||
type = 'master'
|
||||
elif dj_type == '--dj':
|
||||
type = 'dj'
|
||||
|
||||
response = api_clients.check_live_stream_auth(username, password, type)
|
||||
|
||||
print response['msg']
|
|
@ -40,10 +40,11 @@ default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
|
|||
|
||||
#live stream setup
|
||||
set("harbor.bind_addr", "0.0.0.0")
|
||||
|
||||
#auth function for live stream
|
||||
def check_client(user,password) =
|
||||
def check_master_dj_client(user,password) =
|
||||
#get the output of the php script
|
||||
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py #{user} #{password}")
|
||||
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}")
|
||||
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
||||
ret = list.hd(ret)
|
||||
#return true to let the client transmit data, or false to tell harbor to decline
|
||||
|
@ -54,17 +55,47 @@ def check_client(user,password) =
|
|||
end
|
||||
end
|
||||
|
||||
def configure_live(harbor_input_port, harbor_input_mount_point) =
|
||||
if harbor_input_port != 0 and harbor_input_mount_point != "" then
|
||||
live = input.harbor(harbor_input_mount_point, port=harbor_input_port, auth=check_client)
|
||||
fallback(track_sensitive=false, [live, queue, default])
|
||||
def check_dj_client(user,password) =
|
||||
#get the output of the php script
|
||||
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}")
|
||||
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
|
||||
ret = list.hd(ret)
|
||||
#return true to let the client transmit data, or false to tell harbor to decline
|
||||
if (ret == "True") then
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
master_dj = ref default
|
||||
dj_live = ref default
|
||||
|
||||
def append_master_dj_input(master_harbor_input_port, master_harbor_input_mount_point, s) =
|
||||
if master_harbor_input_port != 0 and master_harbor_input_mount_point != "" then
|
||||
master_dj := input.harbor(master_harbor_input_mount_point, port=master_harbor_input_port, auth=check_master_dj_client, buffer=7.,max=15.)
|
||||
fallback(track_sensitive=false, [!master_dj, s])
|
||||
else
|
||||
fallback(track_sensitive=false, [queue, default])
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
s = configure_live(harbor_input_port, harbor_input_mount_point)
|
||||
def append_dj_input(dj_harbor_input_port, dj_harbor_input_mount_point, s) =
|
||||
if dj_harbor_input_port != 0 and dj_harbor_input_mount_point != "" then
|
||||
dj_live := input.harbor(dj_harbor_input_mount_point, port=dj_harbor_input_port, auth=check_dj_client, buffer=7.,max=15.)
|
||||
fallback(track_sensitive=false, [!dj_live, s])
|
||||
else
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
s = fallback(track_sensitive=false, [queue, default])
|
||||
s = on_metadata(notify, s)
|
||||
s = map_metadata(append_title, s)
|
||||
s = append_dj_input(dj_live_stream_port, dj_live_stream_mp, s)
|
||||
s = append_master_dj_input(master_live_stream_port, master_live_stream_mp, s)
|
||||
|
||||
|
||||
s = crossfade(s)
|
||||
# Attach a skip command to the source s:
|
||||
|
||||
|
@ -83,7 +114,6 @@ s = crossfade(s)
|
|||
#)
|
||||
|
||||
add_skip_command(s)
|
||||
s = map_metadata(append_title, s)
|
||||
|
||||
if output_sound_device then
|
||||
|
||||
|
@ -163,4 +193,6 @@ if s3_enable == true then
|
|||
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)
|
||||
end
|
||||
|
||||
output.dummy(fallible=true, !master_dj)
|
||||
output.dummy(fallible=true, !dj_live)
|
||||
ignore(output.dummy(blank()))
|
||||
|
|
|
@ -153,11 +153,12 @@ if __name__ == '__main__':
|
|||
recorder.daemon = True
|
||||
recorder.start()
|
||||
|
||||
pmh.join()
|
||||
pfile.join()
|
||||
# all join() are commented out becase we want to exit entire pypo
|
||||
# if pypofetch is exiting
|
||||
#pmh.join()
|
||||
#recorder.join()
|
||||
#pp.join()
|
||||
pf.join()
|
||||
pp.join()
|
||||
recorder.join()
|
||||
|
||||
logger.info("pypo fetch exit")
|
||||
sys.exit()
|
||||
|
|
|
@ -111,7 +111,7 @@ class PypoFetch(Thread):
|
|||
self.logger.debug(e)
|
||||
self.logger.debug('Could not connect to liquidsoap')
|
||||
|
||||
def regenerateLiquidsoapConf(self, setting):
|
||||
def regenerateLiquidsoapConf(self, setting_p):
|
||||
existing = {}
|
||||
# create a temp file
|
||||
fh = open('/etc/airtime/liquidsoap.cfg', 'r')
|
||||
|
@ -146,8 +146,9 @@ class PypoFetch(Thread):
|
|||
restart = False
|
||||
|
||||
self.logger.info("Looking for changes...")
|
||||
setting = sorted(setting_p.items())
|
||||
# look for changes
|
||||
for s in setting:
|
||||
for k, s in setting:
|
||||
if "output_sound_device" in s[u'keyname'] or "icecast_vorbis_metadata" in s[u'keyname']:
|
||||
dump, stream = s[u'keyname'].split('_', 1)
|
||||
state_change_restart[stream] = False
|
||||
|
@ -155,9 +156,9 @@ class PypoFetch(Thread):
|
|||
if (existing[s[u'keyname']] != s[u'value']):
|
||||
self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
||||
restart = True;
|
||||
elif "harbor_input_mount_point" in s[u'keyname'] or "harbor_input_port" in s[u'keyname']:
|
||||
elif "master_live_stream_port" in s[u'keyname'] or "master_live_stream_mp" in s[u'keyname'] or "dj_live_stream_port" in s[u'keyname'] or "dj_live_stream_mp" in s[u'keyname']:
|
||||
if (existing[s[u'keyname']] != s[u'value']):
|
||||
logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
||||
self.logger.info("'Need-to-restart' state detected for %s...", s[u'keyname'])
|
||||
restart = True;
|
||||
else:
|
||||
stream, dump = s[u'keyname'].split('_',1)
|
||||
|
@ -194,7 +195,7 @@ class PypoFetch(Thread):
|
|||
fh.write("################################################\n")
|
||||
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
|
||||
fh.write("################################################\n")
|
||||
for d in setting:
|
||||
for k, d in setting:
|
||||
buffer = d[u'keyname'] + " = "
|
||||
if(d[u'type'] == 'string'):
|
||||
temp = d[u'value']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue