Files
GVFG_Standalone/GVFG_SDK/helpers/gvfg_playback/include/gvfg_playback.h
T
iverson3ya a47ab190bc Add HDMI audio input queries and split OSD into a helper in GVFG SDK 3.2
- Expose HDMI audio input information through the capture API and refresh the bundled Gigabyte library.
- Move OSD rendering into gvfg_osd.dll, connect channel OSD through the capture frame processor, and remove the experimental in-place zero-copy OSD path.
- Update playback integration, the customer API documentation, and the internal build guide.

Validation: git diff --cached --check passed. The MSVC Release SDK build passed. Capture hardware and runtime behavior were not tested.
2026-11-25 09:35:49 +08:00

175 lines
7.6 KiB
C

#pragma once
/* Unified playback API, exported by gvfg_playback.dll.
* Audio and preview backends are statically linked into this DLL.
* Capture remains application owned. Submissions COPY data before returning;
* the caller may immediately release its SDK frame. Handles own both outputs.
* Control calls (start/stop/reset/attach/destroy) must be serialized by the
* caller; one video producer and one audio producer may submit concurrently.
*/
#include <stdint.h>
/* Public audio, image and presentation types. Backends remain private. */
typedef struct
{
uint32_t sample_rate;
uint16_t channels;
uint16_t bits_per_sample; /* Signed interleaved PCM; must be 16. */
} gvfg_audio_playback_format_t;
typedef enum
{
GVFG_PREVIEW_PIXFMT_YUY2 = 1,
GVFG_PREVIEW_PIXFMT_Y210 = 2,
GVFG_PREVIEW_PIXFMT_GRAY16 = 4,
/* Four interleaved 16-bit UNORM components per pixel: R, G, B, A. */
GVFG_PREVIEW_PIXFMT_RGBA16 = 5,
/* DICOM native YBR_FULL_422: four 16-bit words per pixel pair,
* ordered Y0, Y1, Cb, Cr. Values are right-aligned to bit_depth. */
GVFG_PREVIEW_PIXFMT_DICOM_YBR_FULL_422 = 6
} gvfg_preview_pixel_format_t;
typedef struct
{
const void *data;
uint64_t data_size;
int width;
int height;
int pixel_format; /* gvfg_preview_pixel_format_t */
int bit_depth;
int row_bytes;
uint64_t frame_id;
} gvfg_preview_frame_t;
typedef struct
{
int active;
int width;
int height;
int bit_depth;
char pixel_format[32];
char adapter_name[160];
int adapter_index;
} gvfg_preview_info_t;
/*
* Preview presentation statistics.
*
* present_fps counts only frames accepted by DXGI Present, not physical
* scanout. The rate uses successful presents from the most recent five
* seconds. Pending preview replacements are excluded from this rate.
*/
typedef struct
{
double present_fps;
uint64_t presented_frames;
uint64_t skipped_presents;
} gvfg_preview_stats_t;
#ifdef _WIN32
#ifdef GVFG_PLAYBACK_BUILD
#define GVFG_PLAYBACK_API __declspec(dllexport)
#else
#define GVFG_PLAYBACK_API __declspec(dllimport)
#endif
#else
#define GVFG_PLAYBACK_API
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct gvfg_playback_t *gvfg_playback;
typedef enum {
GVFG_PLAYBACK_OK = 0,
GVFG_PLAYBACK_EINVAL = -1,
GVFG_PLAYBACK_ESTATE = -2,
GVFG_PLAYBACK_EOUTPUT = -3,
GVFG_PLAYBACK_EQUEUE_FULL = -4, /* Reserved; current APIs do not return this value. */
GVFG_PLAYBACK_EDISCONTINUITY = -5,
GVFG_PLAYBACK_EAUDIO = -6 /* A/V audio output disabled; video remains running. */
} gvfg_playback_status_t;
typedef enum {
GVFG_PLAYBACK_VIDEO_ONLY = 1,
GVFG_PLAYBACK_AUDIO_ONLY = 2,
GVFG_PLAYBACK_AUDIO_VIDEO = 3
} gvfg_playback_mode_t;
typedef enum {
GVFG_PLAYBACK_MASTER_EXTERNAL = 0,
GVFG_PLAYBACK_MASTER_AUDIO = 1,
GVFG_PLAYBACK_MASTER_VIDEO = 2
} gvfg_playback_master_t;
typedef struct {
uint32_t struct_size;
gvfg_playback_mode_t mode;
gvfg_playback_master_t master;
gvfg_audio_playback_format_t audio_format;
uint32_t preroll_ms; /* Default 100; required coverage of both streams. */
/* Advanced capacity limits; normally keep the values from default_config. */
uint32_t max_video_frames; /* Default 32; late preview frames are retired and counted. */
uint32_t max_audio_ms; /* Default 1000. */
uint64_t max_video_bytes; /* Default 256 MiB, including in-flight copy. */
} gvfg_playback_config_t;
typedef struct {
gvfg_preview_frame_t image;
uint64_t timestamp_ns; /* Common monotonic delivery clock, NOT UTC. */
} gvfg_playback_video_frame_t;
GVFG_PLAYBACK_API void gvfg_playback_default_config(gvfg_playback_config_t *config);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_create(gvfg_playback *out);
/* A null HWND hides video while preserving its timeline. Attach on HWND thread. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_attach_window(gvfg_playback p, void *hwnd);
/* Forward Capture's signal.connected (0/1). The helper owns the NO SIGNAL
* overlay; it does not query Capture or infer signal from missing frames.
* Call on the attached HWND thread, serialized with attach/destroy.
* Default connected=1. State persists across stop/start/reset and reattach. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_set_signal_connected(gvfg_playback p, int connected);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_start(gvfg_playback p, const gvfg_playback_config_t *config);
/* Monotonic timestamps required per stream. Zero/reversed timestamps rejected.
* Queue pressure triggers bounded best-effort playback; obsolete queued data
* may be discarded even on OK. Never block capture holding an SDK frame.
* A single packet/frame exceeding its configured capacity returns EINVAL.
* Each PCM submission must contain at most 100 ms of audio.
* Audio timestamp is SDK DELIVERY time. The first PCM sample is estimated by
* subtracting packet duration. Following PCM remains continuous while its
* source-time mapping smoothly tracks long-term delivery-clock differences.
* Forward audio delivery gaps recover automatically in best-effort playback.
* Delivery timestamps cannot recover unknown hardware latency or lost samples.
*/
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_submit_video(gvfg_playback p, const gvfg_playback_video_frame_t *frame);
/* Synchronously present one still image without starting a playback timeline.
* Requires an attached window and a stopped handle. Caller data stays valid
* through return. Used for RAW/DICOM image display; no audio is initialized. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_present_image(gvfg_playback p, const gvfg_preview_frame_t *image);
/* In A/V mode an unavailable audio output returns EAUDIO while video continues.
* With reconnect enabled, keep submitting new PCM so monitoring can resume
* when the default output becomes available. Otherwise recreate the handle
* to retry monitoring. Keep capture/recording audio independent.
* A/V start may succeed with monitoring disabled; audio-only start still fails
* if its output is unavailable. Other errors retain their normal meaning. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_submit_audio(gvfg_playback p, const void *pcm, uint32_t bytes, uint64_t timestamp_ns);
/* Opt in before start. Retries the default Windows output in A/V mode only. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_enable_audio_reconnect(gvfg_playback p);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_set_volume(gvfg_playback p, float gain);
/* Default enabled=1. Set 0 for independent best-effort playback with no
* automatic return to synchronization. May be called before start or while
* active. Re-enabling waits for stable input/output before synchronizing.
* This choice persists across stop/start and reset_timeline. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_set_sync_enabled(gvfg_playback p, int enabled);
/* Explicit discontinuity: discards pending output and establishes a new epoch.
* Stop/reset discard queued data; they are NOT lossless end-of-stream drains. */
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_reset_timeline(gvfg_playback p);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_stop(gvfg_playback p);
GVFG_PLAYBACK_API void gvfg_playback_destroy(gvfg_playback p);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_get_preview_info(gvfg_playback p, gvfg_preview_info_t *info);
GVFG_PLAYBACK_API gvfg_playback_status_t gvfg_playback_get_preview_stats(gvfg_playback p, gvfg_preview_stats_t *stats);
GVFG_PLAYBACK_API const char *gvfg_playback_strerror(gvfg_playback_status_t status);
#ifdef __cplusplus
}
#endif