From c12ae6ddccdeb3ba54f7da2ee331371290840e77 Mon Sep 17 00:00:00 2001 From: dailz Date: Mon, 22 Jun 2026 16:37:11 +0800 Subject: [PATCH] =?UTF-8?q?docs(lib):=20=E4=B8=AD=E6=96=87=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20build.rs=20=E4=B8=8E=20src/lib.rs=20=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E6=80=BB=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.rs | 5 +++++ src/lib.rs | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/build.rs b/build.rs index f328e4d..7d90106 100644 --- a/build.rs +++ b/build.rs @@ -1 +1,6 @@ +//! Cargo build script(编译前钩子)。 +//! +//! 当前为空:本项目直接复用 `wayland-client`、`pipewire`、`ffmpeg-sys` 等现成 crate, +//! 不需要在编译前跑 wayland-scanner 或 bindgen 生成代码。类比 Go 无 `//go:generate`。 +// Cargo 编译前不需要生成任何代码(无 wayland-scanner / bindgen),因此 build script 留空。 fn main() {} diff --git a/src/lib.rs b/src/lib.rs index d245351..6c7303d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,29 @@ +//! `wl-webrtc` 库 crate 入口。 +//! +//! 本 crate 既被三个二进制(`wl-webrtc`、`vaapi_import_bench`、`sw_encode_bench`) +//! 复用,也对外暴露测试入口。下面按声明顺序列出所有子模块。 +//! +//! Rust 的 `pub mod xxx;` 类似 Go 的 package 组织:每个文件即一个模块, +//! 但 Rust 模块是分层的文件树(`src/.rs` 或 `src//mod.rs`)。 +// CLI 参数定义(clap derive):类似 Go 的 flag 包,但用过程宏从结构体字段自动生成。 pub mod args; +// FFmpeg/VAAPI 硬件编码 FFI 绑定(含大量 unsafe),是项目最密集的 C interop 模块。 pub mod avhw; +// 后端自动检测:根据 Wayland global 与 D-Bus 服务在 wlr-screencopy 与 XDG Portal 之间选择。 pub mod backend_detect; +// XDG Portal + PipeWire 截屏后端实现。 pub mod cap_portal; +// wlroots `wlr-screencopy-unstable-v1` 协议绑定。 pub mod cap_wlr_screencopy; +// 帧率限制器:基于 `std::time::Instant` 控制捕获循环节奏。 pub mod fps_limit; +// wlroots 后端核心状态机:用 `mio` 直接跑 Wayland fd 事件循环。 pub mod state; +// Portal 后端核心状态机:基于 `tokio` + crossbeam channel 拉取 PipeWire 帧。 pub mod state_portal; +// 管道性能统计:用 `AtomicU64` + `Mutex` 暴露帧率/延迟计数。 pub mod stats; +// 图像变换(旋转/翻转):对传入帧做几何变换。 pub mod transform; +// str0m WebRTC 信令服务器:内嵌一个轻量 HTTP 端点做 SDP 交换。 pub mod webrtc;