Hi,

I am trying to get liquidsoap-full-1.0.0-beta1 working against a shoutcast 
server and I am seeing liquidsoap (cry.ml) barf on what looks like a legitimate 
icy response on first connect.  Here is a dump of the server response on the 
connect:

00000000  48 54 54 50 2f 31 2e 30  20 32 30 30 20 4f 4b 32 HTTP/1.0  200 OK2
00000010  0d 0a 69 63 79 2d 63 61  70 73 3a 31 31 0d 0a 0d ..icy-ca ps:11...
00000020  0a                                               .

And output from liquidsoap:

[audio]$ liquidsoap --verbose --debug 'output.shoutcast(%mp3, host="xxxxxx", 
port = xx, password = "xxxxxxx",  mksafe(playlist("playlist.m3u")))'  
2011/01/30 19:52:07 >>> LOG START
2011/01/30 19:52:06 [protocols.external:3] Didn't find "ufetch".
2011/01/30 19:52:06 [protocols.external:3] Found "/usr/bin/wget".
2011/01/30 19:52:06 [main:3] Liquidsoap 1.0.0-beta1
2011/01/30 19:52:07 [lang:3] flac binary not found: flac decoder disabled.
2011/01/30 19:52:07 [lang:3] metaflac binary not found: flac metadata resolver 
disabled.
2011/01/30 19:52:07 [lang:3] faad binary not found: faad decoder disabled.
2011/01/30 19:52:07 [lang:3] Lastfm/audioscrobbler support was not compiled.
2011/01/30 19:52:07 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz master.
2011/01/30 19:52:07 [frame:3] Frame size must be a multiple of 1764 ticks = 
1764 
audio samples = 1 video samples.
2011/01/30 19:52:07 [frame:3] Targetting 'frame.duration': 0.04s = 1764 audio 
samples = 1764 ticks.
2011/01/30 19:52:07 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video 
samples = 1764 ticks.
2011/01/30 19:52:07 [video.converter:4] Couldn't find preferred video 
converter: 
gavl.
2011/01/30 19:52:07 [audio.converter:4] Couldn't find preferred samplerate 
converter: libsamplerate.
2011/01/30 19:52:07 [audio.converter:4] Using native samplerate converter
2011/01/30 19:52:07 [threads:3] Created thread "generic queue #1".
2011/01/30 19:52:07 [clock:4] Currently 1 clocks allocated.
2011/01/30 19:52:07 [clock.wallclock_main:4] Starting 1 sources...
2011/01/30 19:52:07 [source:4] Source output(dot)shoutcast gets up.
2011/01/30 19:52:07 [output(dot)shoutcast:4] Content kind is 
{audio=2;video=0;midi=0}.
2011/01/30 19:52:07 [source:4] Source mksafe gets up.
2011/01/30 19:52:07 [source:4] Source playlist_3750 gets up.
2011/01/30 19:52:07 [playlist_3750:4] Content kind is {audio=2;video=0;midi=0}.
2011/01/30 19:52:07 [playlist(dot)m3u:3] Loading playlist...
2011/01/30 19:52:07 [playlist(dot)m3u:3] No mime type specified, trying 
autodetection.
2011/01/30 19:52:07 [playlist parser:4] Trying audio/x-scpls parser
2011/01/30 19:52:07 [playlist parser:4] Trying audio/mpegurl parser
2011/01/30 19:52:07 [playlist(dot)m3u:3] Playlist treated as format 
audio/mpegurl
2011/01/30 19:52:07 [playlist(dot)m3u:3] Successfully loaded a playlist of 10 
tracks.
2011/01/30 19:52:07 [decoder:4] Trying method "WAV" for "./Synkronized/07 
Supersonic.mp3"...
2011/01/30 19:52:07 [playlist(dot)m3u:4] Activations changed: static=[], 
dynamic=[mksafe:output(dot)shoutcast:output(dot)shoutcast].
2011/01/30 19:52:07 [source:4] Source safe_blank gets up.
2011/01/30 19:52:07 [safe_blank:4] Content kind is {audio=2;video=0;midi=0}.
2011/01/30 19:52:07 [decoder:4] Decoder "WAV" failed on "./Synkronized/07 
Supersonic.mp3": Wav.Not_a_wav_file("Bad header : string \"RIFF\", \"WAVE\" or 
\"fmt \" not found")!
2011/01/30 19:52:07 [safe_blank:4] Activations changed: static=[], 
dynamic=[mksafe:output(dot)shoutcast:output(dot)shoutcast].
2011/01/30 19:52:07 [mksafe:4] Activations changed: 
static=[output(dot)shoutcast:output(dot)shoutcast], dynamic=[].
2011/01/30 19:52:07 [output(dot)shoutcast:4] Activations changed: 
static=[output(dot)shoutcast], dynamic=[].
2011/01/30 19:52:07 [output(dot)shoutcast:4] Enabling caching mode: active 
source.
2011/01/30 19:52:07 [decoder:4] Trying method "MIDI" for "./Synkronized/07 
Supersonic.mp3"...
2011/01/30 19:52:07 [output(dot)shoutcast:3] Connecting mount / for 
[email protected]...
2011/01/30 19:52:07 [decoder:4] Trying method "MP3/LIBMAD" for 
"./Synkronized/07 
Supersonic.mp3"...
2011/01/30 19:52:07 [decoder.mp3:4] Libmad recognizes "./Synkronized/07 
Supersonic.mp3" as MP3 (44100Hz,2 channels).
2011/01/30 19:52:07 [decoder:3] Method "MP3/LIBMAD" accepted "./Synkronized/07 
Supersonic.mp3".
2011/01/30 19:52:07 [playlist(dot)m3u:4] Remaining: 0, queued: 0, adding: 
1323000 (RID 1)
2011/01/30 19:52:07 [output(dot)shoutcast:2] Connection failed: bad answer3 
dude!   <<<< XXX SM: This is tracked back to cry.ml
init: exception encountered during main phase:
  Tutils.Exit
