WSCLib SDK 1.0.0
GPU-accelerated video output framework for Windows
Loading...
Searching...
No Matches
WSCLib SDK API Reference

Introduction

WSCLib SDK is a GPU-accelerated video output framework for Windows, built on Direct3D 11. It consists of four libraries:

Library Description
WSCLib Core rendering engine — output windows, frame submission, color/crop/flip/rotate, overlays, recording, streaming
WSCLibVideo Video playback — VLC and Media Foundation backends with DXVA2/D3D11VA hardware decode
WSCLibInput Camera/audio capture — webcam enumeration, WASAPI audio, automatic frame delivery
WSCLibWeb Headless Chromium browser rendering via CEF — web pages as BGRA frames to WSCLib outputs

Architecture

┌────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ WSCLibVideo │ │ WSCLibInput │ │ WSCLibWeb │ │ Your App │
│ (VLC / MF) │ │ (Camera/Audio) │ │ (CEF/Chromium)│ │ │
└───────┬────────┘ └────────┬─────────┘ └────────┬────────┘ └────────┬────────┘
│ AttachOutput │ AttachOutput │ AttachOutput │ SubmitFrame
▼ ▼ ▼ ▼
┌────────────────────────────────────────────────────────────────────────────────────┐
│ WSCLib │
│ D3D11 Rendering │ Video Processor │ Overlays │ Recording │ Streaming │
└────────────────────────────────────────────────────────────────────────────────────┘

Quick Start

Basic Usage (BGRA frame)

// 1. Initialize
// 2. Create output on a window
int outId = WSC_CreateOutputFromNative(myHwnd);
// 3. Submit a frame
WSC_SubmitFrame(outId, bgraPixels, 1920, 1080, 1920 * 4);
// 4. Cleanup
void WSC_Shutdown()
Shut down WSCLib and release all resources.
WSCResult WSC_Init()
Initialize WSCLib with the default GPU adapter.
WSCResult WSC_SubmitFrame(int outputId, const void *bgra, int width, int height, int pitch)
Submit a BGRA frame from CPU memory.
WSCResult WSC_DestroyOutput(int outputId)
Destroy an output and free its GPU resources.
int WSC_CreateOutputFromNative(HWND nativeHwnd)
Create an output bound directly to an existing native HWND.

Video Playback

int outId = WSC_CreateOutputFromNative(myHwnd);
int playerId = WSCV_CreatePlayerMF("video.mp4"); // HW decode
WSCV_AttachOutput(playerId, outId);
WSCV_Play(playerId);
// ... playback runs automatically ...
WSCV_Stop(playerId);
void WSCV_Shutdown()
Shut down engines and destroy all players.
WSCVResult WSCV_Init()
Initialize VLC and Media Foundation engines.
int WSCV_CreatePlayerMF(const char *filePath)
Create a Media Foundation player with D3D11 hardware decode.
WSCVResult WSCV_AttachOutput(int playerId, int outputId)
Attach a WSCLib output to this player.
WSCVResult WSCV_Play(int playerId)
Start or resume playback.
WSCVResult WSCV_Stop(int playerId)
Stop playback.
WSCVResult WSCV_DestroyPlayer(int playerId)
Destroy a player and free resources.

Camera Capture

int outId = WSC_CreateOutputFromNative(myHwnd);
WSCICaptureFormat fmt = { 1920, 1080, 30 };
int capId = WSCI_CreateCapture(0, &fmt);
WSCI_AttachOutput(capId, outId);
int WSCI_CreateCapture(int videoDeviceIndex, const WSCICaptureFormat *format)
Create a video capture from a device index.
WSCIResult WSCI_StartCapture(int captureId)
Start capturing frames.
WSCIResult WSCI_Init()
Initialize Media Foundation for capture.
WSCIResult WSCI_AttachOutput(int captureId, int outputId)
Attach a WSCLib output — each captured frame auto-submits to WSC_SubmitFrame().
Capture format parameters (optional).
Definition wscinput.h:105

Web Browser Rendering

