-greatly simplified ls_script. Much easier to add live-streaming support.

-begin adding configurability for ogg/mp3/audio_out
This commit is contained in:
martin 2011-02-17 19:46:43 -05:00
parent 2cbddf0f82
commit a4b5a1d618
4 changed files with 64 additions and 196 deletions

View file

@ -28,7 +28,8 @@ icecast_port = 8000
icecast_pass = "hackme"
# mountpoints
mount_scheduler = "airtime.mp3"
mount_point_mp3 = "airtime.mp3"
mount_point_vorbis = "airtime.ogg"
# mount intra is used for scheduler >>> fallback stream
mount_intra = "pypo_intra"
@ -38,3 +39,10 @@ intra_host = "127.0.0.1"
intra_port = 9000
intra_pass = "hackme"
icecast_url = "http://airtime.sourcefabric.org"
icecast_description = "Airtime Radio!"
icecast_genre = "genre"
output_sound_device = true
output_icecast_vorbis = true
output_icecast_mp3 = true

View file

@ -5,42 +5,14 @@ set("log.file.path", log_file)
set("log.stdout", true)
set("server.telnet", true)
active_queue = ref 0
scheduler_q0 = request.queue(conservative=true,length=600.,id="scheduler_q0")
scheduler_q1 = request.queue(conservative=true,length=600.,id="scheduler_q1")
scheduler_q0 = audio_to_stereo(scheduler_q0)
scheduler_q1 = audio_to_stereo(scheduler_q1)
queue = request.queue(conservative=true,length=600.,id="queue")
queue = audio_to_stereo(queue)
pypo_data = ref '0'
# push function, enqueues file in inactive queue (does not start automatically)
def scheduler_push(s)
ignore(server.execute("scheduler_q#{!active_queue}.push #{s}"))
print('push to #{!active_queue} - #{s}')
"Done"
end
# flips the queues
def scheduler_flip()
# get playing (active) queue and flush it
l = list.hd(server.execute("scheduler_q#{!active_queue}.queue"))
l = string.split(separator=" ",l)
list.iter(fun (rid) -> ignore(server.execute("scheduler_q#{!active_queue}.ignore #{rid}")), l)
# skip the playing item
source.skip(if !active_queue==0 then scheduler_q0 else scheduler_q1 end)
# flip variables
active_queue := 1-!active_queue
print('switch to active queue: #{!active_queue}')
"Done"
end
def notify(m)
print("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']}")
end
#def notify(m)
# print("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']}")
#end
def crossfade(s)
s = fade.in(type="log", s)
@ -49,23 +21,42 @@ def crossfade(s)
cross(fader,s)
end
server.register(namespace="scheduler","push", scheduler_push)
server.register(namespace="scheduler","flip", fun (s) -> begin scheduler_flip() end)
server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
default = single("/opt/pypo/files/basic/silence.mp3")
radio = fallback(track_sensitive=false, [switch(track_sensitive=false, [(fun () -> !active_queue==1, scheduler_q0), (fun () -> !active_queue==0, scheduler_q1)]), default])
default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
#radio = on_metadata(notify, radio)
s = fallback(track_sensitive=false, [queue, default])
radio = crossfade(radio)
#s = on_metadata(notify, s)
s = crossfade(s)
out(radio)
clock(id="clock_icecast",
output.icecast(%mp3,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_scheduler,
fallible = true,
restart = true,
restart_delay = 5,
buffer(radio)))
if output_sound_device then
out_device = out(s)
end
if output_icecast_mp3 then
out_mp3 = output.icecast(%mp3,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_point_mp3,
fallible = true,
restart = true,
restart_delay = 5,
url = icecast_url,
description = icecast_description,
genre = icecast_genre,
s)
end
if output_icecast_vorbis then
out_vorbis = output.icecast(%vorbis,
host = icecast_host, port = icecast_port,
password = icecast_pass, mount = mount_point_vorbis,
fallible = true,
restart = true,
restart_delay = 5,
url = icecast_url,
description = icecast_description,
genre = icecast_genre,
s)
end