Rename CodingMode to Application

Makes it more in line with the Opus terminology
This commit is contained in:
Jean-Marc Valin 2016-07-20 17:03:07 -04:00 committed by Tad Hardesty
parent 4173ad0371
commit 0117ef5011
No known key found for this signature in database
GPG Key ID: AEFCC915C75ACC47
2 changed files with 7 additions and 7 deletions

View File

@ -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_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)]
pub enum CodingMode {
pub enum Application {
/// Best for most VoIP/videoconference applications where listening quality and intelligibility matter most.
Voip = 2048,
/// 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 {
/// 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 ptr = unsafe { ffi::opus_encoder_create(
sample_rate as i32,

View File

@ -10,7 +10,7 @@ const MONO_20MS: usize = 48000 * 1 * 20 / 1000;
#[test]
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 len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap();
@ -31,7 +31,7 @@ fn encode_mono() {
#[test]
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 len = encoder.encode(&[0_i16; 2 * MONO_20MS], &mut output).unwrap();
@ -56,7 +56,7 @@ fn encode_stereo() {
#[test]
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"),
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),
}
@ -64,7 +64,7 @@ fn encode_bad_rate() {
#[test]
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]) {
Ok(_) => panic!("encode with 0-length buffer did not return BadArg"),
Err(err) => assert_eq!(err.code(), opus::ErrorCode::BadArg),