opus_sys/
lib.rs

1#![allow(non_camel_case_types)]
2
3extern crate libc;
4
5pub type int8_t = ::libc::c_char;
6pub type int16_t = ::libc::c_short;
7pub type int32_t = ::libc::c_int;
8pub type int64_t = ::libc::c_long;
9pub type uint8_t = ::libc::c_uchar;
10pub type uint16_t = ::libc::c_ushort;
11pub type uint32_t = ::libc::c_uint;
12pub type uint64_t = ::libc::c_ulong;
13pub type int_least8_t = ::libc::c_char;
14pub type int_least16_t = ::libc::c_short;
15pub type int_least32_t = ::libc::c_int;
16pub type int_least64_t = ::libc::c_long;
17pub type uint_least8_t = ::libc::c_uchar;
18pub type uint_least16_t = ::libc::c_ushort;
19pub type uint_least32_t = ::libc::c_uint;
20pub type uint_least64_t = ::libc::c_ulong;
21pub type int_fast8_t = ::libc::c_char;
22pub type int_fast16_t = ::libc::c_long;
23pub type int_fast32_t = ::libc::c_long;
24pub type int_fast64_t = ::libc::c_long;
25pub type uint_fast8_t = ::libc::c_uchar;
26pub type uint_fast16_t = ::libc::c_ulong;
27pub type uint_fast32_t = ::libc::c_ulong;
28pub type uint_fast64_t = ::libc::c_ulong;
29pub type intptr_t = ::libc::c_long;
30pub type uintptr_t = ::libc::c_ulong;
31pub type intmax_t = ::libc::c_long;
32pub type uintmax_t = ::libc::c_ulong;
33pub type opus_int16 = int16_t;
34pub type opus_uint16 = uint16_t;
35pub type opus_int32 = int32_t;
36pub type opus_uint32 = uint32_t;
37
38pub enum OpusEncoder { }
39pub enum OpusDecoder { }
40pub enum OpusRepacketizer { }
41
42// ------ Constants from opus_defines.h ------
43
44pub const OPUS_OK               : i32 =  0;
45pub const OPUS_BAD_ARG          : i32 = -1;
46pub const OPUS_BUFFER_TOO_SMALL : i32 = -2;
47pub const OPUS_INTERNAL_ERROR   : i32 = -3;
48pub const OPUS_INVALID_PACKET   : i32 = -4;
49pub const OPUS_UNIMPLEMENTED    : i32 = -5;
50pub const OPUS_INVALID_STATE    : i32 = -6;
51pub const OPUS_ALLOC_FAIL       : i32 = -7;
52
53// -------------------------------------------
54
55extern "C" {
56    pub fn opus_strerror(error: ::libc::c_int) -> *const ::libc::c_char;
57    pub fn opus_get_version_string() -> *const ::libc::c_char;
58    pub fn opus_encoder_get_size(channels: ::libc::c_int) -> ::libc::c_int;
59    pub fn opus_encoder_create(Fs: opus_int32, channels: ::libc::c_int,
60                               application: ::libc::c_int,
61                               error: *mut ::libc::c_int) -> *mut OpusEncoder;
62    pub fn opus_encoder_init(st: *mut OpusEncoder, Fs: opus_int32,
63                             channels: ::libc::c_int,
64                             application: ::libc::c_int) -> ::libc::c_int;
65    pub fn opus_encode(st: *mut OpusEncoder, pcm: *const opus_int16,
66                       frame_size: ::libc::c_int, data: *mut ::libc::c_uchar,
67                       max_data_bytes: opus_int32) -> opus_int32;
68    pub fn opus_encode_float(st: *mut OpusEncoder,
69                             pcm: *const ::libc::c_float,
70                             frame_size: ::libc::c_int,
71                             data: *mut ::libc::c_uchar,
72                             max_data_bytes: opus_int32) -> opus_int32;
73    pub fn opus_encoder_destroy(st: *mut OpusEncoder) -> ();
74    pub fn opus_encoder_ctl(st: *mut OpusEncoder, request: ::libc::c_int, ...)
75     -> ::libc::c_int;
76    pub fn opus_decoder_get_size(channels: ::libc::c_int) -> ::libc::c_int;
77    pub fn opus_decoder_create(Fs: opus_int32, channels: ::libc::c_int,
78                               error: *mut ::libc::c_int) -> *mut OpusDecoder;
79    pub fn opus_decoder_init(st: *mut OpusDecoder, Fs: opus_int32,
80                             channels: ::libc::c_int) -> ::libc::c_int;
81    pub fn opus_decode(st: *mut OpusDecoder, data: *const ::libc::c_uchar,
82                       len: opus_int32, pcm: *mut opus_int16,
83                       frame_size: ::libc::c_int, decode_fec: ::libc::c_int)
84     -> ::libc::c_int;
85    pub fn opus_decode_float(st: *mut OpusDecoder,
86                             data: *const ::libc::c_uchar, len: opus_int32,
87                             pcm: *mut ::libc::c_float,
88                             frame_size: ::libc::c_int,
89                             decode_fec: ::libc::c_int) -> ::libc::c_int;
90    pub fn opus_decoder_ctl(st: *mut OpusDecoder, request: ::libc::c_int, ...)
91     -> ::libc::c_int;
92    pub fn opus_decoder_destroy(st: *mut OpusDecoder) -> ();
93    pub fn opus_packet_parse(data: *const ::libc::c_uchar, len: opus_int32,
94                             out_toc: *mut ::libc::c_uchar,
95                             frames: *mut *const ::libc::c_uchar,
96                             size: *mut opus_int16,
97                             payload_offset: *mut ::libc::c_int)
98     -> ::libc::c_int;
99    pub fn opus_packet_get_bandwidth(data: *const ::libc::c_uchar)
100     -> ::libc::c_int;
101    pub fn opus_packet_get_samples_per_frame(data: *const ::libc::c_uchar,
102                                             Fs: opus_int32) -> ::libc::c_int;
103    pub fn opus_packet_get_nb_channels(data: *const ::libc::c_uchar)
104     -> ::libc::c_int;
105    pub fn opus_packet_get_nb_frames(packet: *const ::libc::c_uchar,
106                                     len: opus_int32) -> ::libc::c_int;
107    pub fn opus_packet_get_nb_samples(packet: *const ::libc::c_uchar,
108                                      len: opus_int32, Fs: opus_int32)
109     -> ::libc::c_int;
110    pub fn opus_decoder_get_nb_samples(dec: *const OpusDecoder,
111                                       packet: *const ::libc::c_uchar,
112                                       len: opus_int32) -> ::libc::c_int;
113    pub fn opus_pcm_soft_clip(pcm: *mut ::libc::c_float,
114                              frame_size: ::libc::c_int,
115                              channels: ::libc::c_int,
116                              softclip_mem: *mut ::libc::c_float) -> ();
117    pub fn opus_repacketizer_get_size() -> ::libc::c_int;
118    pub fn opus_repacketizer_init(rp: *mut OpusRepacketizer)
119     -> *mut OpusRepacketizer;
120    pub fn opus_repacketizer_create() -> *mut OpusRepacketizer;
121    pub fn opus_repacketizer_destroy(rp: *mut OpusRepacketizer) -> ();
122    pub fn opus_repacketizer_cat(rp: *mut OpusRepacketizer,
123                                 data: *const ::libc::c_uchar,
124                                 len: opus_int32) -> ::libc::c_int;
125    pub fn opus_repacketizer_out_range(rp: *mut OpusRepacketizer,
126                                       begin: ::libc::c_int,
127                                       end: ::libc::c_int,
128                                       data: *mut ::libc::c_uchar,
129                                       maxlen: opus_int32) -> opus_int32;
130    pub fn opus_repacketizer_get_nb_frames(rp: *mut OpusRepacketizer)
131     -> ::libc::c_int;
132    pub fn opus_repacketizer_out(rp: *mut OpusRepacketizer,
133                                 data: *mut ::libc::c_uchar,
134                                 maxlen: opus_int32) -> opus_int32;
135    pub fn opus_packet_pad(data: *mut ::libc::c_uchar, len: opus_int32,
136                           new_len: opus_int32) -> ::libc::c_int;
137    pub fn opus_packet_unpad(data: *mut ::libc::c_uchar, len: opus_int32)
138     -> opus_int32;
139    pub fn opus_multistream_packet_pad(data: *mut ::libc::c_uchar,
140                                       len: opus_int32, new_len: opus_int32,
141                                       nb_streams: ::libc::c_int)
142     -> ::libc::c_int;
143    pub fn opus_multistream_packet_unpad(data: *mut ::libc::c_uchar,
144                                         len: opus_int32,
145                                         nb_streams: ::libc::c_int)
146     -> opus_int32;
147}
148
149// ------ From opus_multistream.h ------------
150
151pub enum OpusMSEncoder { }
152pub enum OpusMSDecoder { }
153
154extern "C" {
155    pub fn opus_multistream_encoder_get_size(streams: ::libc::c_int,
156                                             coupled_streams: ::libc::c_int)
157     -> opus_int32;
158    pub fn opus_multistream_surround_encoder_get_size(channels: ::libc::c_int,
159                                                      mapping_family:
160                                                          ::libc::c_int)
161     -> opus_int32;
162    pub fn opus_multistream_encoder_create(Fs: opus_int32,
163                                           channels: ::libc::c_int,
164                                           streams: ::libc::c_int,
165                                           coupled_streams: ::libc::c_int,
166                                           mapping: *const ::libc::c_uchar,
167                                           application: ::libc::c_int,
168                                           error: *mut ::libc::c_int)
169     -> *mut OpusMSEncoder;
170    pub fn opus_multistream_surround_encoder_create(Fs: opus_int32,
171                                                    channels: ::libc::c_int,
172                                                    mapping_family:
173                                                        ::libc::c_int,
174                                                    streams:
175                                                        *mut ::libc::c_int,
176                                                    coupled_streams:
177                                                        *mut ::libc::c_int,
178                                                    mapping:
179                                                        *mut ::libc::c_uchar,
180                                                    application:
181                                                        ::libc::c_int,
182                                                    error: *mut ::libc::c_int)
183     -> *mut OpusMSEncoder;
184    pub fn opus_multistream_encoder_init(st: *mut OpusMSEncoder,
185                                         Fs: opus_int32,
186                                         channels: ::libc::c_int,
187                                         streams: ::libc::c_int,
188                                         coupled_streams: ::libc::c_int,
189                                         mapping: *const ::libc::c_uchar,
190                                         application: ::libc::c_int)
191     -> ::libc::c_int;
192    pub fn opus_multistream_surround_encoder_init(st: *mut OpusMSEncoder,
193                                                  Fs: opus_int32,
194                                                  channels: ::libc::c_int,
195                                                  mapping_family:
196                                                      ::libc::c_int,
197                                                  streams: *mut ::libc::c_int,
198                                                  coupled_streams:
199                                                      *mut ::libc::c_int,
200                                                  mapping:
201                                                      *mut ::libc::c_uchar,
202                                                  application: ::libc::c_int)
203     -> ::libc::c_int;
204    pub fn opus_multistream_encode(st: *mut OpusMSEncoder,
205                                   pcm: *const opus_int16,
206                                   frame_size: ::libc::c_int,
207                                   data: *mut ::libc::c_uchar,
208                                   max_data_bytes: opus_int32)
209     -> ::libc::c_int;
210    pub fn opus_multistream_encode_float(st: *mut OpusMSEncoder,
211                                         pcm: *const ::libc::c_float,
212                                         frame_size: ::libc::c_int,
213                                         data: *mut ::libc::c_uchar,
214                                         max_data_bytes: opus_int32)
215     -> ::libc::c_int;
216    pub fn opus_multistream_encoder_destroy(st: *mut OpusMSEncoder) -> ();
217    pub fn opus_multistream_encoder_ctl(st: *mut OpusMSEncoder,
218                                        request: ::libc::c_int, ...)
219     -> ::libc::c_int;
220    pub fn opus_multistream_decoder_get_size(streams: ::libc::c_int,
221                                             coupled_streams: ::libc::c_int)
222     -> opus_int32;
223    pub fn opus_multistream_decoder_create(Fs: opus_int32,
224                                           channels: ::libc::c_int,
225                                           streams: ::libc::c_int,
226                                           coupled_streams: ::libc::c_int,
227                                           mapping: *const ::libc::c_uchar,
228                                           error: *mut ::libc::c_int)
229     -> *mut OpusMSDecoder;
230    pub fn opus_multistream_decoder_init(st: *mut OpusMSDecoder,
231                                         Fs: opus_int32,
232                                         channels: ::libc::c_int,
233                                         streams: ::libc::c_int,
234                                         coupled_streams: ::libc::c_int,
235                                         mapping: *const ::libc::c_uchar)
236     -> ::libc::c_int;
237    pub fn opus_multistream_decode(st: *mut OpusMSDecoder,
238                                   data: *const ::libc::c_uchar,
239                                   len: opus_int32, pcm: *mut opus_int16,
240                                   frame_size: ::libc::c_int,
241                                   decode_fec: ::libc::c_int)
242     -> ::libc::c_int;
243    pub fn opus_multistream_decode_float(st: *mut OpusMSDecoder,
244                                         data: *const ::libc::c_uchar,
245                                         len: opus_int32,
246                                         pcm: *mut ::libc::c_float,
247                                         frame_size: ::libc::c_int,
248                                         decode_fec: ::libc::c_int)
249     -> ::libc::c_int;
250    pub fn opus_multistream_decoder_ctl(st: *mut OpusMSDecoder,
251                                        request: ::libc::c_int, ...)
252     -> ::libc::c_int;
253    pub fn opus_multistream_decoder_destroy(st: *mut OpusMSDecoder) -> ();
254}