Files
jellytau/specs/playback-backend-unification.html
T

457 lines
34 KiB
HTML

<!DOCTYPE HTML>
<html lang="en" class="navy" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Playback Backend Unification - JellyTau Documentation</title>
<!-- Custom HTML head -->
<meta name="description" content="Requirements, traceability, and architecture for the JellyTau Jellyfin client.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "navy";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('navy')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">Introduction</a></li><li class="chapter-item expanded affix "><li class="part-title">Requirements & Traceability</li><li class="chapter-item expanded "><a href="../requirements.html"><strong aria-hidden="true">1.</strong> Requirements Specification</a></li><li class="chapter-item expanded "><a href="../traceability.html"><strong aria-hidden="true">2.</strong> Traceability Matrix</a></li><li class="chapter-item expanded "><a href="../traceability-ci.html"><strong aria-hidden="true">3.</strong> Traceability CI</a></li><li class="chapter-item expanded "><a href="../traces-quick-ref.html"><strong aria-hidden="true">4.</strong> Traces Quick Reference</a></li><li class="chapter-item expanded affix "><li class="part-title">Architecture</li><li class="chapter-item expanded "><a href="../architecture/index.html"><strong aria-hidden="true">5.</strong> Overview</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../architecture/01-rust-backend.html"><strong aria-hidden="true">5.1.</strong> Rust Backend</a></li><li class="chapter-item "><a href="../architecture/02-svelte-frontend.html"><strong aria-hidden="true">5.2.</strong> Svelte Frontend</a></li><li class="chapter-item "><a href="../architecture/03-data-flow.html"><strong aria-hidden="true">5.3.</strong> Data Flow</a></li><li class="chapter-item "><a href="../architecture/04-type-sync-and-threading.html"><strong aria-hidden="true">5.4.</strong> Type Sync & Threading</a></li><li class="chapter-item "><a href="../architecture/05-platform-backends.html"><strong aria-hidden="true">5.5.</strong> Platform Backends</a></li><li class="chapter-item "><a href="../architecture/06-downloads-and-offline.html"><strong aria-hidden="true">5.6.</strong> Downloads & Offline</a></li><li class="chapter-item "><a href="../architecture/07-connectivity.html"><strong aria-hidden="true">5.7.</strong> Connectivity</a></li><li class="chapter-item "><a href="../architecture/08-database-design.html"><strong aria-hidden="true">5.8.</strong> Database Design</a></li><li class="chapter-item "><a href="../architecture/09-security.html"><strong aria-hidden="true">5.9.</strong> Security</a></li></ol></li><li class="chapter-item expanded "><li class="part-title">UX</li><li class="chapter-item expanded "><a href="../ux-flows.html"><strong aria-hidden="true">6.</strong> UX Flows</a></li><li class="chapter-item expanded affix "><li class="part-title">Specs — Pending Work</li><li class="chapter-item expanded "><a href="../specs/index.html"><strong aria-hidden="true">7.</strong> Specs Index</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-TEMPLATE.html"><strong aria-hidden="true">8.</strong> Spec Template</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-REVIEW-CHECKLIST.html"><strong aria-hidden="true">9.</strong> Spec Review Checklist</a></li><li class="chapter-item expanded "><a href="../specs/playback-backend-unification.html" class="active"><strong aria-hidden="true">10.</strong> Playback Backend Unification</a></li><li class="chapter-item expanded "><a href="../specs/linux-native-video-spike.html"><strong aria-hidden="true">11.</strong> Linux Native Video Spike</a></li><li class="chapter-item expanded "><a href="../specs/backend-owned-stream-selection.html"><strong aria-hidden="true">12.</strong> Backend-Owned Stream Selection</a></li><li class="chapter-item expanded "><a href="../specs/player-facade-enforcement.html"><strong aria-hidden="true">13.</strong> Player Facade Enforcement</a></li><li class="chapter-item expanded "><a href="../specs/windows-native-audio-backend.html"><strong aria-hidden="true">14.</strong> Windows Native Audio Backend</a></li><li class="chapter-item expanded "><a href="../specs/libmpv2-migration.html"><strong aria-hidden="true">15.</strong> libmpv2 Migration</a></li><li class="chapter-item expanded "><a href="../specs/read-through-media-cache.html"><strong aria-hidden="true">16.</strong> Read-Through Media Cache</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search.html"><strong aria-hidden="true">17.</strong> Scoped Search</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary.html"><strong aria-hidden="true">18.</strong> Scoped Search Boundary</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary-implementation.html"><strong aria-hidden="true">19.</strong> Scoped Search Boundary — Implementation</a></li><li class="chapter-item expanded "><a href="../specs/frontend-domain-model.html"><strong aria-hidden="true">20.</strong> Frontend Domain Model</a></li><li class="chapter-item expanded "><a href="../specs/desktop-native-video.html"><strong aria-hidden="true">21.</strong> Desktop Native Video</a></li><li class="chapter-item expanded "><a href="../specs/build-provenance.html"><strong aria-hidden="true">22.</strong> Build Provenance</a></li><li class="chapter-item expanded affix "><li class="part-title">Build & Release</li><li class="chapter-item expanded "><a href="../build/build-release.html"><strong aria-hidden="true">23.</strong> Build & Release</a></li><li class="chapter-item expanded "><a href="../release-checklist.html"><strong aria-hidden="true">24.</strong> Release Checklist</a></li><li class="chapter-item expanded "><a href="../native-player-verification.html"><strong aria-hidden="true">25.</strong> Native Player Verification</a></li><li class="chapter-item expanded "><a href="../build/build-desktop-packages.html"><strong aria-hidden="true">26.</strong> Desktop Packaging</a></li><li class="chapter-item expanded "><a href="../build/build-windows.html"><strong aria-hidden="true">27.</strong> Windows Build</a></li><li class="chapter-item expanded "><a href="../defect-windows.html"><strong aria-hidden="true">28.</strong> Defect Windows</a></li><li class="chapter-item expanded "><a href="../build/docker.html"><strong aria-hidden="true">29.</strong> Docker</a></li><li class="chapter-item expanded "><a href="../build/build-builder-image.html"><strong aria-hidden="true">30.</strong> Builder Image</a></li><li class="chapter-item expanded affix "><li class="spacer"></li><li class="chapter-item expanded affix "><a href="../api-redirect.html">Rust API Reference (rustdoc)</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">JellyTau Documentation</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau/_edit/master/docs/../docs/specs/playback-backend-unification.md" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa fa-edit"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="spec-playback-backend-unification--findings-and-strategy"><a class="header" href="#spec-playback-backend-unification--findings-and-strategy">Spec: Playback backend unification — findings and strategy</a></h1>
<p><strong>Status:</strong> Accepted (analysis; no code changes)
<strong>Requirements:</strong> IR-004, UR-031, UR-032, UR-033 — revises the "Platform Playback Backend Parity" issue in requirements.md
<strong>UX spec:</strong> n/a
<strong>Supersedes / revises:</strong> informed the Android native-video and audio-parity
work (both since shipped — see
<a href="../architecture/05-platform-backends.html">05-platform-backends.md</a>) and
<a href="windows-native-audio-backend.html">windows-native-audio-backend.md</a>, still open</p>
<h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
<p>This spec records the outcome of an investigation into unifying JellyTau's
playback backends (Linux/MPV, Android/ExoPlayer, Windows/webview) onto a single
engine with hardware acceleration everywhere. <strong>The conclusion is that video
cannot be unified onto a native engine, and should not be attempted.</strong> Audio
<em>can</em> be, and that is where the remaining specs direct effort.</p>
<p>No code changes follow from this spec directly. It exists so the decision is
written down with its evidence, and so a future session does not re-run the same
investigation.</p>
<h2 id="motivation"><a class="header" href="#motivation">Motivation</a></h2>
<p>The requirements doc carries a "Platform Playback Backend Parity" issue noting
that audio settings work on Linux but not Android, and proposing eventual
convergence. The natural next question — "should we just run one engine
everywhere?" — needed answering before spending effort on per-backend patches.</p>
<p>The investigation also surfaced that several statements in requirements.md and in
code comments are factually wrong. Those corrections are part of the deliverable.</p>
<h2 id="findings"><a class="header" href="#findings">Findings</a></h2>
<h3 id="1-the-current-architecture-is-not-what-the-docs-describe"><a class="header" href="#1-the-current-architecture-is-not-what-the-docs-describe">1. The current architecture is not what the docs describe</a></h3>
<div class="table-wrapper"><table><thead><tr><th>Platform</th><th>Audio</th><th>Video</th></tr></thead><tbody>
<tr><td>Linux</td><td>MPV (native, <strong>audio-only</strong>)</td><td>webview <code>&lt;video&gt;</code> + hls.js</td></tr>
<tr><td>Android</td><td>ExoPlayer (native)</td><td><strong>webview <code>&lt;video&gt;</code> + hls.js</strong></td></tr>
<tr><td>Windows</td><td>webview <code>&lt;audio&gt;</code></td><td>webview <code>&lt;video&gt;</code> + hls.js</td></tr>
</tbody></table>
</div>
<p>Two surprises:</p>
<ul>
<li><strong>MPV never decodes video.</strong> <code>mpv_backend.rs</code> sets <code>video = no</code> and
<code>audio-display = no</code> at construction. Linux video has always been the webview.
Correspondingly, <code>player_play_item</code> deliberately does <em>not</em> load into MPV on
Linux (it calls <code>set_current_item</code>, which only updates the queue).</li>
<li><strong>Android video is also the webview.</strong> <code>createAdapter()</code> in
<code>src/lib/player/adapters/index.ts</code> hardcodes <code>const effectiveKind = "html5"</code>
and does <code>void backendKind</code>, discarding the <code>use_html5_element</code> signal that
<code>get_player_status</code> computes in Rust. <code>NativePlayerAdapter</code> is dead code, and
ExoPlayer's <code>SurfaceView</code> path in <code>JellyTauPlayer.kt</code> is unreachable.</li>
</ul>
<p>So video is <em>already</em> unified — on HTML5, everywhere, by accident of that
hardcode — and on the path without hardware decoding on Android.</p>
<h3 id="2-native-video-cannot-be-composited-with-a-tauri-webview"><a class="header" href="#2-native-video-cannot-be-composited-with-a-tauri-webview">2. Native video cannot be composited with a Tauri webview</a></h3>
<p>This is the load-bearing finding. It is <strong>not</strong> an mpv limitation; it defeats
every candidate engine identically:</p>
<ul>
<li><strong>mpv</strong>: <code>tauri-plugin-libmpv</code>'s own platform table reads Linux ⚠️
<em>"Experimental. Window embedding is not working."</em></li>
<li><strong>GStreamer</strong> (wry discussion #284, 2024): <em>"Gstreamer was rendering above the
surface and covering all html elements."</em></li>
<li><strong>libVLC</strong> (tauri discussion #6343, 2024): <em>"I had to render the webview in a
child window though because vlc kept rendering on top of it."</em></li>
</ul>
<p>Root cause, from Tauri maintainer amrbashir (tauri#9220, 2024-03-30):</p>
<blockquote>
<p>"we are limited to using Webkit2GTK on Linux and that requires a GTK window.
While possible to add a GTK widget as a child X11 window inside raw X11 window,
this is however a bit hacky and <strong>it is not possible on Wayland at all</strong>."</p>
</blockquote>
<p>WebKitGTK, WebView2, and Android WebView each draw into their own compositor
surface. A native video surface is either entirely above or entirely below the
webview; it cannot interleave with HTML. Every working example in the ecosystem
is the same hack — a separate child window position-synced to a
<code>getBoundingClientRect()</code> div — which breaks on resize, scroll, and any UI drawn
over the video. For JellyTau that means the controls, subtitle overlay, and
mini-player.</p>
<p>The most recent comment on tauri#6343 (2026-05-23) confirms it is still unsolved:</p>
<blockquote>
<p>"I'm faking it and the window is not truly embedded, basically when the parent
moves or resizes I reset the position and size of the libmpv window to align it
with an HTML div."</p>
</blockquote>
<p><strong>The principle to carry forward: audio can unify on a native engine; video
cannot, because video needs a surface and the webview owns the surface.</strong></p>
<blockquote>
<p><strong>Re-opened on Linux (2026-08-21).</strong> This finding's general form has since been
falsified on Android — native video now composites behind a transparent Tauri
WebView and ships on by default (see
<a href="../architecture/05-platform-backends.html#native-video-compositing-android">05-platform-backends.md</a>).
The evidence above is also entirely about <em>foreign-window embedding</em>; mpv's
render API, drawing into a GL context we own inside Tauri's own GTK tree, was
never tested. <a href="linux-native-video-spike.html">linux-native-video-spike.md</a> tests
that one claim on Linux. <strong>Findings 3-6 below are untouched by it</strong> - in
particular finding 3, which is an independent disqualifier a green spike would
not clear.</p>
</blockquote>
<h3 id="3-mpv-would-regress-streaming-quality"><a class="header" href="#3-mpv-would-regress-streaming-quality">3. mpv would regress streaming quality</a></h3>
<p>mpv has <strong>no adaptive bitrate</strong>. It delegates HLS to FFmpeg's demuxer, which
selects one variant at open time and never adapts; mpv#3548 (2016) requested ABR
and it never landed. <code>--hls-bitrate</code> is a static picker defaulting to <code>max</code>.</p>
<p>The webview path already has real ABR via hls.js. Moving video to mpv would be a
<strong>downgrade</strong> on every platform — no graceful degradation on weak networks, and
quality changes requiring teardown and reload.</p>
<blockquote>
<p><strong>Premise in doubt (2026-08-21).</strong> "The webview path already has real ABR"
was not verified against the URLs this app actually builds.
<code>get_video_stream_url</code> requests a <em>single</em> rendition (one <code>VideoBitrate</code>, one
<code>MaxHeight</code>), the frontend has <strong>no</strong> level-handling code (<code>hls.levels</code>,
<code>LEVEL_SWITCH</code>, <code>currentLevel</code> appear nowhere), and this repo implements a
quality switch by <em>re-opening the stream</em> — all of which point to a
single-variant playlist, i.e. no ABR to lose. The decisive test is counting
<code>#EXT-X-STREAM-INF</code> lines in a real <code>master.m3u8</code>; it needs a live server and
has not been run. See
<a href="linux-native-video-spike.html">linux-native-video-spike.md</a>.</p>
</blockquote>
<h3 id="4-crossfade-is-architecturally-blocked-on-mpv"><a class="header" href="#4-crossfade-is-architecturally-blocked-on-mpv">4. Crossfade is architecturally blocked on mpv</a></h3>
<p>mpv's audio chain is single-stream. FFmpeg's <code>acrossfade</code> is an <code>N→A</code> filter
requiring two input streams, so there is no second input to feed it. Real
crossfade needs <strong>two libmpv instances</strong> with manually ramped volumes. Upstream
maintainer response (mpv#4512, closed three minutes after opening):</p>
<blockquote>
<p>"No. I also find crossfading stupid and complex, so the likeliness of that
happening is low."</p>
</blockquote>
<p>GStreamer <em>could</em> do it via <code>audiomixer</code>. mpv cannot, at any reasonable cost.</p>
<h3 id="5-engine-comparison-summary"><a class="header" href="#5-engine-comparison-summary">5. Engine comparison summary</a></h3>
<div class="table-wrapper"><table><thead><tr><th>Criterion</th><th>mpv</th><th>GStreamer</th><th>libVLC</th></tr></thead><tbody>
<tr><td>Webview compositing</td><td>❌ Linux broken</td><td>❌ same wall</td><td>❌ same wall</td></tr>
<tr><td>Adaptive bitrate HLS</td><td>❌ none</td><td>✅ adaptivedemux2</td><td>✅ adaptive module</td></tr>
<tr><td>Rust bindings</td><td>⚠️ <code>libmpv2</code> active; our pin is dead</td><td><code>gstreamer-rs</code> excellent</td><td><code>vlc-rs</code> abandoned (2018)</td></tr>
<tr><td>Windows cross-MSVC</td><td>⚠️ prebuilt DLL</td><td>❌ pkg-config vs cargo-xwin</td><td>❌ no better</td></tr>
<tr><td>Android packaging</td><td>✅ Maven AAR (used by Findroid)</td><td>⚠️ Cerbero/NDK, painful</td><td>✅ mature AAR</td></tr>
<tr><td>ASS/SSA subtitles</td><td>✅ libass built in</td><td>✅ libass</td><td>✅ libass</td></tr>
<tr><td>Crossfade</td><td>❌ impossible</td><td><code>audiomixer</code></td><td>⚠️ unclear</td></tr>
</tbody></table>
</div>
<p>Every candidate fails the first row, which is the disqualifying one.</p>
<h3 id="6-two-further-options-ruled-out"><a class="header" href="#6-two-further-options-ruled-out">6. Two further options ruled out</a></h3>
<p><strong>Webview <code>&lt;audio&gt;</code>/<code>&lt;video&gt;</code> everywhere</strong> (i.e. delete the native audio backends
too) is dead on Android: <code>navigator.mediaSession</code> is <em>deliberately compiled out</em>
of Android WebView (Chromium CL 2613133003), so lockscreen/media-notification
control would be impossible. Chromium has also never shipped <code>audioTracks</code>. It
remains fine for Windows <em>video</em>, which is what we already do.</p>
<p><strong>FFmpeg-direct / Rust-native</strong> (<code>ffmpeg-next</code>, <code>rsmpeg</code>, Symphonia) is not
close: the safe bindings do not expose hardware decode at all, <code>ffmpeg-next</code> is
self-declared maintenance-only, and Symphonia lacks HE-AAC and gapless AAC. This
is a multi-person-year path to reach parity with what we already have.</p>
<h3 id="7-if-libmpv-is-ever-revisited-on-android"><a class="header" href="#7-if-libmpv-is-ever-revisited-on-android">7. If libmpv is ever revisited on Android</a></h3>
<p>Recorded so the next investigation starts from evidence rather than repeating the
search. The <code>dev.jdtech.mpv:libmpv</code> AAR — maintained by Findroid's author, i.e.
another Jellyfin Android client — was inspected directly:</p>
<ul>
<li><code>libmpv.so</code> exports the full 54-function <code>mpv_*</code> C API with <strong>zero <code>Java_</code>
symbols</strong>; JNI is a separate optional ~19 KB <code>libplayer.so</code>. So it is drivable
from Rust without a Java shim. (This is precisely what disqualifies libVLC,
whose Android video path hard-requires a Java <code>AWindow</code> jobject.)</li>
<li>~23 MB/ABI, versus libVLC's ~46 MB/ABI.</li>
<li>🔴 <strong>The published AAR is built <code>--enable-gpl --enable-version3</code> — it is
GPLv3</strong>, not LGPL. Fine for us (see <a href="libmpv2-migration.html">libmpv2-migration.md</a>),
but it would be a hard constraint for anyone shipping closed source, and an
LGPL rebuild would be your own build to own.</li>
<li>Top unverified risk if anyone tries this: whether <code>libmpv2-sys</code> can
cross-compile for <code>aarch64-linux-android</code> against that prebuilt <code>.so</code>. No
working example of <code>libmpv2</code> on Android was found.</li>
</ul>
<p>None of this changes the verdict — the cost is the MediaSession/foreground-service
rewrite, not the bindings.</p>
<h2 id="decision"><a class="header" href="#decision">Decision</a></h2>
<ol>
<li><strong>Do not unify video onto a native engine.</strong> Video stays in the webview with
hls.js on all platforms. This is not a compromise — it is the configuration
that falls out of the compositing constraint, and it is the only one that
gives us ABR for free.</li>
<li><strong>Android native video is worth a bounded spike anyway</strong> — not for
unification, but because ExoPlayer's <code>SurfaceView</code> path already exists and
would restore hardware decode plus ASS/SSA subtitles. See
<a href="../architecture/05-platform-backends.html#native-video-compositing-android">05-platform-backends.md</a>.</li>
<li><strong>Audio parity is the real gap</strong> and is achievable without touching any of the
above. See <a href="../architecture/05-platform-backends.html">05-platform-backends.md</a>
and <a href="windows-native-audio-backend.html">windows-native-audio-backend.md</a>.</li>
<li><strong>Migrate the dead libmpv pin</strong> regardless of any of this. See
<a href="libmpv2-migration.html">libmpv2-migration.md</a>.</li>
</ol>
<h2 id="corrections-to-existing-docs"><a class="header" href="#corrections-to-existing-docs">Corrections to existing docs</a></h2>
<p>These are factual errors found during the investigation. Fixing them is in scope
for this spec.</p>
<div class="table-wrapper"><table><thead><tr><th>Location</th><th>Says</th><th>Actually</th></tr></thead><tbody>
<tr><td><code>requirements.md</code> UR-031 (line ~44)</td><td>"Done (Linux only)"</td><td>Not implemented on any platform.</td></tr>
<tr><td><code>requirements.md</code> DR-034 (line ~196)</td><td>"Done (Linux only)"</td><td>Not implemented anywhere — <code>mpv_backend.rs</code> has a bare <code>// TODO: Implement crossfade via MPV audio filters if needed</code>. Architecturally blocked on mpv (finding 4).</td></tr>
<tr><td><code>requirements.md</code> parity matrix</td><td>Crossfade ✅ Linux / ❌ Android</td><td>❌ / ❌</td></tr>
<tr><td><code>requirements.md</code> parity matrix</td><td>(no EQ row)</td><td>EQ is also Linux-only — <code>build_af_filter</code>/<code>eq_filter_entries</code> exist only in <code>mpv_backend.rs</code>. Same root cause, same fix.</td></tr>
<tr><td><code>nativeAdapter.ts:11-14</code></td><td>Native Android video "blocked upstream by tauri#10152"</td><td>tauri#10152 is a stale <em>feature request</em>, dead since 2024-07-01. The capability shipped in tauri commit <code>27d01834</code> (2024-09-02). Not a blocker.</td></tr>
</tbody></table>
</div>
<h2 id="layer-assignment"><a class="header" href="#layer-assignment">Layer assignment</a></h2>
<p>No new logic. The one boundary observation worth recording:</p>
<div class="table-wrapper"><table><thead><tr><th>Logic / responsibility</th><th>Layer</th><th>Why it belongs there</th></tr></thead><tbody>
<tr><td>Which video backend a platform uses (<code>use_html5_element</code>)</td><td>Rust</td><td>Already correctly computed in <code>get_player_status</code>. The frontend currently <em>discards</em> it — that is the bug, not the design. Restoring it means the frontend consumes a backend decision rather than making its own.</td></tr>
</tbody></table>
</div>
<h2 id="out-of-scope"><a class="header" href="#out-of-scope">Out of scope</a></h2>
<ul>
<li>Any code change. This spec is analysis; the sibling specs carry the work.</li>
<li>iOS/macOS. Not current targets.</li>
<li>Replacing hls.js.</li>
</ul>
<h2 id="acceptance-criteria"><a class="header" href="#acceptance-criteria">Acceptance criteria</a></h2>
<ul>
<li><input disabled="" type="checkbox"/>
<code>requirements.md</code> DR-034 status corrected; parity matrix updated (crossfade ❌/❌, EQ row added).</li>
<li><input disabled="" type="checkbox"/>
Stale tauri#10152 comment in <code>nativeAdapter.ts</code> corrected.</li>
<li><input disabled="" type="checkbox"/>
The four sibling specs exist and are linked from here.</li>
</ul>
<h2 id="testing"><a class="header" href="#testing">Testing</a></h2>
<p>n/a — documentation only.</p>
<h2 id="traces"><a class="header" href="#traces">TRACES</a></h2>
<p>No new code. Requirement text changes only; DR-034's status line is the one
substantive edit.</p>
<h2 id="notes-for-the-implementer"><a class="header" href="#notes-for-the-implementer">Notes for the implementer</a></h2>
<ul>
<li>The evidence above was gathered in July 2026. The compositing constraint has
been stable since 2021 (wry#284) and is maintainer-declared unfixable, so it is
unlikely to change soon — but if someone revisits this, tauri#6343 and wry#284
are the threads to re-read first.</li>
<li>A parallel Claude session may be active in this repo — <code>git diff</code> before
"repairing" unexpected changes.</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../specs/SPEC-REVIEW-CHECKLIST.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../specs/linux-native-video-spike.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="../specs/SPEC-REVIEW-CHECKLIST.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../specs/linux-native-video-spike.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
</div>
</body>
</html>