Skip to content

Commit

Permalink
Rewrite with ActivateAudioInterfaceAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbez committed Aug 25, 2021
1 parent 393e11a commit c22cd0f
Show file tree
Hide file tree
Showing 25 changed files with 1,442 additions and 2,458 deletions.
16 changes: 4 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20)
project(win-capture-audio VERSION 1.0.0)
project(win-capture-audio VERSION 2.0.0)

set(PLUGIN_AUTHOR "bozbez")
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
Expand All @@ -22,12 +22,10 @@ set(win-capture-audio_SOURCES
src/plugin.c
src/audio-capture.c
src/obfuscate.c
src/window-helpers.c
src/inject-library.c)
src/window-helpers.c)

add_library(win-capture-audio MODULE ${win-capture-audio_SOURCES})
target_link_libraries(win-capture-audio libobs dwmapi psapi ksuser)

target_link_libraries(win-capture-audio libobs dwmapi psapi)

add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
Expand Down Expand Up @@ -81,10 +79,4 @@ function(copy_helper_lib)
)
endfunction()


add_subdirectory(src/get-audio-offsets)
add_subdirectory(src/audio-hook)
add_subdirectory(src/inject-helper)

add_custom_target(all-no-plugin)
add_dependencies(all-no-plugin get-audio-offsets audio-hook inject-helper)
add_subdirectory(src/audio-capture-helper)
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# win-capture-audio

An OBS plugin based on OBS's win-capture/game-capture that hooks WASAPI's audio output functions (rather than the various graphics API funcitons) that enables capture of audio streams directly from applications. This eliminates the need for third-party software or hardware audio mixing tools that introduce complexity, and in the case of software tools introduce mandatory latency.
An OBS plugin similar to OBS's win-capture/game-capture that uses [ActivateAudioInterfaceAsync](https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-activateaudiointerfaceasync) with [AUDIOCLIENT_PROCESS_LOOPBACK_PARAMS](https://docs.microsoft.com/en-us/windows/win32/api/audioclientactivationparams/ns-audioclientactivationparams-audioclient_process_loopback_params) to capture audio output from a specific process (and optionally its tree of child processes). This eliminates the need for third-party software or hardware audio mixing tools that introduce complexity, and in the case of software tools introduce mandatory latency.

The modus operandi is identical to the aforementioned game-capture plugin (and most likely to Discord's solution), and is inherently liable to instability and other issues due to the lack of a more "official" solution from the Windows API.

WARNING: I am not able to guarantee that using this is anti-cheat safe, however similar hook methods are employed in many widely deployed applications (Discord, Steam Overlay, RTSS, NVIDIA's ShadowPlay, etc...).
**This plugin requires an updated version of Windows 10 2004 (released 2020-05-27) or later.**

![overview](https://raw.githubusercontent.com/bozbez/win-capture-audio/main/media/overview.png)

## Limitations (current)

- WASAPI only (no DirectSound, WaveOut, etc...)
- No Windows App support (probably?)
- Chrome and Chrome-based (e.g. Electron) applications don't work (probably a limitation of the process selection logic rather than the hooking)
- Directly conflicts with Discord streaming (and maybe ShadowPlay) (unresolvable?)

## Installation and Usage

1. Head over to the [Releases](https://github.com/bozbez/win-capture-audio/releases) page and download the latest installer (or zip if you are using a portable installation)
Expand Down
12 changes: 6 additions & 6 deletions data/locale/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Window.Priority.Exe="Match title, otherwise find window of same executable"
Hotkey.Start="Capture foreground window"
Hotkey.Stop="Deactivate capture"

UseIndirectHook="Use anti-cheat compatibility hook"
IncludeProcessTree="Include process tree"

HookRate="Hook Rate"
HookRate.Slow="Slow"
HookRate.Normal="Normal (recommended)"
HookRate.Fast="Fast"
HookRate.Fastest="Fastest"
RecaptureRate="Recapture Rate"
RecaptureRate.Slow="Slow"
RecaptureRate.Normal="Normal (recommended)"
RecaptureRate.Fast="Fast"
RecaptureRate.Fastest="Fastest"
10 changes: 10 additions & 0 deletions src/audio-capture-helper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project(audio-capture-helper)

set(audio-capture-helper_SOURCES audio-capture-helper.c uuids.cpp)
add_executable(audio-capture-helper ${audio-capture-helper_SOURCES})
target_link_libraries(audio-capture-helper libobs ksuser mmdevapi)

set_target_properties(audio-capture-helper PROPERTIES
OUTPUT_NAME "audio-capture-helper")

copy_helper_lib(audio-capture-helper)
Loading

0 comments on commit c22cd0f

Please sign in to comment.