Expose common delivery timestamps for A/V sync

Compared with 7e5d3d2:

- Add monotonic timestamp_ns fields to public video and audio frame tokens so applications can compare delivery timing in one SDK clock domain.

- Stamp video delivery in the PCIe backend and audio delivery in the GVFG facade while preserving complete read/release token validation.

- Update x64 ABI assertions and bump the standalone SDK version to 0.2.0 for the public frame-structure change.

- Document timestamp semantics and limitations across the README, customer API references, internal ABI notes, and build guidance.

- Leave the standalone preview sample behavior unchanged; timestamp-based synchronization remains an application policy.

Validation: git diff --check and focused source inspection passed; no build, ABI consumer rebuild, recording, or hardware capture validation was run.
This commit is contained in:
Mark.lin
2026-09-08 15:20:40 +08:00
parent 7e5d3d2cca
commit 3cd7fbbb3f
10 changed files with 36 additions and 10 deletions
+6 -1
View File
@@ -144,7 +144,7 @@ Audio 採用相同的 pull 與 ownership 模型:
可用 `gvfg_strerror()` 取得靜態英文說明字串;呼叫端不可釋放該字串。
可用 `gvfg_get_version()` 查詢目前實際載入的 `gvfg.dll` 版本。回傳值為
靜態字串,例如 `"0.1.0"`,呼叫端不可釋放。
靜態字串,例如 `"0.2.0"`,呼叫端不可釋放。
需要記錄最近一次失敗的詳細原因時,可在 API 失敗後立即呼叫
`gvfg_get_channel_last_error_detail()`;driver/register 等內部診斷仍保留在 debug API。
@@ -168,6 +168,7 @@ Audio 採用相同的 pull 與 ownership 模型:
- `row_stride_bytes`:相鄰兩列起點的 byte 距離。
- `pixel_format`、`bit_depth`:原生 payload 格式。
- `frame_id`:同一次 start/stop session 中單調遞增的識別值。
- `timestamp_ns`:SDK monotonic delivery timestamp,與 audio 使用相同 clock domain。
### PCM audio
@@ -180,6 +181,10 @@ Audio 採用相同的 pull 與 ownership 模型:
- `data`、`data_size`:SDK-owned PCM 與本次有效 byte 數。
- `sample_rate`、`channels`、`bits_per_sample`:此 frame 的 PCM 格式。
- `frame_id`:同一次 start/stop session 中單調遞增的 audio frame ID。
- `timestamp_ns`:SDK monotonic delivery timestamp,與 video 使用相同 clock domain。
`timestamp_ns` 用於比較同一 process/session 內的 video/audio delivery timing;它
不是 driver 或硬體 capture timestamp。
目前 audio 僅支援 CH0,且必須與 video 一起啟動;不支援 audio-only。公開
audio API 不是 zero-copy,但上層仍使用和 video 相同的 read/release contract。
+6 -1
View File
@@ -97,6 +97,7 @@ register 與 DMA 實作不屬於本文件。
| `pixel_format` | `int` | `gvfg_pixel_format_t` 值 |
| `bit_depth` | `int` | 原生 frame 每色彩 channel 的 bit depth |
| `frame_id` | `uint64_t` | 此次 start/stop run 中單調遞增的 frame ID |
| `timestamp_ns` | `uint64_t` | SDK 交付時間;與 audio 共用 monotonic clock,單位 ns |
Caller 不得修改任何欄位再 release。SDK 會將完整 token 與目前 held frame 比對。
@@ -127,10 +128,14 @@ Driver 一次傳回多少 bytes、buffer capacity 與 block alignment 均由 SDK
| `channels` | `uint32_t` | interleaved PCM channel 數 |
| `bits_per_sample` | `uint32_t` | 每個 PCM sample 的 bit 數 |
| `frame_id` | `uint64_t` | 此次 start/stop run 中單調遞增的 audio frame ID |
| `timestamp_ns` | `uint64_t` | SDK 交付時間;與 video 共用 monotonic clock,單位 ns |
與 video 相同,每個 channel 同時只能持有一個 audio frame,且 caller 不得修改
descriptor 後再 release。
Video/audio 的 `timestamp_ns` 可在同一 process/session 內直接比較。它代表 SDK
delivery timing,不是 driver 或硬體 capture timestamp。
### 1.9 `gvfg_gpu_output_format_t`
| 成員 | 值 | 說明 |
@@ -491,7 +496,7 @@ gvfg_status_t gvfg_get_channel_runtime_info(
const char *gvfg_get_version(void);
```
- 回傳目前實際載入的 GVFG runtime DLL 版本,例如 `"0.1.0"`。
- 回傳目前實際載入的 GVFG runtime DLL 版本,例如 `"0.2.0"`。
- 回傳值是靜態 null-terminated 字串,caller 不可 free。
- 可用於 log、問題回報,以及確認 header、LIB、DLL 是否來自同一版本。
+1 -1
View File
@@ -119,7 +119,7 @@ driver pointer,才能再次 read。SDK 不根據 read 間隔推算 frame loss
Facade 在 release 時驗證原 token 的 data、size、width、height、stride、format、
bit depth 與 frame ID。任何欄位遭修改都回傳 `GVFG_EINVAL`。
x64 `gvfg_frame_t` ABI 已在 `gvfg_capture.cpp` 以 static assertions 固定為 48 bytes
x64 `gvfg_frame_t` ABI 已在 `gvfg_capture.cpp` 以 static assertions 固定為 56 bytes
及明確欄位 offsets。修改公開 struct 時必須視為 ABI 變更,不能只重新編譯 DLL。
新增 metadata 優先考慮新 query API 或帶 size/version 的新 struct。
+1 -1
View File
@@ -41,7 +41,7 @@
版本只有一個來源:根目錄 `CMakeLists.txt` 的 `project()`:
```cmake
project(gvfg_standalone VERSION 0.1.0 LANGUAGES CXX)
project(gvfg_standalone VERSION 0.2.0 LANGUAGES CXX)
```
例如準備 `0.2.0` 時改成: