How zvuk/kithara works
Purpose and entry points
Kithara is a Rust workspace for modular audio playback: progressive HTTP and HLS VOD ingestion, cache-backed decoding, real-time playback/mixing, DRM, and platform bindings. The primary library facade is crates/kithara/src/lib.rs. Runnable entry points are the native DJ studio in crates/kithara-app/src/main.rs and the browser/WASM surface in crates/kithara-ffi/src/web/mod.rs; Android and Apple SDK wrappers live under android/lib/src/main/kotlin/com/kithara/Kithara.kt and apple/Sources/Kithara/KitharaPlayer.swift.
Public playback orchestration
kithara-play owns the AVPlayer-like control plane: player state, playlist/item transitions, resource construction, policy enforcement, and command bridging into real-time processing. Its engine/session boundary separates asynchronous orchestration from the RT renderer. Core paths: crates/kithara-play/src/player/core.rs, crates/kithara-play/src/engine/core.rs, crates/kithara-play/src/rt/processor.rs.
Source acquisition and adaptive streaming
Progressive sources use pull-driven download sessions; HLS parses master/variant playlists, resolves and fetches segments, supports seeking and variant lifecycle. ABR estimates bandwidth and publishes switching decisions. Data crosses from network streams into readers/resources consumed by decoding. Core paths: crates/kithara-file/src/session/mod.rs, crates/kithara-hls/src/stream/hls.rs, crates/kithara-hls/src/variant/core.rs, crates/kithara-abr/src/abr.rs.
Network, DRM, and persistent assets
kithara-net abstracts HTTP across native, Apple URLSession, and browser Fetch, including retries/timeouts/metrics. kithara-drm provides cipher contexts and decryption; HLS has a decrypt processor. kithara-assets provides the persistent cache contract: disk/memory backends, leases/pins, LRU eviction, and crash-safe index persistence. Core paths: crates/kithara-net/src/client.rs, crates/kithara-drm/src/decrypt.rs, crates/kithara-hls/src/decrypt_processor.rs, crates/kithara-assets/src/store/builder.rs, crates/kithara-assets/src/index/persistence/atomic.rs.
Decode and audio pipeline
Readers feed decoder factories that select software Symphonia or native Android/Apple/WebCodecs backends. Decoded PCM flows through track state machines, resampling, time-stretch/EQ/limiter effects, and fixed-buffer renderer/runtime components. Buffer pooling is a dedicated subsystem to avoid allocation in hot paths. Core paths: crates/kithara-decode/src/factory/mod.rs, crates/kithara-audio/src/pipeline/decode/core.rs, crates/kithara-audio/src/renderer/node.rs, crates/kithara-resampler/src/factory.rs, crates/kithara-bufpool/src/pool/core.rs.
Application and UI layer
The native app composes catalog, decks, mixing/crossfade, waveform/analysis, and a declarative UI. kithara-ui compiles RON layout/module/skin documents into render trees and interactive widgets; it is a separate UI system rather than a web frontend. Core paths: crates/kithara-app/src/frontend.rs, crates/kithara-app/src/gui/app.rs, crates/kithara-ui/src/compile.rs, crates/kithara-ui/src/render/tree/mod.rs.
Platform and delivery boundaries
Rust targets native, Android, Apple, and WASM. Platform primitives centralize cancellation, synchronization, time, task/runtime selection, and deterministic/loom-like modes rather than allowing direct runtime use throughout the workspace. Native decoding uses AudioToolbox and MediaCodec; networking uses URLSession, Reqwest/native backends, or Fetch. FFI exposes the engine to Swift/Kotlin and browser JS. Core paths: crates/kithara-platform/src/lib.rs, crates/kithara-decode/src/apple/mod.rs, crates/kithara-decode/src/android/mod.rs, crates/kithara-ffi/src/player/facade.rs.
Main entry points: hls.rs HLS stream · core.rs Player control · session/mod.rs Progressive session · factory/mod.rs Decoder factory
Components 25
Entry surfaces
- Kithara facade · Primary public library surface.
crates/kithara/src/lib.rs - Native DJ studio
crates/kithara-app/src/main.rs - Browser/WASM API
crates/kithara-ffi/src/web/mod.rs - Android SDK
android/lib/src/main/kotlin/com/kithara/Kithara.kt - Apple SDK
apple/Sources/Kithara/KitharaPlayer.swift
Playback control
- Player control · Owns state, playlists, policies, and resource construction.
crates/kithara-play/src/player/core.rs - Engine session · Bridges control commands into the renderer.
crates/kithara-play/src/engine/core.rs - RT processor
crates/kithara-play/src/rt/processor.rs
Ingestion and assets
- Progressive session
crates/kithara-file/src/session/mod.rs - HLS stream · Parses playlists and resolves segment reads.
crates/kithara-hls/src/stream/hls.rs - HLS variant lifecycle
crates/kithara-hls/src/variant/core.rs - ABR controller
crates/kithara-abr/src/abr.rs - HTTP client · Provides retries, timeouts, and metrics.
crates/kithara-net/src/client.rs - Asset store · Cache contract with leases, eviction, and durable index.
crates/kithara-assets/src/store/builder.rs - HLS decrypt
crates/kithara-hls/src/decrypt_processor.rs - DRM decryptor
crates/kithara-drm/src/decrypt.rs
Decode and real-time audio
- Decoder factory · Selects software and platform decoder backends.
crates/kithara-decode/src/factory/mod.rs - Audio pipeline · Track state, resampling, and effects processing.
crates/kithara-audio/src/pipeline/decode/core.rs - Audio renderer
crates/kithara-audio/src/renderer/node.rs - Buffer pool · Avoids hot-path allocations.
crates/kithara-bufpool/src/pool/core.rs
Platform and delivery
- Platform primitives · Centralizes tasks, cancellation, synchronization, and time.
crates/kithara-platform/src/lib.rs - Player FFI facade
crates/kithara-ffi/src/player/facade.rs
Studio UI
- Studio frontend · Composes catalog, decks, mixing, and analysis.
crates/kithara-app/src/frontend.rs - UI compiler · Compiles layout, module, and skin documents.
crates/kithara-ui/src/compile.rs - UI render tree
crates/kithara-ui/src/render/tree/mod.rs
Connections 30
- Kithara facade → Player control: public playback API
- Native DJ studio → Studio frontend: starts
- Studio frontend → Player control: deck controls
- Studio frontend → UI compiler: builds UI
- UI compiler → UI render tree: renders as
- Browser/WASM API → Player FFI facade: browser calls
- Android SDK → Player FFI facade: Kotlin calls
- Apple SDK → Player FFI facade: Swift calls
- Player FFI facade → Player control: controls
- Player control → Engine session: creates session
- Engine session → RT processor: commands
- Player control → Progressive session: progressive resource
- Player control → HLS stream: HLS resource
- HLS stream → HLS variant lifecycle: manages
- HLS variant lifecycle → ABR controller: switch decisions
- Progressive session → HTTP client: HTTP reads
- HLS stream → HTTP client: playlist and segments
- Progressive session → Asset store: cached bytes
- HLS stream → Asset store: cached segments
- HLS stream → HLS decrypt: encrypted segments
- HLS decrypt → DRM decryptor: cipher context
- Progressive session → Decoder factory: reader
- HLS stream → Decoder factory: reader
- Decoder factory → Audio pipeline: PCM
- Audio pipeline → RT processor: tracks
- RT processor → Audio renderer: render buffers
- Buffer pool → Audio pipeline: pooled buffers
- Platform primitives → HTTP client: runtime primitives
- Platform primitives → Engine session: tasks and sync
- Platform primitives → Decoder factory: platform backends