Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 9.5 KB

ARCHITECTURE.md

File metadata and controls

44 lines (28 loc) · 9.5 KB

Current source status (2026-11-29): brrPlayer remains offline-only and uses one read-only persisted SAF tree, local Room/Compose catalogue, Media3 with a pinned local NextLib fallback, independent captions/checkpoints, bounded artwork and the brrMusic-derived Glass dock. CI #354 passed 47/47 Android tests, R8 launch, all 71 Python contracts, JVM/build, NextLib offline policy, benchmark ABI/16 KiB alignment, native license/privacy and Room v1–v6 checks. Signed Release v0.1.354, versionCode 354, preserves the permanent certificate. No CPH2531 appearance, codec coverage, timing, thermal/battery or phase acceptance is inferred.

Boundaries

  • Package: com.mangoloads.player; app name: brrPlayer. The legacy com.batmancpu.player app is separate and cannot transfer its app data or SAF grant.
  • One user-selected local tree, persisted with read-only permission. Reject unsupported/nonlocal providers and keep scans, local artwork, playback and subtitle reads inside the selected tree.
  • Never enumerate arbitrary shared storage, write/rename/delete selected media, upload media, or run a Player server.
  • Keep allowBackup=false. The merged release manifest must not request INTERNET or broad media/all-files access. No analytics, telemetry, advertising, crash uploads or cloud data.
  • User-facing titles, parsed years/episodes and associated images are derived locally. No title, file path, subtitle or media content is sent anywhere.

Components and data flow

  1. FolderAccessManager stores and revalidates the selected tree and read grant. Folder changes retire the former indexed tree; clearing the library clears Player-owned index and resume data, not original files.
  2. SafLocalMediaSource walks child document IDs with bounded cursor reads and cancellation, and exposes local video/subtitle document references. It never opens video bytes during scanning.
  3. MediaNameParser and LocalCatalogue produce deterministic movie/year/episode groupings from supported filename patterns; ambiguous names remain local and conservative.
  4. OfflineLibraryIndex reconciles a complete scan transactionally in Room. A failed or cancelled scan cannot delete prior indexed rows. Only indexed_media is a current Room entity. ResumePositions stores selected-tree-scoped checkpoints in app-private preferences and the Home shelf reads only currently indexed video IDs.
  5. LocalArtworkResolver checks bounded image names among safe descendants associated with each title's selected-tree parent. Matching sidecar images take precedence. If absent, LocalVideoArtworkCache lazily extracts one scaled frame through a read-only SAF descriptor and stores only an opaque, size/count-bounded JPEG in app-private cache. Cache entries are scoped to the hashed tree/document revision and purged on folder switch/Forget. Coil decodes both local content URIs and private file:// thumbnails; no network module or image transport is packaged. Artwork failure retains the designed placeholder.
  6. LibraryViewModel validates the selected grant and indexed document identity before opening playback. LocalPlaybackEngine creates one ContentDataSource.Factory and passes it to video and subtitle sources. It routes only legacy AVI/DIVX/ASF/WMV/FLV MIME types into pinned NextLib's offline FfmpegMediaSourceFactory; standard containers retain Media3 extraction. Both factories read only content:// descendants through that same factory. The pinned NextLib NextRenderersFactory and attached DecoderManager keep platform MediaCodec first with FFmpeg/dav1d as a software fallback. Gradle builds a generated copy of the pinned module with a narrow, exact downstream renderer mapping from video/mp4v-es to the already enabled FFmpeg mpeg4 decoder; the submodule source remains pristine. Its explicit local decoder set also includes MPEG-1/2, MSMPEG-4, VC-1/WMV, MJPEG, H.263/FLV, Cinepak and DV alongside common modern/audio codecs. Decoder-category retry is offered only for decoder/format errors. Detach the manager before player release. The generated source uses the root app/benchmark Android Gradle Plugin version; FFmpeg 9.0.3 disables network protocols and enables only file/pipe. brrPlayer supplies validated selected-tree content:// URIs through Media3 and has no Android Internet permission. Unsupported/expired access fails visibly. Playback checkpoints and local episode-neighbor selection stay on-device. Indexed video/sidecar/neighbor selection is performed on Dispatchers.Default with cancellation checks every 256 entries; the view model enters its coroutine before walking a potentially large library and cancels that walk when a newer playback request or close arrives. CI #335 verified a synthetic Xvid AVI first frame and selected local SRT cue. Actual OEM codec support and native CPU/thermal cost remain unverified.
  7. Embedded audio/subtitle tracks are exposed in a Compose sheet. Sidecar subtitle documents are paired only within the same selected parent. Media3 continues parsing ordinary text formats such as SRT/WebVTT; NextLib's extractor/renderer adds supported local ASS/SSA and embedded bitmap subtitle formats. Subtitle timing is applied in the renderer and stored as a bounded preference in 100 ms steps so it covers text and bitmap cues without reloading the movie. The custom PlayerView layout keeps SubtitleView outside the video resize/zoom frame; native ASS/bitmap cues retain authored positioning and appearance, while ordinary text captions expose size and position controls. Tests for local ASS bitmap output, delay, independent overlay placement, H.264 FFmpeg playback and FFmpeg→AUTO surface reuse are added locally; their Kotlin/Android results remain pending CI. Existing SRT and caption UI coverage is in earlier green CI; physical-device format behavior remains unmeasured.
  8. The functional Glass layer is limited to navigation and selected controls. The pinned, licensed brrMusic-derived renderer provides bounded backdrop composition and collapsing dock motion. Solid/reduced-motion fallbacks remain available. Glass does not cover posters or the video.

