Hello, sure!
1. Here it's request.dynamic definition ("config.get" is our function, just
simple getter):
playlist = request.dynamic(conservative = true,
fun () -> request.create(bridge.getNextTrack(config.get("station_id"))))
playlist = cue_cut(playlist);
playlist = transition.crossfade(start_next =
float_of_string(config.get("default_crossfade")),
fade_in = float_of_string(config.get("default_fade_in")),
fade_out = float_of_string(config.get("default_fade_out")),
playlist);
2. Here is bridge functions (i am giving two of them to provide everything
as it is)
# Returns new track for dynamic playlist
# ?param (int) stationId
# ?return (request)
def bridge.getNextTrack(stationId) =
result = bridge.request("nextTrack", [stationId]);
result = of_json(default = [("", "")], result);
if (list.mem_assoc("file", result)) then
annotate = ref "";
annotate.mapping = [
("cue_in", "liq_cue_in"),
("cue_out", "liq_cue_out"),
("crossfade", "liq_start_next"),
("fade_in", "liq_fade_in"),
("fade_out", "liq_fade_out")
];
def annotate.iterator(pair) =
key = fst(pair);
val = string_of(float_of_string(snd(pair)));
if ((key == "cue_in") or
(key == "cue_out") or
(key == "crossfade") or
(key == "fade_in") or
(key == "fade_out")) then
name = annotate.mapping[key];
if (string.length(!annotate) > 0) then
annotate := "#{!annotate},#{name}=\"#{val}\"";
else
annotate := "#{name}=\"#{val}\"";
end
end
end
list.iter(annotate.iterator, result)
if (string.length(!annotate) > 0) then
"annotate:#{!annotate}:" ^ result["file"];
else
result["file"];
end
else
config.get("security_track")
end
end
# Performs bridge request
# ?param (string) command
# ?param [string] arguments
# ?return (string)
def bridge.request(command, args) =
# Prepare arguments
command = quote(command);
args = list.map(fun(a) -> quote(a), args);
args = list.toString(args);
# Perform request
output = get_process_lines(config.get("php-brigde") ^ " #{command}
#{args}");
response = list.hd(output);
response = of_json(default=[("", "")], response);
# Check if request was successful and return data
if (response["status"] == "error") then
log(label = "brigde", "[#{command}] request error: " ^
response["message"]);
""
else
response["result"]
end
end
3. Php bridge simply returns json-encoded data about file, it's location,
cue_cuts, etc.
Here is it's response example (i have to encode json string twice here to
implement multidimensional assoc arrays in liquidsoap):
{"status":"success","result":"{\"file\":\"http:\\\/\\\/myserver.com
\\\/files\\\/1\\\/52c9cb42c4609.mp3\"}"}
2014-01-28 David Baelde <david.bae...@gmail.com>
> Hi Alexander,
>
> Could you please describe a little bit how you use dynamic requests?
> At least, I need to know what parameters (queue, etc.) you are using
> but the kind of protocol involved is probably useful too.
>
> Cheers,
>
> David
>
> On Fri, Jan 24, 2014 at 10:26 AM, Alexander <truenr...@gmail.com> wrote:
> > Issue still reproduces, every day.
> > I found http://dev.sourcefabric.org/browse/LS-508, where it is said
> that bug
> > was fixed...
> >
> > Have no idea how to workaround this... please assist :(
> >
> >
> > 2014/1/19 Alexander <truenr...@gmail.com>
> >>
> >> Hello,
> >>
> >> We use request.dynamic to play files from remote server (via http).
> >> Yesterday i've found liquidsoap crashed, could you please help to
> research?
> >> In log i saw following lines:
> >>
> >> 2014/01/18 14:55:16 [request.dynamic_5970:3] Finished with
> >> "/tmp/liq7e1fc7.mp3".
> >> 2014/01/18 14:55:16 [request.dynamic_5970:3] Prepared
> "/tmp/liqef6b8f.mp3"
> >> (RID 1).
> >> 2014/01/18 14:55:16 [threads:2] Queue generic queue #1 crashed with
> >> exception Sys_error("/tmp/liq5a2504.mp3: Too many open files")
> >> 2014/01/18 14:55:16 [threads:2] Raised by primitive operation at file
> >> "filename.ml", line 206, characters 16-75
> >> Re-raised at file "filename.ml", line 209, characters 36-37
> >> Called from file "protocols/extproto.ml", line 45, characters 14-21
> >> Called from file "request.ml", line 584, characters 20-64
> >> Called from file "request.ml", line 610, characters 12-27
> >> Called from file "sources/request_source.ml", line 356, characters
> 22-49
> >> Called from file "sources/request_source.ml", line 340, characters
> 13-26
> >> Called from file "duppy.ml", line 351, characters 20-24
> >> Called from file "duppy.ml", line 131, characters 61-77
> >> Called from file "duppy.ml", line 253, characters 14-23
> >> Called from file "duppy.ml", line 280, characters 9-26
> >> Called from file "tools/tutils.ml", line 207, characters 19-55
> >>
> >> 2014/01/18 14:55:16 [threads:1] PANIC: Liquidsoap has crashed, exiting..
> >> 2014/01/18 14:55:16 [threads:1] Please report at:
> >> savonet-us...@lists.sf.net
> >>
> >>
> >>
> >> --
> >> Kind regards,
> >> Alexander.
> >
> >
> >
> >
> > --
> > Kind regards,
> > Alexander.
> >
> >
> ------------------------------------------------------------------------------
> > CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> > Learn Why More Businesses Are Choosing CenturyLink Cloud For
> > Critical Workloads, Development Environments & Everything In Between.
> > Get a Quote or Start a Free Trial Today.
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Savonet-users mailing list
> > Savonet-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/savonet-users
> >
>
>
>
> --
> David
>
>
> ------------------------------------------------------------------------------
> WatchGuard Dimension instantly turns raw network data into actionable
> security intelligence. It gives you real-time visual feedback on key
> security issues and trends. Skip the complicated setup - simply import
> a virtual appliance and go from zero to informed in seconds.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
> _______________________________________________
> Savonet-users mailing list
> Savonet-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
--
Kind regards,
Alexander.
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users