feat: migrate CaptureDemo capture flow into SDK

This commit is contained in:
Mark.lin
2026-07-22 09:23:26 +08:00
parent c760f2e97d
commit 8914281d2e
12 changed files with 379 additions and 520 deletions
+37 -18
View File
@@ -105,6 +105,12 @@ typedef enum
GVFG_PIXFMT_BGRA8 = 100
} gvfg_pixel_format_t;
typedef enum
{
GVFG_CHANNEL_0 = 0,
GVFG_CHANNEL_1 = 1
} gvfg_channel_t;
typedef enum
{
GVFG_FRAME_LAYOUT_CONTIGUOUS = 1u << 0, /* Planes are contained inside one contiguous data buffer. */
@@ -119,13 +125,12 @@ typedef struct
typedef struct
{
int width; /* Signal width in pixels when available. */
int height; /* Signal height in pixels when available. */
char video_format[16]; /* Decoded signal format name. */
char frame_rate_name[16]; /* None, 23.98, 24, 47.95, ..., or "--" for unsupported codes. */
int bit_depth; /* Signal bit depth: 8 or 10 when valid. */
int sdi_locked; /* Non-zero when SDI reports locked. */
int hdmi_locked; /* Non-zero when HDMI reports locked. */
int connected; /* Non-zero while the selected channel has a valid input signal. */
int channel; /* gvfg_channel_t selected when the device was opened. */
int width; /* Signal width in pixels when connected. */
int height; /* Signal height in pixels when connected. */
char pixel_format[16]; /* Actual DMA payload format, for example Y210. */
int bit_depth; /* Signal bit depth derived from the payload format. */
} gvfg_signal_status_t;
typedef struct
@@ -172,10 +177,15 @@ typedef struct
typedef enum
{
GVFG_EVENT_UNKNOWN = 0,
GVFG_EVENT_PLUG_IN = 1,
GVFG_EVENT_PLUG_OUT = 2,
GVFG_EVENT_SIGNAL_CONNECTED = 1,
GVFG_EVENT_SIGNAL_DISCONNECTED = 2,
GVFG_EVENT_CAPTURE_PAUSED = 3,
GVFG_EVENT_CAPTURE_RESUMED = 4
GVFG_EVENT_CAPTURE_RESUMED = 4,
/* Backward-compatible aliases. These events describe the input signal,
not physical insertion/removal of the PCIe capture device. */
GVFG_EVENT_PLUG_IN = GVFG_EVENT_SIGNAL_CONNECTED,
GVFG_EVENT_PLUG_OUT = GVFG_EVENT_SIGNAL_DISCONNECTED
} gvfg_event_type_t;
typedef struct
@@ -202,8 +212,8 @@ typedef void (*gvfg_frame_callback_t)(
/*
* Optional callback-mode event delivery.
*
* Event callbacks may be invoked from a different SDK-owned thread than frame
* callbacks. Do not assume ordering between frame and event callbacks.
* Frame and event callbacks for one handle are serialized on the same
* SDK-owned dispatch thread. A callback must not block for long periods.
*/
typedef void (*gvfg_event_callback_t)(
_In_ gvfg_handle handle,
@@ -273,12 +283,18 @@ GVFG_API gvfg_status_t gvfg_destroy(
* - GVFG_ENODEV if the device cannot be opened.
* - GVFG_EIO for driver/backend failures.
*
* The current implementation selects the SDI input internally.
* This is a backward-compatible shorthand for opening CH0.
*/
GVFG_API gvfg_status_t gvfg_open(
_In_ gvfg_handle handle,
_In_ int device_index);
/* Open CH0 or CH1 explicitly on a physical capture device. */
GVFG_API gvfg_status_t gvfg_open_channel(
_In_ gvfg_handle handle,
_In_ int device_index,
_In_ int channel_index);
/*
* Configure and start capture on an opened device.
*
@@ -286,13 +302,15 @@ GVFG_API gvfg_status_t gvfg_open(
* - handle: Opened session handle.
*
* Returns:
* - GVFG_OK on success, including when capture is already running.
* - GVFG_OK on success, including when capture is already running or the SDK
* has entered signal-monitoring mode while no input is connected.
* - GVFG_EINVAL if handle is NULL.
* - GVFG_ESTATE if no device is open.
* - GVFG_EIO or another status code if stream configuration/start fails.
*
* After success, call gvfg_read_frame() to receive frames and gvfg_poll_event()
* to receive capture events.
* to receive capture events. With no input signal, frame reads time out; capture
* starts automatically after a signal-connected event.
*/
GVFG_API gvfg_status_t gvfg_start(
_In_ gvfg_handle handle);
@@ -318,14 +336,15 @@ GVFG_API gvfg_status_t gvfg_set_event_callback(
/*
* Start capture in callback mode.
*
* The SDK creates one frame worker thread for this handle. The frame callback
* is not invoked concurrently for the same handle.
* The SDK creates one callback dispatch thread for this handle. Frame and event
* callbacks are not invoked concurrently for the same handle. The backend uses
* one additional thread to wait for driver DMA and signal events.
*/
GVFG_API gvfg_status_t gvfg_start_callback_mode(
_In_ gvfg_handle handle);
/*
* Stop callback mode and wait for the frame worker thread to exit.
* Stop callback mode and wait for the callback dispatch thread to exit.
*
* Do not call this from inside the frame callback.
*/
-23
View File
@@ -39,7 +39,6 @@ typedef struct
int backend_running;
int backend_capture_active;
int backend_data_worker_stop;
uint32_t backend_pending_events;
uint64_t backend_latest_sequence;
uint64_t backend_delivered_sequence;
@@ -48,19 +47,6 @@ typedef struct
uint64_t backend_ring_size;
} gvfg_debug_backend_stats_t;
typedef struct
{
uint32_t valid_mask;
uint32_t width_valid;
uint32_t height_valid;
uint32_t width_raw;
uint32_t height_raw;
uint32_t video_format_raw;
uint32_t frame_rate_raw;
uint32_t bit_depth_raw;
uint32_t status_raw;
} gvfg_debug_fpga_signal_raw_t;
/*
* Query driver-neutral internal backend counters.
*
@@ -71,15 +57,6 @@ GVFG_API gvfg_status_t gvfg_debug_get_backend_stats(
_In_ gvfg_handle handle,
_Out_ gvfg_debug_backend_stats_t *out_stats);
/*
* Query raw FPGA signal values for internal hardware/FPGA debugging.
*
* These values are intentionally excluded from gvfg_capture.h.
*/
GVFG_API gvfg_status_t gvfg_debug_get_fpga_signal_raw(
_In_ gvfg_handle handle,
_Out_ gvfg_debug_fpga_signal_raw_t *out_raw);
/*
* Copy the latest backend error detail into out_message.
*