# yukarikaname/openchromecast architecture

> Architecture diagram of the GitHub repository yukarikaname/openchromecast, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yukarikaname/openchromecast
- Repository: https://github.com/yukarikaname/openchromecast

## Overview

openchromecast emulates a Chromecast flinging receiver: a Cast sender discovers it on the LAN, connects over TLS, launches a receiver session, then submits media URLs and playback controls that are handled by Cast namespaces and delegated to a local player. Receiver and media state feed protocol status responses; mpv and VLC are alternative backends. The README also documents YouTube MDX and media queues. Those capabilities are represented from documentation, but their internal wiring is not inferred beyond the sampled code.

Main entry points: [`src/server.rs`](https://github.com/yukarikaname/openchromecast/blob/main/src/server.rs) (TLS and dispatch), [`src/main.rs`](https://github.com/yukarikaname/openchromecast/blob/main/src/main.rs) (Runtime entry), [`src/player/mod.rs`](https://github.com/yukarikaname/openchromecast/blob/main/src/player/mod.rs) (Player actor), [`src/state.rs`](https://github.com/yukarikaname/openchromecast/blob/main/src/state.rs) (Session state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application runtime"]
  node_main["Runtime entry<br/>[main.rs]"]
  node_config["CLI config<br/>[config.rs]"]
  node_state["Session state<br/>[state.rs]"]
end

subgraph group_transport["Cast protocol"]
  node_identity["Device identity<br/>[crypto.rs]"]
  node_discovery["mDNS advertisement<br/>[mdns.rs]"]
  node_server["TLS and dispatch<br/>[server.rs]"]
  node_protobuf["Cast messages<br/>[proto.rs]"]
  node_receiver["Receiver control<br/>[receiver.rs]"]
  node_media["Media namespace<br/>[media.rs]"]
  node_youtube["YouTube MDX<br/>[youtube.rs]"]
end

subgraph group_playback["Playback"]
  node_player_api["Player actor<br/>[mod.rs]"]
  node_mpv_backend["mpv backend<br/>[mpv.rs]"]
  node_vlc_backend["VLC backend<br/>[vlc.rs]"]
end

subgraph group_interface["User interface"]
  node_tray["System tray<br/>[tray.rs]"]
end

node_sender(("Cast sender"))
node_mpv["mpv process"]
node_vlc["VLC process"]
node_autolaunch["Login startup"]
node_lan(("Local network"))

node_sender -->|"browses Cast"| node_lan
node_main -->|"parses options"| node_config
node_main -->|"loads identity"| node_identity
node_main -->|"advertises device"| node_discovery
node_discovery -->|"publishes service"| node_lan
node_main -->|"starts listener"| node_server
node_sender -->|"opens TLS"| node_server
node_server -->|"authenticates sender"| node_identity
node_server -->|"frames messages"| node_protobuf
node_server -->|"dispatches namespace"| node_receiver
node_server -->|"dispatches namespace"| node_media
node_server -->|"dispatches namespace"| node_youtube
node_receiver -->|"reads and updates"| node_state
node_media -->|"reads and updates"| node_state
node_youtube -.->|"uses session state"| node_state
node_receiver -->|"sets volume"| node_player_api
node_media -->|"controls playback"| node_player_api
node_server -->|"tracks connections"| node_state
node_player_api -->|"selects backend"| node_mpv_backend
node_player_api -->|"selects backend"| node_vlc_backend
node_mpv_backend -->|"controls via JSON IPC"| node_mpv
node_vlc_backend -->|"controls via RC"| node_vlc
node_main -->|"starts interface"| node_tray
node_tray -->|"requests shutdown"| node_main
node_tray -->|"toggles login start"| node_autolaunch

click node_main "https://github.com/yukarikaname/openchromecast/blob/main/src/main.rs"
click node_config "https://github.com/yukarikaname/openchromecast/blob/main/src/config.rs"
click node_identity "https://github.com/yukarikaname/openchromecast/blob/main/src/crypto.rs"
click node_discovery "https://github.com/yukarikaname/openchromecast/blob/main/src/mdns.rs"
click node_server "https://github.com/yukarikaname/openchromecast/blob/main/src/server.rs"
click node_protobuf "https://github.com/yukarikaname/openchromecast/blob/main/src/proto.rs"
click node_receiver "https://github.com/yukarikaname/openchromecast/blob/main/src/receiver.rs"
click node_media "https://github.com/yukarikaname/openchromecast/blob/main/src/media.rs"
click node_youtube "https://github.com/yukarikaname/openchromecast/blob/main/src/youtube.rs"
click node_state "https://github.com/yukarikaname/openchromecast/blob/main/src/state.rs"
click node_player_api "https://github.com/yukarikaname/openchromecast/blob/main/src/player/mod.rs"
click node_mpv_backend "https://github.com/yukarikaname/openchromecast/blob/main/src/player/mpv.rs"
click node_vlc_backend "https://github.com/yukarikaname/openchromecast/blob/main/src/player/vlc.rs"
click node_tray "https://github.com/yukarikaname/openchromecast/blob/main/src/tray.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_config,node_state toneBlue
class node_identity,node_discovery,node_server,node_protobuf,node_receiver,node_media,node_youtube toneAmber
class node_player_api,node_mpv_backend,node_vlc_backend toneMint
class node_tray toneRose
class node_sender,node_mpv,node_vlc,node_autolaunch,node_lan toneIndigo
```

## Components

### Application runtime

- [Runtime entry](https://github.com/yukarikaname/openchromecast/blob/main/src/main.rs): `src/main.rs`
- [CLI config](https://github.com/yukarikaname/openchromecast/blob/main/src/config.rs): `src/config.rs`
- [Session state](https://github.com/yukarikaname/openchromecast/blob/main/src/state.rs): `src/state.rs`

### Cast protocol

- [Device identity](https://github.com/yukarikaname/openchromecast/blob/main/src/crypto.rs): `src/crypto.rs`
- [mDNS advertisement](https://github.com/yukarikaname/openchromecast/blob/main/src/mdns.rs): `src/mdns.rs`
- [TLS and dispatch](https://github.com/yukarikaname/openchromecast/blob/main/src/server.rs): `src/server.rs`
- [Cast messages](https://github.com/yukarikaname/openchromecast/blob/main/src/proto.rs): `src/proto.rs`
- [Receiver control](https://github.com/yukarikaname/openchromecast/blob/main/src/receiver.rs): `src/receiver.rs`
- [Media namespace](https://github.com/yukarikaname/openchromecast/blob/main/src/media.rs): `src/media.rs`
- [YouTube MDX](https://github.com/yukarikaname/openchromecast/blob/main/src/youtube.rs): `src/youtube.rs`

### Playback

- [Player actor](https://github.com/yukarikaname/openchromecast/blob/main/src/player/mod.rs): `src/player/mod.rs`
- [mpv backend](https://github.com/yukarikaname/openchromecast/blob/main/src/player/mpv.rs): `src/player/mpv.rs`
- [VLC backend](https://github.com/yukarikaname/openchromecast/blob/main/src/player/vlc.rs): `src/player/vlc.rs`

### User interface

- [System tray](https://github.com/yukarikaname/openchromecast/blob/main/src/tray.rs): `src/tray.rs`

### Other components

- **Cast sender**
- **mpv process**
- **VLC process**
- **Login startup**
- **Local network**

## Connections

- Cast sender → Local network: browses Cast
- Runtime entry → CLI config: parses options
- Runtime entry → Device identity: loads identity
- Runtime entry → mDNS advertisement: advertises device
- mDNS advertisement → Local network: publishes service
- Runtime entry → TLS and dispatch: starts listener
- Cast sender → TLS and dispatch: opens TLS
- TLS and dispatch → Device identity: authenticates sender
- TLS and dispatch → Cast messages: frames messages
- TLS and dispatch → Receiver control: dispatches namespace
- TLS and dispatch → Media namespace: dispatches namespace
- TLS and dispatch → YouTube MDX: dispatches namespace
- Receiver control → Session state: reads and updates
- Media namespace → Session state: reads and updates
- YouTube MDX → Session state: uses session state
- Receiver control → Player actor: sets volume
- Media namespace → Player actor: controls playback
- TLS and dispatch → Session state: tracks connections
- Player actor → mpv backend: selects backend
- Player actor → VLC backend: selects backend
- mpv backend → mpv process: controls via JSON IPC
- VLC backend → VLC process: controls via RC
- Runtime entry → System tray: starts interface
- System tray → Runtime entry: requests shutdown
- System tray → Login startup: toggles login start
