1#![warn(missing_docs)]
3#![warn(clippy::all)]
4#![warn(clippy::pedantic)]
5#![warn(clippy::cargo)]
6#![allow(clippy::cast_possible_wrap)]
7#![allow(clippy::cast_possible_truncation)]
8
9#[allow(warnings)]
11#[allow(clippy::all)]
12mod bindings {
13 include!("bindings.rs");
14}
15
16pub mod constants;
17pub mod decoder;
18#[cfg(feature = "dred")]
19pub mod dred;
21pub mod encoder;
22pub mod error;
23pub mod multistream;
24pub mod packet;
25pub mod projection;
26pub mod repacketizer;
27pub mod types;
28
29pub use constants::{MAX_FRAME_SAMPLES_48KHZ, MAX_PACKET_DURATION_MS, max_frame_samples_for};
30pub use decoder::Decoder;
31#[cfg(feature = "dred")]
32pub use dred::{DredDecoder, DredState};
33pub use encoder::Encoder;
34pub use error::{Error, Result};
35pub use multistream::{MSDecoder, MSEncoder, Mapping};
36pub use packet::{
37 packet_bandwidth, packet_channels, packet_has_lbrr, packet_nb_frames, packet_nb_samples,
38 packet_parse, packet_samples_per_frame, soft_clip,
39};
40pub use projection::{ProjectionDecoder, ProjectionEncoder};
41pub use repacketizer::Repacketizer;
42pub use types::{
43 Application, Bandwidth, Bitrate, Channels, Complexity, ExpertFrameDuration, FrameSize,
44 SampleRate, Signal,
45};
46
47#[doc(hidden)]
48pub use bindings::*;
49
50#[must_use]
52pub fn version() -> &'static str {
53 "1.5.2"
54}
55
56#[must_use]
58pub fn runtime_version() -> &'static str {
59 unsafe {
60 let ptr = crate::bindings::opus_get_version_string();
61 if ptr.is_null() {
62 return "";
63 }
64 std::ffi::CStr::from_ptr(ptr).to_str().unwrap_or("")
65 }
66}
67
68#[must_use]
70pub fn strerror(code: i32) -> &'static str {
71 unsafe {
72 let ptr = crate::bindings::opus_strerror(code);
73 if ptr.is_null() {
74 return "";
75 }
76 std::ffi::CStr::from_ptr(ptr).to_str().unwrap_or("")
77 }
78}