libobs: Add output duplicator support
This adds support for the windows 8+ output duplicator feature which allows the efficient capturing of a specific monitor connected to the currently used device.
This commit is contained in:
@@ -175,6 +175,11 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
|
||||
#elif _WIN32
|
||||
GRAPHICS_IMPORT(device_gdi_texture_available);
|
||||
GRAPHICS_IMPORT(device_shared_texture_available);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_get_duplicator_monitor_info);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_duplicator_create);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_destroy);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_update_frame);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_duplicator_get_texture);
|
||||
GRAPHICS_IMPORT_OPTIONAL(device_texture_create_gdi);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_get_dc);
|
||||
GRAPHICS_IMPORT_OPTIONAL(gs_texture_release_dc);
|
||||
|
@@ -232,6 +232,16 @@ struct gs_exports {
|
||||
bool (*device_gdi_texture_available)(void);
|
||||
bool (*device_shared_texture_available)(void);
|
||||
|
||||
bool (*device_get_duplicator_monitor_info)(gs_device_t *device,
|
||||
int monitor_idx, struct gs_monitor_info *monitor_info);
|
||||
|
||||
gs_duplicator_t *(*device_duplicator_create)(gs_device_t *device,
|
||||
int monitor_idx);
|
||||
void (*gs_duplicator_destroy)(gs_duplicator_t *duplicator);
|
||||
|
||||
bool (*gs_duplicator_update_frame)(gs_duplicator_t *duplicator);
|
||||
gs_texture_t *(*gs_duplicator_get_texture)(gs_duplicator_t *duplicator);
|
||||
|
||||
gs_texture_t *(*device_texture_create_gdi)(gs_device_t *device,
|
||||
uint32_t width, uint32_t height);
|
||||
|
||||
|
@@ -1967,6 +1967,60 @@ bool gs_shared_texture_available(void)
|
||||
return thread_graphics->exports.device_shared_texture_available();
|
||||
}
|
||||
|
||||
bool gs_get_duplicator_monitor_info(int monitor_idx,
|
||||
struct gs_monitor_info *monitor_info)
|
||||
{
|
||||
if (!thread_graphics)
|
||||
return false;
|
||||
if (!thread_graphics->exports.device_get_duplicator_monitor_info)
|
||||
return false;
|
||||
|
||||
return thread_graphics->exports.device_get_duplicator_monitor_info(
|
||||
thread_graphics->device, monitor_idx,
|
||||
monitor_info);
|
||||
}
|
||||
|
||||
gs_duplicator_t *gs_duplicator_create(int monitor_idx)
|
||||
{
|
||||
if (!thread_graphics)
|
||||
return NULL;
|
||||
if (!thread_graphics->exports.device_duplicator_create)
|
||||
return NULL;
|
||||
|
||||
return thread_graphics->exports.device_duplicator_create(
|
||||
thread_graphics->device, monitor_idx);
|
||||
}
|
||||
|
||||
void gs_duplicator_destroy(gs_duplicator_t *duplicator)
|
||||
{
|
||||
if (!thread_graphics)
|
||||
return;
|
||||
if (!thread_graphics->exports.gs_duplicator_destroy)
|
||||
return;
|
||||
|
||||
thread_graphics->exports.gs_duplicator_destroy(duplicator);
|
||||
}
|
||||
|
||||
bool gs_duplicator_update_frame(gs_duplicator_t *duplicator)
|
||||
{
|
||||
if (!thread_graphics)
|
||||
return true;
|
||||
if (!thread_graphics->exports.gs_duplicator_get_texture)
|
||||
return true;
|
||||
|
||||
return thread_graphics->exports.gs_duplicator_update_frame(duplicator);
|
||||
}
|
||||
|
||||
gs_texture_t *gs_duplicator_get_texture(gs_duplicator_t *duplicator)
|
||||
{
|
||||
if (!thread_graphics)
|
||||
return NULL;
|
||||
if (!thread_graphics->exports.gs_duplicator_get_texture)
|
||||
return NULL;
|
||||
|
||||
return thread_graphics->exports.gs_duplicator_get_texture(duplicator);
|
||||
}
|
||||
|
||||
/** creates a windows GDI-lockable texture */
|
||||
gs_texture_t *gs_texture_create_gdi(uint32_t width, uint32_t height)
|
||||
{
|
||||
|
@@ -168,6 +168,14 @@ enum gs_texture_type {
|
||||
GS_TEXTURE_CUBE
|
||||
};
|
||||
|
||||
struct gs_monitor_info {
|
||||
int rotation_degrees;
|
||||
long x;
|
||||
long y;
|
||||
long cx;
|
||||
long cy;
|
||||
};
|
||||
|
||||
struct gs_tvertarray {
|
||||
size_t width;
|
||||
void *array;
|
||||
@@ -712,6 +720,23 @@ EXPORT bool gs_texture_rebind_iosurface(gs_texture_t *texture,
|
||||
EXPORT bool gs_gdi_texture_available(void);
|
||||
EXPORT bool gs_shared_texture_available(void);
|
||||
|
||||
struct gs_duplicator;
|
||||
typedef struct gs_duplicator gs_duplicator_t;
|
||||
|
||||
/**
|
||||
* Gets information about the monitor at the specific index, returns false
|
||||
* when there is no monitor at the specified index
|
||||
*/
|
||||
EXPORT bool gs_get_duplicator_monitor_info(int monitor_idx,
|
||||
struct gs_monitor_info *monitor_info);
|
||||
|
||||
/** creates a windows 8+ output duplicator (monitor capture) */
|
||||
EXPORT gs_duplicator_t *gs_duplicator_create(int monitor_idx);
|
||||
EXPORT void gs_duplicator_destroy(gs_duplicator_t *duplicator);
|
||||
|
||||
EXPORT bool gs_duplicator_update_frame(gs_duplicator_t *duplicator);
|
||||
EXPORT gs_texture_t *gs_duplicator_get_texture(gs_duplicator_t *duplicator);
|
||||
|
||||
/** creates a windows GDI-lockable texture */
|
||||
EXPORT gs_texture_t *gs_texture_create_gdi(uint32_t width, uint32_t height);
|
||||
|
||||
|
Reference in New Issue
Block a user