feat(video): 打通桌面端真实视频画面链路

- Rust: 新增 media::stream 访问单元队列与分片重组,FFI 增加 ttstd_video_next/pending/stats(ABI 2)

- Windows: runner 内嵌 Media Foundation 解码纹理插件(NV12/RGB32→BGRA),开启 CODECAPI_AVLowLatencyMode 消除约 36 帧积压,按显示区域裁掉 16 对齐补齐行

- Android: 大帧按 1200 字节分片发送;csd(SPS/PPS) 随每个关键帧重发,修复先投屏后连接时只收到 P 帧导致的黑屏

- Flutter: 独立 ttstd/video 通道获取 textureId 与统计,VideoView 渲染 Texture 并显示分辨率/PTS/失败原因

- 诊断: stats 增加 format/auBytes/keyframes/submitHr;缺插件、缺 SPS/PPS 显式提示;TTSTD_DUMP_VIDEO 可抓码流配合 ffprobe 定位

- 发现与服务检查: mDNS 发现客户端、服务地址探测、设置页与连接状态卡片(启动本机监听/停止)

- 工具与文档: video_feed 推流示例、一键打包脚本、DEMO 出画面排查表与实测截图
This commit is contained in:
tongtong committed 2026-11-27 04:29:40 +08:00
1 parent adaa23f895
commit df2affa9e2
30 files changed
+2814 -134

No files matched your search

+69 -1
View File
@@ -391,8 +391,76 @@ pub unsafe extern "C" fn ttstd_demo_status(out_json: *mut u8, capacity: usize) -
copy_out(json.as_bytes(), out_json, capacity)
}
/// 视频访问单元元信息。字段布局需与 Windows 原生解码侧保持一致。
#[repr(C)]
#[derive(Debug, Clone, Copy, Default)]
pub struct TtstdVideoFrame {
/// 访问单元序号,单调递增。
pub seq: u64,
/// 呈现时间戳(微秒)。
pub pts: u64,
/// 负载字节数。
pub len: u32,
/// 负载格式:1=H.264 Annex-B,2=HEVC Annex-B。
pub format: u8,
/// 媒体包标志位(bit0=关键帧)。
pub flags: u8,
/// 对齐保留字段。
pub reserved: u16,
}
/// 当前待解码的访问单元数量。
#[no_mangle]
pub extern "C" fn ttstd_video_pending() -> u32 {
crate::media::stream::stats().queued as u32
}
/// 读取队首视频访问单元。
///
/// - 返回 `0`:队列为空。
/// - 返回正数:实际写入 `out` 的字节数,该访问单元已出队。
/// - 返回 `ERR_BUFFER_TOO_SMALL`:`out` 容量不足,`meta` 已写入所需长度,访问单元保留在队列中。
///
/// # Safety
/// meta 必须可写;out 可写且容量为 capacity。
#[no_mangle]
pub unsafe extern "C" fn ttstd_video_next(
meta: *mut TtstdVideoFrame,
out: *mut u8,
capacity: usize,
) -> i32 {
let Some(front) = crate::media::stream::peek_meta() else {
return 0;
};
if !meta.is_null() {
*meta = TtstdVideoFrame {
seq: front.seq,
pts: front.pts,
len: front.len as u32,
format: front.format,
flags: front.flags,
reserved: 0,
};
}
if out.is_null() || capacity < front.len {
return ERR_BUFFER_TOO_SMALL;
}
let buffer = slice::from_raw_parts_mut(out, front.len);
match crate::media::stream::pop_into(front.seq, buffer) {
Some(taken) => taken.len as i32,
None => 0,
}
}
/// 视频队列统计 JSON(诊断用)。
#[no_mangle]
pub unsafe extern "C" fn ttstd_video_stats(out_json: *mut u8, capacity: usize) -> i32 {
let json = crate::media::stream::stats_json();
copy_out(json.as_bytes(), out_json, capacity)
}
/// ABI 版本,便于 Dart 侧校验动态库是否匹配。
#[no_mangle]
pub extern "C" fn ttstd_core_abi_revision() -> i32 {
1
2
}