Commit Graph

77 Commits (3c1f17ca662d4f794e3034035f3bb5d888b2acca)

Author SHA1 Message Date
sorayuki b3ed50aa08
win-capture: Avoid segfault when retrieve size
When changing size of a game-capture scene item in preview window, 
if the capture target window closed, it may crash.
2018-08-08 16:28:40 +08:00
jp9000 4b54bde426 cmake, libobs, win-capture: Fix VS2017 warnings 2018-03-12 16:16:38 -07:00
Joel Bethke 10b27723a3 win-capture: Change string for memory capture option
Makes it a bit more clear this option shouldn't be used unless you're on
SLI/crossfire.

In the future, something should be put in to the program that detects
laptops and warns on how to set up their adapter for efficient capture.

Closes jp9000/obs-studio#1138
2018-01-08 15:44:05 -08:00
Richard Stanway 66ec96d52c
win-capture: Fix memory capture crash on new capture
If the target process re-creates its D3D context, the game capture tick
can trigger before the capture is setup, in which case OBS gets a
CAPTURE_RETRY message. However with the memory capture method, it
continues to try and copy from the shared memory pointer which is no
longer valid, resulting in a crash. The fix uses the old texture until
the next tick at which point the new capture should be ready for use.
2017-12-14 16:40:14 +01:00
Richard Stanway bc3a5cb832
win-capture: Log when game capture compatibilty mode is set 2017-07-01 21:39:20 +02:00
jp9000 603825ee39 win-capture: Use PROCESS_QUERY_INFORMATION for game capture
PROCESS_QUERY_LIMITED_INFORMATION might be a bit insufficient for what
we need to do.
2017-06-19 16:02:02 -07:00
jp9000 0acf86ba04 win-capture: Limit OpenProcess flags to prevent A/C issues
Limits OpenProcess flags to only the flags that are necessary to prevent
any further issues with anti-cheat hooks in the future.
2017-05-29 19:30:10 -07:00
Richard Stanway 9e95b2eb6f
Various: Don't use boolean bitfields
Using bitfields causes less optimized code generation and the memory
savings are minimal as none of the objects are instantiated enough
times to be worth it.

See https://blogs.msdn.microsoft.com/oldnewthing/20081126-00/?p=20073
2017-05-10 23:28:46 +02:00
Richard Stanway 62c40eac0c
win-capture: Hide cursor when in background (game capture)
Prevents random OS cursors showing if someone alt+tabs out of a game but
still moves their cursor over the captured area (possibly fullscreen).
2017-05-10 23:08:25 +02:00
Richard Stanway d4de8b9a7e win-capture: Log if shared texture capture is unavailable 2017-04-26 21:04:41 +02:00
jp9000 5b8a0a2777 win-capture: Blacklist chrome/firefox from game capture 2017-02-21 23:05:49 -08:00
jp9000 c30d4f5075 win-capture: Fix game capture size bug when rehooking
When rehooking, even if scaling is off, it'll unintentionally overwrite
the game's backbuffer texture size with the scale size.
2017-01-16 04:19:16 -08:00
jp9000 21d70fa207 win-capture: Don't use FindWindow for game capture keepalive
Using and creating a window can use issues in game capture if multiple
game captures are active, so revert back to using a mutex, and just
ignore the keepalive check failure if injected inside a UWP program
(only check to see if GetLastError reports that it's not found -- if it
returns access denied or any other error, assume it's in a UWP program,
and ignore the keepalive check).
2017-01-15 09:15:45 -08:00
jp9000 2da7f3cb0e win-capture: Add a few new blacklisted game capture exes 2016-12-23 02:17:14 -08:00
jp9000 4f4aea4562 win-capture: Add debug messages when hooking
These are helpful for debugging UWP capture issues.
2016-12-16 14:06:04 -08:00
jp9000 61773bcbf2 win-capture: Fix cursor not painting with UWP windows
Because the hook cannot get the window handle of UWP windows, fall back
to using the window handle stored in the game capture source itself if
it's unavailable from the hook.
2016-12-16 14:06:03 -08:00
jp9000 b3119e0a8d win-capture: Don't hard fail if thread ID not found
Under certain circumstances, the program may not be able to acquire the
window thread ID for a UWP process, but will be able to acquire the
process ID.  In this case, it should soft fail and retry, rather than
assume it's unacquirable and stop trying to reacquire.
2016-12-16 14:06:02 -08:00
jp9000 a5337605cd win-capture: Add ApplicationFrameHost to game capture blacklist
The ApplicationFrameHost process is a sandbox process, and should not be
hooked.
2016-12-16 14:06:01 -08:00
jp9000 480d0e986f win-capture: Fix "attempting to hook [executable]" message
The "attempting to hook [executable]" message would not display the
correct executable if it's fallen back to a different window with the
same window class.
2016-12-16 14:06:00 -08:00
jp9000 209bcda1f4 win-capture: Wait a few frames for hook to load
Now that the game capture hook creates and controls all the
synchronization objects, it's no longer possible to expect that the hook
is fully loaded by the time game capture tries to initialize it.  In
that case, allow game capture to retry the hook for a few frames before
assuming something failed.
2016-12-16 14:05:59 -08:00
jp9000 bddd9766ac win-capture: Don't hook suspended processes
Remote threads in suspended processes will also start up suspended, so
do not attempt to hook suspended processes.
2016-12-16 14:05:58 -08:00
jp9000 e29638ebf9 win-capture: Log plugin-side when capture successful/lost 2016-12-16 14:05:57 -08:00
jp9000 926b9c5f96 win-capture: Open UWP named objects with helper functions
This detects whether the target process is a UWP process, and then uses
the open_app_* functions for mutexes/events/mapping.  Also slightly
refactors named object open functions.
2016-12-16 14:05:56 -08:00
jp9000 c63bb17b08 win-capture: Remove redundant function
This function now already exists elsewhere -- open_event_plus_id.
2016-12-16 02:21:09 -08:00
jp9000 ab9bda52e0 win-capture: Create all named objects within hook
All named objects (including file mapped shared memory) need to be
created within the hook itself due to the fact that UWP programs cannot
access named objects outside of the UWP process.