exception: Tutils.Exit
2011/01/30 19:52:07 [main:3] Shutdown started!
2011/01/30 19:52:07 [main:3] Waiting for threads to terminate...
2011/01/30 19:52:07 [main:3] Cleaning downloaded files...
2011/01/30 19:52:07 >>> LOG END

From:
ocaml-cry-0.1.5/src/cry.ml:
...
let connect_icy c socket source =
  let request = Printf.sprintf "%s\r\n" source.password in
  try
    write_data socket request;
    (** Read input from socket. *)
    let ret = read_data socket in
    let f s =
      if s.[0] <> 'O' && s.[1] <> 'K' then
        raise (Error (Bad_answer1 (Some s)));
    in
    begin
     try
      Scanf.sscanf (List.hd ret) "%[^\r^\n]" f
     with
       | Scanf.Scan_failure s -> raise (Error (Bad_answer2 (Some s)))
       | _ -> raise (Error (Bad_answer3 None))  (** XXX SM: this throws on 
seemingly correct ICY response **)
    end;
    (* Read another line *)
    let ret =
      match ret with
        | x :: y :: _ -> y
        | _ -> List.hd (read_data socket)
    in
    let f s =
      c.icy_cap <- true
    in
    begin
     try
       Scanf.sscanf ret "icy-caps:%[1]" f
     with
       | Scanf.Scan_failure s -> ()
    end;
    (* Now Write headers *)
    let headers = header_string source in
    let request = Printf.sprintf "%s\r\n\r\n" headers in
    write_data socket request;
    c.status <- PrivConnected (source,socket)
  with
    | e ->
       begin
        try
          close c
        with
          | _ -> ()
       end ;
       raise e
...

I'll try with older sources, but this parsing code looks flawed:
- Where is the http response code parsing? eg: HTTP/1.[01] 200
- Is ocaml %s[^\r^\n] really mean match any but \r and \n? Is that equivalent 
to 
%s[^\r\n] ?

One last thing... I am looking at ocaml for the first time today, and I am 
having a hard time figuring out how to print the http response body from 
connect_icy.  I tried a few things without any success:
1. Printf.printf (List.hd ret); 
2. prerr_string (List.hd ret);
If any output was printed, I couldnt find it either on stdout or stderr.  
What's 
going on?  How can I get some debug print stmts from that module?

Cheers,
Seb


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to