Room migration contract

  • v1 is the original indexed_media table. v2/v3 historically added provider matches and cached provider metadata; v4 added the opaque parentDocumentId needed for safe sibling subtitle/artwork lookup. The v1–v4 schema JSON snapshots are immutable migration history.
  • Room v5 retains the v4 indexed_media columns exactly and removes manual_tmdb_matches plus cached_tmdb_metadata using an explicit 4→5 migration. v1→v5 and v4→v5 instrumentation must prove indexed files survive and provider tables disappear. Resume checkpoints live outside Room and must remain unaffected.
  • A one-time startup cleanup removes only the old app-private metadata-settings.bin and AtomicFile sidecars, tmdb-artwork/ cache and the exact AndroidKeyStore alias used by the discontinued provider code. The cleanup uses a private completion marker, retries after failures, and never visits the SAF tree or other app-private paths. The cleanup implementation and synthetic tests are committed in bd6b193; CI #293 passed both migration paths and private-data cleanup instrumentation after the test helper correction in 7f9f00d. The checked-in v5 JSON is the exact KSP output from that run, not hand-authored.

Privacy, build and evidence

Static Python checks, merged-manifest instrumentation and release APK verification reject Internet permission. Startup provider cleanup is asynchronous on Dispatchers.IO so launch rendering does not wait on disk/key-store work. The selected folder is read-only; the build cannot request network access for titles or images.

The isolated :macrobenchmark module compiles release-like, non-debuggable target and test APKs. <profileable> and ProfileInstaller apply only to the benchmark variant. CI assembles them but does not run emulator timing; see docs/MACROBENCHMARK_GUIDE.md for physical-device use.

GitHub CI runs JVM unit tests, debug assembly, Android 15 instrumentation and Room schema validation. These verify code and synthetic fixtures only. No claim about OPPO Reno10 appearance, codec breadth, smoothness, battery, thermal behavior or phase acceptance is made without real device evidence. Performance targets and profiling criteria are specified in DESIGN_SYSTEM_AND_PERFORMANCE.md; product acceptance gates are in ROADMAP.md and PHASE1_PHONE_TEST.md.

Playback selection cancellation follow-up (2026-11-29)

The ViewModel retains the current background selection Job. Opening another title cancels the previous selection before assigning its generation; closing playback increments the generation, cancels and clears the job. Folder updates and Forget already close playback, so selection cannot continue consuming worker time for a retired tree. The old job's finally clears the reference only if its generation remains current, preserving a newer job. CI is required to confirm Kotlin compilation and both assertion paths. The hide-title test now chooses a non-clipped Movies-grid result and waits for the details-only Play control before scrolling; the production UI is unchanged by that navigation fix. No selected-folder I/O policy changes.

Room schema snapshot review

The CI schema verifier now prints the exact generated Room v6 JSON between delimiters after its v1–v6 structural checks. This provides a reviewable source for the schema file without editing generated output by hand. Check in only the output from a fully passing secondary verification job; keep Room history test coverage exact through v6.