Skip to content

Commit 291ac3f

Browse files
committed
refactor: remove Opus feature dependencies and related code from various modules[latest]
1 parent 95153f2 commit 291ac3f

8 files changed

Lines changed: 5 additions & 50 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ exclude = [
3030
]
3131

3232
[features]
33-
opus = ["audio-codec/opus"]
33+
cross = []
3434
console = ["dep:minijinja"]
3535
addon-acme = ["instant-acme"]
3636
addon-wholesale = [
@@ -74,7 +74,6 @@ contact-center = [
7474
]
7575

7676
default = [
77-
"opus",
7877
"console",
7978
"addon-acme",
8079
"addon-transcript",
@@ -205,7 +204,6 @@ csv = "1.4.0"
205204
quick-xml = { version = "0.39.3", features = ["serialize"] }
206205
ruzstd = "0.8"
207206
minimp3 = "0.6.1"
208-
aws-lc-rs = { version = "1", optional = true }
209207
totp-rs = { version = "5.7.1", features = ["qr", "gen_secret"] }
210208
ldap3 = { version = "0.12.1", optional = true }
211209
ring = { version = "0.17", optional = true }
@@ -239,7 +237,6 @@ path = "src/bin/rustpbx.rs"
239237
[[bin]]
240238
name = "sipflow"
241239
path = "src/bin/sipflow.rs"
242-
required-features = ["opus"]
243240

244241
[[bin]]
245242
name = "verify-i18n"

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ ENV TZ=UTC
1313
RUN --mount=type=cache,target=/var/cache/apt \
1414
apt-get update && apt-get install -y --no-install-recommends \
1515
ca-certificates \
16-
tzdata \
17-
libopus0 \
18-
&& rm -rf /var/lib/apt/lists/*
16+
tzdata
1917

2018
# Create application directory structure
2119
WORKDIR /app

Dockerfile.cross-aarch64

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
11
FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main
22

3-
# Install clang, libclang (for bindgen), and dependencies
3+
# Install cross-compilation dependencies
44
RUN set -eux; \
55
apt_opts='-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30'; \
66
apt-get ${apt_opts} update; \
77
apt-get ${apt_opts} install -y \
8-
cmake \
98
pkg-config \
10-
clang \
11-
llvm \
12-
libclang-dev \
13-
crossbuild-essential-arm64 \
14-
libssl-dev; \
9+
crossbuild-essential-arm64; \
1510
rm -rf /var/lib/apt/lists/*
16-
17-
# Install cross-compiled libs for ARM64
18-
RUN set -eux; \
19-
dpkg --add-architecture arm64; \
20-
apt_opts='-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30'; \
21-
apt-get ${apt_opts} update; \
22-
apt-get ${apt_opts} install -y \
23-
libopus-dev:arm64 \
24-
libssl-dev:arm64 || true; \
25-
rm -rf /var/lib/apt/lists/*
26-
27-
# Bake all cross-compilation environment variables into the image
28-
ENV LIBCLANG_PATH=/usr/lib/llvm-10/lib
29-
ENV CC=clang
30-
ENV CXX=clang++
3111
ENV PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
3212
ENV PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu
3313
ENV PKG_CONFIG_ALLOW_CROSS=1

Dockerfile.cross-x86_64

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ RUN set -eux; \
44
apt_opts='-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30'; \
55
apt-get ${apt_opts} update; \
66
apt-get ${apt_opts} install -y \
7-
cmake \
8-
pkg-config \
9-
libopus-dev \
10-
libssl-dev; \
7+
pkg-config; \
118
rm -rf /var/lib/apt/lists/*

src/media/bridge.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,6 @@ mod tests {
40314031

40324032
/// Verify Opus → PCMU transcoding via Transcoder produces correct output.
40334033
#[tokio::test]
4034-
#[cfg(feature = "opus")]
40354034
async fn test_transcoder_opus_to_pcmu() {
40364035
use audio_codec::create_encoder;
40374036
// Generate 20ms of 48kHz mono PCM (960 samples)
@@ -4110,7 +4109,6 @@ mod tests {
41104109

41114110
/// Verify Opus → G.722 transcoding via Transcoder produces correct output.
41124111
#[tokio::test]
4113-
#[cfg(feature = "opus")]
41144112
async fn test_transcoder_opus_to_g722() {
41154113
use audio_codec::create_encoder;
41164114

@@ -4147,7 +4145,6 @@ mod tests {
41474145

41484146
/// Run full Opus→PCMU round-trip: encode PCM → Opus → transcode → PCMU → decode → verify PCM correlation.
41494147
#[tokio::test]
4150-
#[cfg(feature = "opus")]
41514148
async fn test_transcoder_opus_to_pcmu_roundtrip_quality() {
41524149
use audio_codec::{create_decoder, create_encoder};
41534150

src/media/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ impl RtpTrackBuilder {
487487
probation_max_packets: None,
488488
ice_servers: Vec::new(),
489489
rtp_map: vec![
490-
#[cfg(feature = "opus")]
491490
CodecType::Opus,
492491
CodecType::G729,
493492
CodecType::G722,

src/media/negotiate.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl CodecInfo {
3737
CodecType::PCMA => ("PCMA".to_string(), None),
3838
CodecType::G722 => ("G722".to_string(), None),
3939
CodecType::G729 => ("G729".to_string(), None),
40-
#[cfg(feature = "opus")]
4140
CodecType::Opus => (
4241
"opus".to_string(),
4342
Some("minptime=10;useinbandfec=1".to_string()),
@@ -174,20 +173,16 @@ impl MediaNegotiator {
174173
let static_codec = if let Ok(codec) = CodecType::try_from(pt) {
175174
let (rate, chans) = match codec {
176175
CodecType::PCMU | CodecType::PCMA | CodecType::G722 | CodecType::G729 => (8000, 1),
177-
#[cfg(feature = "opus")]
178176
CodecType::Opus => (48000, 2),
179177
_ => return None,
180178
};
181179
Some((codec, rate, chans))
182180
} else {
183-
#[cfg(feature = "opus")]
184181
if (pt == 96 || pt == 111) && section.kind == MediaKind::Audio {
185182
Some((CodecType::Opus, 48000, 2))
186183
} else {
187184
None
188185
}
189-
#[cfg(not(feature = "opus"))]
190-
None
191186
};
192187

193188
static_codec.map(|(codec, rate, chans)| CodecInfo {
@@ -339,7 +334,6 @@ impl MediaNegotiator {
339334
/// Build default codec list for RTP endpoints
340335
pub fn default_rtp_codecs() -> Vec<CodecType> {
341336
vec![
342-
#[cfg(feature = "opus")]
343337
CodecType::Opus,
344338
CodecType::G729,
345339
CodecType::G722,
@@ -352,7 +346,6 @@ impl MediaNegotiator {
352346
/// Build default codec list for WebRTC endpoints
353347
pub fn default_webrtc_codecs() -> Vec<CodecType> {
354348
vec![
355-
#[cfg(feature = "opus")]
356349
CodecType::Opus,
357350
CodecType::G722,
358351
CodecType::PCMU,
@@ -376,7 +369,6 @@ impl MediaNegotiator {
376369
CodecType::PCMA => "PCMA",
377370
CodecType::G722 => "G722",
378371
CodecType::G729 => "G729",
379-
#[cfg(feature = "opus")]
380372
CodecType::Opus => "opus",
381373
CodecType::TelephoneEvent => "telephone-event",
382374
};
@@ -472,7 +464,6 @@ impl MediaNegotiator {
472464
}),
473465
_ => {
474466
let preferred_rate = match audio.as_ref().map(|codec| codec.codec) {
475-
#[cfg(feature = "opus")]
476467
Some(CodecType::Opus) => 48000,
477468
_ => 8000,
478469
};
@@ -1528,7 +1519,6 @@ a=rtpmap:0 PCMU/8000\r\n";
15281519
assert_eq!(dtmf[0].clock_rate, 8000);
15291520
}
15301521

1531-
#[cfg(feature = "opus")]
15321522
#[test]
15331523
fn test_callee_offer_appends_dtmf_in_final_audio_clock_order() {
15341524
let caller_sdp = "v=0\r\n\
@@ -1555,7 +1545,6 @@ a=rtpmap:0 PCMU/8000\r\n";
15551545
assert_eq!(dtmf[1].clock_rate, 48000);
15561546
}
15571547

1558-
#[cfg(feature = "opus")]
15591548
#[test]
15601549
fn test_caller_answer_filters_dtmf_by_final_audio_clock_rate() {
15611550
let caller_sdp = "v=0\r\n\
@@ -2244,7 +2233,6 @@ a=rtpmap:8 PCMA/8000\r\n";
22442233
);
22452234
}
22462235

2247-
#[cfg(feature = "opus")]
22482236
#[test]
22492237
fn test_rewrite_sdp_codec_list_uses_dtmf_clock_rate() {
22502238
let caller_sdp = "v=0\r\n\

src/media/transcoder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ mod tests {
303303
assert!(!output.data.is_empty(), "G729 output must not be empty");
304304
}
305305

306-
#[cfg(feature = "opus")]
307306
#[test]
308307
fn test_transcoder_pcmu_to_opus() {
309308
let pcm = silence_pcm_8k();

0 commit comments

Comments
 (0)