window-capture.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. #include <stdlib.h>
  2. #include <util/dstr.h>
  3. #include <util/threading.h>
  4. #include "dc-capture.h"
  5. #include "window-helpers.h"
  6. #include "../../libobs/util/platform.h"
  7. #include "../../libobs-winrt/winrt-capture.h"
  8. /* clang-format off */
  9. #define TEXT_WINDOW_CAPTURE obs_module_text("WindowCapture")
  10. #define TEXT_WINDOW obs_module_text("WindowCapture.Window")
  11. #define TEXT_METHOD obs_module_text("WindowCapture.Method")
  12. #define TEXT_METHOD_AUTO obs_module_text("WindowCapture.Method.Auto")
  13. #define TEXT_METHOD_BITBLT obs_module_text("WindowCapture.Method.BitBlt")
  14. #define TEXT_METHOD_WGC obs_module_text("WindowCapture.Method.WindowsGraphicsCapture")
  15. #define TEXT_MATCH_PRIORITY obs_module_text("WindowCapture.Priority")
  16. #define TEXT_MATCH_TITLE obs_module_text("WindowCapture.Priority.Title")
  17. #define TEXT_MATCH_CLASS obs_module_text("WindowCapture.Priority.Class")
  18. #define TEXT_MATCH_EXE obs_module_text("WindowCapture.Priority.Exe")
  19. #define TEXT_CAPTURE_CURSOR obs_module_text("CaptureCursor")
  20. #define TEXT_COMPATIBILITY obs_module_text("Compatibility")
  21. #define TEXT_CLIENT_AREA obs_module_text("ClientArea")
  22. /* clang-format on */
  23. #define WC_CHECK_TIMER 1.0f
  24. #define RESIZE_CHECK_TIME 0.2f
  25. #define CURSOR_CHECK_TIME 0.2f
  26. typedef BOOL (*PFN_winrt_capture_supported)();
  27. typedef BOOL (*PFN_winrt_capture_cursor_toggle_supported)();
  28. typedef struct winrt_capture *(*PFN_winrt_capture_init_window)(
  29. BOOL cursor, HWND window, BOOL client_area);
  30. typedef void (*PFN_winrt_capture_free)(struct winrt_capture *capture);
  31. typedef BOOL (*PFN_winrt_capture_active)(const struct winrt_capture *capture);
  32. typedef BOOL (*PFN_winrt_capture_show_cursor)(struct winrt_capture *capture,
  33. BOOL visible);
  34. typedef void (*PFN_winrt_capture_render)(struct winrt_capture *capture);
  35. typedef uint32_t (*PFN_winrt_capture_width)(const struct winrt_capture *capture);
  36. typedef uint32_t (*PFN_winrt_capture_height)(
  37. const struct winrt_capture *capture);
  38. struct winrt_exports {
  39. PFN_winrt_capture_supported winrt_capture_supported;
  40. PFN_winrt_capture_cursor_toggle_supported
  41. winrt_capture_cursor_toggle_supported;
  42. PFN_winrt_capture_init_window winrt_capture_init_window;
  43. PFN_winrt_capture_free winrt_capture_free;
  44. PFN_winrt_capture_active winrt_capture_active;
  45. PFN_winrt_capture_show_cursor winrt_capture_show_cursor;
  46. PFN_winrt_capture_render winrt_capture_render;
  47. PFN_winrt_capture_width winrt_capture_width;
  48. PFN_winrt_capture_height winrt_capture_height;
  49. };
  50. enum window_capture_method {
  51. METHOD_AUTO,
  52. METHOD_BITBLT,
  53. METHOD_WGC,
  54. };
  55. typedef DPI_AWARENESS_CONTEXT(WINAPI *PFN_SetThreadDpiAwarenessContext)(
  56. DPI_AWARENESS_CONTEXT);
  57. typedef DPI_AWARENESS_CONTEXT(WINAPI *PFN_GetThreadDpiAwarenessContext)(VOID);
  58. typedef DPI_AWARENESS_CONTEXT(WINAPI *PFN_GetWindowDpiAwarenessContext)(HWND);
  59. struct window_capture {
  60. obs_source_t *source;
  61. pthread_mutex_t update_mutex;
  62. char *title;
  63. char *class;
  64. char *executable;
  65. enum window_capture_method method;
  66. enum window_priority priority;
  67. bool cursor;
  68. bool compatibility;
  69. bool client_area;
  70. bool use_wildcards; /* TODO */
  71. struct dc_capture capture;
  72. bool previously_failed;
  73. void *winrt_module;
  74. struct winrt_exports exports;
  75. struct winrt_capture *capture_winrt;
  76. float resize_timer;
  77. float check_window_timer;
  78. float cursor_check_time;
  79. HWND window;
  80. RECT last_rect;
  81. PFN_SetThreadDpiAwarenessContext set_thread_dpi_awareness_context;
  82. PFN_GetThreadDpiAwarenessContext get_thread_dpi_awareness_context;
  83. PFN_GetWindowDpiAwarenessContext get_window_dpi_awareness_context;
  84. };
  85. static const char *wgc_partial_match_classes[] = {
  86. "Chrome",
  87. "Mozilla",
  88. NULL,
  89. };
  90. static const char *wgc_whole_match_classes[] = {
  91. "ApplicationFrameWindow",
  92. "Windows.UI.Core.CoreWindow",
  93. "XLMAIN", /* excel*/
  94. "PPTFrameClass", /* powerpoint */
  95. "OpusApp", /* word */
  96. NULL,
  97. };
  98. static enum window_capture_method
  99. choose_method(enum window_capture_method method, bool wgc_supported,
  100. const char *current_class)
  101. {
  102. if (!wgc_supported)
  103. return METHOD_BITBLT;
  104. if (method != METHOD_AUTO)
  105. return method;
  106. if (!current_class)
  107. return METHOD_BITBLT;
  108. const char **class = wgc_partial_match_classes;
  109. while (*class) {
  110. if (astrstri(current_class, *class) != NULL) {
  111. return METHOD_WGC;
  112. }
  113. class ++;
  114. }
  115. class = wgc_whole_match_classes;
  116. while (*class) {
  117. if (astrcmpi(current_class, *class) == 0) {
  118. return METHOD_WGC;
  119. }
  120. class ++;
  121. }
  122. return METHOD_BITBLT;
  123. }
  124. static const char *get_method_name(int method)
  125. {
  126. const char *method_name = "";
  127. switch (method) {
  128. case METHOD_AUTO:
  129. method_name = "Automatic";
  130. break;
  131. case METHOD_BITBLT:
  132. method_name = "BitBlt";
  133. break;
  134. case METHOD_WGC:
  135. method_name = "WGC";
  136. break;
  137. }
  138. return method_name;
  139. }
  140. static void log_settings(struct window_capture *wc, obs_data_t *s)
  141. {
  142. int method = (int)obs_data_get_int(s, "method");
  143. if (wc->title != NULL) {
  144. blog(LOG_INFO,
  145. "[window-capture: '%s'] update settings:\n"
  146. "\texecutable: %s\n"
  147. "\tmethod selected: %s\n"
  148. "\tmethod chosen: %s\n",
  149. obs_source_get_name(wc->source), wc->executable,
  150. get_method_name(method), get_method_name(wc->method));
  151. blog(LOG_DEBUG, "\tclass: %s", wc->class);
  152. }
  153. }
  154. extern bool wgc_supported;
  155. static void update_settings(struct window_capture *wc, obs_data_t *s)
  156. {
  157. pthread_mutex_lock(&wc->update_mutex);
  158. int method = (int)obs_data_get_int(s, "method");
  159. const char *window = obs_data_get_string(s, "window");
  160. int priority = (int)obs_data_get_int(s, "priority");
  161. bfree(wc->title);
  162. bfree(wc->class);
  163. bfree(wc->executable);
  164. build_window_strings(window, &wc->class, &wc->title, &wc->executable);
  165. wc->method = choose_method(method, wgc_supported, wc->class);
  166. wc->priority = (enum window_priority)priority;
  167. wc->cursor = obs_data_get_bool(s, "cursor");
  168. wc->use_wildcards = obs_data_get_bool(s, "use_wildcards");
  169. wc->compatibility = obs_data_get_bool(s, "compatibility");
  170. wc->client_area = obs_data_get_bool(s, "client_area");
  171. pthread_mutex_unlock(&wc->update_mutex);
  172. }
  173. /* ------------------------------------------------------------------------- */
  174. static const char *wc_getname(void *unused)
  175. {
  176. UNUSED_PARAMETER(unused);
  177. return TEXT_WINDOW_CAPTURE;
  178. }
  179. #define WINRT_IMPORT(func) \
  180. do { \
  181. exports->func = (PFN_##func)os_dlsym(module, #func); \
  182. if (!exports->func) { \
  183. success = false; \
  184. blog(LOG_ERROR, \
  185. "Could not load function '%s' from " \
  186. "module '%s'", \
  187. #func, module_name); \
  188. } \
  189. } while (false)
  190. static bool load_winrt_imports(struct winrt_exports *exports, void *module,
  191. const char *module_name)
  192. {
  193. bool success = true;
  194. WINRT_IMPORT(winrt_capture_supported);
  195. WINRT_IMPORT(winrt_capture_cursor_toggle_supported);
  196. WINRT_IMPORT(winrt_capture_init_window);
  197. WINRT_IMPORT(winrt_capture_free);
  198. WINRT_IMPORT(winrt_capture_active);
  199. WINRT_IMPORT(winrt_capture_show_cursor);
  200. WINRT_IMPORT(winrt_capture_render);
  201. WINRT_IMPORT(winrt_capture_width);
  202. WINRT_IMPORT(winrt_capture_height);
  203. return success;
  204. }
  205. extern bool graphics_uses_d3d11;
  206. static void *wc_create(obs_data_t *settings, obs_source_t *source)
  207. {
  208. struct window_capture *wc = bzalloc(sizeof(struct window_capture));
  209. wc->source = source;
  210. pthread_mutex_init(&wc->update_mutex, NULL);
  211. if (graphics_uses_d3d11) {
  212. static const char *const module = "libobs-winrt";
  213. wc->winrt_module = os_dlopen(module);
  214. if (wc->winrt_module) {
  215. load_winrt_imports(&wc->exports, wc->winrt_module,
  216. module);
  217. }
  218. }
  219. const HMODULE hModuleUser32 = GetModuleHandle(L"User32.dll");
  220. if (hModuleUser32) {
  221. PFN_SetThreadDpiAwarenessContext
  222. set_thread_dpi_awareness_context =
  223. (PFN_SetThreadDpiAwarenessContext)GetProcAddress(
  224. hModuleUser32,
  225. "SetThreadDpiAwarenessContext");
  226. PFN_GetThreadDpiAwarenessContext
  227. get_thread_dpi_awareness_context =
  228. (PFN_GetThreadDpiAwarenessContext)GetProcAddress(
  229. hModuleUser32,
  230. "GetThreadDpiAwarenessContext");
  231. PFN_GetWindowDpiAwarenessContext
  232. get_window_dpi_awareness_context =
  233. (PFN_GetWindowDpiAwarenessContext)GetProcAddress(
  234. hModuleUser32,
  235. "GetWindowDpiAwarenessContext");
  236. if (set_thread_dpi_awareness_context &&
  237. get_thread_dpi_awareness_context &&
  238. get_window_dpi_awareness_context) {
  239. wc->set_thread_dpi_awareness_context =
  240. set_thread_dpi_awareness_context;
  241. wc->get_thread_dpi_awareness_context =
  242. get_thread_dpi_awareness_context;
  243. wc->get_window_dpi_awareness_context =
  244. get_window_dpi_awareness_context;
  245. }
  246. }
  247. update_settings(wc, settings);
  248. log_settings(wc, settings);
  249. return wc;
  250. }
  251. static void wc_actual_destroy(void *data)
  252. {
  253. struct window_capture *wc = data;
  254. if (wc->capture_winrt) {
  255. wc->exports.winrt_capture_free(wc->capture_winrt);
  256. }
  257. obs_enter_graphics();
  258. dc_capture_free(&wc->capture);
  259. obs_leave_graphics();
  260. bfree(wc->title);
  261. bfree(wc->class);
  262. bfree(wc->executable);
  263. if (wc->winrt_module)
  264. os_dlclose(wc->winrt_module);
  265. pthread_mutex_destroy(&wc->update_mutex);
  266. bfree(wc);
  267. }
  268. static void wc_destroy(void *data)
  269. {
  270. obs_queue_task(OBS_TASK_GRAPHICS, wc_actual_destroy, data, false);
  271. }
  272. static void force_reset(struct window_capture *wc)
  273. {
  274. wc->window = NULL;
  275. wc->resize_timer = RESIZE_CHECK_TIME;
  276. wc->check_window_timer = WC_CHECK_TIMER;
  277. wc->cursor_check_time = CURSOR_CHECK_TIME;
  278. wc->previously_failed = false;
  279. }
  280. static void wc_update(void *data, obs_data_t *settings)
  281. {
  282. struct window_capture *wc = data;
  283. update_settings(wc, settings);
  284. log_settings(wc, settings);
  285. force_reset(wc);
  286. }
  287. static uint32_t wc_width(void *data)
  288. {
  289. struct window_capture *wc = data;
  290. return (wc->method == METHOD_WGC)
  291. ? wc->exports.winrt_capture_width(wc->capture_winrt)
  292. : wc->capture.width;
  293. }
  294. static uint32_t wc_height(void *data)
  295. {
  296. struct window_capture *wc = data;
  297. return (wc->method == METHOD_WGC)
  298. ? wc->exports.winrt_capture_height(wc->capture_winrt)
  299. : wc->capture.height;
  300. }
  301. static void wc_defaults(obs_data_t *defaults)
  302. {
  303. obs_data_set_default_int(defaults, "method", METHOD_AUTO);
  304. obs_data_set_default_bool(defaults, "cursor", true);
  305. obs_data_set_default_bool(defaults, "compatibility", false);
  306. obs_data_set_default_bool(defaults, "client_area", true);
  307. }
  308. static void update_settings_visibility(obs_properties_t *props,
  309. struct window_capture *wc)
  310. {
  311. pthread_mutex_lock(&wc->update_mutex);
  312. const enum window_capture_method method = wc->method;
  313. const bool bitblt_options = method == METHOD_BITBLT;
  314. const bool wgc_options = method == METHOD_WGC;
  315. const bool wgc_cursor_toggle =
  316. wgc_options &&
  317. wc->exports.winrt_capture_cursor_toggle_supported();
  318. obs_property_t *p = obs_properties_get(props, "cursor");
  319. obs_property_set_visible(p, bitblt_options || wgc_cursor_toggle);
  320. p = obs_properties_get(props, "compatibility");
  321. obs_property_set_visible(p, bitblt_options);
  322. p = obs_properties_get(props, "client_area");
  323. obs_property_set_visible(p, wgc_options);
  324. pthread_mutex_unlock(&wc->update_mutex);
  325. }
  326. static bool wc_capture_method_changed(obs_properties_t *props,
  327. obs_property_t *p, obs_data_t *settings)
  328. {
  329. UNUSED_PARAMETER(p);
  330. struct window_capture *wc = obs_properties_get_param(props);
  331. if (!wc)
  332. return false;
  333. update_settings(wc, settings);
  334. update_settings_visibility(props, wc);
  335. return true;
  336. }
  337. extern bool check_window_property_setting(obs_properties_t *ppts,
  338. obs_property_t *p,
  339. obs_data_t *settings, const char *val,
  340. size_t idx);
  341. static bool wc_window_changed(obs_properties_t *props, obs_property_t *p,
  342. obs_data_t *settings)
  343. {
  344. struct window_capture *wc = obs_properties_get_param(props);
  345. if (!wc)
  346. return false;
  347. update_settings(wc, settings);
  348. update_settings_visibility(props, wc);
  349. check_window_property_setting(props, p, settings, "window", 0);
  350. return true;
  351. }
  352. static obs_properties_t *wc_properties(void *data)
  353. {
  354. struct window_capture *wc = data;
  355. obs_properties_t *ppts = obs_properties_create();
  356. obs_properties_set_param(ppts, wc, NULL);
  357. obs_property_t *p;
  358. p = obs_properties_add_list(ppts, "window", TEXT_WINDOW,
  359. OBS_COMBO_TYPE_LIST,
  360. OBS_COMBO_FORMAT_STRING);
  361. fill_window_list(p, EXCLUDE_MINIMIZED, NULL);
  362. obs_property_set_modified_callback(p, wc_window_changed);
  363. p = obs_properties_add_list(ppts, "method", TEXT_METHOD,
  364. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  365. obs_property_list_add_int(p, TEXT_METHOD_AUTO, METHOD_AUTO);
  366. obs_property_list_add_int(p, TEXT_METHOD_BITBLT, METHOD_BITBLT);
  367. obs_property_list_add_int(p, TEXT_METHOD_WGC, METHOD_WGC);
  368. obs_property_list_item_disable(p, 2, !wgc_supported);
  369. obs_property_set_modified_callback(p, wc_capture_method_changed);
  370. p = obs_properties_add_list(ppts, "priority", TEXT_MATCH_PRIORITY,
  371. OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
  372. obs_property_list_add_int(p, TEXT_MATCH_TITLE, WINDOW_PRIORITY_TITLE);
  373. obs_property_list_add_int(p, TEXT_MATCH_CLASS, WINDOW_PRIORITY_CLASS);
  374. obs_property_list_add_int(p, TEXT_MATCH_EXE, WINDOW_PRIORITY_EXE);
  375. obs_properties_add_bool(ppts, "cursor", TEXT_CAPTURE_CURSOR);
  376. obs_properties_add_bool(ppts, "compatibility", TEXT_COMPATIBILITY);
  377. obs_properties_add_bool(ppts, "client_area", TEXT_CLIENT_AREA);
  378. return ppts;
  379. }
  380. static void wc_hide(void *data)
  381. {
  382. struct window_capture *wc = data;
  383. if (wc->capture_winrt) {
  384. wc->exports.winrt_capture_free(wc->capture_winrt);
  385. wc->capture_winrt = NULL;
  386. }
  387. memset(&wc->last_rect, 0, sizeof(wc->last_rect));
  388. }
  389. static void wc_tick(void *data, float seconds)
  390. {
  391. struct window_capture *wc = data;
  392. RECT rect;
  393. bool reset_capture = false;
  394. if (!obs_source_showing(wc->source))
  395. return;
  396. if (!wc->window || !IsWindow(wc->window)) {
  397. if (!wc->title && !wc->class) {
  398. if (wc->capture.valid)
  399. dc_capture_free(&wc->capture);
  400. return;
  401. }
  402. wc->check_window_timer += seconds;
  403. if (wc->check_window_timer < WC_CHECK_TIMER) {
  404. if (wc->capture.valid)
  405. dc_capture_free(&wc->capture);
  406. return;
  407. }
  408. if (wc->capture_winrt) {
  409. wc->exports.winrt_capture_free(wc->capture_winrt);
  410. wc->capture_winrt = NULL;
  411. }
  412. wc->check_window_timer = 0.0f;
  413. wc->window = (wc->method == METHOD_WGC)
  414. ? find_window_top_level(INCLUDE_MINIMIZED,
  415. wc->priority,
  416. wc->class,
  417. wc->title,
  418. wc->executable)
  419. : find_window(INCLUDE_MINIMIZED,
  420. wc->priority, wc->class,
  421. wc->title, wc->executable);
  422. if (!wc->window) {
  423. if (wc->capture.valid)
  424. dc_capture_free(&wc->capture);
  425. return;
  426. }
  427. wc->previously_failed = false;
  428. reset_capture = true;
  429. } else if (IsIconic(wc->window) || !IsWindowVisible(wc->window)) {
  430. return; /* If HWND is invisible, WGC module can't be initialized successfully */
  431. }
  432. wc->cursor_check_time += seconds;
  433. if (wc->cursor_check_time >= CURSOR_CHECK_TIME) {
  434. DWORD foreground_pid, target_pid;
  435. // Can't just compare the window handle in case of app with child windows
  436. if (!GetWindowThreadProcessId(GetForegroundWindow(),
  437. &foreground_pid))
  438. foreground_pid = 0;
  439. if (!GetWindowThreadProcessId(wc->window, &target_pid))
  440. target_pid = 0;
  441. const bool cursor_hidden = foreground_pid && target_pid &&
  442. foreground_pid != target_pid;
  443. wc->capture.cursor_hidden = cursor_hidden;
  444. if (wc->capture_winrt &&
  445. !wc->exports.winrt_capture_show_cursor(wc->capture_winrt,
  446. !cursor_hidden)) {
  447. force_reset(wc);
  448. return;
  449. }
  450. wc->cursor_check_time = 0.0f;
  451. }
  452. obs_enter_graphics();
  453. if (wc->method == METHOD_BITBLT) {
  454. DPI_AWARENESS_CONTEXT previous = NULL;
  455. if (wc->get_window_dpi_awareness_context != NULL) {
  456. const DPI_AWARENESS_CONTEXT context =
  457. wc->get_window_dpi_awareness_context(
  458. wc->window);
  459. previous =
  460. wc->set_thread_dpi_awareness_context(context);
  461. }
  462. GetClientRect(wc->window, &rect);
  463. if (!reset_capture) {
  464. wc->resize_timer += seconds;
  465. if (wc->resize_timer >= RESIZE_CHECK_TIME) {
  466. if ((rect.bottom - rect.top) !=
  467. (wc->last_rect.bottom -
  468. wc->last_rect.top) ||
  469. (rect.right - rect.left) !=
  470. (wc->last_rect.right -
  471. wc->last_rect.left))
  472. reset_capture = true;
  473. wc->resize_timer = 0.0f;
  474. }
  475. }
  476. if (reset_capture) {
  477. wc->resize_timer = 0.0f;
  478. wc->last_rect = rect;
  479. dc_capture_free(&wc->capture);
  480. dc_capture_init(&wc->capture, 0, 0,
  481. rect.right - rect.left,
  482. rect.bottom - rect.top, wc->cursor,
  483. wc->compatibility);
  484. }
  485. dc_capture_capture(&wc->capture, wc->window);
  486. if (previous)
  487. wc->set_thread_dpi_awareness_context(previous);
  488. } else if (wc->method == METHOD_WGC) {
  489. if (wc->window && (wc->capture_winrt == NULL)) {
  490. if (!wc->previously_failed) {
  491. wc->capture_winrt =
  492. wc->exports.winrt_capture_init_window(
  493. wc->cursor, wc->window,
  494. wc->client_area);
  495. if (!wc->capture_winrt) {
  496. wc->previously_failed = true;
  497. }
  498. }
  499. }
  500. }
  501. obs_leave_graphics();
  502. }
  503. static void wc_render(void *data, gs_effect_t *effect)
  504. {
  505. struct window_capture *wc = data;
  506. if (wc->method == METHOD_WGC) {
  507. if (wc->capture_winrt) {
  508. if (wc->exports.winrt_capture_active(
  509. wc->capture_winrt)) {
  510. wc->exports.winrt_capture_render(
  511. wc->capture_winrt);
  512. } else {
  513. wc->exports.winrt_capture_free(
  514. wc->capture_winrt);
  515. wc->capture_winrt = NULL;
  516. }
  517. }
  518. } else {
  519. dc_capture_render(
  520. &wc->capture,
  521. obs_source_get_texcoords_centered(wc->source));
  522. }
  523. UNUSED_PARAMETER(effect);
  524. }
  525. struct obs_source_info window_capture_info = {
  526. .id = "window_capture",
  527. .type = OBS_SOURCE_TYPE_INPUT,
  528. .output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
  529. OBS_SOURCE_SRGB,
  530. .get_name = wc_getname,
  531. .create = wc_create,
  532. .destroy = wc_destroy,
  533. .update = wc_update,
  534. .video_render = wc_render,
  535. .hide = wc_hide,
  536. .video_tick = wc_tick,
  537. .get_width = wc_width,
  538. .get_height = wc_height,
  539. .get_defaults = wc_defaults,
  540. .get_properties = wc_properties,
  541. .icon_type = OBS_ICON_TYPE_WINDOW_CAPTURE,
  542. };