Move capture safeguards into the SDK

Compared with 0fc22a1:

- normalize public pixel-format values and keep release diagnostics backend-neutral

- enforce the cross-channel Y210 constraint in the SDK and simplify the customer-facing contract
This commit is contained in:
Mark.lin
2026-09-22 14:29:52 +08:00
parent 0fc22a1646
commit 663804469f
10 changed files with 375 additions and 249 deletions
@@ -328,7 +328,7 @@ namespace gvfg::internal
}
gvfg_status_t GigabyteCaptureSession::get_device_capabilities(
gvfg_device_capabilities_t &out)
gvfg_debug_device_capabilities_t &out)
{
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
@@ -48,7 +48,7 @@ namespace gvfg::internal
gvfg_status_t set_video_format(gvfg_pixel_format_t format);
gvfg_status_t get_signal_status(gvfg_signal_status_t &out);
void get_cached_signal_status(gvfg_signal_status_t &out) const;
gvfg_status_t get_device_capabilities(gvfg_device_capabilities_t &out);
gvfg_status_t get_device_capabilities(gvfg_debug_device_capabilities_t &out);
gvfg_status_t get_sdi_info(gvfg_sdi_info_t &out);
gvfg_status_t get_audio_format(GigabyteAudioInfo &out);
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user);
@@ -15,7 +15,11 @@ using Microsoft::WRL::ComPtr;
static void d3d_preview_log_debug(const char *message)
{
#if GVFG_INTERNAL_DIAGNOSTICS
OutputDebugStringA(message ? message : "");
#else
(void)message;
#endif
}
static const char *ss_dxgi_format_name(DXGI_FORMAT fmt)
+35 -15
View File
@@ -885,7 +885,23 @@ struct gvfg_handle_t
return rejectChannel(channelIndex, GVFG_EINVAL,
"gvfg_set_channel_video_format rejected: pixel format is invalid");
return channel->setVideoFormat(format);
const size_t slot = static_cast<size_t>(channelIndex);
const size_t otherSlot = static_cast<size_t>(
channelIndex == GVFG_CHANNEL_0 ? GVFG_CHANNEL_1 : GVFG_CHANNEL_0);
std::lock_guard<std::mutex> lock(formatMutex);
if (format == GVFG_PIXFMT_Y210 &&
requestedVideoFormats[otherSlot] == GVFG_PIXFMT_Y210)
{
return rejectChannel(
channelIndex,
GVFG_EBUSY,
"gvfg_set_channel_video_format rejected: Y210 is already selected by the other channel");
}
const gvfg_status_t status = channel->setVideoFormat(format);
if (status == GVFG_OK)
requestedVideoFormats[slot] = format;
return status;
}
gvfg_status_t stopAll()
@@ -923,6 +939,9 @@ struct gvfg_handle_t
std::array<std::unique_ptr<gvfg_channel_session_t>, 2> channels;
int currentIndex = -1;
std::array<bool, 2> zeroCopyRequested{false, false};
std::mutex formatMutex;
std::array<gvfg_pixel_format_t, 2> requestedVideoFormats{
GVFG_PIXFMT_UNKNOWN, GVFG_PIXFMT_UNKNOWN};
};
extern "C"
@@ -1206,18 +1225,6 @@ extern "C"
"gvfg_get_channel_runtime_info rejected: channel is not open");
}
gvfg_status_t gvfg_get_device_capabilities(
gvfg_handle handle, gvfg_device_capabilities_t *out_capabilities)
{
if (!handle || !out_capabilities)
return GVFG_EINVAL;
gvfg_channel_session_t *channel = handle->findOpenChannel();
if (!channel || !channel->session)
return handle->rejectAllChannels(
GVFG_ESTATE, "gvfg_get_device_capabilities rejected: no channel is open");
return channel->session->get_device_capabilities(*out_capabilities);
}
gvfg_status_t gvfg_get_channel_sdi_info(
gvfg_handle handle, int channel_index, gvfg_sdi_info_t *out_info)
{
@@ -1281,8 +1288,8 @@ extern "C"
}
gvfg_status_t gvfg_debug_get_channel_backend_stats(gvfg_handle handle,
int channel_index,
gvfg_debug_backend_stats_t *out_stats)
int channel_index,
gvfg_debug_backend_stats_t *out_stats)
{
if (!handle || !out_stats)
return GVFG_EINVAL;
@@ -1299,6 +1306,19 @@ extern "C"
return GVFG_OK;
}
gvfg_status_t gvfg_debug_get_device_capabilities(
gvfg_handle handle, gvfg_debug_device_capabilities_t *out_capabilities)
{
if (!handle || !out_capabilities)
return GVFG_EINVAL;
gvfg_channel_session_t *channel = handle->findOpenChannel();
if (!channel || !channel->session)
return handle->rejectAllChannels(
GVFG_ESTATE,
"gvfg_debug_get_device_capabilities rejected: no channel is open");
return channel->session->get_device_capabilities(*out_capabilities);
}
gvfg_status_t gvfg_debug_read_register(gvfg_handle handle,
uint32_t offset,
uint32_t *out_value)