Commit Graph

361 Commits (355cd6ccc0f8435fc1d45043e2ffa1f74ee36b94)

Author SHA1 Message Date
jp9000 764d5a2d3f win-capture: Preserve current window setting
This re-uses the game capture code for checking whether the original
window still exists or not.  If it doesn't or the name changed, it'll
insert the value at the top of the list so it doesn't automatically
select another when the user opens properties.

Basically, this fixes an issue where opening properties could sometimes
cause it to instantly capture whatever window was at the top of the
list, which is undesirable.

Closes obsproject/obs-studio#2421
2020-02-27 04:45:21 -08:00
jp9000 ffe4c767c3 win-capture: Move window capture method below window 2020-02-27 03:22:04 -08:00
jpark37 2111a3a02f libobs-winrt: win-capture: Support client area toggle for WGC 2020-02-24 21:31:53 -08:00
jpark37 cce9fb7f95 win-capture: Hide settings if Automatic is WGC 2020-02-24 19:42:46 -08:00
jp9000 572ce73115 win-capture: Add 'auto' method to window capture
Adds an "Automatic" method to the capture method property of window
capture.  This allows the ability for window capture to automatically
determine the best capture method to use.  Primarily, it prefers BitBlt
in most cases, but will use WGC when it detects the window is a browser,
microsoft office, or a UWP program.

This was implemented because the new capture method has a number of
undesired effects associated with it -- the issue of the capture border
that we can do nothing about, the fact that we can't control the capture
of the cursor, and the fact that Microsoft designed it to switch the
cursor away from hardware cursor mode when the capture is active (there
was absolutely no reason to do this because even OBS can capture the
hardware cursor with no issue).  Until we get a new version of this API
that doesn't absolutely blow, we're stuck preferring BitBlt instead.

But hey, at least people will be able to capture browser windows now.
2020-02-22 21:02:33 -08:00
jpark37 ffc48dbbab win-capture: Windows Graphics Capture support
Users will now have the option of legacy window capture via BitBlt, or
Windows Graphics Capture, which is new to Windows 10.

There are two annoyances with the new capture method though. One is that
there is a bright, yellow border added to the original window (but not
the OBS view of it). The other is that the mouse cursor is always
captured, and we won't be able to capture without cursor until a later
version of Windows 10 is released.

It should also be noted that DPI scaling is now applied, which may
result in blurrier images caused by Windows rescaling.
2020-02-22 21:02:33 -08:00
jpark37 d4ca08c4c7 win-capture: Add support for finding windows via EnumWindows
The top-level window appears to be preferred for upcoming Windows
Graphics Capture support, at least for UWP apps.
2020-02-22 21:02:33 -08:00
VodBox d2e115881d win-capture: Fix hook collisions with multiple game captures
Before this change, after a game capture source would send a signal to
init or restart a graphics hook, it would respond to any and all hook
ready signals.

With multiple game capture sources in the same scene, a source could
receive the signal intended for another source, and show the wrong
texture.

This change adds the window handle to the name for shared data with the
hook, resulting in hooks for other sources being ignored.
2020-02-18 21:20:48 +13:00
Richard Stanway fb6936a934 win-capture: Faster display / window capture updates
When changing the target for display or window capture, force a
refresh of the source by setting the timer to fire immediately. This
removes 1-3 seconds of "lag" before the new display or window is
visible and makes the UI feel more responsive.

Closes https://github.com/obsproject/obs-studio/issues/2322
2020-02-03 23:22:42 +01:00
Peter Geis 64d0b7fcb4 libobs: Enable compilation on aarch64
Add arch checks to enable aarch-compat layer on aarch64, retain normal
gcc intrinsics on x86 and ppc64.
2019-11-25 13:04:21 -05:00
Clayton Groeneveld 82ffcdc827 UI: Add source icons 2019-11-24 20:50:42 -08:00
tujinshu 76e6a99124 win-capture: Fix rare crash when GL program exits
**Commit message modified and clarified by Jim**

When hooking a program that has both DirectX and OpenGL contexts in use,
it is possible to cause a crash on shutdown due to capture_active()
returning true when an OpenGL context is deleted.  Normally, when
capturing an OpenGL program, this would not happen because the 'active'
variable would not be set due to OpenGL capture not being initialized,
but if DirectX is captured while an OpenGL context is available, and
OpenGL could not load these required functions, then GL can crash due to
trying to use unavailable functions.

