feat(android): play the original file — decode Dolby/DTS audio with FFmpeg
Android ships no AC-3, E-AC-3, DTS or TrueHD decoders; they are licensed codecs, present only where a vendor paid for them. The ROD2-W09 tablet has a vendor DTS decoder and no AC-3/E-AC-3 at all. So every film with Dolby audio was re-encoded by the server, for streaming and for download alike, and a transcoded download has no Content-Length and ignores Range: ~1 MB/s, restarting from byte zero on every network blip. ExoPlayer now carries Jellyfin's media3 FFmpeg audio decoder in extension mode ON (platform decoders first, FFmpeg for what they lack), and CodecDetector reports its codecs so the device profile and the download policy agree with what actually decodes. The download policy judges audio against the renderer that will play the file (renderer_can_decode_audio) instead of the webview's list, so Android downloads are always the direct copy — a 910 MB E-AC-3 5.1 episode downloaded in 94 s and played offline. The webview video path is removed on Android: it decodes none of these codecs, so a stored "native video off" would play every original-file download silent. Rust reports webview_video_fallback (false on Android, true only beside mpv native video on Linux); Settings offers the switch and the player honours it only then. Linux keeps the fallback and, with it, the server transcode for undecodable audio. The decoder is GPL-3.0; the distributed APK carries its terms and the source stays MIT (THIRD_PARTY_NOTICES.md). The on-device remux spec this replaces is folded into 05-platform-backends.md and deleted. DR-293, UT-259, UT-262.
This commit is contained in:
@@ -2187,6 +2187,25 @@ pub struct PlaybackCapabilities {
|
||||
/// beneath the WebView. Linux cannot do this (WebKitGTK/Wayland
|
||||
/// compositing), so it stays on the HTML5 element.
|
||||
pub supports_native_video: bool,
|
||||
/// True when the user may send video to the webview element instead of the
|
||||
/// native renderer — the frontend offers the switch only then, and honours
|
||||
/// the stored preference only then. See [`webview_video_fallback`].
|
||||
pub webview_video_fallback: bool,
|
||||
}
|
||||
|
||||
/// Whether the user may send video to the webview `<video>` element instead of
|
||||
/// the native renderer.
|
||||
///
|
||||
/// Never on Android: ExoPlayer is its only video renderer. Downloads there are
|
||||
/// the untouched source file (DR-293), and the webview decodes none of the
|
||||
/// AC-3/E-AC-3/DTS/TrueHD that ExoPlayer plays through the FFmpeg extension, so
|
||||
/// the fallback would be a silent film. Beside mpv's native video on Linux the
|
||||
/// webview is still the tested fallback; everywhere else it is the only
|
||||
/// renderer and there is nothing to switch.
|
||||
///
|
||||
/// TRACES: UR-003, UR-071 | DR-293 | UT-259
|
||||
pub fn webview_video_fallback(is_android: bool, native_video_enabled: bool) -> bool {
|
||||
!is_android && native_video_enabled
|
||||
}
|
||||
|
||||
/// Report this platform's playback capabilities to the frontend.
|
||||
@@ -2203,6 +2222,11 @@ pub async fn player_get_capabilities() -> Result<PlaybackCapabilities, String> {
|
||||
// TRACES: UR-080 | DR-235
|
||||
supports_native_video: cfg!(target_os = "android")
|
||||
|| crate::player::native_video::enabled(),
|
||||
// TRACES: UR-003, UR-071 | DR-293
|
||||
webview_video_fallback: webview_video_fallback(
|
||||
cfg!(target_os = "android"),
|
||||
crate::player::native_video::enabled(),
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3058,6 +3082,37 @@ pub async fn player_disable_jellyfin(player: State<'_, PlayerStateWrapper>) -> R
|
||||
mod tests {
|
||||
use crate::utils::lock::MutexSafe;
|
||||
|
||||
/// Android has one video renderer, ExoPlayer. The webview element could only
|
||||
/// be reached by the user switching native video off, and a file downloaded
|
||||
/// as the untouched original — AC-3 audio included — plays silent there,
|
||||
/// so the switch is gone on Android (DR-293). Where mpv draws video on Linux
|
||||
/// the webview is still the tested fallback, so the switch stays there;
|
||||
/// everywhere else the webview is the only renderer and there is nothing to
|
||||
/// switch.
|
||||
///
|
||||
/// TRACES: UR-003, UR-071 | DR-293 | UT-259
|
||||
#[test]
|
||||
fn test_webview_video_fallback_is_offered_only_beside_mpv_native_video() {
|
||||
use super::webview_video_fallback;
|
||||
|
||||
assert!(
|
||||
!webview_video_fallback(true, false),
|
||||
"Android: ExoPlayer is the only video renderer"
|
||||
);
|
||||
assert!(
|
||||
!webview_video_fallback(true, true),
|
||||
"Android never falls back, whatever else is switched on"
|
||||
);
|
||||
assert!(
|
||||
webview_video_fallback(false, true),
|
||||
"Linux with mpv native video: the webview is the fallback"
|
||||
);
|
||||
assert!(
|
||||
!webview_video_fallback(false, false),
|
||||
"the webview is the only renderer; nothing to fall back from"
|
||||
);
|
||||
}
|
||||
|
||||
/// UT-206 — the volume the command hands on is always a real number in
|
||||
/// 0.0..=1.0.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user