Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
cov/c3 ▾

Modern-Apps.git / cast / AGENTS.md

AGENTS.md5.0 KiBRenderedCodeRaw
1# AGENTS.md — cast/ (':cast')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `cast/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install cast (dev by default)._
6<!-- last-reviewed: 2026-10-16 -->
7- Gradle: :cast / dir: cast/
8- Package roots present: ui, domain, platform, network, service
9- Entry files: MainActivity.kt, Route.kt, Navigation.kt (CastApplication.kt was deleted by the shared-boilerplate migration — do NOT re-add)
10- Deps: :library:aosp-stubs, :cast:protocol, :sdk:cast
11- Metadata: metadata_data/cast.md (present)
12- Rust: no / screenshotTest: yes
13
14## Overview
15**Purpose:** Phone-side sender for offline screen mirroring + media handoff to the `cast/tv` receiver over your own Wi-Fi — E2EE session with pairing-code-bound handshake, no internet. Sibling `:cast:protocol` owns the wire; `:sdk:cast` is the third-party handoff API.
16**Key features:**
17- Mirroring pipeline: screen capture → video/audio encoders (`platform/mirror/`) → RTP sender → TV; codec negotiated from the receiver's capabilities so the phone sends full resolution
18- Content casting (`CastContentSession`, `MediaProxyServer`) so other apps hand media off through `:sdk:cast`
19- Discovery + pairing UI, Quick Settings tile start/stop, remote-display provider for system routing
20**Architecture / data-flow:** `ui/` picker/status → `platform/CastViewModel` (+ `CastUiContract`) + `platform/CastController` → `platform/MirrorClient`/`CastConnection` over `network/` UDP + control sockets, framed by `:cast:protocol` (`StreamingSession`, `Pairing`); `service/CastService` + `ContentCastService` own the session lifetime.
21**Entry points + reading order:** `Route` → `MainActivity.kt` → `Navigation.kt` → `platform/CastController.kt` → `platform/mirror/MirrorEngine.kt` → `network/ControlSocket.kt`.
22**Gotchas:**
23- Encoder support varies by device (`mirror/EncoderSupport`) — capability checks before assuming codecs
24- Screen-capture consent is one-shot per session (`MirrorConsentActivity`); losing it mid-mirror kills the stream
25- Keep `:cast:protocol` untouched from here — wire changes need sender + TV receiver updated together
26
27## Key files
28### Root — entry + navigation
29- com/vayunmathur/cast/MainActivity.kt
30- com/vayunmathur/cast/Navigation.kt
31- com/vayunmathur/cast/Route.kt
32### domain/ — device + client state
33- com/vayunmathur/cast/domain/CastDevice.kt
34- com/vayunmathur/cast/domain/ClientState.kt
35### network/ — transports
36- com/vayunmathur/cast/network/CastUdpTransport.kt
37- com/vayunmathur/cast/network/ControlSocket.kt
38### platform/ — controller, sessions, discovery, proxy
39- com/vayunmathur/cast/platform/CastViewModel.kt
40- com/vayunmathur/cast/platform/CastUiContract.kt
41- com/vayunmathur/cast/platform/CastController.kt
42- com/vayunmathur/cast/platform/CastConnection.kt
43- com/vayunmathur/cast/platform/CastSessionTypes.kt
44- com/vayunmathur/cast/platform/CastSessionWatch.kt
45- com/vayunmathur/cast/platform/CastCodecNegotiation.kt
46- com/vayunmathur/cast/platform/CastContentSession.kt
47- com/vayunmathur/cast/platform/CastMirrorSession.kt
48- com/vayunmathur/cast/platform/MirrorClient.kt
49- com/vayunmathur/cast/platform/MediaProxyServer.kt
50- com/vayunmathur/cast/platform/CastPickerActivity.kt
51- com/vayunmathur/cast/platform/CastPairActivity.kt
52- com/vayunmathur/cast/platform/CastDesktopDisplay.kt
53- com/vayunmathur/cast/platform/discovery/CastDiscoveryManager.kt
54### platform/mirror/ — capture + encoders + sender
55- com/vayunmathur/cast/platform/mirror/MirrorEngine.kt
56- com/vayunmathur/cast/platform/mirror/MirrorSource.kt
57- com/vayunmathur/cast/platform/mirror/ScreenCapture.kt
58- com/vayunmathur/cast/platform/mirror/VideoEncoder.kt
59- com/vayunmathur/cast/platform/mirror/AudioEncoder.kt
60- com/vayunmathur/cast/platform/mirror/PcmAudioEncoder.kt
61- com/vayunmathur/cast/platform/mirror/OpusEncoder.kt
62- com/vayunmathur/cast/platform/mirror/EncoderSupport.kt
63- com/vayunmathur/cast/platform/mirror/StreamSender.kt
64- com/vayunmathur/cast/platform/mirror/MirrorGeometry.kt
65- com/vayunmathur/cast/platform/mirror/MirrorPreferences.kt
66- com/vayunmathur/cast/platform/mirror/MirrorConsentActivity.kt
67- com/vayunmathur/cast/platform/mirror/MirrorTileService.kt
68### platform/remotedisplay/ — system display routing
69- com/vayunmathur/cast/platform/remotedisplay/MaRemoteDisplayProvider.kt
70- com/vayunmathur/cast/platform/remotedisplay/CastSystemDisplay.kt
71### service/ — session services
72- com/vayunmathur/cast/service/CastService.kt
73- com/vayunmathur/cast/service/ContentCastService.kt
74- com/vayunmathur/cast/service/CastRemoteDisplayService.kt
75- com/vayunmathur/cast/service/ClientResourceResolver.kt
76### ui/ — picker + status + pairing
77- com/vayunmathur/cast/ui/CastScreen.kt
78- com/vayunmathur/cast/ui/CastPickerContent.kt
79- com/vayunmathur/cast/ui/CastDeviceRow.kt
80- com/vayunmathur/cast/ui/CastContent.kt
81- com/vayunmathur/cast/ui/CastMirrorStatusCard.kt
82- com/vayunmathur/cast/ui/CastPairCodeCard.kt
83- com/vayunmathur/cast/ui/CastPairDialog.kt
84
85## Verify (this module only)
86```
87./gradlew :cast:compileDevKotlin
88./gradlew :cast:lint
89./gradlew :cast:checkMetadata
90```