How kazuki0824/recisdb-rs works
Project Type & Purpose
• This is a command‐line television tuner reader and ARIB STD-B25 decoder written in Rust. It is designed to read bitstreams from various tuner devices (Unix character devices and BonDriver on Windows) and decode them using a Rust wrapper (b25-sys) over libaribb25.
• The project is split into at least two main components: the command-line application (recisdb-rs) that provides various subcommands (checksignal, tune, decode) and a supporting library (b25-sys) that serves as an interface/wrapper to the external libaribb25.
Key Parts in the File Structure
• At the repository root you see cargo configurations, continuous integration workflows (GitHub Actions), and some configuration files.
• Two primary directories are present:
– b25-sys: Contains its own Cargo.toml, build.rs, and structured modules (e.g., ‘access_control’ and ‘bindings’) to wrap libaribb25. It includes external submodules in “externals/libaribb25”.
– recisdb-rs: Contains the main.rs and additional modules organizing “channels”, “commands”, “tuner” (with separate folders for linux and windows), and utility functions.
• This shows a clear separation where the “recisdb” CLI logic and device handling are implemented in recisdb-rs and the underlying ARIB STD-B25 decoding functionality is abstracted into the b25-sys library.
Components
a. User Interface / CLI:
– Represent the “CLI Application” (recisdb-rs) with its three subcommands:
• checksignal – for validating signal levels.
• tune – for selecting channels and streaming recorded TS data.
• decode – for taking scrambled input and producing a descrambled TS output.
b. Tuner Device Abstraction Layer:
– Break this out into platform-specific modules:
• Linux modules (chardev, DVBv5 support, tuner/linux).
• Windows modules (BonDriver and associated wrappers).
– Include “channels” and “commands” modules which parse command line input and coordinate between the CLI and underlying hardware.
c. Decoding Engine:
– Represent the b25-sys library as a distinct component that provides ARIB STD-B25 decoding.
– Under b25-sys, indicate several submodules:
• “access_control” handling control logic and structure.
• “bindings” which encapsulate the FFI layer to libaribb25.
• “externals/libaribb25” to show the native C library dependency.
d. External Dependencies:
– Illustrate dependencies such as libaribb25 and other system libraries (e.g., libdvbv5, libpcsclite) that are required for tuner operations.
– You might also show integration with build tools (Rust toolchain, build.rs) that help in building the FFI layer.
Relationships and Data Flow
– Parses and processes user commands.
– For tuner operations, directs requests to the platform-specific tuner modules.
– For decoding tasks, calls into the b25-sys decoding library.
• Then, b25-sys in turn invokes its “bindings” module that bridges the Rust code to the external libaribb25 library.
• Additionally, show that error/status information from tuner operations and decoding processes flows back to CLI for logging/debugging.
Important Architectural Patterns / Design Principles
• Modularity & separation of concerns:
– Clear isolation of CLI logic, hardware abstraction, and decoding functions.
• Cross-platform abstraction:
– Distinct handling of Linux (character devices, DVBv5) versus Windows (BonDriver) builds.
• FFI and wrapper usage:
– The b25-sys library wraps libaribb25 using Rust’s FFI capabilities, encapsulating native library interaction within a safe layer.
• Build script usage:
– Use of build.rs in both crates to handle custom build tasks (such as linking external libraries).