int outId = WSC_CreateOutputFromNative(myHwnd);
int browserId = WSCW_CreateBrowser("https://example.com", 1920, 1080);
WSCW_AttachOutput(browserId, outId);
// Pump CEF messages in your main loop (~60 Hz)
while (running) {
// ... handle Win32 messages ...
}
int WSCW_CreateBrowser(const char *url, int width, int height)
Create an off-screen browser and navigate to a URL.
WSCWResult WSCW_DestroyBrowser(int browserId)
Destroy a browser and free resources.
WSCWResult WSCW_Init()
Initialize CEF engine.
void WSCW_DoMessageLoopWork()
Pump CEF message loop.
void WSCW_Shutdown()
Shut down CEF engine and destroy all browsers.
WSCWResult WSCW_AttachOutput(int browserId, int outputId)
Attach a WSCLib output to this browser.

Web Navigation & JavaScript

// Navigate to a different URL
WSCW_Navigate(browserId, "https://google.com");
// Browser controls
WSCW_GoBack(browserId);
WSCW_GoForward(browserId);
WSCW_Reload(browserId);
// Execute JavaScript
WSCW_ExecuteJS(browserId, "document.title = 'Hello from WSCLib!';");
// Resize viewport
WSCW_Resize(browserId, 3840, 2160);
// Set rendering frame rate (default 30, max 60)
WSCW_SetFrameRate(browserId, 60);
WSCWResult WSCW_SetFrameRate(int browserId, int fps)
Set the frame rate for off-screen rendering.
WSCWResult WSCW_Resize(int browserId, int width, int height)
Resize the virtual viewport.
WSCWResult WSCW_ExecuteJS(int browserId, const char *code)
Execute JavaScript code in the browser's main frame.
WSCWResult WSCW_Navigate(int browserId, const char *url)
Navigate to a new URL.
WSCWResult WSCW_Reload(int browserId)
Reload the current page.
WSCWResult WSCW_GoBack(int browserId)
Navigate back.
WSCWResult WSCW_GoForward(int browserId)
Navigate forward.

Web Mouse & Keyboard Input

// Send mouse events
WSCW_SendMouseMove(browserId, 100, 200);
WSCW_SendMouseDown(browserId, WSCW_MOUSE_LEFT, 100, 200);
WSCW_SendMouseUp(browserId, WSCW_MOUSE_LEFT, 100, 200);
WSCW_SendMouseWheel(browserId, 100, 200, 0, -120);
// Send keyboard events
WSCW_SendKeyEvent(browserId, 'A', 0, 0); // key down
WSCW_SendChar(browserId, 'A'); // character
WSCW_SendKeyEvent(browserId, 'A', 1, 0); // key up
WSCWResult WSCW_SendMouseDown(int browserId, WSCWMouseButton button, int x, int y)
Send a mouse button down event.
WSCWResult WSCW_SendMouseWheel(int browserId, int x, int y, int deltaX, int deltaY)
Send a mouse scroll event.
WSCWResult WSCW_SendMouseMove(int browserId, int x, int y)
Send a mouse move event.
WSCWResult WSCW_SendChar(int browserId, int character)
Send a character input event (for text input).
WSCWResult WSCW_SendKeyEvent(int browserId, int keyCode, int isKeyUp, int modifiers)
Send a key event.
WSCWResult WSCW_SendMouseUp(int browserId, WSCWMouseButton button, int x, int y)
Send a mouse button up event.
@ WSCW_MOUSE_LEFT
Definition wscweb.h:190

Hardware Capabilities

Query capabilities at runtime:

unsigned caps = WSC_GetCapabilities();
if (caps & WSC_CAP_VIDEO_PROC)
printf("D3D11 Video Processor — NV12 zero-copy, HW color adjust\n");
if (caps & WSC_CAP_NVENC)
printf("NVENC — hardware H.264 encoding\n");
unsigned WSC_GetCapabilities()
Query available hardware capabilities.
@ WSC_CAP_NVENC
Definition wsclib.h:447
@ WSC_CAP_VIDEO_PROC
Definition wsclib.h:450

NV12 Video Processor Path

When WSC_CAP_VIDEO_PROC is available, NV12 frames bypass the 3D pipeline entirely. Color conversion (YUV→RGB), scaling, brightness/contrast/saturation/hue adjustments, and rotation are performed by the GPU's dedicated Video engine. This shows as GPU-Copy in Task Manager instead of GPU-3D.

The NV12 path is automatic when using WSCLibVideo:

  • VLC backend: Requests NV12 from VLC via format callback
  • MF backend: Requests NV12 output from SourceReader, submits DXVA textures directly

Module Groups