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

Modern-Apps.git / cast / AGENTS.md

AGENTS.md4.9 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- Gradle: :cast / dir: cast/
7- Package roots present: ui, domain, platform, network, service
8- Entry files: MainActivity.kt, Route.kt, Navigation.kt (no `CastApplication` class)
9- Deps: :library:aosp-stubs, :cast:protocol, :sdk:cast
10- Metadata: metadata_data/cast.md (present)
11- Rust: no / screenshotTest: yes
12
13## Overview
14**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.
15**Key features:**
16- 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
17- Content casting (`CastContentSession`, `MediaProxyServer`) so other apps hand media off through `:sdk:cast`
18- Discovery + pairing UI, Quick Settings tile start/stop, remote-display provider for system routing
19**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.
20**Entry points + reading order:** `Route` → `MainActivity.kt` → `Navigation.kt` → `platform/CastController.kt` → `platform/mirror/MirrorEngine.kt` → `network/ControlSocket.kt`.
21**Gotchas:**
22- Encoder support varies by device (`mirror/EncoderSupport`) — capability checks before assuming codecs
23- Screen-capture consent is one-shot per session (`MirrorConsentActivity`); losing it mid-mirror kills the stream
24- Keep `:cast:protocol` untouched from here — wire changes need sender + TV receiver updated together
25
26## Key files
27### Root — entry + navigation
28- com/vayunmathur/cast/MainActivity.kt
29- com/vayunmathur/cast/Navigation.kt
30- com/vayunmathur/cast/Route.kt
31### domain/ — device + client state
32- com/vayunmathur/cast/domain/CastDevice.kt
33- com/vayunmathur/cast/domain/ClientState.kt
34### network/ — transports
35- com/vayunmathur/cast/network/CastUdpTransport.kt
36- com/vayunmathur/cast/network/ControlSocket.kt
37### platform/ — controller, sessions, discovery, proxy
38- com/vayunmathur/cast/platform/CastViewModel.kt
39- com/vayunmathur/cast/platform/CastUiContract.kt
40- com/vayunmathur/cast/platform/CastController.kt
41- com/vayunmathur/cast/platform/CastConnection.kt
42- com/vayunmathur/cast/platform/CastSessionTypes.kt
43- com/vayunmathur/cast/platform/CastSessionWatch.kt
44- com/vayunmathur/cast/platform/CastCodecNegotiation.kt
45- com/vayunmathur/cast/platform/CastContentSession.kt
46- com/vayunmathur/cast/platform/CastMirrorSession.kt
47- com/vayunmathur/cast/platform/MirrorClient.kt
48- com/vayunmathur/cast/platform/MediaProxyServer.kt
49- com/vayunmathur/cast/platform/CastPickerActivity.kt
50- com/vayunmathur/cast/platform/CastPairActivity.kt
51- com/vayunmathur/cast/platform/CastDesktopDisplay.kt
52- com/vayunmathur/cast/platform/discovery/CastDiscoveryManager.kt
53### platform/mirror/ — capture + encoders + sender
54- com/vayunmathur/cast/platform/mirror/MirrorEngine.kt
55- com/vayunmathur/cast/platform/mirror/MirrorSource.kt
56- com/vayunmathur/cast/platform/mirror/ScreenCapture.kt
57- com/vayunmathur/cast/platform/mirror/VideoEncoder.kt
58- com/vayunmathur/cast/platform/mirror/AudioEncoder.kt
59- com/vayunmathur/cast/platform/mirror/PcmAudioEncoder.kt
60- com/vayunmathur/cast/platform/mirror/OpusEncoder.kt
61- com/vayunmathur/cast/platform/mirror/EncoderSupport.kt
62- com/vayunmathur/cast/platform/mirror/StreamSender.kt
63- com/vayunmathur/cast/platform/mirror/MirrorGeometry.kt
64- com/vayunmathur/cast/platform/mirror/MirrorPreferences.kt
65- com/vayunmathur/cast/platform/mirror/MirrorConsentActivity.kt
66- com/vayunmathur/cast/platform/mirror/MirrorTileService.kt
67### platform/remotedisplay/ — system display routing
68- com/vayunmathur/cast/platform/remotedisplay/MaRemoteDisplayProvider.kt
69- com/vayunmathur/cast/platform/remotedisplay/CastSystemDisplay.kt
70### service/ — session services
71- com/vayunmathur/cast/service/CastService.kt
72- com/vayunmathur/cast/service/ContentCastService.kt
73- com/vayunmathur/cast/service/CastRemoteDisplayService.kt
74- com/vayunmathur/cast/service/ClientResourceResolver.kt
75### ui/ — picker + status + pairing
76- com/vayunmathur/cast/ui/CastScreen.kt
77- com/vayunmathur/cast/ui/CastPickerContent.kt
78- com/vayunmathur/cast/ui/CastDeviceRow.kt
79- com/vayunmathur/cast/ui/CastContent.kt
80- com/vayunmathur/cast/ui/CastMirrorStatusCard.kt
81- com/vayunmathur/cast/ui/CastPairCodeCard.kt
82- com/vayunmathur/cast/ui/CastPairDialog.kt
83
84## Verify (this module only)
85```
86./gradlew :cast:compileDevKotlin
87./gradlew :cast:lint
88./gradlew :cast:checkMetadata
89```