From 786a4b8662ca6944561df78240147b52b6d74e47 Mon Sep 17 00:00:00 2001 From: Killswitch Date: Tue, 2 Mar 2021 11:06:32 +0100 Subject: [PATCH 1/4] Added support for DTX --- src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index a347bda..68ac6a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,10 @@ const OPUS_SET_INBAND_FEC: c_int = 4012; // in i32 const OPUS_GET_INBAND_FEC: c_int = 4013; // out *i32 const OPUS_SET_PACKET_LOSS_PERC: c_int = 4014; // in i32 const OPUS_GET_PACKET_LOSS_PERC: c_int = 4015; // out *i32 +const OPUS_SET_DTX_REQUEST: c_int = 4016; +const OPUS_GET_DTX_REQUEST: c_int = 4017; const OPUS_GET_LOOKAHEAD: c_int = 4027; // out *i32 +const OPUS_GET_IN_DTX_REQUEST: c_int = 4049; // Decoder CTLs const OPUS_SET_GAIN: c_int = 4034; // in i32 const OPUS_GET_GAIN: c_int = 4045; // out *i32 @@ -369,6 +372,20 @@ impl Encoder { Ok(value) } + /// Configures the encoder's use of discontinuous transmission (DTX). + pub fn set_dtx(&mut self, value: bool) -> Result<()> { + let value: i32 = if value { 1 } else { 0 }; + enc_ctl!(self, OPUS_SET_DTX_REQUEST, value); + Ok(()) + } + + /// Gets encoder's configured use of discontinuous transmission. + pub fn get_dtx(&mut self) -> Result { + let mut value: i32 = 0; + enc_ctl!(self, OPUS_GET_DTX_REQUEST, &mut value); + Ok(value != 0) + } + /// Gets the total samples of delay added by the entire codec. pub fn get_lookahead(&mut self) -> Result { let mut value: i32 = 0; @@ -376,6 +393,15 @@ impl Encoder { Ok(value) } + /// Gets the DTX state of the encoder. + /// Returns whether the last encoded frame was either a comfort noise update during DTX or not encoded because of DTX. + pub fn get_in_dtx(&mut self) -> Result { + let mut value: i32 = 0; + enc_ctl!(self, OPUS_GET_IN_DTX_REQUEST, &mut value); + Ok(value != 0) + } + + // TODO: Encoder-specific CTLs } From a620ea6e34dcbef54317636832a898ca96852f85 Mon Sep 17 00:00:00 2001 From: sergey duck Date: Tue, 2 Mar 2021 14:04:40 +0300 Subject: [PATCH 2/4] opusic-sys update --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index adbbc9f..e0909fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "magnum-opus" -version = "0.3.2" +version = "0.4.0" authors = ["Tad Hardesty ", "Sergey Duck "] edition = "2018" description = "Safe Rust bindings for libopus" @@ -14,5 +14,5 @@ repository = "https://github.com/DuckerMan/magnum-opus" documentation = "https://docs.rs/magnum-opus" [dependencies] -opusic-sys = "0.3" +opusic-sys = "0.3.4" libc = "0.2" From 301735e924aaeee4260c98d9c82a75be4cd6be44 Mon Sep 17 00:00:00 2001 From: sergey duck Date: Tue, 2 Mar 2021 14:06:39 +0300 Subject: [PATCH 3/4] 0.4.0 release --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e0909fc..159184f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ repository = "https://github.com/DuckerMan/magnum-opus" documentation = "https://docs.rs/magnum-opus" [dependencies] -opusic-sys = "0.3.4" +opusic-sys = "0.4.0" libc = "0.2" From 171e1d021004626f7444d1e39b98f50bc3cb2604 Mon Sep 17 00:00:00 2001 From: sergey duck Date: Tue, 2 Mar 2021 14:07:23 +0300 Subject: [PATCH 4/4] opusic-sys is updated to 0.3.4 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 159184f..e0909fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ repository = "https://github.com/DuckerMan/magnum-opus" documentation = "https://docs.rs/magnum-opus" [dependencies] -opusic-sys = "0.4.0" +opusic-sys = "0.3.4" libc = "0.2"