initial commit

This commit is contained in:
i2p
2026-08-27 11:03:10 -06:00
commit d164820ea9
282 changed files with 90944 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
#ifndef DXGI_CAPTURE_H
#define DXGI_CAPTURE_H
#ifdef _WIN32
#include <windows.h>
#include <stdint.h>
typedef struct dxgi_ctx dxgi_ctx_t;
/* Initialize DXGI Desktop Duplication.
* Returns context on success, NULL on failure (e.g., no GPU, RDP session).
* Dynamically loads d3d11.dll and dxgi.dll — no link-time dependencies. */
dxgi_ctx_t *dxgi_init(void);
/* Capture current frame via Desktop Duplication.
* Returns:
* 0 = success, pixels/width/height/dirty_rects/num_dirty filled
* 1 = no change (timeout, screen idle) — caller should skip frame
* -1 = error (ACCESS_LOST, device removed, etc.) — caller should reinit or fallback
*
* On success, pixels points to tightly-packed RGB (3 bytes/pixel, top-down).
* dirty_rects points to an internal array valid until the next call. */
int dxgi_capture(dxgi_ctx_t *ctx, uint8_t **pixels, int *width, int *height,
RECT **dirty_rects, int *num_dirty);
/* Capture frame returning raw mapped BGRA pointer (no RGB conversion).
* Returns:
* 0 = success, bgra_data/row_pitch/width/height/dirty_rects/num_dirty filled
* 1 = no change (timeout)
* -1 = error
*
* On success, bgra_data points to mapped GPU memory (BGRA, 4 bytes/pixel).
* Caller MUST call dxgi_release_frame() when done reading the data. */
int dxgi_capture_mapped(dxgi_ctx_t *ctx, const uint8_t **bgra_data,
int *row_pitch, int *width, int *height,
RECT **dirty_rects, int *num_dirty);
/* Release the acquired frame (must be called after dxgi_capture/dxgi_capture_mapped returns 0). */
void dxgi_release_frame(dxgi_ctx_t *ctx);
/* Clean up all DXGI/D3D11 resources. */
void dxgi_cleanup(dxgi_ctx_t *ctx);
#endif /* _WIN32 */
#endif /* DXGI_CAPTURE_H */