module Cry:Native implementation of the shout source protocols for icecast and shoutcast.sig
..end
Cry
implements the protocols used to connect and send source data to
icecast2 and shoutcast servers.
It is a low-level implementation, so it only does the minimal source connection.
In particular, it does not handle synchronisation. Hence, the task of sending
audio data to the streaming server at real time rate is up to the programmer,
contrary to the main implementation, libshout.
type
error =
| |
Create |
| |
Connect |
| |
Close |
| |
Write |
| |
Read |
| |
Busy |
| |
Not_connected |
| |
Invalid_usage |
| |
Bad_answer of |
| |
Http_answer of |
exception Error of error
val string_of_error : error -> string
type
protocol =
| |
Icy |
| |
Http |
Icy
is the (undocumented) shoutcast source protocol.
Http
is the icecast2 source protocol.
Ogg streaming is only possible with Http
. Any headerless format,
(e.g. mpeg containers), should work with both protocols,
provided you set the correct content-type (mime) for the source.
type
content_type
val ogg_application : content_type
val ogg_audio : content_type
val ogg_video : content_type
val mpeg : content_type
val content_type_of_string : string -> content_type
val string_of_content_type : content_type -> string
type
connection = {
|
mount : |
|
user : |
|
password : |
|
host : |
|
port : |
|
content_type : |
|
protocol : |
|
headers : |
headers
is a hash table containing the headers.
See connection
function for more details.
typeaudio_info =
(string, string) Hashtbl.t
audio_info
function for more details.typemetadata =
(string, string) Hashtbl.t
type
status =
| |
Connected of |
| |
Disconnected |
type
t
val create : ?ipv6:bool -> ?timeout:float -> ?bind:string -> unit -> t
ipv6
is false
by default.
timeout
is 30.
(seconds) by default.
bind
is "0.0.0.0"
by default.
val get_status : t -> status
val get_icy_cap : t -> bool
Http
protocol, this is always true.
For the Icy
protocol, this is detected upon connecting.val get_socket : t -> Unix.file_descr
Raises: Error Not_connected
if not connected.
val audio_info : ?samplerate:int ->
?channels:int -> ?quality:float -> ?bitrate:int -> unit -> audio_info
audio_info
value,
filed with given values.val connection : ?user_agent:string ->
?name:string ->
?genre:string ->
?url:string ->
?public:bool ->
?audio_info:audio_info ->
?description:string ->
?host:string ->
?port:int ->
?password:string ->
?protocol:protocol ->
?user:string ->
mount:string -> content_type:content_type -> unit -> connection
connection
value
with default values.
host
is "localhost"
by default.
password
is "hackme"
by default.
user
is "source"
by default. Change user
only if you know
what your are doing.
protocol
is Http
by default.
port
is 8000
by default.
The list of preset headers for Http
connections is:
"User-Agent"
, "ice-name"
, "ice-genre"
,
"ice-url"
, "ice-public"
, "ice-audio-info"
,
"ice-description"
.
The list of preset headers for Icy
connections is:
"User-Agent"
, "icy-name"
, "icy-url"
, "icy-pub"
,
"icy-genre"
, "icy-br"
.
Additionally, you can also add:
"icy-irc"
, "icy-icq"
and "icy-aim"
but these are not added
by this function.
val connect : t -> connection -> unit
val update_metadata : t -> metadata -> unit
icy_cap
is true
for Icy
connections.
For Icy
protocol, the relevant metadata are only "song"
and "url"
.
Raises: Error Not_connected
if not connected.
val manual_update_metadata : host:string ->
port:int ->
protocol:protocol ->
user:string ->
password:string ->
mount:string ->
?headers:(string, string) Hashtbl.t ->
?ipv6:bool -> ?bind:string -> metadata -> unit
Use it only if you know what you are doing !
val send : t -> string -> unit
Raises: Error Not_connected
if not connected.
val close : t -> unit
Raises: Error Not_connected
if not connected.