How streetpea/chiaki-ng works
Project type and purpose
• chiaki-ng is an open-source, cross-platform remote-play client for PS4 and PS5.
• It provides a core C library implementing the PlayStation Remote Play protocol, plus multiple front-end applications (GUI, CLI, Android, Switch, Steam Deck).
Main components
a. Core Library (lib/)
• Implements discovery, authentication, streaming protocol, congestion control, FEC, encoding/decoding interfaces.
• Uses external codec/network libs: FFmpeg, Opus, SpeexDSP, libcurl, Nanopb, etc.
b. Front-ends
• GUI (gui/): Qt/QML C++ application that calls the core library, handles UI, session management, input mapping.
• CLI (cli/): command-line interface built on the core library for headless use.
• Android App (android/): Kotlin+JNI layer calls core library native code for discover, streaming, rendering (via Oboe, native video decoders).
• Nintendo Switch (switch/): native C++ app using core library, custom GUI.
• Steam Deck Native (steamdeck_native/) & setsu/: native demos for haptics/motion, input support on Steam Deck.
c. External Services
• PlayStation Network (public authentication endpoints).
• Hole-punch token servers (scripts/holepunch).
d. Build & Deployment Layers
• CMake build system (root CMakeLists + per-module CMakeLists).
• CI/CD pipelines (.github/workflows and .builds).
• Packaging scripts (scripts/* for AppImage, Flatpak, Docker).
Relationships and interactions
• Front-ends → Core Library: all user-facing apps invoke the core API for discovery, auth, session start/stop.
• Core Library ↔ PSN Endpoint: REST calls for login, token refresh.
• Core Library ↔ Discovery Service: UDP broadcast/discovery, hole-punch negotiation with token servers.
• Core Library ↔ Streaming Endpoint: encrypted TCP/UDP connection for video/audio packets.
• Core Library → FFmpeg/Opus: demux/decoding of video/audio packets.
• Front-ends → Rendering/Input APIs:
• GUI: Qt Quick/QML engine for video rendering, user input events.
• Android: Android UI + Oboe for audio, SurfaceView for video, touch control rendering.
• Switch: platform SDK for UI and input mapping.
• Build System orchestrates dependency discovery, compile/link across all targets.
Architectural patterns and design principles
• Layered architecture:
• Platform-agnostic core library (C, pure logic)
• Platform-specific adapters (JNI, Qt, Switch SDK)
• UI layer separate from networking/codec.
• Plugin-style front-end integration—each app links to the same core.
• Clear separation of concerns: networking, codec, UI, input management.
• Use of hardware acceleration when available (native decoders, Vulkan via Flatpak).
• Related components (e.g., cluster platform front-ends).
• Protocol layers (discovery, auth, transport, codec).