Match the GigabyteLib event model
Compared with 82933f8:
- remove the public event-mask setter, getter, mask type, exports, and per-channel mask state
- always register and forward the complete event set created by GvfgCreateEvents
- keep audio enablement as the only event-creation choice exposed to applications
- preserve event polling, signal recovery, format notifications, capture, format switching, zero-copy, and register access
- update customer and architecture documentation to remove the obsolete event-mask controls
This commit is contained in:
@@ -5,8 +5,6 @@ EXPORTS
|
||||
gvfg_create
|
||||
gvfg_destroy
|
||||
gvfg_open_channel
|
||||
gvfg_set_channel_event_mask
|
||||
gvfg_get_channel_event_mask
|
||||
gvfg_set_channel_zero_copy_enabled
|
||||
gvfg_get_channel_zero_copy_enabled
|
||||
gvfg_set_channel_video_format
|
||||
|
||||
@@ -231,16 +231,6 @@ extern "C"
|
||||
GVFG_EVENT_FORMAT_CHANGE_BEGIN = 4
|
||||
} gvfg_event_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GVFG_EVENT_MASK_NONE = 0,
|
||||
GVFG_EVENT_MASK_SIGNAL_CONNECTED = 1u << 0,
|
||||
GVFG_EVENT_MASK_SIGNAL_DISCONNECTED = 1u << 1,
|
||||
GVFG_EVENT_MASK_STREAM_READY = 1u << 2,
|
||||
GVFG_EVENT_MASK_FORMAT_CHANGE_BEGIN = 1u << 3,
|
||||
GVFG_EVENT_MASK_ALL = (1u << 4) - 1u
|
||||
} gvfg_event_mask_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Set to sizeof(gvfg_event_t) before calling gvfg_poll_channel_event(). */
|
||||
@@ -321,22 +311,6 @@ extern "C"
|
||||
_In_ int device_index,
|
||||
_In_ int channel_index);
|
||||
|
||||
/*
|
||||
* Select events for one channel before gvfg_open_channel(). VIDEO_DMA is
|
||||
* always registered because frame capture requires it. Disabling plug,
|
||||
* unplug, or format-change events also disables the corresponding automatic
|
||||
* signal/format recovery path.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_set_channel_event_mask(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ int channel_index,
|
||||
_In_ uint32_t event_mask);
|
||||
|
||||
GVFG_API gvfg_status_t gvfg_get_channel_event_mask(
|
||||
_In_ gvfg_handle handle,
|
||||
_In_ int channel_index,
|
||||
_Out_ uint32_t *out_event_mask);
|
||||
|
||||
/*
|
||||
* A handle may open both channels of the same device. The first call opens
|
||||
* the Windows device; the second channel shares that device connection and
|
||||
|
||||
@@ -305,12 +305,11 @@ gvfg_status_t GigabyteCaptureSession::get_audio_format(GigabyteAudioInfo &out) c
|
||||
}
|
||||
|
||||
gvfg_status_t GigabyteCaptureSession::set_event_callback(
|
||||
GigabyteEventCallback callback, void *user, uint32_t eventMask)
|
||||
GigabyteEventCallback callback, void *user)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
event_callback_ = callback;
|
||||
event_callback_user_ = user;
|
||||
event_mask_filter_ = eventMask;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -590,12 +589,7 @@ void GigabyteCaptureSession::event_thread_proc()
|
||||
void GigabyteCaptureSession::emit_event(gvfg_event_type_t type) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
uint32_t bit = 0;
|
||||
if (type == GVFG_EVENT_SIGNAL_CONNECTED) bit = GVFG_EVENT_MASK_SIGNAL_CONNECTED;
|
||||
if (type == GVFG_EVENT_SIGNAL_DISCONNECTED) bit = GVFG_EVENT_MASK_SIGNAL_DISCONNECTED;
|
||||
if (type == GVFG_EVENT_STREAM_READY) bit = GVFG_EVENT_MASK_STREAM_READY;
|
||||
if (type == GVFG_EVENT_FORMAT_CHANGE_BEGIN) bit = GVFG_EVENT_MASK_FORMAT_CHANGE_BEGIN;
|
||||
if (event_callback_ && (event_mask_filter_ & bit) != 0)
|
||||
if (event_callback_)
|
||||
event_callback_(type, event_callback_user_);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace gvfg::internal
|
||||
gvfg_status_t get_device_capabilities(gvfg_device_capabilities_t &out) const;
|
||||
gvfg_status_t get_sdi_info(gvfg_sdi_info_t &out) const;
|
||||
gvfg_status_t get_audio_format(GigabyteAudioInfo &out) const;
|
||||
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user, uint32_t eventMask);
|
||||
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user);
|
||||
gvfg_status_t configure_stream();
|
||||
gvfg_status_t start_stream();
|
||||
gvfg_status_t stop_stream();
|
||||
@@ -96,7 +96,6 @@ namespace gvfg::internal
|
||||
mutable std::mutex callback_mutex_;
|
||||
GigabyteEventCallback event_callback_ = nullptr;
|
||||
void *event_callback_user_ = nullptr;
|
||||
uint32_t event_mask_filter_ = GVFG_EVENT_MASK_ALL;
|
||||
mutable std::mutex state_mutex_;
|
||||
std::vector<uint8_t> copy_buffer_;
|
||||
bool frame_held_ = false;
|
||||
|
||||
@@ -237,7 +237,7 @@ struct gvfg_channel_session_t
|
||||
stop();
|
||||
if (session)
|
||||
{
|
||||
session->set_event_callback(nullptr, nullptr, 0);
|
||||
session->set_event_callback(nullptr, nullptr);
|
||||
session->close();
|
||||
session.reset();
|
||||
}
|
||||
@@ -285,8 +285,7 @@ struct gvfg_channel_session_t
|
||||
if (!session)
|
||||
return;
|
||||
session->set_event_callback(&gvfg_channel_session_t::onSessionEvent,
|
||||
this,
|
||||
eventMask);
|
||||
this);
|
||||
}
|
||||
|
||||
static void onSessionEvent(gvfg_event_type_t event, void *user)
|
||||
@@ -746,7 +745,6 @@ struct gvfg_channel_session_t
|
||||
uint32_t selectedChannel = GVFG_CHANNEL_0;
|
||||
bool zeroCopyRequested = false;
|
||||
bool audioEnabled = false;
|
||||
uint32_t eventMask = GVFG_EVENT_MASK_ALL;
|
||||
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
@@ -845,7 +843,6 @@ struct gvfg_handle_t
|
||||
|
||||
auto channel = std::make_unique<gvfg_channel_session_t>(channelErrors[slot]);
|
||||
channel->zeroCopyRequested = zeroCopyRequested[slot];
|
||||
channel->eventMask = eventMasks[slot];
|
||||
|
||||
const gvfg_status_t status = channel->open(index,
|
||||
channelIndex,
|
||||
@@ -875,27 +872,6 @@ struct gvfg_handle_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t setChannelEventMask(int channelIndex, uint32_t eventMask)
|
||||
{
|
||||
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
|
||||
return GVFG_EINVAL;
|
||||
if ((eventMask & ~static_cast<uint32_t>(GVFG_EVENT_MASK_ALL)) != 0)
|
||||
{
|
||||
channelErrors[static_cast<size_t>(channelIndex)].set(
|
||||
"gvfg_set_channel_event_mask rejected: event mask contains unsupported bits");
|
||||
return GVFG_EINVAL;
|
||||
}
|
||||
const size_t slot = static_cast<size_t>(channelIndex);
|
||||
if (channels[slot])
|
||||
{
|
||||
channelErrors[slot].set(
|
||||
"gvfg_set_channel_event_mask rejected: channel is already open");
|
||||
return GVFG_ESTATE;
|
||||
}
|
||||
eventMasks[slot] = eventMask;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t setChannelVideoFormat(int channelIndex, gvfg_pixel_format_t format)
|
||||
{
|
||||
gvfg_channel_session_t *channel = findChannel(channelIndex);
|
||||
@@ -951,7 +927,6 @@ struct gvfg_handle_t
|
||||
std::array<ChannelErrorState, 2> channelErrors;
|
||||
std::wstring devicePath;
|
||||
std::array<std::unique_ptr<gvfg_channel_session_t>, 2> channels;
|
||||
std::array<uint32_t, 2> eventMasks{GVFG_EVENT_MASK_ALL, GVFG_EVENT_MASK_ALL};
|
||||
int currentIndex = -1;
|
||||
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||
std::array<gvfg_pixel_format_t, 2> requestedFormats{GVFG_PIXFMT_YUY2, GVFG_PIXFMT_YUY2};
|
||||
@@ -1017,26 +992,6 @@ extern "C"
|
||||
return handle->openChannel(device_index, channel_index);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_event_mask(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint32_t event_mask)
|
||||
{
|
||||
if (!handle)
|
||||
return GVFG_EINVAL;
|
||||
return handle->setChannelEventMask(channel_index, event_mask);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_get_channel_event_mask(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint32_t *out_event_mask)
|
||||
{
|
||||
if (!handle || !out_event_mask ||
|
||||
(channel_index != GVFG_CHANNEL_0 && channel_index != GVFG_CHANNEL_1))
|
||||
return GVFG_EINVAL;
|
||||
*out_event_mask = handle->eventMasks[static_cast<size_t>(channel_index)];
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_zero_copy_enabled(gvfg_handle handle,
|
||||
int channel_index,
|
||||
int enabled)
|
||||
|
||||
@@ -201,9 +201,6 @@ audio API 不是 zero-copy,但上層仍使用和 video 相同的 read/release
|
||||
channel 選擇的模式。
|
||||
- `gvfg_open_channel(handle, device_index, channel)`:開啟列舉所得裝置,channel
|
||||
必須為 `GVFG_CHANNEL_0` 或 `GVFG_CHANNEL_1`。
|
||||
- `gvfg_set_channel_event_mask(handle, channel, mask)`:在 open 前設定指定 channel
|
||||
要註冊及通知的事件;預設 `GVFG_EVENT_MASK_ALL`。DMA event 為擷取必要項目,
|
||||
不受 mask 控制。
|
||||
- `gvfg_start_channel(handle, channel)`:開始指定 channel 擷取。若目前無訊號,成功進入訊號監看模式;此時
|
||||
frame read 會 timeout,訊號接上後 SDK 會自動開始擷取。
|
||||
- `gvfg_stop(handle)`:停止擷取;重複呼叫仍回傳成功。
|
||||
|
||||
@@ -168,9 +168,8 @@ delivery timing,不是 driver 或硬體 capture timestamp。
|
||||
`gvfg_event_t` 是 `gvfg_poll_channel_event()` 的輸出。呼叫前將結構清零並把
|
||||
`struct_size` 設為 `sizeof(gvfg_event_t)`。`type` 是上述事件型別。
|
||||
|
||||
`gvfg_event_mask_t` 提供對應的 `GVFG_EVENT_MASK_*` bit,可在 channel open 前用
|
||||
`gvfg_set_channel_event_mask()` 組合。預設為 `GVFG_EVENT_MASK_ALL`;mask 為 0
|
||||
表示不註冊選用的 plug/unplug/format-change driver event,也不送出 SDK 衍生事件。
|
||||
GigabyteLib 會建立並註冊完整的 channel event 集合;使用者直接透過
|
||||
`gvfg_poll_channel_event()` 接收,不另外設定 event mask。
|
||||
|
||||
### 1.12 `gvfg_handle`
|
||||
|
||||
@@ -232,22 +231,6 @@ gvfg_status_t gvfg_open_channel(gvfg_handle handle,
|
||||
對同一 handle 可分別 open CH0、CH1;第二個 channel 共用同一個 Windows device
|
||||
handle,但擁有獨立 backend stream 狀態。已開啟 channel 時不可切換 device index。
|
||||
|
||||
### 1.17 `gvfg_set_channel_event_mask`/`gvfg_get_channel_event_mask`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_set_channel_event_mask(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint32_t event_mask);
|
||||
gvfg_status_t gvfg_get_channel_event_mask(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint32_t *out_event_mask);
|
||||
```
|
||||
|
||||
- `set` 必須在指定 channel open 前呼叫。
|
||||
- `event_mask` 只能包含 `GVFG_EVENT_MASK_*`;預設為 `GVFG_EVENT_MASK_ALL`。
|
||||
- VIDEO_DMA 是擷取必要事件,不受此 mask 控制。
|
||||
- 關閉 plug/unplug/format-change event 也會停用對應的自動 recovery。
|
||||
|
||||
### 1.18 Zero-copy mode selection
|
||||
|
||||
```c
|
||||
|
||||
@@ -41,7 +41,6 @@ frame ownership 與 timeout 契約,不再直接操作 driver IOCTL 或 FPGA re
|
||||
| `deviceConnection` | CH0、CH1 共用的 Windows device connection |
|
||||
| `channels[2]` | CH0、CH1 facade session;未 open 時為 null |
|
||||
| `channelErrors[2]` | 每條 channel 最近一次詳細錯誤 |
|
||||
| `eventMasks[2]` | open 前設定的 channel event mask |
|
||||
| `currentIndex` | 此 handle 已綁定的 device index;`-1` 表示尚未綁定 |
|
||||
| `zeroCopyRequested[2]` | 各 channel open 前獨立選擇的 delivery mode |
|
||||
|
||||
|
||||
@@ -120,11 +120,6 @@ struct gvfg_handle_t
|
||||
2
|
||||
> channels;
|
||||
|
||||
std::array<uint32_t, 2> eventMasks{
|
||||
GVFG_EVENT_MASK_ALL,
|
||||
GVFG_EVENT_MASK_ALL
|
||||
};
|
||||
|
||||
int currentIndex = -1;
|
||||
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||
};
|
||||
@@ -212,8 +207,6 @@ struct gvfg_channel_session_t
|
||||
int currentIndex;
|
||||
uint32_t selectedChannel;
|
||||
bool zeroCopyRequested;
|
||||
uint32_t eventMask;
|
||||
|
||||
std::atomic<bool> running;
|
||||
bool readInProgress;
|
||||
bool frameHeld;
|
||||
|
||||
Reference in New Issue
Block a user