This case is extremely rare and doesn't happen under normal
circumstances; only if a program is using both DirectX and OpenGL within
the same program simultaneously, and *only* if OpenGL could not load the
required functions.  This likely almost never happens under normal
programs, games, and hardware.  This was apparently produced by hooking
a GL Qt program that used QWebEngine, which used multiple contexts at
once.
2019-11-05 13:44:15 -08:00
Joel Bethke 6fb3552d70 win-capture: Add additional exe to window capture blacklist
These are additional internal windows processes that should not
be listed in the window capture dropdown.
2019-10-16 19:47:43 -05:00
Jim 6b08c064f6
Merge pull request #2066 from jpark37/feature-level-baseline
Use D3D_FEATURE_LEVEL_10_0 as baseline
2019-10-12 20:55:33 -07:00
jpark37 1ce61c57c0 win-capture: Fix extra duplicator refs
Make duplicator_capture_tick the sole creater, and reference adder of
IDXGIOutputDuplication objects. This prevents a situation where
duplicator_capture::showing cause be false while
duplicator_capture::duplicator was not null at startup on background
scenes, preventing IDXGIOutputDuplication from being recreated when
DXGI_ERROR_ACCESS_LOST.
2019-10-10 19:03:18 -07:00
Gol-D-Ace 03b5be75e4 Update translations from Crowdin 2019-09-17 23:21:00 +02:00
jpark37 3ddef4bf7d win-capture: Remove support for feature level 9.3
Be consistent with libobs-d3d11, which now uses 10_0 as the baseline.
2019-09-08 22:43:41 -07:00
jpark37 ef39715c31 win-capture: Remove unused variable from D3D12 capture 2019-09-08 22:36:25 -07:00
craftwar e004ce8064 graphics-hook: Fix format specifier 2019-09-02 21:12:27 +08:00
jp9000 d981c10906 Revert "win-capture: Don't leak dynamic library references"
This reverts commit c5928bff4a.

