Consolidate playback APIs and add standalone OSD bitmap rendering
- move public PCM, image and presentation types into gvfg_playback.h and remove the separate backend headers from source and installation - keep WASAPI and D3D backends private while preserving the existing public type names, fields and static backend integration - move detailed preview delivery counters into a private header and expose their playback query only through the Debug diagnostics API - retain public preview information and basic presentation statistics, mark EQUEUE_FULL as reserved, and document capacity limits as advanced settings with recommended defaults - refresh customer guides, API reference and error handling for the single-header interface, presentation counter limits and EAUDIO handle-recreation policy - add SDK-owned standalone premultiplied BGRA text rendering with transparent backgrounds, measured dimensions, thread-local snapshot lifetime and validated output bounds Validation: git diff --cached --check passed. Release gvfg_playback and Customer Sample builds, standalone C/C++ header checks, Debug playback syntax checks and Release export inspection passed earlier in this session. Final follow-up changes affect comments and documentation only. No runtime or hardware playback validation was performed. The existing Release gvfg target was also checked and was up to date. OSD rendering changes were source-reviewed; no new bitmap or hardware test was run in this commit pass. Capture debug exports are unchanged.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -1214,6 +1215,59 @@ extern "C"
|
||||
catch (...) { return GVFG_EIO; }
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_render_osd_bgra(const gvfg_channel_osd_config_t *config,
|
||||
gvfg_osd_bitmap_t *out_bitmap)
|
||||
{
|
||||
thread_local std::vector<uint8_t> pixels;
|
||||
pixels.clear();
|
||||
if (out_bitmap) *out_bitmap = {};
|
||||
if (!config || !config->text || !out_bitmap)
|
||||
return GVFG_EINVAL;
|
||||
const size_t length = strnlen_s(config->text, GVFG_OSD_MAX_TEXT_CHARACTERS + 1u);
|
||||
if (length == 0 || length > GVFG_OSD_MAX_TEXT_CHARACTERS)
|
||||
return GVFG_EINVAL;
|
||||
try
|
||||
{
|
||||
gvfg_osd_handle rawHandle = nullptr;
|
||||
if (gvfg_osd_create(&rawHandle) != GVFG_OSD_OK)
|
||||
return GVFG_EIO;
|
||||
const std::unique_ptr<void, decltype(&gvfg_osd_destroy)> helper(rawHandle, &gvfg_osd_destroy);
|
||||
uint32_t width = 0, height = 0;
|
||||
auto status = gvfg_osd_measure(helper.get(), config->text,
|
||||
static_cast<uint32_t>(length), config->font_size_px, config->font_family,
|
||||
&width, &height);
|
||||
if (status != GVFG_OSD_OK)
|
||||
return status == GVFG_OSD_EINVAL ? GVFG_EINVAL : GVFG_EIO;
|
||||
const uint64_t stride = static_cast<uint64_t>(width) * 4u;
|
||||
// WIC GetDataPointer reports its byte count as UINT.
|
||||
if (width > INT_MAX || height > INT_MAX || stride > UINT_MAX ||
|
||||
stride * height > UINT_MAX ||
|
||||
stride * height > (std::numeric_limits<size_t>::max)())
|
||||
return GVFG_EINVAL;
|
||||
pixels.resize(static_cast<size_t>(stride * height));
|
||||
gvfg_osd_config_t render{};
|
||||
render.struct_size = sizeof(render);
|
||||
render.width = width;
|
||||
render.height = height;
|
||||
render.text = config->text;
|
||||
render.font_family = config->font_family;
|
||||
render.text_length = static_cast<uint32_t>(length);
|
||||
render.font_size_px = config->font_size_px;
|
||||
render.color_rgb = config->color_rgb;
|
||||
status = gvfg_osd_render_bgra(helper.get(), &render, pixels.data(), pixels.size(),
|
||||
static_cast<uint32_t>(stride));
|
||||
if (status != GVFG_OSD_OK)
|
||||
return status == GVFG_OSD_EINVAL ? GVFG_EINVAL : GVFG_EIO;
|
||||
out_bitmap->data = pixels.data();
|
||||
out_bitmap->data_size = pixels.size();
|
||||
out_bitmap->width = width;
|
||||
out_bitmap->height = height;
|
||||
out_bitmap->stride = static_cast<uint32_t>(stride);
|
||||
return GVFG_OK;
|
||||
}
|
||||
catch (...) { return GVFG_EIO; }
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_osd(gvfg_handle handle, int channel_index,
|
||||
uint32_t osd_index, const gvfg_channel_osd_config_t *config)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user