Refine backend status handling

Compared with 5ee2ee1:

- update the bundled GigabyteLib interface and binary, reset backend events across stream transitions, and wait for requested video format changes before reporting refreshed signal state

- translate private GigabyteLib results into stable public GVFG errors, including GVFG_EBUSY, while keeping vendor API names, enum values, and raw codes in internal diagnostics

- keep customer-facing error strings and detailed faults backend-neutral, and show the original library failure only in the Debug internal Sample

- update the public and internal error-handling documentation to match the new ownership boundary

Validation: git diff --check passed. The SDK MSVC Release build and Qt Sample MSVC Release and Debug builds completed successfully. Hardware behavior was not tested.
This commit is contained in:
Mark.lin
2026-09-22 10:15:49 +08:00
parent 5ee2ee12e6
commit 0fc22a1646
13 changed files with 1573 additions and 883 deletions
+9 -8
View File
@@ -88,11 +88,10 @@ extern "C"
GVFG_ESTATE = -3, /* API was called in the wrong state. */
GVFG_EIO = -4, /* SDK-owned I/O, GPU, or internal extension failure. */
GVFG_ENOTSUP = -5, /* Requested feature or format is not supported. */
GVFG_ETIMEOUT = -6 /* Timed out waiting for driver/backend work. */
GVFG_ETIMEOUT = -6, /* Timed out waiting for driver/backend work. */
GVFG_EBUSY = -7 /* Device or capture resource is currently busy. */
};
/* Positive return values are unmodified GigabyteLib GVFG_HRESULT values. */
typedef enum
{
GVFG_PIXFMT_UNKNOWN = 0,
@@ -192,7 +191,7 @@ extern "C"
int height; /* Signal height in pixels when connected. */
int pixel_format; /* gvfg_pixel_format_t value for the actual DMA payload. */
int bit_depth; /* Signal bit depth derived from the payload format. */
int video_interface; /* gvfg_video_interface_t reported by GigabyteLib. */
int video_interface; /* gvfg_video_interface_t reported by the capture backend. */
} gvfg_signal_status_t;
typedef struct
@@ -326,7 +325,8 @@ extern "C"
* - GVFG_OK on success.
* - GVFG_EINVAL if handle is NULL or channel_index is invalid.
* - GVFG_ENODEV if the device cannot be opened.
* - A positive, unmodified GVFG_HRESULT for GigabyteLib failures.
* - GVFG_EBUSY if the device or capture resource is already in use.
* - GVFG_EIO for other capture backend failures.
*/
GVFG_API gvfg_status_t gvfg_open_channel(
GVFG_PARAM_IN gvfg_handle handle,
@@ -415,7 +415,8 @@ extern "C"
* - GVFG_ESTATE if capture is not running or a previous frame has not been
* released.
* - GVFG_ETIMEOUT if no frame is ready before timeout_ms expires.
* - A positive, unmodified GVFG_HRESULT for GigabyteLib failures.
* - GVFG_EBUSY if the device or capture resource is busy.
* - GVFG_EIO for other capture backend failures.
*
* In copy mode the returned data pointer is owned by the SDK. In zero-copy
* mode it points to driver-owned memory. In both modes it remains valid
@@ -570,7 +571,7 @@ extern "C"
*
* No input signal is a normal state: the function returns GVFG_OK with
* out_status->connected set to 0. Before capture starts, this function
* refreshes the status from GigabyteLib. While capture is running, it returns
* refreshes the status from the capture backend. While capture is running, it returns
* the SDK cache; format-change, input-plug and input-unplug processing updates
* that cache before the corresponding public event is queued.
*/
@@ -630,7 +631,7 @@ extern "C"
/*
* Copy the most recent SDK-owned detailed fault or rejected API call for
* one channel. Positive GigabyteLib results and normal timeouts are not stored.
* one channel. Backend implementation details and normal timeouts are not stored.
* A successful gvfg_start_channel() begins a new diagnostic lifetime.
*/
GVFG_API gvfg_status_t gvfg_get_channel_last_sdk_error_detail(
+3
View File
@@ -30,6 +30,9 @@ typedef struct
double get_frame_timing_average_us;
double get_frame_timing_max300_us;
double get_frame_timing_max_us;
int32_t last_vendor_error_code;
char last_vendor_api[64];
char last_vendor_error_name[64];
} gvfg_debug_backend_stats_t;
/*
File diff suppressed because it is too large Load Diff
@@ -75,7 +75,7 @@ namespace gvfg::internal
gvfg_status_t wait_for_recovery(uint32_t timeoutMs);
gvfg_status_t refresh_video_info();
gvfg_status_t refresh_audio_info();
static gvfg_status_t from_vendor(GVFG_HRESULT result);
gvfg_status_t from_vendor(GVFG_HRESULT result, const char *apiName);
gvfg_status_t reject(gvfg_status_t status, const char *message) const;
void record_get_frame_timing(double elapsedUs);
@@ -89,6 +89,8 @@ namespace gvfg::internal
bool events_created_ = false;
bool channel_open_ = false;
bool video_info_valid_ = false;
bool format_change_pending_ = false;
gvfg_pixel_format_t requested_video_format_ = GVFG_PIXFMT_UNKNOWN;
bool audio_info_valid_ = false;
gvfg_signal_status_t cached_signal_{};
GVFG_VIDEO_INFO video_info_{};
+3 -15
View File
@@ -1263,22 +1263,10 @@ extern "C"
return "Not supported";
case GVFG_ETIMEOUT:
return "Timeout";
case GVFG_HRESULT_ERROR:
return "GVFG_HRESULT_ERROR";
case GVFG_HRESULT_DEV_ERROR:
return "GVFG_HRESULT_DEV_ERROR";
case GVFG_HRESULT_DEV_BUSY:
return "GVFG_HRESULT_DEV_BUSY";
case GVFG_HRESULT_VIDEO_CHN_ERROR:
return "GVFG_HRESULT_VIDEO_CHN_ERROR";
case GVFG_HRESULT_CONTEXT_ERROR:
return "GVFG_HRESULT_CONTEXT_ERROR";
case GVFG_HRESULT_VIDEO_CHN_INVALID:
return "GVFG_HRESULT_VIDEO_CHN_INVALID";
case GVFG_HRESULT_API_ERROR:
return "GVFG_HRESULT_API_ERROR";
case GVFG_EBUSY:
return "Device busy";
default:
return status > 0 ? "GVFG_HRESULT_UNKNOWN" : "Unknown";
return "Unknown";
}
}
+26
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <utility>
@@ -9,16 +10,34 @@ namespace gvfg::internal
class ChannelErrorState final
{
public:
struct VendorDetail
{
int32_t code = 0;
std::string api;
std::string name;
};
void set(std::string message)
{
std::lock_guard<std::mutex> lock(mutex_);
message_ = std::move(message);
vendor_detail_ = {};
}
void set_vendor(std::string message, int32_t code, std::string api, std::string name)
{
std::lock_guard<std::mutex> lock(mutex_);
message_ = std::move(message);
vendor_detail_.code = code;
vendor_detail_.api = std::move(api);
vendor_detail_.name = std::move(name);
}
void clear()
{
std::lock_guard<std::mutex> lock(mutex_);
message_.clear();
vendor_detail_ = {};
}
std::string message() const
@@ -27,8 +46,15 @@ namespace gvfg::internal
return message_;
}
VendorDetail vendor_detail() const
{
std::lock_guard<std::mutex> lock(mutex_);
return vendor_detail_;
}
private:
mutable std::mutex mutex_;
std::string message_;
VendorDetail vendor_detail_;
};
}
Binary file not shown.
+21 -1
View File
@@ -1,3 +1,23 @@
/*++
Copyright (C) Gigabyte, All Rights Reserved
Module Name:
gvfgframework.h
Abstract:
This module contains the type definitions for Gigabyte VFG100 SDK
Environment:
Windows Win32
--*/
#ifndef __GVFG_SDK_FRAMEWORK_H__
#define __GVFG_SDK_FRAMEWORK_H__
@@ -9,7 +29,7 @@ extern "C" {
#define GVFG_PARAM_OUT
#define GVFG_SDK_API
#define GVFG_SDK_VER "1.0.2"
#define GVFG_SDK_VER "1.0.3"
#ifdef __cplusplus
+540 -50
View File
@@ -1,3 +1,23 @@
/*++
Copyright (C) Gigabyte, All Rights Reserved
Module Name:
gvfgsdkapi.h
Abstract:
This module contains the type, structure and function definitions
for Gigabyte video frame grabber SDK.
Environment:
Windows Win32
--*/
#ifndef __GVFG_SDK_API_H__
#define __GVFG_SDK_API_H__
@@ -7,12 +27,23 @@ extern "C" {
#include <windows.h>
#include "gvfgframework.h"
/* Interface ID Declarations.
* This is the interface GUID used to enumerate GVFG100 device(s).
* SetupDiGetClassDevs(...) and SetupDiEnumDeviceInterfaces(...) are
* Win32 APIs used to enumeate devices.
*/
#define GUID_DEVINTERFACE_GVFG100 \
{0x8c47b9c3, 0x1faa, 0x4557, {0xbc, 0x1d, 0xf2, 0x25, 0xd2, 0x6c, 0x9e, 0x91}}
// Per device context, this is a data abstraction used by the SDK API.
typedef struct _GVFG_CONTEXT GVFG_CONTEXT, *PGVFG_CONTEXT;
// SDK API return code.
typedef enum GVFG_HRESULT {
@@ -27,16 +58,39 @@ typedef enum GVFG_HRESULT {
} GVFG_HRESULT;
/* GvfgSetVideoColorDepth(...) colorDepth parameter.
*
* It is used to set the color bit depth of video.
* 8 bits has YUY2 color space.
* 10 bits has Y210 color spcae.
*
*/
#define GVFG_VIDEO_COLOR_DEPTH_8_BITS (8)
#define GVFG_VIDEO_COLOR_DEPTH_10_BITS (10)
// GVFG_VIDEO_INFO.VideoInterface values
#define GVFG_VIDEO_INTERFACE_SDI (0)
#define GVFG_VIDEO_INTERFACE_HDMI (1)
#define GVFG_VIDEO_FRAME_BUF_COPY ((ULONG)0x1)
#define GVFG_VIDEO_FRAME_ZERO_COPY ((ULONG)0x2)
/* GvfgOpenDev(...) AVMemMode parameter.
*
* Frame data passed from driver to application can
* be in two modes:
* a. data copy to user provided buffer
* b. data memory pointer
*
* Audio frame supports user buffer copy at this time.
*/
#define GVFG_VIDEO_FRAME_BUF_COPY ((ULONG)0x1) // data copied to user provided buffer
#define GVFG_VIDEO_FRAME_ZERO_COPY ((ULONG)0x2) // pass memory pointer to user
#define GVFG_AUDIO_FRAME_BUF_COPY ((ULONG)0x4)
#define GVFG_AV_FRAME_MEM_MODE_DEFAULT ((ULONG)0xFF)
#define GVFG_AV_FRAME_MEM_MODE_DEFAULT ((ULONG)0xFF) // video and audio frame are user buffers copy.
#define GVFG_MAKEFOURCC(ch0, ch1, ch2, ch3) \
@@ -46,62 +100,108 @@ typedef enum GVFG_HRESULT {
((ULONG)(UCHAR)(ch3) << 24))
/* GvfgGetDevInfo(...) parameter.
*
* Device information
*/
typedef struct _GVFG_DEV_INFO {
UINT16 NumVideoChn; // number of video channel.
// VFG 100 SDI model is fixed at 1
// VFG 100 HDMI mode is fixed at 1
// VFG 100 HDMI model is fixed at 1
UINT16 HasAudio; // VFG100 has audio channel
// 0: no audio channels
// 1: has audio channels
} GVFG_DEV_INFO, *PGVFG_DEV_INFO;
/* GvfgGetVideoInfo(...) pDevInfo parameter.
*
* video frame information.
*/
typedef struct _GVFG_VIDEO_INFO {
UINT32 Fourcc; // color format, makefourcc('Y210') or makefourcc('YUY2')
UINT32 Width;
UINT32 Height;
UINT32 cbBufSize; // buffer size is calcuated from width,
// height and color format
UINT32 Fourcc; // color format:
// 8 bits color space: makefourcc('Y','2','1',0')
// 10 bits color space: makefourcc('Y','U','Y','2')
UINT32 Width; // pixels
UINT32 Height; // pixels
UINT32 cbBufSize; // buffer size: number of bytes.
// Calcuated from width, height and color format.
UINT32 VideoInterface; // GVFG_VIDEO_INTERFACE_XXX
UINT32 VideoSignalLock;
UINT64 FrameCount;
UINT32 VideoSignalLock; // 0: no video signal lock
// 1: video signal lock
UINT64 FrameCount; // Driver keeps track of the video frame count.
// This is for book-keeping purpose.
} GVFG_VIDEO_INFO, *PGVFG_VIDEO_INFO;
/* GvfgGetAudioInfo(...) pAudioInfo parameter.
*
* video frame information.
*/
typedef struct _GVFG_AUDIO_INFO {
UINT16 Channels; // 2, stero sound
UINT16 SamplesPerSec; // 48000
UINT16 BitsPerSample; // 16, sample data size in bit, sign integer
UINT16 FramesPerSec; // 100, number audio frames in 1 second
UINT32 cbBufSize; // audio frame in bytes. fixed at 1920
UINT64 FrameCount;
UINT16 Channels; // number of audio channels.
// Fixed at 2 for stero sound
UINT16 SamplesPerSec; // Sampling rate.
// Fixed at 48000
UINT16 BitsPerSample; // Sampling data size in bit in sign integer.
// Fixed at 16
UINT16 FramesPerSec; // Number audio frames in 1 second.
// Fixed at 1000
UINT32 cbBufSize; // buffer size: number of bytes.
// fixed at 1920
UINT64 FrameCount; // Driver keeps track of the video frame count.
// This is for book-keeping purpose.
} GVFG_AUDIO_INFO, *PGVFG_AUDIO_INFO;
/* GvfgCreateEvents(...) and GvfgOpenVideoChn(...) pEvents parameter.
*
* Events notify handles.
* Driver notifies user about an event.
* User should use WIN32 API WaitForSingleObject(...) or WaitForMultipleObjects(...)
* to wait for events.
*/
typedef struct _GVFG_VIDEO_CHN_EVENT {
HANDLE hVideoFrameInEvent;
HANDLE hAudioFrameInEvent;
HANDLE hVideoFormatChangedEvent;
HANDLE hVideoInputPluginEvent;
HANDLE hVideoInputUnplugEvent;
HANDLE hVideoExtraFrame;
HANDLE hAudioExtraFrame;
HANDLE hVideoFrameInEvent; // new video frame arrvied
HANDLE hAudioFrameInEvent; // new audio frame arrived
HANDLE hVideoFormatChangedEvent; // video color space changed.
// This is triggered when
// changing video color space.
HANDLE hVideoInputPluginEvent; // Video cable is plugged in
HANDLE hVideoInputUnplugEvent; // video cable is unplug.
HANDLE hVideoExtraFrame; // Extra video frame is queued in the driver
HANDLE hAudioExtraFrame; // Extra audio frame is queued in the driver.
} GVFG_VIDEO_CHN_EVENT, *PGVFG_VIDEO_CHN_EVENT;
// SDI Video input signal information.
// SDI ST352 Video input signal information.
#define GVFG_SDI_MODE_HD 0
#define GVFG_SDI_MODE_SD 1
@@ -167,81 +267,471 @@ typedef struct _GVFG_SDI_VIDEO_INFO_STR {
char St352PayloadByte3BitDepth[24];
} GVFG_SDI_VIDEO_INFO_STR, *PGVFG_SDI_VIDEO_INFO_STR;
/*********************************************************************
* FUNCTION: Create events notify handles.
* PURPOSE: Driver uses these handles to notify user active events.
* PARAMS: pEvents - User allocates GVFG_VIDEO_CHN_EVENT.
* audioDisable - disable audio frame data event notifier
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgCreateEvents(GVFG_PARAM_IN PGVFG_VIDEO_CHN_EVENT pEvents,
GVFG_PARAM_IN BOOL audioDisable);
/*********************************************************************
* FUNCTION: Delete events notify handles.
* PURPOSE: When events are no longer needed, user should destroy them.
* PARAMS: pEvents - created by the GvfgCreateEvents(...)
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgDestroyEvents(GVFG_PARAM_IN PGVFG_VIDEO_CHN_EVENT pEvents);
GVFG_SDK_API GVFG_HRESULT GvfgOpenDev(GVFG_PARAM_IN HANDLE hDev,
GVFG_PARAM_IN PGVFG_CONTEXT *pCxt,
GVFG_PARAM_IN ULONG AVMemMode);
/*********************************************************************
* FUNCTION: Reset events notify handles.
* PURPOSE: When events need to be clean/reset to the waiting state
* PARAMS: pEvents - created by the GvfgCreateEvents(...)
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgResetEvents(GVFG_PARAM_IN PGVFG_VIDEO_CHN_EVENT pEvents);
/*********************************************************************
* FUNCTION: Open Gigabyte video frame grabber.
* This should be the first function to call to setup the device.
*
* PURPOSE: Setup Gigabyte video frame grabber and create device context.
*
* PARAMS: hDev - this is the device handler created by WIN32 API CreateFileA(...)
* It is user's responsibility to enumerate Gigabyte device by using
* GUID.
* pCxt - Gigabyte device context.
* user should use a POINTER only, PGVFG_CONTEXT(pointer),
* and pass in its address (double pointer).
*
* AVMemMode - decides how video and audio frame data are passed to user.
* User can supply user space buffer for data copy or
* access driver's memory space (as a pointer).
*
* Logical OR of
* GVFG_VIDEO_FRAME_ZERO_COPY/ GVFG_VIDEO_FRAME_BUF_COPY and
* GVFG_AUDIO_FRAME_BUF_COPY.
*
* Example: 1. GVFG_VIDEO_FRAME_ZERO_COPY | GVFG_AUDIO_FRAME_BUF_COPY
* 2. GVFG_VIDEO_FRAME_BUF_COPY | GVFG_AUDIO_FRAME_BUF_COPY
* 3. GVFG_AV_FRAME_MEM_MODE_DEFAULT
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgOpenDev(GVFG_PARAM_IN HANDLE hDev,
GVFG_PARAM_OUT PGVFG_CONTEXT *pCxt,
GVFG_PARAM_IN ULONG AVMemMode);
/*********************************************************************
* FUNCTION: Close Gigabyte video frame grabber.
*
*
* PURPOSE: Deactivate Gigabyte video frame grabber and destory device context.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgCloseDev(GVFG_PARAM_IN PGVFG_CONTEXT *pCxt);
/*********************************************************************
* FUNCTION: Get Gigabyte device information.
*
*
* PURPOSE: Get number of video channels and audio function state.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* pDevInfo - device information.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetDevInfo(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_OUT PGVFG_DEV_INFO pDevInfo);
/*********************************************************************
* FUNCTION: Open a video channel.
*
*
* PURPOSE: Activate video channel and register events.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* videoChn - video channel index, counting from 0.
* This should always < GVFG_DEV_INFO.NumVideoChn.
*
* pEvents - events handler.
* Created by GvfgCreateEvents(...)
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgOpenVideoChn(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_IN PGVFG_VIDEO_CHN_EVENT pEvents);
/*********************************************************************
* FUNCTION: Close a video channel.
*
*
* PURPOSE: Deactivate a video channel and un-registers events when opening the video channel.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index, counting from 0.
* This should always < GVFG_DEV_INFO.NumVideoChn.
*
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgCloseVideoChn(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn);
/*********************************************************************
* FUNCTION: Get S352 SDI video interface information.
*
*
* PURPOSE: SDI standard (ST352) can provide video information within video stream.
* This is not a requirement. Some SDI video source does not implement this standard.
*
* If GVFG_SDI_VIDEO_INFO.St352Payload is 0, it is likely video
* source does not use ST352.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* pSdiInfo - SDI ST352 information.
*
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetSdiVideoInputInfo(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT PGVFG_SDI_VIDEO_INFO pSdiInfo);
/*********************************************************************
* FUNCTION: Pretty print and strigify S352 SDI video interface information,
* a helper function.
*
*
* PURPOSE: If user knows how to decode GVFG_SDI_VIDEO_INFO.St352Payload or wants to
* pretty print his own SDI information based on GvfgGetSdiVideoInputInfo(...),
* this function would not be usefull.
*
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* pSdiInfo - SDI ST352 information from GvfgGetSdiVideoInputInfo(...).
*
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgStringifySdiVideoInputInfo(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN PGVFG_SDI_VIDEO_INFO pSdiInfo,
GVFG_PARAM_OUT PGVFG_SDI_VIDEO_INFO_STR pSdiInfoStr);
/*********************************************************************
* FUNCTION: Get video channel property (widht, height, color space, interface and etc)
*
*
* PURPOSE: In order to use a video frame, some information is necessary.
* 1. color space (fourcc)
* 2. width
* 3. height
* 4. frame size
*
* A frame size can be calculated from width, height, and color space.
* Howerver, frame size is already calculated. User can double check it.
*
* NOTE: width and height are meaningful only when video input source is stable, i.e.
* signal lock.
*
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* pVideoInfo - video frame information.
*
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetVideoInfo(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT PGVFG_VIDEO_INFO pVideoInfo);
/*********************************************************************
* FUNCTION: Get PCM audio property.
*
*
* PURPOSE: In order to use a audio frame, some information is necessary.
* 1. sampling rate
* 2. sample size,
* 3. number of PCM channels.
* 4. frame size
*
* A frame size can be calculated from sampling rate, sample size, and
* number of audio channels.
*
* 2 channels, 48K sampling rate, signed 16 bits PCM format are supported.
*
* NOTE: Every single audio frame includes left and right channels and
* There are 100 audio frames per second.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* pAudioInfo - audio frame information.
*
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetAudioInfo(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT PGVFG_AUDIO_INFO pAudioInfo);
/*********************************************************************
* FUNCTION: Start capturing video and/or audio
*
*
* PURPOSE: Activate video/audio DMA.
* After GvfgOpenVideoChn(...), user should wait for video and audio events.
*
* NOTE: For 1080P@60, every video frame is around 16 ms. Depedning on the user application,
* user may take more than 16ms to process a video frame, hence the next frame may already
* be ready in the driver.
*
* User should also listen to
* 1. GVFG_VIDEO_CHN_EVENT.hVideoExtraFrame and
* 2. GVFG_VIDEO_CHN_EVENT.hAudioExtraFrame.
*
* And treat them as new video and audio frame event.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgStartCapture(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn);
/*********************************************************************
* FUNCTION: Stop capturing video and/or audio
*
*
* PURPOSE: Stop video and audio DMA.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...)
*
* videoChn - video channel index.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgStopCapture(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn);
/*********************************************************************
* FUNCTION: Get video frame data, user buffer copy mode.
*
* PURPOSE: Driver copy frame data to user buffer.
* User should allocate frame buffer based on the GvfgGetVideoInfo(...).
*
* NOTE: This function should only be called when GVFG_VIDEO_FRAME_BUF_COPY
* is used with GvfgOpenDev(...).
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* videoChn - video channel index.
*
* pBuf - user allocated buffer.
* cbBufSize - user allocated buffer size in bytes.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetVideoFrame(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT VOID *pBuf,
GVFG_PARAM_IN ULONG cbBufSize);
/*********************************************************************
* FUNCTION: Get video frame data, zero copy mode.
*
* PURPOSE: Driver allows user to access frame memory stored in kernel mode.
* Compared to user buffer copy mode, user passes a double pointer.
*
*
* NOTE: This function should only be called when GVFG_VIDEO_FRAME_ZERO_COPY
* is used with GvfgOpenDev(...).
*
* It is strongly recommended calling GvfgReleaseVideoFrameZeroCopy(...)
* to notify driver that a frame is done processing by the user.
*
* DO NOT double-release as driver may get confused.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* videoChn - video channel index.
*
* pBuf - user pointer (double pointer) to access kernel memory.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetVideoFrameZeroCopy(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT VOID **pBuf);
/*********************************************************************
* FUNCTION: Release a video frame, zero copy mode.
*
* PURPOSE: Notify driver that a zero copy frame is finished processing.
*
*
* NOTE: This function should only be called when GVFG_VIDEO_FRAME_ZERO_COPY
* is used with GvfgOpenDev(...) and GvfgGetVideoFrameZeroCopy(...) is called.
*
* DO NOT double-release as driver may get confused.
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* videoChn - video channel index.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgReleaseVideoFrameZeroCopy(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn);
/*********************************************************************
* FUNCTION: Get audio frame data, user buffer copy mode.
*
* PURPOSE: Driver copy frame data to user buffer.
* User should allocate frame buffer based on the GvfgGetAudioInfo(...).
*
* NOTE: This function should only be called when GVFG_AUDIO_FRAME_BUF_COPY
* is used with GvfgOpenDev(...) and audio is NOT disabled when calling
* GvfgCreateEvents(...).
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the GvfgOpenDev(...).
*
* videoChn - video channel index.
*
* pBuf - user allocated buffer.
* cbBufSize - user allocated buffer size in bytes.
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgGetAudioFrame(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_OUT VOID *pBuf,
GVFG_PARAM_IN ULONG cbBufSize);
/*********************************************************************
* FUNCTION: Set 8 bits or 10 bits 4:2:2 video data color space.
*
* PURPOSE: 8 bits (YUY2) is the default video frame data color space.
* For vivid and detailed color scale, 10 bits (Y210) can be selected.
*
* Please note Y210 required twice the bandwidth compared to YUY2.
*
*
* NOTE: This function should only be called after calling GvfgOpenVideoChn(...)
* and video/audio is not capturing.
*
* GVFG_VIDEO_CHN_EVENT.hVideoFormatChangedEvent will be triggered if
* color space is changed successfully.
*
*
* PARAMS: pCxt - Gigabyte device context.
* Device context created by the
*
* videoChn - video channel index.
*
* colorDepth - Set 8 or 10 bits color space.
* 1. GVFG_VIDEO_COLOR_DEPTH_8_BITS
* 2. GVFG_VIDEO_COLOR_DEPTH_10_BITS
*
* RETURNS: GVFG_HRESULT_OK: success.
* other: failure.
*
*********************************************************************/
GVFG_SDK_API GVFG_HRESULT GvfgSetVideoColorDepth(GVFG_PARAM_IN PGVFG_CONTEXT pCxt,
GVFG_PARAM_IN ULONG videoChn,
GVFG_PARAM_IN ULONG colorDepth);