From 73e3bf709d7c054df7bd75cfafceda0721c6cda1 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Sun, 13 Sep 2026 06:43:29 +0800 Subject: [PATCH] [perf] exclude optional libaom from default builds --- apps/ios/README.md | 7 ++++++- apps/ios/scripts/build_minirtc_ios.sh | 15 ++++++++++++--- apps/ios/tests/build_minirtc_ios_test.py | 17 +++++++++++++++++ deps/submodules/minirtc | 2 +- docs/BUILD.md | 1 + 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/apps/ios/README.md b/apps/ios/README.md index 11f46866..9c508d4e 100644 --- a/apps/ios/README.md +++ b/apps/ios/README.md @@ -56,12 +56,17 @@ the desktop-compatible `DisplayN`, `control_audio`, `mouse`, `keyboard`, ## Video codecs -Every iOS build includes VideoToolbox, OpenH264, dav1d, libaom, and SVT-AV1. H.264 uses +Every iOS build includes VideoToolbox, OpenH264, dav1d, and SVT-AV1. H.264 uses VideoToolbox by default; choose software processing under **设置 → 视频编解码 → 处理方式** (Settings → Video codec → Processing mode) to use OpenH264 for H.264. The change takes effect on the next connection. AV1 encoding uses SVT-AV1 and AV1 decoding uses dav1d; VideoToolbox AV1 hardware decoding is currently unsupported. +The unused libaom backends are excluded by default. To include them for development, +set the `MINIRTC_ENABLE_AOM` environment variable (or Xcode user-defined build setting) +to `true`. This includes libaom in the merged native archive without changing the +AV1 factories' choice of SVT-AV1 and dav1d. + ## Physical-device test checklist Run the app from Xcode on a physical device and connect to a current desktop diff --git a/apps/ios/scripts/build_minirtc_ios.sh b/apps/ios/scripts/build_minirtc_ios.sh index 4ec18f43..fcef5d56 100755 --- a/apps/ios/scripts/build_minirtc_ios.sh +++ b/apps/ios/scripts/build_minirtc_ios.sh @@ -8,6 +8,11 @@ REPO_DIR="${IOS_DIR:h:h}" MINIRTC_DIR="${REPO_DIR}/deps/submodules/minirtc" CONFIG_NAME="${CONFIGURATION:-Debug}" MODE="${CONFIG_NAME:l}" +MINIRTC_ENABLE_AOM="${MINIRTC_ENABLE_AOM:-false}" +if [[ "${MINIRTC_ENABLE_AOM}" != "true" && "${MINIRTC_ENABLE_AOM}" != "false" ]]; then + print -u2 "MINIRTC_ENABLE_AOM must be true or false." + exit 64 +fi # Keep iOS dependencies isolated from desktop Xmake packages. Besides avoiding # cross-project cache collisions, this guarantees every archive is compiled @@ -85,7 +90,7 @@ fi # Still configure on every invocation: Xmake must see manifest edits and restore # the iOS configuration if MiniRTC was built standalone for another platform. CONFIG_SIGNATURE="$(print -r -- "${XMAKE_BIN}" "${XMAKE_DEVELOPER_DIR}" \ - "${MODE}" "${ARCH_NAME}" "16.0" "${XMAKE_PKG_INSTALLDIR}" + "${MODE}" "${ARCH_NAME}" "16.0" "${XMAKE_PKG_INSTALLDIR}" "${MINIRTC_ENABLE_AOM}" run_xmake --version | sed -n '1p' DEVELOPER_DIR="${XMAKE_DEVELOPER_DIR}" xcodebuild -version DEVELOPER_DIR="${XMAKE_DEVELOPER_DIR}" xcrun --sdk iphoneos --show-sdk-path @@ -112,7 +117,8 @@ configure_xmake() { ( cd "${MINIRTC_DIR}" configure_xmake "${MINIRTC_DIR}" "${MINIRTC_BUILD_DIR}" \ - --as="${XMAKE_TOOLCHAIN_BIN}/clang" --USE_CUDA=false + --as="${XMAKE_TOOLCHAIN_BIN}/clang" --USE_CUDA=false \ + --MINIRTC_ENABLE_AOM="${MINIRTC_ENABLE_AOM}" run_xmake b -P "${MINIRTC_DIR}" minirtc ) @@ -146,8 +152,11 @@ REQUIRED_LINKS=( nice glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0 gthread-2.0 intl gupnp-igd-1.6 gupnp-1.6 gssdp-1.6 soup-3.0 nghttp2 sqlite3 psl xml2 ffi pcre2-8 pcre2-posix z ssl crypto srtp2 openfec opus yuv kcp - datachannel usrsctp openh264 dav1d aom SvtAv1Enc + datachannel usrsctp openh264 dav1d SvtAv1Enc ) +if [[ "${MINIRTC_ENABLE_AOM}" == "true" ]]; then + REQUIRED_LINKS+=(aom) +fi DEPENDENCY_ARCHIVES=() for link_name in "${REQUIRED_LINKS[@]}"; do diff --git a/apps/ios/tests/build_minirtc_ios_test.py b/apps/ios/tests/build_minirtc_ios_test.py index f1aaf18c..5a1f047d 100644 --- a/apps/ios/tests/build_minirtc_ios_test.py +++ b/apps/ios/tests/build_minirtc_ios_test.py @@ -67,6 +67,7 @@ elif args[0] == "show": ''') self.env = dict(os.environ, PATH=f"{self.bin}:{os.environ['PATH']}", XMAKE_BIN=str(self.bin / "xmake"), CONFIGURATION="Release", + MINIRTC_ENABLE_AOM="false", CURRENT_ARCH="arm64", DEVELOPER_DIR=subprocess.check_output( ["xcode-select", "-p"], text=True).strip()) self.output = self.ios / "Vendor/iphoneos/Release/libCrossDeskMiniRTC.a" @@ -132,6 +133,22 @@ elif args[0] == "show": self.run_build() self.assertTrue(all("-c" in args for args in self.config_calls())) + def test_aom_is_only_required_and_merged_when_enabled(self): + self.run_build() + manifest = Path(str(self.output) + ".inputs.sha256") + self.assertNotIn("libaom.a", manifest.read_text()) + original = self.output.read_bytes() + self.env["MINIRTC_ENABLE_AOM"] = "true" + result = self.run_build(success=False) + self.assertIn("Unable to resolve static dependency libaom.a", result.stderr) + self.assertEqual(self.output.read_bytes(), original) + shutil.copy2(self.archive, self.library_dir / "libaom.a") + self.run_build() + self.assertIn("libaom.a", manifest.read_text()) + self.env["MINIRTC_ENABLE_AOM"] = "false" + self.run_build() + self.assertNotIn("libaom.a", manifest.read_text()) + if __name__ == "__main__": unittest.main() diff --git a/deps/submodules/minirtc b/deps/submodules/minirtc index 32b689b1..f169a696 160000 --- a/deps/submodules/minirtc +++ b/deps/submodules/minirtc @@ -1 +1 @@ -Subproject commit 32b689b1709e61bf8f4f6211433476a11562e9f4 +Subproject commit f169a696cb4e6cb59037ec02e85532e30d3c1262 diff --git a/docs/BUILD.md b/docs/BUILD.md index b5e346f0..843297c1 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -131,6 +131,7 @@ PipeWire 不属于强制运行时依赖:程序在运行时检测宿主系统 --USE_DRM=true/false: 在 Linux 上启用 DRM 捕获,默认不启用 --CROSSDESK_PORTABLE=true/false: 构建便携版本,默认不启用 --CROSSDESK_VERSION=xxx: 指定 CrossDesk 的版本 +--MINIRTC_ENABLE_AOM=true/false: 编译可选 libaom 后端,默认不启用;AV1 仍使用 SVT-AV1 / dav1d # 示例 xmake f --CROSSDESK_VERSION=1.4.3 --USE_CUDA=true