mirror of
https://github.com/rustdesk/magnum-opus.git
synced 2026-10-26 22:10:09 +00:00
Add bitrate getter and setter bindings
This commit is contained in:
1 file changed
+16
+16
@@ -25,6 +25,8 @@ use libc::c_int;
|
|||||||
|
|
||||||
// Generic CTLs
|
// Generic CTLs
|
||||||
const OPUS_RESET_STATE: c_int = 4028; // void
|
const OPUS_RESET_STATE: c_int = 4028; // void
|
||||||
|
const OPUS_SET_BITRATE: c_int = 4002; // void
|
||||||
|
const OPUS_GET_BITRATE: c_int = 4003; // *int
|
||||||
const OPUS_GET_FINAL_RANGE: c_int = 4031; // *uint
|
const OPUS_GET_FINAL_RANGE: c_int = 4031; // *uint
|
||||||
const OPUS_GET_BANDWIDTH: c_int = 4009; // *int
|
const OPUS_GET_BANDWIDTH: c_int = 4009; // *int
|
||||||
const OPUS_GET_SAMPLE_RATE: c_int = 4029; // *int
|
const OPUS_GET_SAMPLE_RATE: c_int = 4029; // *int
|
||||||
@@ -179,6 +181,20 @@ impl Encoder {
|
|||||||
Ok(value as u32)
|
Ok(value as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the encoder's bitrate.
|
||||||
|
pub fn set_bitrate(&mut self, value: i32) -> Result<()> {
|
||||||
|
let result = unsafe { ffi::opus_encoder_ctl(self.ptr, OPUS_SET_BITRATE, value) };
|
||||||
|
check("opus_encoder_ctl(OPUS_SET_BITRATE)", result)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the encoder's bitrate.
|
||||||
|
pub fn get_bitrate(&mut self) -> Result<i32> {
|
||||||
|
let mut value = 0;
|
||||||
|
let result = unsafe { ffi::opus_encoder_ctl(self.ptr, OPUS_GET_BITRATE, &mut value) };
|
||||||
|
try!(check("opus_encoder_ctl(OPUS_GET_BITRATE)", result));
|
||||||
|
Ok(value)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Encoder-specific CTLs
|
// TODO: Encoder-specific CTLs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user