# Diamond Player Handoff Protocol

## Diamond Handoff

The app accepts:

- `sonyatv-diamond://open?capsule=...`
- HTTPS links on `usps.music`, `www.usps.music`, `sonyatv.store`,
  `www.sonyatv.store`, `gtarad.io`, or `www.gtarad.io`
- equivalent QR or Data Matrix content scanned from the settings page

Capsules are bounded to 96 KiB encoded/decoded data, support the documented v1
and v2 Diamond schemas, and select at most one audio track for this wallet. The
selected track must have a safe HTTPS source and an `audio/*` media type.

## Encrypted WAV Import

Import follows this path:

1. Parse and validate the handoff capsule.
2. Resolve each HTTPS destination and reject private or special-use addresses.
3. Follow no more than five redirects, all of which must remain HTTPS.
4. Stream the response through a size-limited input directly into the Tella
   app-private encrypted vault.
5. Probe decrypted WAV/FLAC headers locally for actual bit depth and sample
   rate when available.
6. Play through the private `diamond-vault://media/<id>` data source and the
   non-exported Media3 session service.

No plaintext shared-storage copy or public export API is created. Settings
provide HLS/WAV radio selection, Play Radio, Play/Pause, Scan Handoff, Play
Encrypted, and Remove controls. Android media-session controls continue while
the app is backgrounded.
