fix(wzp-video): gate shiguredo AV1 crates to macOS only; fix Linux relay build

- Cargo.toml: merge duplicate [target.macos.deps] sections; move
  shiguredo_dav1d/svt_av1/video_toolbox into single block
- lib.rs: dav1d + svt_av1 modules and re-exports guarded by
  cfg(target_os = "macos") instead of cfg(not(android))
- factory.rs: AV1 encoder/decoder paths split into macos (svt-av1/dav1d)
  and linux fallback (NotInitialized); update doc comments and tests
- build-linux-docker.sh: build only wzp-relay + wzp-web (drops
  wzp-client which pulled in shiguredo crates); fix Docker copy step;
  add --deploy flag + deploy_relay(); fix branch auto-detection
- build-tauri-android.sh: default to release build, arm64 only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-05-25 06:33:35 +04:00
parent 4ac62d99e0
commit 5d05b021aa
5 changed files with 39 additions and 41 deletions

View File

@@ -10,13 +10,12 @@ bytes = { workspace = true }
tracing = { workspace = true }
wzp-proto = { path = "../wzp-proto" }
# AV1 SW codecs do not support Android target (build.rs panics on
# aarch64-linux-android). Android uses MediaCodec for AV1 instead.
[target.'cfg(not(target_os = "android"))'.dependencies]
# AV1 SW codecs: shiguredo crates download prebuilt binaries at build time.
# Prebuilts are available for macOS only; Android uses MediaCodec; Linux will
# use system/vendored libs when that path is wired up (TODO).
[target.'cfg(target_os = "macos")'.dependencies]
shiguredo_dav1d = "2026.1.0"
shiguredo_svt_av1 = "2026.1.0"
[target.'cfg(target_os = "macos")'.dependencies]
shiguredo_video_toolbox = "2026.1"
[target.'cfg(target_os = "android")'.dependencies]

View File

@@ -11,7 +11,7 @@ use crate::encoder::{VideoEncoder, VideoError};
/// **Encoder dispatch:**
/// - `H264Baseline` → `VideoToolboxEncoder` (macOS) / `MediaCodecEncoder` (Android)
/// - `H265Main` → `VideoToolboxHevcEncoder` (macOS) / `MediaCodecHevcEncoder` (Android)
/// - `Av1Main` → `SvtAv1Encoder` (all platforms — universal SW fallback)
/// - `Av1Main` → `SvtAv1Encoder` (macOS only — SW fallback)
///
/// Non-video codecs return [`VideoError::InvalidInput`].
pub fn create_video_encoder(
@@ -78,10 +78,15 @@ pub fn create_video_encoder(
#[allow(clippy::needless_return)]
return Err(VideoError::NotInitialized);
}
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
{
Ok(Box::new(crate::svt_av1::SvtAv1Encoder::new(width, height)?))
}
#[cfg(not(any(target_os = "macos", target_os = "android")))]
{
let _ = (width, height);
Err(VideoError::NotInitialized)
}
}
_ => Err(VideoError::InvalidInput("not a video codec".into())),
}
@@ -92,7 +97,7 @@ pub fn create_video_encoder(
/// **Decoder dispatch:**
/// - `H264Baseline` → `VideoToolboxDecoder` (macOS) / `MediaCodecDecoder` (Android)
/// - `H265Main` → `VideoToolboxHevcDecoder` (macOS) / `MediaCodecHevcDecoder` (Android)
/// - `Av1Main` → `VideoToolboxAv1Decoder` (macOS M3+) → `Dav1dDecoder` (fallback, all platforms)
/// - `Av1Main` → `VideoToolboxAv1Decoder` (macOS M3+) → `Dav1dDecoder` (macOS SW fallback)
///
/// Non-video codecs return [`VideoError::InvalidInput`].
pub fn create_video_decoder(
@@ -154,10 +159,15 @@ pub fn create_video_decoder(
return crate::mediacodec::MediaCodecAv1Decoder::new(width, height)
.map(|d| Box::new(d) as Box<dyn VideoDecoder>);
}
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
{
Ok(Box::new(crate::dav1d::Dav1dDecoder::new()?))
}
#[cfg(not(any(target_os = "macos", target_os = "android")))]
{
let _ = (width, height);
Err(VideoError::NotInitialized)
}
}
_ => Err(VideoError::InvalidInput("not a video codec".into())),
}
@@ -170,30 +180,24 @@ mod tests {
#[test]
fn av1_encoder_factory_creates_svt_av1() {
let enc = create_video_encoder(CodecId::Av1Main, 640, 480, 2_000_000);
#[cfg(target_os = "android")]
#[cfg(target_os = "macos")]
assert!(enc.is_ok(), "AV1 encoder factory should succeed on macOS");
#[cfg(not(target_os = "macos"))]
assert!(
matches!(enc, Err(VideoError::NotInitialized)),
"AV1 SW encoder is unavailable on Android (no shiguredo_svt_av1)"
);
#[cfg(not(target_os = "android"))]
assert!(
enc.is_ok(),
"AV1 encoder factory should succeed on non-Android platforms"
"AV1 SW encoder is unavailable on Android/Linux (no shiguredo_svt_av1)"
);
}
#[test]
fn av1_decoder_factory_creates_decoder() {
let dec = create_video_decoder(CodecId::Av1Main, 640, 480);
#[cfg(target_os = "android")]
#[cfg(target_os = "macos")]
assert!(dec.is_ok(), "AV1 decoder factory should succeed on macOS (dav1d fallback)");
#[cfg(not(target_os = "macos"))]
assert!(
matches!(dec, Err(VideoError::NotInitialized)),
"AV1 decoder requires MediaCodec on Android; non-Android device returns NotInitialized"
);
#[cfg(not(target_os = "android"))]
assert!(
dec.is_ok(),
"AV1 decoder factory should succeed on non-Android (dav1d SW fallback)"
"AV1 decoder unavailable on Android/Linux (no shiguredo_dav1d)"
);
}

View File

@@ -6,7 +6,7 @@
pub mod av1_obu;
pub mod controller;
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
pub mod dav1d;
pub mod decoder;
pub mod depacketizer;
@@ -17,13 +17,13 @@ pub mod framer;
pub mod mediacodec;
pub mod nack;
pub mod simulcast;
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
pub mod svt_av1;
pub mod videotoolbox;
pub use av1_obu::{Av1Depacketizer, Av1ObuFramer, is_keyframe_obu};
pub use controller::{VideoQualityController, VideoTarget};
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
pub use dav1d::Dav1dDecoder;
pub use decoder::VideoDecoder;
pub use depacketizer::H264Depacketizer;
@@ -37,7 +37,7 @@ pub use mediacodec::{
};
pub use nack::{CachedPacket, NackAction, NackReceiver, NackSender};
pub use simulcast::{LayerPacket, LayerTarget, SimulcastEncoder, SimulcastLayer};
#[cfg(not(target_os = "android"))]
#[cfg(target_os = "macos")]
pub use svt_av1::SvtAv1Encoder;
pub use videotoolbox::{
VideoToolboxAv1Decoder, VideoToolboxDecoder, VideoToolboxEncoder, VideoToolboxHevcDecoder,