This breaks game capture.
2019-08-17 12:23:44 -07:00
Michael Fabian 'Xaymar' Dirks c5928bff4a win-capture: Don't leak dynamic library references 2019-07-24 18:26:45 +02:00
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00
jp9000 53615ee10f clang-format: Add clang-format files 2019-06-23 01:53:56 -07:00
Gol-D-Ace 973bc481ce Update translations from Crowdin 2019-06-11 01:42:42 +02:00
jp9000 1f39259bc5 win-capture: Add discord to game capture blacklist 2019-06-01 20:07:39 -07:00
geemion f6581952bc win-capture/graphics-hook: Check if mutex abandoned
It's possible that the mutexes used with shared memory capture to return
WAIT_ABANDONED if OBS is shut down abnormally while the mutex is locked.
2019-04-14 03:44:48 -07:00
Gol-D-Ace e78ac5ebef Update translations from Crowdin 2019-04-04 16:19:51 +02:00
jp9000 93cc09f078 obs-text, win-capture: Do not use premultiplied alpha 2019-03-07 08:14:34 -08:00
Gol-D-Ace c3711bdd5e Update translations from Crowdin 2019-02-20 22:26:07 +01:00
jp9000 c372d26c02 win-capture: Don't try to find window every frame
When window capture is not capturing a window, don't try to find the
window every frame.  Instead, just check once per frame.  The process of
finding a window has a lot of checks and requires a surprising amount of
processing.
2019-02-11 17:57:24 -08:00
Colin Edwards 17524a9691
Merge pull request #1638 from WizardCM/offset-monitor-count
win-capture: Start user-facing monitor count at 1
2019-02-04 21:00:05 -06:00
jp9000 a4e8b93653 win-capture: Add a few more blacklisted capture exes 2019-02-04 18:16:43 -08:00
jp9000 da1f84133e win-capture: Do not capture "explorer.exe" with null titles 2019-02-04 18:16:43 -08:00
Matt Gajownik 84a3a906a0 win-capture: Start user-facing monitor count at 1
Operating systems don't report monitors from 0, so OBS shouldn't
either. This avoids user confusion when display capture doesn't work.
This does not change monitor count internally.
2019-02-03 11:18:00 +11:00
Christopher Serr 7c53483388 Use Premultiplied Alpha for Text and Game Capture (#1578)
The GDI+ based Text Source actually uses Premultiplied Alpha. The edges
of the fonts are therefore incorrectly blended, causing ugly artifacts
especially if bright text above a bright background is used. Here's an
image comparing the new text blending (left) to before (right):
![https://i.imgur.com/VhhkQcZ.png](https://i.imgur.com/VhhkQcZ.png)

Additionally, the game capture has the same problem, so premultiplied
alpha is used there as well now.
2019-01-30 21:54:24 -06:00
Richard Stanway 7a32f12d9c win-capture: Disable cached offsets writing
We don't read cached offsets any more, so it makes little sense to write
them on every startup.
2019-01-27 16:18:53 +01:00
Richard Stanway f48b210d61 win-capture: Improve reading from get-graphics-offsets
Increase the buffer size to read the response in one call if possible,
and cause an error condition with log message if the offsets string is
empty.
2019-01-27 16:18:53 +01:00
Jim 0f6761468b
Merge pull request #1479 from tompeeters368/master
win-capture: Add option to adjust hook rate for game capture
2018-09-17 13:52:41 -07:00
Jim af320a0838
Merge pull request #1480 from kkartaltepe/module-descriptions
Plugins: Add descriptions to modules
2018-09-16 15:34:28 -07:00
Tom Peeters 6bbeaae02e win-capture: Add option to adjust hook rate for game capture
This option slows down or speeds up the rate at which
the game capture plugin checks for a valid window.
2018-09-13 19:35:37 +02:00
jp9000 b3ef46d986 cmake: Make static VC runtime libraries consistent
Makes Visual C runtime libraries consistent across
Debug/MinSizeRel/Release/RelWithDebInfo, rather than just changing those
flags for RelWithDebInfo.  Also adds /Zl for statically linked
libraries.

Closes obsproject/obs-studio#1421
2018-09-12 07:49:13 -07:00
Kurt Kartaltepe d86c8121ed Plugins: Add descriptions to modules 2018-09-11 18:28:58 -07:00
Jim 4e90b61210
Merge pull request #1364 from kkartaltepe/patch-5
[win-capture] Modify log for sharedmem
2018-09-05 23:59:03 -07:00
Matt Gajownik d2538690b5 UI: Blacklist LockApp and Text Input from Game Capture
Occasionally users accidentally select the following applications built
into Windows 10 using game capture, which cannot be captured.
This PR simply hides them from the game capture list.
The latter takes up 6 entries in the dropdown.

LockApp.exe - the lock screen which doesn't run in user space
WindowsInternal.ComposableShell.Experiences.TextInput.InputApp
2018-09-02 15:21:10 +10:00
Gol-D-Ace a79aaa28ab Update translations from Crowdin 2018-08-18 04:16:35 +02:00
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
sorayuki ce53c5cc70
win-capture: Avoid tex size mismatch for cursor
Re-fetch texture when cursor's either width or height changed.

When the cursor icon changed and the new one has the same width or height,
it may not recreate the texture and thus cause memory access violation.
2018-08-07 17:15:07 +08:00
Kurt Kartaltepe f90a052b5e win-capture: Modify log for sharedmem
Distinguish in the log that this is for shared-mem/mutli-adapter
not anti-cheat.
2018-07-13 23:14:30 -07:00
SuslikV a75724d8a5 win-capture: Fix cursor draw size with certain cursors
When drawing cursor to window capture area - use actual resource width
and height instead of system metric values for icons.  Fixes an issue
where under rare circumstances, certain cursors would not draw at the
correct size.

Closes obsproject/obs-studio#1284
2018-05-06 11:38:49 -07:00
Richard Stanway 4df7914767
win-capture: Update D3D9 signature for Win10 April 2018 Update 2018-05-02 14:00:44 +02:00
Zachary Lund 6475a1c000 win-capture: Avoid obs functions in init_hooks 2018-04-24 14:17:28 -07:00
Gol-D-Ace 88282c168c Update translations from Crowdin 2018-03-15 09:00:28 +01:00
jp9000 4b54bde426 cmake, libobs, win-capture: Fix VS2017 warnings 2018-03-12 16:16:38 -07:00
jp9000 8a16fa8341 win-capture/graphics-hook: Fix memory offset calculation
Fixes an issue where align_pos could be smaller than
sizeof(struct shmem_data), potentially overwriting memory of the header.

References jp9000/obs-studio#1202
2018-02-24 21:48:50 -08:00
Gol-D-Ace ae22886f67 Update translations from Crowdin 2018-01-22 04:55:52 +01:00
jp9000 ae259bf8d8 win-capture: Make minor clarification to locale string 2018-01-13 18:30:23 -08: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 cf9f016820
win-capture: Rename structs to avoid SDK conflict
Windows SDK 10.0.16299.0 defines these structures as part of winternl.h
but using different types and names. Unfortunately there's no macro to
detect the SDK version, so to avoid conflicting with newer / older SDKs
the OBS structs have been renamed.
2017-12-12 18:20:56 +01:00
Ryan Foster 1db301f907 win-capture: Log window capture's target
Closes jp9000/obs-studio#983
2017-11-26 18:00:51 -08:00
Bazhenoff b9d044267d graphics-hook: blacklist OpenGL capture for "cm_client.exe"
Closes jp9000/obs-studio#1076
2017-11-16 17:57:11 -08:00
jp9000 e5d660e944 graphics-hook: Blacklist specific game from GL capture
"Life is Feudal: Your Own" will use Direct3D to render the game, then
OpenGL to render its in-game menus, which causes a conflict with itself.
This specifically blacklists the game from capturing OpenGL to prevent
that from happening.
2017-10-02 15:29:04 -07:00
jp9000 008e38f5b6 win-capture: Remove buffering from window capture
Removes the unnecessary buffering from window capture to prevent window
capture from being one frame out of sync
2017-10-02 07:36:02 -07:00
Gol-D-Ace 8d8c2e5a22 Update translations from Crowdin 2017-08-10 16:07:40 +02:00
Richard Stanway bc3a5cb832
win-capture: Log when game capture compatibilty mode is set 2017-07-01 21:39:20 +02:00
Richard Stanway 20cc8e6ab7
inject-helper: Set error mode to SEM_FAILCRITICALERRORS
This prevents spurious dialog boxes appearing, such as "No disk is in the
drive" if the application attempts to access an invalid drive.
2017-06-21 17:42:05 +02:00
Richard Stanway 8ad8e18d04
get-graphics-offsets: Set error mode to SEM_FAILCRITICALERRORS
This prevents spurious dialog boxes appearing, such as "No disk is in the
drive" if the application attempts to access an invalid drive.
2017-06-21 17:41:26 +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 1ca9f8872e win-capture: Add IDXGISwapChain1::Present1 hook support
Allows capturing games/programs that may be using Present1 instead of
the regular Present call for rendering.
2017-06-19 15:45:00 -07:00
jp9000 c4036b18bb win-capture/graphics-hook: Fix D3D10/D3D11 detection
When hooking DXGI-based graphics programs in the hook, the first hook
point is IDXGISwapChain::Present.  To be able to initiate a capture, a
pointer to the device context that created the swap chain is required,
which can be retrieved via IDXGISwapChain::GetDevice.  Determining
whether the device context was D3D10 or D3D11 has always been somewhat
of an issue due to D3D10 and D3D11 being nearly identical, as well as
their interoperability/interchangeability.  The GetDevice function would
first be called with the UUID of ID3D10Device, then if that failed,
the UUID of ID3D11Device.

However, with certain specific D3D11 games, GetDevice would for some
unknown reason succeed with the UUID of ID3D10Device, which would cause
capture to fail.  (Conversely, attempting to call GetDevice with the
UUID of ID3D11Device on a device that's actually ID3D10Device would
always succeed, so reversing the order of the test was not an option).
There were originally three known D3D11 games that would erroneously
succeed when querying a D3D10 device interface:  Call of Duty: Ghosts,
Just Cause 3, and theHunter: Call of the Wild.  All other known D3D11
games would work correctly.  Because it was only these three games, a
hack was originally implemented in the form of an executable exception
list that would force them to capture D3D11.

Unfortunately, Oculus games are now failing under the same circumstance
as well, so a simple hack will no longer work.  To fix this, a more
reliable method of detecting which context it is had to be discovered:
simply check the feature level using ID3D11Device::GetFeatureLevel.  If
the feature level is D3D_FEATURE_LEVEL_11_0 or D3D_FEATURE_LEVEL_11_1,
the device is definitely a D3D11 device.  Otherwise, continue the tests
as they were before.  Successfully tested with many D3D10 games, many
D3D11 games, and especially those three D3D11 games that previously were
detected as D3D10 erroneously.
2017-06-15 03:48:43 -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
Gol-D-Ace 3d2cacd782 Update translations from Crowdin 2017-05-20 10:18:41 +02:00
Richard Stanway 0c167d27a6
win-capture: Hide cursor when in background (window capture) 2017-05-11 00:01:33 +02: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 2ae706782c
Merge branch 'new-get-graphics-offsets'
Added offsets to support Windows 10 Creator's Update
2017-05-01 16:15:16 +02:00
jp9000 2e0d237341 win-capture: Fix and clarify window capture prioritization
Changes "class" prioritization to attempt to find the window either with
the same title, or the next window of the same window class (window
type), changes "title" prioritization to only find the window based
upon its title, and changes "executable" prioritization to attempt to
find the window with the same title, or the next window of the same
executable.

Additionally changes the text associated with these selections to
clarify that functionality to users.
2017-04-30 00:25:02 -07:00
Richard Stanway 38294d6c47
win-capture: Add missing 32 bit offsets 2017-04-26 21:36:49 +02:00
Richard Stanway 35a9b2d27f
win-capture: Update get-graphics-offsets
Added support for multiple signature matching and variable offset
positions. Added support for Win7 64 bit signature for consistency.
2017-04-26 21:23:34 +02:00
Richard Stanway d4de8b9a7e win-capture: Log if shared texture capture is unavailable 2017-04-26 21:04:41 +02:00
Ryan Foster be98cee2a0 Fix various typos across multiple modules 2017-04-25 22:39:42 -04:00
Gol-D-Ace dbf95bdc15 Update translations from Crowdin 2017-03-05 23:40:11 +01:00
Gol-D-Ace a13c0a3c29 Update translations from Crowdin 2017-02-27 20:54:02 +01:00
Richard Stanway d2e9e47bb4 graphics-hook: Account for sizeof(wchar_t) in len 2017-02-25 17:18:55 +01:00
Cam 8a6491c9bf win-capture: Add hook exception for theHunter: COTW
Adds an exception to skip d3d10 checks for theHunter: Call of the Wild,
which fixes incompatibility with game capture.

Closes jp9000/obs-studio#801
2017-02-25 06:42:36 -08:00
jp9000 5b8a0a2777 win-capture: Blacklist chrome/firefox from game capture 2017-02-21 23:05:49 -08:00
jp9000 eb90b7dfff win-capture: Fall back to GetWindow if FindWindowEx fails
When kaspersky is installed on windows 7, FindWindowEx will fail to find
any windows due to apparently being blocked by kaspersky, so detect when
that happens, and fall back to GetWindow instead if it does.
2017-02-21 00:42:14 -08:00
jp9000 839e593e77 Revert "Revert "win-capture: Use FindWindowEx to traverse window list""
This reverts commit f4d7f0cbba.

Never thought a revert of a revert would happen.
2017-01-18 20:18:28 -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 f4d7f0cbba Revert "win-capture: Use FindWindowEx to traverse window list"
This reverts commit bd67c18c02.

Causes performance issues when the window isn't found.  The situation it
fixes is also very rare anyway.
2017-01-16 03:22:12 -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
Gol-D-Ace 6223ed6520 Update translations from Crowdin 2017-01-07 00:23:16 +01:00
Gol-D-Ace 69f0bc244a Update translations from Crowdin 2016-12-23 20:46:47 +01:00
jp9000 21be33805d win-capture: Release backbuffers immediately upon init
There's no need to keep a reference to the backbuffers.  That and the
backbuffer references weren't being released anyway, so that fixes that
bug.
2016-12-23 08:07:26 -08:00
jp9000 74a5bdf993 win-capture: If backbuffer count is 1, disable dxgi 1.4 use
Executing the dxgi 1.4 code causes it to cycle through backbuffers,
backbuffers which may not exist if in discard mode.
2016-12-23 08:02:35 -08:00
jp9000 414ff5ba14 win-capture: Refactor DX12 backbuffer code
It was undesirable to pass arrays via function parameters, so a
structure should be used instead.

Also increases total allowable backbuffers to 8.
2016-12-23 08:02:30 -08:00
jp9000 a4143be052 win-capture: Fix possible access of array beyond size
If the backbuffer count is larger than 3, it could still try to assign
backbuffers to pointers beyond the variable's array size when calling
swap->GetBuffer.
2016-12-23 07:49:13 -08:00
jp9000 2da7f3cb0e win-capture: Add a few new blacklisted game capture exes 2016-12-23 02:17:14 -08:00
jp9000 ad72194090 win-capture: Do not add certain windows to window lists
Due to using FindWindowEx to search for certain windows, certain windows
will show up that aren't usable/capturable.  Prevent these windows from
showing up in the window lists.
2016-12-23 02:15:59 -08:00
jp9000 4fe2ca0f75 win-capture: Fix possible null pointer dereference 2016-12-23 02:04:26 -08:00