1#![no_std]
4#![allow(non_upper_case_globals)]
5#![allow(non_camel_case_types)]
6#![allow(non_snake_case)]
7
8pub const OPUS_OK: core::ffi::c_int = 0;
9pub const OPUS_BAD_ARG: core::ffi::c_int = -1;
10pub const OPUS_BUFFER_TOO_SMALL: core::ffi::c_int = -2;
11pub const OPUS_INTERNAL_ERROR: core::ffi::c_int = -3;
12pub const OPUS_INVALID_PACKET: core::ffi::c_int = -4;
13pub const OPUS_UNIMPLEMENTED: core::ffi::c_int = -5;
14pub const OPUS_INVALID_STATE: core::ffi::c_int = -6;
15pub const OPUS_ALLOC_FAIL: core::ffi::c_int = -7;
16pub const OPUS_SET_APPLICATION_REQUEST: core::ffi::c_int = 4000;
17pub const OPUS_GET_APPLICATION_REQUEST: core::ffi::c_int = 4001;
18pub const OPUS_SET_BITRATE_REQUEST: core::ffi::c_int = 4002;
19pub const OPUS_GET_BITRATE_REQUEST: core::ffi::c_int = 4003;
20pub const OPUS_SET_MAX_BANDWIDTH_REQUEST: core::ffi::c_int = 4004;
21pub const OPUS_GET_MAX_BANDWIDTH_REQUEST: core::ffi::c_int = 4005;
22pub const OPUS_SET_VBR_REQUEST: core::ffi::c_int = 4006;
23pub const OPUS_GET_VBR_REQUEST: core::ffi::c_int = 4007;
24pub const OPUS_SET_BANDWIDTH_REQUEST: core::ffi::c_int = 4008;
25pub const OPUS_GET_BANDWIDTH_REQUEST: core::ffi::c_int = 4009;
26pub const OPUS_SET_COMPLEXITY_REQUEST: core::ffi::c_int = 4010;
27pub const OPUS_GET_COMPLEXITY_REQUEST: core::ffi::c_int = 4011;
28pub const OPUS_SET_INBAND_FEC_REQUEST: core::ffi::c_int = 4012;
29pub const OPUS_GET_INBAND_FEC_REQUEST: core::ffi::c_int = 4013;
30pub const OPUS_SET_PACKET_LOSS_PERC_REQUEST: core::ffi::c_int = 4014;
31pub const OPUS_GET_PACKET_LOSS_PERC_REQUEST: core::ffi::c_int = 4015;
32pub const OPUS_SET_DTX_REQUEST: core::ffi::c_int = 4016;
33pub const OPUS_GET_DTX_REQUEST: core::ffi::c_int = 4017;
34pub const OPUS_SET_VBR_CONSTRAINT_REQUEST: core::ffi::c_int = 4020;
35pub const OPUS_GET_VBR_CONSTRAINT_REQUEST: core::ffi::c_int = 4021;
36pub const OPUS_SET_FORCE_CHANNELS_REQUEST: core::ffi::c_int = 4022;
37pub const OPUS_GET_FORCE_CHANNELS_REQUEST: core::ffi::c_int = 4023;
38pub const OPUS_SET_SIGNAL_REQUEST: core::ffi::c_int = 4024;
39pub const OPUS_GET_SIGNAL_REQUEST: core::ffi::c_int = 4025;
40pub const OPUS_GET_LOOKAHEAD_REQUEST: core::ffi::c_int = 4027;
41pub const OPUS_GET_SAMPLE_RATE_REQUEST: core::ffi::c_int = 4029;
42pub const OPUS_GET_FINAL_RANGE_REQUEST: core::ffi::c_int = 4031;
43pub const OPUS_GET_PITCH_REQUEST: core::ffi::c_int = 4033;
44pub const OPUS_SET_GAIN_REQUEST: core::ffi::c_int = 4034;
45pub const OPUS_GET_GAIN_REQUEST: core::ffi::c_int = 4045;
46pub const OPUS_SET_LSB_DEPTH_REQUEST: core::ffi::c_int = 4036;
47pub const OPUS_GET_LSB_DEPTH_REQUEST: core::ffi::c_int = 4037;
48pub const OPUS_GET_LAST_PACKET_DURATION_REQUEST: core::ffi::c_int = 4039;
49pub const OPUS_SET_EXPERT_FRAME_DURATION_REQUEST: core::ffi::c_int = 4040;
50pub const OPUS_GET_EXPERT_FRAME_DURATION_REQUEST: core::ffi::c_int = 4041;
51pub const OPUS_SET_PREDICTION_DISABLED_REQUEST: core::ffi::c_int = 4042;
52pub const OPUS_GET_PREDICTION_DISABLED_REQUEST: core::ffi::c_int = 4043;
53pub const OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: core::ffi::c_int = 4046;
54pub const OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: core::ffi::c_int = 4047;
55pub const OPUS_GET_IN_DTX_REQUEST: core::ffi::c_int = 4049;
56pub const OPUS_SET_DRED_DURATION_REQUEST: core::ffi::c_int = 4050;
57pub const OPUS_GET_DRED_DURATION_REQUEST: core::ffi::c_int = 4051;
58pub const OPUS_SET_DNN_BLOB_REQUEST: core::ffi::c_int = 4052;
59pub const OPUS_AUTO: core::ffi::c_int = -1000;
60pub const OPUS_BITRATE_MAX: core::ffi::c_int = -1;
61pub const OPUS_APPLICATION_VOIP: core::ffi::c_int = 2048;
62pub const OPUS_APPLICATION_AUDIO: core::ffi::c_int = 2049;
63pub const OPUS_APPLICATION_RESTRICTED_LOWDELAY: core::ffi::c_int = 2051;
64pub const OPUS_SIGNAL_VOICE: core::ffi::c_int = 3001;
65pub const OPUS_SIGNAL_MUSIC: core::ffi::c_int = 3002;
66pub const OPUS_BANDWIDTH_NARROWBAND: core::ffi::c_int = 1101;
67pub const OPUS_BANDWIDTH_MEDIUMBAND: core::ffi::c_int = 1102;
68pub const OPUS_BANDWIDTH_WIDEBAND: core::ffi::c_int = 1103;
69pub const OPUS_BANDWIDTH_SUPERWIDEBAND: core::ffi::c_int = 1104;
70pub const OPUS_BANDWIDTH_FULLBAND: core::ffi::c_int = 1105;
71pub const OPUS_FRAMESIZE_ARG: core::ffi::c_int = 5000;
72pub const OPUS_FRAMESIZE_2_5_MS: core::ffi::c_int = 5001;
73pub const OPUS_FRAMESIZE_5_MS: core::ffi::c_int = 5002;
74pub const OPUS_FRAMESIZE_10_MS: core::ffi::c_int = 5003;
75pub const OPUS_FRAMESIZE_20_MS: core::ffi::c_int = 5004;
76pub const OPUS_FRAMESIZE_40_MS: core::ffi::c_int = 5005;
77pub const OPUS_FRAMESIZE_60_MS: core::ffi::c_int = 5006;
78pub const OPUS_FRAMESIZE_80_MS: core::ffi::c_int = 5007;
79pub const OPUS_FRAMESIZE_100_MS: core::ffi::c_int = 5008;
80pub const OPUS_FRAMESIZE_120_MS: core::ffi::c_int = 5009;
81pub const OPUS_RESET_STATE: core::ffi::c_int = 4028;
82pub const OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST: core::ffi::c_int = 5120;
83pub const OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST: core::ffi::c_int = 5122;
84pub type opus_int8 = i8;
85pub type opus_uint8 = u8;
86pub type opus_int16 = i16;
87pub type opus_uint16 = u16;
88pub type opus_int32 = i32;
89pub type opus_uint32 = u32;
90pub type opus_int64 = i64;
91pub type opus_uint64 = u64;
92unsafe extern "C" {
93 pub fn opus_strerror(error: core::ffi::c_int) -> *const core::ffi::c_char;
94}
95unsafe extern "C" {
96 pub fn opus_get_version_string() -> *const core::ffi::c_char;
97}
98#[repr(C)]
99#[derive(Debug, Copy, Clone)]
100pub struct OpusEncoder {
101 _unused: [u8; 0],
102}
103unsafe extern "C" {
104 pub fn opus_encoder_get_size(channels: core::ffi::c_int) -> core::ffi::c_int;
105}
106unsafe extern "C" {
107 pub fn opus_encoder_create(
108 Fs: opus_int32,
109 channels: core::ffi::c_int,
110 application: core::ffi::c_int,
111 error: *mut core::ffi::c_int,
112 ) -> *mut OpusEncoder;
113}
114unsafe extern "C" {
115 pub fn opus_encoder_init(
116 st: *mut OpusEncoder,
117 Fs: opus_int32,
118 channels: core::ffi::c_int,
119 application: core::ffi::c_int,
120 ) -> core::ffi::c_int;
121}
122unsafe extern "C" {
123 pub fn opus_encode(
124 st: *mut OpusEncoder,
125 pcm: *const opus_int16,
126 frame_size: core::ffi::c_int,
127 data: *mut core::ffi::c_uchar,
128 max_data_bytes: opus_int32,
129 ) -> opus_int32;
130}
131unsafe extern "C" {
132 pub fn opus_encode_float(
133 st: *mut OpusEncoder,
134 pcm: *const f32,
135 frame_size: core::ffi::c_int,
136 data: *mut core::ffi::c_uchar,
137 max_data_bytes: opus_int32,
138 ) -> opus_int32;
139}
140unsafe extern "C" {
141 pub fn opus_encoder_destroy(st: *mut OpusEncoder);
142}
143unsafe extern "C" {
144 pub fn opus_encoder_ctl(
145 st: *mut OpusEncoder,
146 request: core::ffi::c_int,
147 ...
148 ) -> core::ffi::c_int;
149}
150#[repr(C)]
151#[derive(Debug, Copy, Clone)]
152pub struct OpusDecoder {
153 _unused: [u8; 0],
154}
155#[repr(C)]
156#[derive(Debug, Copy, Clone)]
157pub struct OpusDREDDecoder {
158 _unused: [u8; 0],
159}
160#[repr(C)]
161#[derive(Debug, Copy, Clone)]
162pub struct OpusDRED {
163 _unused: [u8; 0],
164}
165unsafe extern "C" {
166 pub fn opus_decoder_get_size(channels: core::ffi::c_int) -> core::ffi::c_int;
167}
168unsafe extern "C" {
169 pub fn opus_decoder_create(
170 Fs: opus_int32,
171 channels: core::ffi::c_int,
172 error: *mut core::ffi::c_int,
173 ) -> *mut OpusDecoder;
174}
175unsafe extern "C" {
176 pub fn opus_decoder_init(
177 st: *mut OpusDecoder,
178 Fs: opus_int32,
179 channels: core::ffi::c_int,
180 ) -> core::ffi::c_int;
181}
182unsafe extern "C" {
183 pub fn opus_decode(
184 st: *mut OpusDecoder,
185 data: *const core::ffi::c_uchar,
186 len: opus_int32,
187 pcm: *mut opus_int16,
188 frame_size: core::ffi::c_int,
189 decode_fec: core::ffi::c_int,
190 ) -> core::ffi::c_int;
191}
192unsafe extern "C" {
193 pub fn opus_decode_float(
194 st: *mut OpusDecoder,
195 data: *const core::ffi::c_uchar,
196 len: opus_int32,
197 pcm: *mut f32,
198 frame_size: core::ffi::c_int,
199 decode_fec: core::ffi::c_int,
200 ) -> core::ffi::c_int;
201}
202unsafe extern "C" {
203 pub fn opus_decoder_ctl(
204 st: *mut OpusDecoder,
205 request: core::ffi::c_int,
206 ...
207 ) -> core::ffi::c_int;
208}
209unsafe extern "C" {
210 pub fn opus_decoder_destroy(st: *mut OpusDecoder);
211}
212unsafe extern "C" {
213 pub fn opus_dred_decoder_get_size() -> core::ffi::c_int;
214}
215unsafe extern "C" {
216 pub fn opus_dred_decoder_create(error: *mut core::ffi::c_int) -> *mut OpusDREDDecoder;
217}
218unsafe extern "C" {
219 pub fn opus_dred_decoder_init(dec: *mut OpusDREDDecoder) -> core::ffi::c_int;
220}
221unsafe extern "C" {
222 pub fn opus_dred_decoder_destroy(dec: *mut OpusDREDDecoder);
223}
224unsafe extern "C" {
225 pub fn opus_dred_decoder_ctl(
226 dred_dec: *mut OpusDREDDecoder,
227 request: core::ffi::c_int,
228 ...
229 ) -> core::ffi::c_int;
230}
231unsafe extern "C" {
232 pub fn opus_dred_get_size() -> core::ffi::c_int;
233}
234unsafe extern "C" {
235 pub fn opus_dred_alloc(error: *mut core::ffi::c_int) -> *mut OpusDRED;
236}
237unsafe extern "C" {
238 pub fn opus_dred_free(dec: *mut OpusDRED);
239}
240unsafe extern "C" {
241 pub fn opus_dred_parse(
242 dred_dec: *mut OpusDREDDecoder,
243 dred: *mut OpusDRED,
244 data: *const core::ffi::c_uchar,
245 len: opus_int32,
246 max_dred_samples: opus_int32,
247 sampling_rate: opus_int32,
248 dred_end: *mut core::ffi::c_int,
249 defer_processing: core::ffi::c_int,
250 ) -> core::ffi::c_int;
251}
252unsafe extern "C" {
253 pub fn opus_dred_process(
254 dred_dec: *mut OpusDREDDecoder,
255 src: *const OpusDRED,
256 dst: *mut OpusDRED,
257 ) -> core::ffi::c_int;
258}
259unsafe extern "C" {
260 pub fn opus_decoder_dred_decode(
261 st: *mut OpusDecoder,
262 dred: *const OpusDRED,
263 dred_offset: opus_int32,
264 pcm: *mut opus_int16,
265 frame_size: opus_int32,
266 ) -> core::ffi::c_int;
267}
268unsafe extern "C" {
269 pub fn opus_decoder_dred_decode_float(
270 st: *mut OpusDecoder,
271 dred: *const OpusDRED,
272 dred_offset: opus_int32,
273 pcm: *mut f32,
274 frame_size: opus_int32,
275 ) -> core::ffi::c_int;
276}
277unsafe extern "C" {
278 pub fn opus_packet_parse(
279 data: *const core::ffi::c_uchar,
280 len: opus_int32,
281 out_toc: *mut core::ffi::c_uchar,
282 frames: *mut *const core::ffi::c_uchar,
283 size: *mut opus_int16,
284 payload_offset: *mut core::ffi::c_int,
285 ) -> core::ffi::c_int;
286}
287unsafe extern "C" {
288 pub fn opus_packet_get_bandwidth(data: *const core::ffi::c_uchar) -> core::ffi::c_int;
289}
290unsafe extern "C" {
291 pub fn opus_packet_get_samples_per_frame(
292 data: *const core::ffi::c_uchar,
293 Fs: opus_int32,
294 ) -> core::ffi::c_int;
295}
296unsafe extern "C" {
297 pub fn opus_packet_get_nb_channels(data: *const core::ffi::c_uchar) -> core::ffi::c_int;
298}
299unsafe extern "C" {
300 pub fn opus_packet_get_nb_frames(
301 packet: *const core::ffi::c_uchar,
302 len: opus_int32,
303 ) -> core::ffi::c_int;
304}
305unsafe extern "C" {
306 pub fn opus_packet_get_nb_samples(
307 packet: *const core::ffi::c_uchar,
308 len: opus_int32,
309 Fs: opus_int32,
310 ) -> core::ffi::c_int;
311}
312unsafe extern "C" {
313 pub fn opus_packet_has_lbrr(
314 packet: *const core::ffi::c_uchar,
315 len: opus_int32,
316 ) -> core::ffi::c_int;
317}
318unsafe extern "C" {
319 pub fn opus_decoder_get_nb_samples(
320 dec: *const OpusDecoder,
321 packet: *const core::ffi::c_uchar,
322 len: opus_int32,
323 ) -> core::ffi::c_int;
324}
325unsafe extern "C" {
326 pub fn opus_pcm_soft_clip(
327 pcm: *mut f32,
328 frame_size: core::ffi::c_int,
329 channels: core::ffi::c_int,
330 softclip_mem: *mut f32,
331 );
332}
333#[repr(C)]
334#[derive(Debug, Copy, Clone)]
335pub struct OpusRepacketizer {
336 _unused: [u8; 0],
337}
338unsafe extern "C" {
339 pub fn opus_repacketizer_get_size() -> core::ffi::c_int;
340}
341unsafe extern "C" {
342 pub fn opus_repacketizer_init(rp: *mut OpusRepacketizer) -> *mut OpusRepacketizer;
343}
344unsafe extern "C" {
345 pub fn opus_repacketizer_create() -> *mut OpusRepacketizer;
346}
347unsafe extern "C" {
348 pub fn opus_repacketizer_destroy(rp: *mut OpusRepacketizer);
349}
350unsafe extern "C" {
351 pub fn opus_repacketizer_cat(
352 rp: *mut OpusRepacketizer,
353 data: *const core::ffi::c_uchar,
354 len: opus_int32,
355 ) -> core::ffi::c_int;
356}
357unsafe extern "C" {
358 pub fn opus_repacketizer_out_range(
359 rp: *mut OpusRepacketizer,
360 begin: core::ffi::c_int,
361 end: core::ffi::c_int,
362 data: *mut core::ffi::c_uchar,
363 maxlen: opus_int32,
364 ) -> opus_int32;
365}
366unsafe extern "C" {
367 pub fn opus_repacketizer_get_nb_frames(rp: *mut OpusRepacketizer) -> core::ffi::c_int;
368}
369unsafe extern "C" {
370 pub fn opus_repacketizer_out(
371 rp: *mut OpusRepacketizer,
372 data: *mut core::ffi::c_uchar,
373 maxlen: opus_int32,
374 ) -> opus_int32;
375}
376unsafe extern "C" {
377 pub fn opus_packet_pad(
378 data: *mut core::ffi::c_uchar,
379 len: opus_int32,
380 new_len: opus_int32,
381 ) -> core::ffi::c_int;
382}
383unsafe extern "C" {
384 pub fn opus_packet_unpad(data: *mut core::ffi::c_uchar, len: opus_int32) -> opus_int32;
385}
386unsafe extern "C" {
387 pub fn opus_multistream_packet_pad(
388 data: *mut core::ffi::c_uchar,
389 len: opus_int32,
390 new_len: opus_int32,
391 nb_streams: core::ffi::c_int,
392 ) -> core::ffi::c_int;
393}
394unsafe extern "C" {
395 pub fn opus_multistream_packet_unpad(
396 data: *mut core::ffi::c_uchar,
397 len: opus_int32,
398 nb_streams: core::ffi::c_int,
399 ) -> opus_int32;
400}
401#[repr(C)]
402#[derive(Debug, Copy, Clone)]
403pub struct OpusMSEncoder {
404 _unused: [u8; 0],
405}
406#[repr(C)]
407#[derive(Debug, Copy, Clone)]
408pub struct OpusMSDecoder {
409 _unused: [u8; 0],
410}
411unsafe extern "C" {
412 pub fn opus_multistream_encoder_get_size(
413 streams: core::ffi::c_int,
414 coupled_streams: core::ffi::c_int,
415 ) -> opus_int32;
416}
417unsafe extern "C" {
418 pub fn opus_multistream_surround_encoder_get_size(
419 channels: core::ffi::c_int,
420 mapping_family: core::ffi::c_int,
421 ) -> opus_int32;
422}
423unsafe extern "C" {
424 pub fn opus_multistream_encoder_create(
425 Fs: opus_int32,
426 channels: core::ffi::c_int,
427 streams: core::ffi::c_int,
428 coupled_streams: core::ffi::c_int,
429 mapping: *const core::ffi::c_uchar,
430 application: core::ffi::c_int,
431 error: *mut core::ffi::c_int,
432 ) -> *mut OpusMSEncoder;
433}
434unsafe extern "C" {
435 pub fn opus_multistream_surround_encoder_create(
436 Fs: opus_int32,
437 channels: core::ffi::c_int,
438 mapping_family: core::ffi::c_int,
439 streams: *mut core::ffi::c_int,
440 coupled_streams: *mut core::ffi::c_int,
441 mapping: *mut core::ffi::c_uchar,
442 application: core::ffi::c_int,
443 error: *mut core::ffi::c_int,
444 ) -> *mut OpusMSEncoder;
445}
446unsafe extern "C" {
447 pub fn opus_multistream_encoder_init(
448 st: *mut OpusMSEncoder,
449 Fs: opus_int32,
450 channels: core::ffi::c_int,
451 streams: core::ffi::c_int,
452 coupled_streams: core::ffi::c_int,
453 mapping: *const core::ffi::c_uchar,
454 application: core::ffi::c_int,
455 ) -> core::ffi::c_int;
456}
457unsafe extern "C" {
458 pub fn opus_multistream_surround_encoder_init(
459 st: *mut OpusMSEncoder,
460 Fs: opus_int32,
461 channels: core::ffi::c_int,
462 mapping_family: core::ffi::c_int,
463 streams: *mut core::ffi::c_int,
464 coupled_streams: *mut core::ffi::c_int,
465 mapping: *mut core::ffi::c_uchar,
466 application: core::ffi::c_int,
467 ) -> core::ffi::c_int;
468}
469unsafe extern "C" {
470 pub fn opus_multistream_encode(
471 st: *mut OpusMSEncoder,
472 pcm: *const opus_int16,
473 frame_size: core::ffi::c_int,
474 data: *mut core::ffi::c_uchar,
475 max_data_bytes: opus_int32,
476 ) -> core::ffi::c_int;
477}
478unsafe extern "C" {
479 pub fn opus_multistream_encode_float(
480 st: *mut OpusMSEncoder,
481 pcm: *const f32,
482 frame_size: core::ffi::c_int,
483 data: *mut core::ffi::c_uchar,
484 max_data_bytes: opus_int32,
485 ) -> core::ffi::c_int;
486}
487unsafe extern "C" {
488 pub fn opus_multistream_encoder_destroy(st: *mut OpusMSEncoder);
489}
490unsafe extern "C" {
491 pub fn opus_multistream_encoder_ctl(
492 st: *mut OpusMSEncoder,
493 request: core::ffi::c_int,
494 ...
495 ) -> core::ffi::c_int;
496}
497unsafe extern "C" {
498 pub fn opus_multistream_decoder_get_size(
499 streams: core::ffi::c_int,
500 coupled_streams: core::ffi::c_int,
501 ) -> opus_int32;
502}
503unsafe extern "C" {
504 pub fn opus_multistream_decoder_create(
505 Fs: opus_int32,
506 channels: core::ffi::c_int,
507 streams: core::ffi::c_int,
508 coupled_streams: core::ffi::c_int,
509 mapping: *const core::ffi::c_uchar,
510 error: *mut core::ffi::c_int,
511 ) -> *mut OpusMSDecoder;
512}
513unsafe extern "C" {
514 pub fn opus_multistream_decoder_init(
515 st: *mut OpusMSDecoder,
516 Fs: opus_int32,
517 channels: core::ffi::c_int,
518 streams: core::ffi::c_int,
519 coupled_streams: core::ffi::c_int,
520 mapping: *const core::ffi::c_uchar,
521 ) -> core::ffi::c_int;
522}
523unsafe extern "C" {
524 pub fn opus_multistream_decode(
525 st: *mut OpusMSDecoder,
526 data: *const core::ffi::c_uchar,
527 len: opus_int32,
528 pcm: *mut opus_int16,
529 frame_size: core::ffi::c_int,
530 decode_fec: core::ffi::c_int,
531 ) -> core::ffi::c_int;
532}
533unsafe extern "C" {
534 pub fn opus_multistream_decode_float(
535 st: *mut OpusMSDecoder,
536 data: *const core::ffi::c_uchar,
537 len: opus_int32,
538 pcm: *mut f32,
539 frame_size: core::ffi::c_int,
540 decode_fec: core::ffi::c_int,
541 ) -> core::ffi::c_int;
542}
543unsafe extern "C" {
544 pub fn opus_multistream_decoder_ctl(
545 st: *mut OpusMSDecoder,
546 request: core::ffi::c_int,
547 ...
548 ) -> core::ffi::c_int;
549}
550unsafe extern "C" {
551 pub fn opus_multistream_decoder_destroy(st: *mut OpusMSDecoder);
552}