1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2023 d-k-bo
// SPDX-License-Identifier: BSD-3-Clause
//! High-level bindings for
//! [libopusenc](https://opus-codec.org/docs/libopusenc_api-0.2/index.html).
//!
//! # Example
//!
//! ```
//! # use std::io::Read;
//! # use opusenc::{Comments, Encoder, MappingFamily, RecommendedTag};
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let audio_data: Vec<i16> = {
//! let mut file = std::fs::File::open("/dev/urandom")?;
//! let mut buf = vec![0; 60 * 48_000 * 2 * 2];
//! file.read_exact(&mut buf)?;
//! buf.chunks_exact(2)
//! .map(|a| i16::from_ne_bytes([a[0], a[1]]))
//! .collect()
//! };
//!
//! let mut encoder = Encoder::create_file(
//! "/tmp/noise.opus",
//! Comments::create()
//! .add(RecommendedTag::Title, "Random Noise")?
//! .add(RecommendedTag::Artist, "/dev/urandom")?,
//! 48_000,
//! 2,
//! MappingFamily::MonoStereo,
//! )?;
//!
//! encoder.write(&audio_data)?;
//! encoder.drain()?;
//!
//! # Ok(())
//! # }
//! ```
//!
//! # Encoder options
//!
//! This crate provides a `encoder-options` feature which enables reading and changing encoder options.
//!
//! **Warning:** Some of these options might not work with opusenc, may be unsafe or even cause UB.
//! They are intended to be used via C macros that don't work with Rust.
//! Make sure to check if the methods you use match their intended behaviour.
use CStr;
pub use crate::;
pub use opusenc_sys as ffi;
/// Returns a string representing the version of libopusenc being used at run time.
/// ABI version for libopusenc's header.
/// Can be used to check for features at run time.