| s when s = C.signal_VOICE -> `voice
| s when s = C.signal_MUSIC -> `music
| _ -> assert false)
| Set_inband_FEC b ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> int32_t @-> returning int) in
fn handle code (Int32.of_int @@ Bool.to_int b) |> Error.wrap ()
| Get_inband_FEC ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> ptr int32_t @-> returning int) in
let b = allocate int32_t 0l in
fn handle code b |> Error.wrap (match !@b with | 0l -> false | 1l -> true | _ -> assert false)
| Set_LSB_depth d ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> int32_t @-> returning int) in
fn handle code (Int32.of_int d) |> Error.wrap ()
| Get_LSB_depth ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> ptr int32_t @-> returning int) in
let d = allocate int32_t 0l in
fn handle code d |> Error.wrap (Int32.to_int !@d)
| Set_DTX b ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> int32_t @-> returning int) in
fn handle code (Int32.of_int @@ Bool.to_int b) |> Error.wrap ()
| Get_DTX ->
let fn = Foreign.foreign ctl_fn (handle_t @-> int32_t @-> ptr int32_t @-> returning int) in
let b = allocate int32_t 0l in
fn handle code b |> Error.wrap (match !@b with | 0l -> false | 1l -> true | _ -> assert false)
| _ -> assert false
| s when s = C.signal_VOICE -> `voice
| s when s = C.signal_MUSIC -> `music
| _ -> assert false
in
conv to_int of_int
let channels =
let to_int = function
| `auto -> C._AUTO
| `mono -> 1
| `stereo -> 2
in
let of_int = function
| n when n = C._AUTO -> `auto
| 1 -> `mono
| 2 -> `stereo
| _ -> assert false
in
conv to_int of_int
let application =
let to_int = function
| Voip -> C.app_VOIP
| Audio -> C.app_AUDIO
| Restricted_lowdelay -> C.app_RESTRICTED_LOWEDELAY
in
let of_int = function
| n when n = C.app_VOIP -> Voip
| n when n = C.app_AUDIO -> Audio
| n when n = C.app_RESTRICTED_LOWEDELAY -> Restricted_lowdelay
| _ -> assert false
in
conv to_int of_int
let framesize =
let to_int = function
| `arg -> C.fs_ARG
| `fs_2_5ms -> C.fs_2_5_MS
| `fs_5ms -> C.fs_5_MS
| `fs_10ms -> C.fs_10_MS
| `fs_20ms -> C.fs_20_MS
| `fs_40ms -> C.fs_40_MS
| `fs_60ms -> C.fs_60_MS
| `fs_80ms -> C.fs_80_MS
| `fs_100ms -> C.fs_100_MS
| `fs_120ms -> C.fs_120_MS
in
let of_int = function
| n when n = C.fs_ARG -> `arg
| n when n = C.fs_2_5_MS -> `fs_2_5ms
| n when n = C.fs_5_MS -> `fs_5ms
| n when n = C.fs_10_MS -> `fs_10ms
| n when n = C.fs_20_MS -> `fs_20ms
| n when n = C.fs_40_MS -> `fs_40ms
| n when n = C.fs_60_MS -> `fs_60ms
| n when n = C.fs_80_MS -> `fs_80ms
| n when n = C.fs_100_MS -> `fs_100ms
| n when n = C.fs_120_MS -> `fs_120ms
| _ -> assert false
in
conv to_int of_int
end
let request: type a b. ctl_fn:string -> a handle -> (a, b) t -> b result
= fun ~ctl_fn handle req ->
let code = _code req in
match req with
(* generic *)
| Reset_state -> R.fn_0 ~code ~handle ctl_fn
| Get_final_range -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Get_bandwidth -> R.fn_1 ~code ~handle ctl_fn R.(get bandwidth)
| Get_sample_rate -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Set_phase_inversion_disabled b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_phase_inversion_disabled -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
| Get_in_DTX -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
(* encoder *)
| Set_complexity c -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg int c)
| Get_complexity -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Set_bitrate br -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bitrate br)
| Get_bitrate -> R.fn_1 ~code ~handle ctl_fn R.(get bitrate)
| Set_VBR b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_VBR -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
| Set_VBR_constraint b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_VBR_constraint -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
| Set_force_channels ch -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg channels ch)
| Get_force_channels -> R.fn_1 ~code ~handle ctl_fn R.(get channels)
| Set_max_bandwidth bw -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg max_bandwidth bw)
| Get_max_bandwidth -> R.fn_1 ~code ~handle ctl_fn R.(get max_bandwidth)
| Set_bandwidth bw -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bandwidth bw)
| Set_signal s -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg signal s)
| Get_signal -> R.fn_1 ~code ~handle ctl_fn R.(get signal)
| Set_application a -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg application a)
| Get_application -> R.fn_1 ~code ~handle ctl_fn R.(get application)
| Get_lookahead -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Set_inband_FEC b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_inband_FEC -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
| Set_packet_loss_perc plp -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg int plp)
| Get_packet_loss_perc -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Set_DTX b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_DTX -> R.fn_1 ~code ~handle ctl_fn R.(get bool)
| Set_LSB_depth d -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg int d)
| Get_LSB_depth -> R.fn_1 ~code ~handle ctl_fn R.(get int)
| Set_expert_frame_duration fs -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg framesize fs)
| Get_expert_frame_duration -> R.fn_1 ~code ~handle ctl_fn R.(get framesize)
| Set_prediction_disabled b -> R.fn_1 ~code ~handle ctl_fn R.(set @@ arg bool b)
| Get_prediction_disabled -> R.fn_1 ~code ~handle ctl_fn R.(get bool)