Because shared memory needs to be created within the hook, the capture
loop cannot start until the shared memory has been filled with valid
data.  Creating an additional "initialize" event fixes this issue.

Additionally, changed the way that named kernel objects are
opened/created.  Before, there were functions that would first try to
open named objects and then implicitly create them if opening failed
(assuming that if the hook didn't create it first, game capture would),
now it's been changed so that you can only either explicitly open or
create.
2016-12-16 02:21:07 -08:00
jp9000 d19342442f win-capture: Use window for keepalive check
To check to make sure game capture is still active in the capture
program, it currently uses a named event, and then it checks to see if
that named event exists.  However with UWP programs, you can't open a
named event outside of the UWP process.  FindWindow on the other hand
does work, so instead of checking to see if a named kernel object
exists, create a window and check to see if that window exists.
2016-12-16 02:21:06 -08:00
jp9000 1e48b522fa win-capture: Fix getting proper UWP window handles
The "main" windows detected for UWP programs are basically to help
sandbox the programs -- they run in the ApplicationFrameHost process and
help reduce the possibility of other programs trying to access the
actual process window, which is a child window.

To bypass this, go through the list of child windows for the
ApplicationFrameHost window, and then find the one that's attached to
a different process; that different process will always be the target,
and will allows us to open the actual process of the UWP program.
2016-12-16 02:21:05 -08:00
jp9000 eaa32c20be win-capture: Defer hook offset loading to separate thread
Boosts startup time significantly to defer this to a separate thread.
2016-11-14 17:34:44 -08:00
jp9000 2c531f04df win-capture: Fix game capture hotkey activating immediately
When game capture was set to hotkey mode by the user, it would try to
activate the capture right away without waiting for the user to press a
hotkey.
2016-08-08 04:57:10 -07:00
jp9000 06b42f4f27 win-capture: Always allow conf. of game capture hotkey
Even if the hotkey is not enabled, always allow configuration of the
hotkey.  Fixes a bug where the hotkey configuration settings would not
save if the settings were changed.

Annoyingly this means that the hotkey will still be shown to the user,
possibly confusing the user as to whether they can use it, but for the
time being it's better than having their hotkey configuration removed
each time they change the mode.
2016-08-06 20:17:29 -07:00
jp9000 8fe01f2de1 win-capture: Do not blacklist league lobby window
The league lobby window can apparently be captured by game capture, and
may actually be useful to capture for some people.
2016-08-05 18:59:37 -07:00
jp9000 bf166c07f4 win-capture: Blacklist specific executables from game capture
Prevents the common problem of injecting in to certain processes and
getting the hook DLL "stuck":
- windows explorer
- steam
- battle.net
- gog galaxy
- skype
- uplay
- origin
- microsoft visual studio
- task manager
- league of legends lobby window
- windows 10 system settings window
2016-07-30 13:04:53 -07:00
jp9000 17667b8b9d win-capture: Add game capture hotkey support
Changed the first property of game capture to be a "mode" list (with
"any fullscreen window", "specific window", and "hotkey").

When hotkey mode is set, it'll add a hotkey pair to hotkey settings to
activate/deactivate game capture.  When the hotkey to activate is
pressed, it'll treat the current foreground window as the target window
similar to "selected window" mode; it'll keep trying to capture the same
window even if the window or its application closes/reopens, and will
continue to do so until deactivated via the deactivate hotkey, or until
a new window is set via the activate hotkey.
2016-07-30 13:04:53 -07:00
jp9000 d24a81868e win-capture: Do not render game capture if not active 2016-05-15 04:20:39 -07:00
jp9000 2707f05c46 Revert "win-capture: Allow window capturing of current process"
This reverts commit 8d520b970d.

This can actually cause a hard lock due to the windows API when
destroying window capture.  When the graphics thread locks the source
list for doing tick or render, and then the UI thread tries to destroy a
source, the UI thread will wait for the graphics thread to complete
rendering/ticking of sources.  The video_tick of window capture would
then check windows in the same process and try to query the window's
name via GetWindowText.  However, GetWindowText is synchronous, and will
not return until the window event has been processed by the UI thread,
so it will perpetually lock because the two threads are waiting for each
other to finish.
2016-05-13 04:21:39 -07:00
jp9000 8d520b970d win-capture: Allow window capturing of current process
Allows window capture to capture windows of the current process, and
adds windows of the current process to the end of the window list.
2016-05-13 02:14:24 -07:00
jp9000 bd9980a206 win-capture: Reset game cap. wait_for_target_startup on update
This flag should be reset when the user changes the game capture
settings.
2016-05-12 19:42:00 -07:00
jp9000 94e22dae49 win-capture: Instantly capture already-hooked processes
If a process is already hooked, immediately initialize the capture
rather than wait for the processes to initialize or wait for the timer
to trigger.
2016-05-12 19:38:46 -07:00
jp9000 8681baeec3 win-capture: Shut down game cap. when not showing
Prevents game capture from acting as a global source.  This fixes an
issue where a game capture in another scene could capture a window and
prevent a separate game capture in the current scene from being able to
capture that same window.
2016-05-12 19:36:33 -07:00
Richard Stanway e5e5189c7b
win-capture: Make sure we don't try to hook ourselves
Can trigger when using "Hook any fullscreen application" is enabled and
the projector is active.
2016-04-25 23:46:20 +02:00
sorayuki a2b6432f53 win-capture: Fix game capture file integrity test
Fixes the file integrity test when required files are placed in a path
containing non-english character encodings.

Closes jp9000/obs-studio#523
2016-03-24 01:05:47 -07:00
jp9000 bcdb3dccb9 win-capture: Always use anti-cheat by default
Originally this on by default, but then was changed to being off by
default because it was thought that there were permission issues, but it
turned out that the permission issues were a separate bug, so it's safe
to have this be default to on again.
2016-03-21 14:11:23 -07:00
jp9000 cd97ce2a17 libobs: Add source output flag OBS_SOURCE_DO_NOT_DUPLICATE
Certain types of sources (display captures, game captures, audio
device captures, video device captures) should not be duplicated.  This
capability flag hints that the source prefers references over full
duplication.
2016-01-26 11:49:50 -08:00
jp9000 6ad8df8adb (API Change) libobs: Use single func for base effects
API removed:
--------------------
gs_effect_t *obs_get_default_effect(void);
gs_effect_t *obs_get_default_rect_effect(void);
gs_effect_t *obs_get_opaque_effect(void);
gs_effect_t *obs_get_solid_effect(void);
gs_effect_t *obs_get_bicubic_effect(void);
gs_effect_t *obs_get_lanczos_effect(void);
gs_effect_t *obs_get_bilinear_lowres_effect(void);

API added:
--------------------
gs_effect_t *obs_get_base_effect(enum obs_base_effect effect);

Summary:
--------------------
Combines multiple near-identical functions into a single function with
an enum parameter.
2015-10-19 00:52:45 -07:00
jp9000 7c39eb4ea4 win-capture: Don't hook game if source not showing 2015-09-21 21:38:54 -07:00
jp9000 ec5059cee1 win-capture: Always have some capture FPS limit
For game capture, if a game is running at for example 800 FPS and limit
capture framerate is off, it would try to capture all 800 of those
frames, dramatically reducing performance more than what would ever be
necessary.

When limit capture framerate is off, instead of capturing all frames,
capture frames at an interval of twice the OBS FPS, identical to how
OBS1 works by default.  This should greatly increase performance under
that circumstance.
2015-09-19 09:42:29 -07:00
jp9000 6285a47726 (API Change) libobs: Pass type data to get_name callbacks
API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
2015-09-16 09:21:12 -07:00
jp9000 d5ebe48180 Revert "win-capture: Use texture for actual source size"
This reverts commit 74354dc4cf.  I really
shouldn't have modified this, especially not in this way.  Was the wrong
approach.  The thing I was trying to fix was very rare as well.
2015-08-16 12:52:09 -07:00
jp9000 74354dc4cf win-capture: Use texture for actual source size 2015-08-01 14:51:19 -07:00
jp9000 bf1d07f513 win-capture: Fix bad return type
This was casting the return type to bool, which caused any non-zero
return code be converted to 1.
2015-07-11 15:36:53 -07:00