Add opt-in Windows 11 target-process audio capture, one AudioEncoder Opus stream, and one shared Pion audio track beside native video.
41 lines
1.9 KiB
PowerShell
41 lines
1.9 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$OutputDirectory
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$helperDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$repositoryRoot = [IO.Path]::GetFullPath((Join-Path $helperDirectory '..\..'))
|
|
$outputPath = [IO.Path]::GetFullPath($OutputDirectory)
|
|
$repositoryPrefix = $repositoryRoot.TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar
|
|
if ($outputPath.Equals($repositoryRoot, [StringComparison]::OrdinalIgnoreCase) -or
|
|
$outputPath.StartsWith($repositoryPrefix, [StringComparison]::OrdinalIgnoreCase)) {
|
|
throw 'OutputDirectory must be outside the repository.'
|
|
}
|
|
|
|
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
|
$installationPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
|
if ([string]::IsNullOrWhiteSpace($installationPath)) {
|
|
throw 'Visual Studio C++ Build Tools were not found.'
|
|
}
|
|
|
|
$developerCommand = Join-Path $installationPath 'Common7\Tools\VsDevCmd.bat'
|
|
$sourcePath = Join-Path $helperDirectory 'main.cpp'
|
|
$executablePath = Join-Path $outputPath 'screener-process-audio.exe'
|
|
$objectPath = Join-Path $outputPath 'main.obj'
|
|
New-Item -ItemType Directory -Path $outputPath -Force | Out-Null
|
|
|
|
$compile = @(
|
|
'call "{0}" -arch=x64 -host_arch=x64 >nul' -f $developerCommand
|
|
'cl.exe /nologo /std:c++20 /EHsc /W4 /WX /DUNICODE /D_UNICODE /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x0A00 /DNTDDI_VERSION=0x0A00000A "{0}" /Fo:"{1}" /Fe:"{2}" /link ole32.lib mmdevapi.lib runtimeobject.lib user32.lib' -f $sourcePath, $objectPath, $executablePath
|
|
) -join ' && '
|
|
|
|
& cmd.exe /d /s /c $compile
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Process-audio helper compilation failed with exit code $LASTEXITCODE."
|
|
}
|
|
Write-Output $executablePath
|