win-capture: Add game capture
This adds the windows version of game capture. New features: - An option to hook any fullscreen application automatically (that doesn't have borders) so that no specific window configuration is required. Definitely a sorely needed feature - An option to force memory capture for the sake of compatibility with things such as SLI, multi-adapter setups (usually laptops), as well as the ability to be used with the OpenGL renderer - An optimization option to force scaling on the GPU before texture transfer, reducing the transfer bandwidth (which is especially important for compatibility capture) - An optimization option to limit framerate to the current OBS framerate to improve capture performance (mostly useful for compatibility capture) - An option to capture third-party overlays (such as steam) - Logging improvements, game capture log will now be sent via pipe instead of written to a separate file, making diagnosing problems a little bit easiermaster
parent
ca59b0c7d0
commit
56899df08f
|
@ -12,9 +12,11 @@ set(win-capture_SOURCES
|
|||
dc-capture.c
|
||||
obfuscate.c
|
||||
cursor-capture.c
|
||||
game-capture.c
|
||||
window-helpers.c
|
||||
monitor-capture.c
|
||||
window-capture.c
|
||||
load-graphics-offsets.c
|
||||
plugin-main.c)
|
||||
|
||||
add_library(win-capture MODULE
|
||||
|
@ -22,6 +24,7 @@ add_library(win-capture MODULE
|
|||
${win-capture_HEADERS})
|
||||
target_link_libraries(win-capture
|
||||
libobs
|
||||
ipc-util
|
||||
psapi.lib)
|
||||
|
||||
install_obs_plugin_with_data(win-capture data)
|
||||
|
|
|
@ -7,5 +7,13 @@ WindowCapture.Priority.Class="Window Class"
|
|||
WindowCapture.Priority.Exe="Executable Name"
|
||||
CaptureCursor="Capture Cursor"
|
||||
Compatibility="Multi-adapter Compatibility"
|
||||
AllowTransparency="Allow Transparency"
|
||||
Monitor="Monitor"
|
||||
PrimaryMonitor="Primary Monitor"
|
||||
GameCapture="Game Capture"
|
||||
GameCapture.AnyFullscreen="Capture any fullscreen application"
|
||||
GameCapture.Activate="Activate"
|
||||
GameCapture.ForceScaling="Force Scaling"
|
||||
GameCapture.ScaleRes="Scale Resolution"
|
||||
GameCapture.LimitFramerate="Limit capture framerate"
|
||||
GameCapture.CaptureOverlays="Capture third-party overlays (such as steam)"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,84 @@
|
|||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/config-file.h>
|
||||
#include <util/pipe.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include "graphics-hook-info.h"
|
||||
|
||||
extern struct graphics_offsets offsets32;
|
||||
extern struct graphics_offsets offsets64;
|
||||
|
||||
static inline bool load_offsets_from_string(struct graphics_offsets *offsets,
|
||||
const char *str)
|
||||
{
|
||||
config_t *config;
|
||||
|
||||
if (config_open_string(&config, str) != CONFIG_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
offsets->d3d9.present =
|
||||
(uint32_t)config_get_uint(config, "d3d9", "present");
|
||||
offsets->d3d9.present_ex =
|
||||
(uint32_t)config_get_uint(config, "d3d9", "present_ex");
|
||||
offsets->d3d9.present_swap =
|
||||
(uint32_t)config_get_uint(config, "d3d9", "present_swap");
|
||||
offsets->d3d9.reset =
|
||||
(uint32_t)config_get_uint(config, "d3d9", "reset");
|
||||
offsets->d3d9.reset_ex =
|
||||
(uint32_t)config_get_uint(config, "d3d9", "reset_ex");
|
||||
|
||||
offsets->dxgi.present =
|
||||
(uint32_t)config_get_uint(config, "dxgi", "present");
|
||||
offsets->dxgi.resize =
|
||||
(uint32_t)config_get_uint(config, "dxgi", "resize");
|
||||
|
||||
config_close(config);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool load_graphics_offsets(bool is32bit)
|
||||
{
|
||||
char *offset_exe_path = NULL;
|
||||
struct dstr offset_exe = {0};
|
||||
struct dstr str = {0};
|
||||
os_process_pipe_t *pp;
|
||||
bool success = false;
|
||||
char data[128];
|
||||
|
||||
dstr_copy(&offset_exe, "get-graphics-offsets");
|
||||
dstr_cat(&offset_exe, is32bit ? "32.exe" : "64.exe");
|
||||
offset_exe_path = obs_module_file(offset_exe.array);
|
||||
|
||||
pp = os_process_pipe_create(offset_exe_path, "r");
|
||||
if (!pp) {
|
||||
blog(LOG_INFO, "load_graphics_offsets: Failed to start '%s'",
|
||||
offset_exe.array);
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
size_t len = os_process_pipe_read(pp, data, 128);
|
||||
if (!len)
|
||||
break;
|
||||
|
||||
dstr_ncat(&str, data, len);
|
||||
}
|
||||
|
||||
success = load_offsets_from_string(is32bit ? &offsets32 : &offsets64,
|
||||
str.array);
|
||||
if (!success) {
|
||||
blog(LOG_INFO, "load_graphics_offsets: Failed to load string");
|
||||
}
|
||||
|
||||
os_process_pipe_destroy(pp);
|
||||
|
||||
error:
|
||||
bfree(offset_exe_path);
|
||||
dstr_free(&offset_exe);
|
||||
dstr_free(&str);
|
||||
return success;
|
||||
}
|
|
@ -5,10 +5,27 @@ OBS_MODULE_USE_DEFAULT_LOCALE("win-capture", "en-US")
|
|||
|
||||
extern struct obs_source_info monitor_capture_info;
|
||||
extern struct obs_source_info window_capture_info;
|
||||
extern struct obs_source_info game_capture_info;
|
||||
|
||||
extern bool load_graphics_offsets(bool is32bit);
|
||||
|
||||
/* temporary, will eventually be erased once we figure out how to create both
|
||||
* 32bit and 64bit versions of the helpers/hook */
|
||||
#ifdef _WIN64
|
||||
#define IS32BIT false
|
||||
#else
|
||||
#define IS32BIT true
|
||||
#endif
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_register_source(&monitor_capture_info);
|
||||
obs_register_source(&window_capture_info);
|
||||
|
||||
if (load_graphics_offsets(IS32BIT)) {
|
||||
load_graphics_offsets(!IS32BIT);
|
||||
obs_register_source(&game_capture_info);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue