mirror of
https://github.com/rustdesk/magnum-opus.git
synced 2026-10-27 06:20:12 +00:00
Rename CodingMode to Application
Makes it more in line with the Opus terminology
This commit is contained in:
1 parent
4173ad0371
commit
0117ef5011
2 files changed
+7
-7
No files matched your search
+3
-3
@@ -32,9 +32,9 @@ const OPUS_GET_SAMPLE_RATE: c_int = 4029; // out *i32
|
|||||||
const OPUS_SET_BITRATE: c_int = 4002; // in i32
|
const OPUS_SET_BITRATE: c_int = 4002; // in i32
|
||||||
const OPUS_GET_BITRATE: c_int = 4003; // out *i32
|
const OPUS_GET_BITRATE: c_int = 4003; // out *i32
|
||||||
|
|
||||||
/// The possible coding modes for the codec.
|
/// The possible applications for the codec.
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||||
pub enum CodingMode {
|
pub enum Application {
|
||||||
/// Best for most VoIP/videoconference applications where listening quality and intelligibility matter most.
|
/// Best for most VoIP/videoconference applications where listening quality and intelligibility matter most.
|
||||||
Voip = 2048,
|
Voip = 2048,
|
||||||
/// Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input.
|
/// Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input.
|
||||||
@@ -121,7 +121,7 @@ pub struct Encoder {
|
|||||||
|
|
||||||
impl Encoder {
|
impl Encoder {
|
||||||
/// Create and initialize an encoder.
|
/// Create and initialize an encoder.
|
||||||
pub fn new(sample_rate: u32, channels: Channels, mode: CodingMode) -> Result<Encoder> {
|
pub fn new(sample_rate: u32, channels: Channels, mode: Application) -> Result<Encoder> {
|
||||||
let mut error = 0;
|
let mut error = 0;
|
||||||
let ptr = unsafe { ffi::opus_encoder_create(
|
let ptr = unsafe { ffi::opus_encoder_create(
|
||||||
sample_rate as i32,
|
sample_rate as i32,
|
||||||
|
|||||||
+4
-4
@@ -10,7 +10,7 @@ const MONO_20MS: usize = 48000 * 1 * 20 / 1000;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encode_mono() {
|
fn encode_mono() {
|
||||||
let mut encoder = opus::Encoder::new(48000, opus::Channels::Mono, opus::CodingMode::Audio).unwrap();
|
let mut encoder = opus::Encoder::new(48000, opus::Channels::Mono, opus::Application::Audio).unwrap();
|
||||||
|
|
||||||
let mut output = [0; 256];
|
let mut output = [0; 256];
|
||||||
let len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap();
|
let len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap();
|
||||||
@@ -31,7 +31,7 @@ fn encode_mono() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encode_stereo() {
|
fn encode_stereo() {
|
||||||
let mut encoder = opus::Encoder::new(48000, opus::Channels::Stereo, opus::CodingMode::Audio).unwrap();
|
let mut encoder = opus::Encoder::new(48000, opus::Channels::Stereo, opus::Application::Audio).unwrap();
|
||||||
|
|
||||||
let mut output = [0; 512];
|
let mut output = [0; 512];
|
||||||
let len = encoder.encode(&[0_i16; 2 * MONO_20MS], &mut output).unwrap();
|
let len = encoder.encode(&[0_i16; 2 * MONO_20MS], &mut output).unwrap();
|
||||||
@@ -56,7 +56,7 @@ fn encode_stereo() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encode_bad_rate() {
|
fn encode_bad_rate() {
|
||||||
match opus::Encoder::new(48001, opus::Channels::Mono, opus::CodingMode::Audio) {
|
match opus::Encoder::new(48001, opus::Channels::Mono, opus::Application::Audio) {
|
||||||
Ok(_) => panic!("Encoder::new did not return BadArg"),
|
Ok(_) => panic!("Encoder::new did not return BadArg"),
|
||||||
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),
|
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ fn encode_bad_rate() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encode_bad_buffer() {
|
fn encode_bad_buffer() {
|
||||||
let mut encoder = opus::Encoder::new(48000, opus::Channels::Stereo, opus::CodingMode::Audio).unwrap();
|
let mut encoder = opus::Encoder::new(48000, opus::Channels::Stereo, opus::Application::Audio).unwrap();
|
||||||
match encoder.encode(&[1_i16; 2 * MONO_20MS], &mut [0; 0]) {
|
match encoder.encode(&[1_i16; 2 * MONO_20MS], &mut [0; 0]) {
|
||||||
Ok(_) => panic!("encode with 0-length buffer did not return BadArg"),
|
Ok(_) => panic!("encode with 0-length buffer did not return BadArg"),
|
||||||
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),
|
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),
|
||||||
|
|||||||
Reference in new issue
Block a user