From 2450189a4f52c48e7dcc174fd9ae4282b6c78e62 Mon Sep 17 00:00:00 2001 From: Oleksii Zbykovskyi Date: Wed, 3 Dec 2025 12:20:49 +0100 Subject: [PATCH] Initial installation of the virtual camera on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not possible to test video APIs in CI, when they require hardware. Install a virtual camera driver on Windows, that can be used in autotests. Steps for installation and configuration of vcam are: install vcam from GitLab, restore NuGet packages and build the solution, register the created DLL in the win register, and set the env. variable. Task-number: QTBUG-139831 Change-Id: I963aca94e980440dc96e6998e3cd6de387dd80e9 Reviewed-by: Axel Spoerl Reviewed-by: Nils Petter Skålerud Reviewed-by: Artem Dyomin --- .../common/windows/install_configure_vcam.ps1 | 89 +++++++++++++++++++ .../89-install-vcam.ps1 | 1 + .../89-install-vcam.ps1 | 1 + .../89-install-vcam.ps1 | 1 + .../89-install-vcam.ps1 | 1 + 5 files changed, 93 insertions(+) create mode 100644 coin/provisioning/common/windows/install_configure_vcam.ps1 create mode 100644 coin/provisioning/qtci-windows-11_21H2-x86_64/89-install-vcam.ps1 create mode 100644 coin/provisioning/qtci-windows-11_22H2-x86_64/89-install-vcam.ps1 create mode 100644 coin/provisioning/qtci-windows-11_23H2-x86_64/89-install-vcam.ps1 create mode 100644 coin/provisioning/qtci-windows-11_24H2-x86_64/89-install-vcam.ps1 diff --git a/coin/provisioning/common/windows/install_configure_vcam.ps1 b/coin/provisioning/common/windows/install_configure_vcam.ps1 new file mode 100644 index 00000000..a7655a92 --- /dev/null +++ b/coin/provisioning/common/windows/install_configure_vcam.ps1 @@ -0,0 +1,89 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +. "$PSScriptRoot\helpers.ps1" + +$script:commitSha = "a8c4d08c9757c1689d832a33252ae465b97bfb9a" +$script:repoUrl = "https://git.qt.io/qtmultimedia/WindowsVirtualCamera/-/archive/$commitSha/WindowsVirtualCamera-$commitSha.zip" +$script:unzip_location = "C:\Utils\WindowsVirtualCamera" +$script:download_location = "C:\Windows\Temp\WindowsVirtualCamera.zip" + +$script:nuget = [System.Environment]::GetEnvironmentVariable('NUGET_EXE_PATH', [System.EnvironmentVariableTarget]::Machine) + +$script:localPath = "$unzip_location\WindowsVirtualCamera-$commitSha" +$script:solutionFile = "VCamManager.sln" +$script:buildConfig = "Release" +$script:targetPlatform = "x64" +$script:dllPath = "$localPath\$targetPlatform\$buildConfig\VCamSampleSource.dll" + +# Save the current location to return later +$previousLocation = Get-Location + +Write-Host "Downloading from $repoUrl to $download_location" +Invoke-WebRequest -Uri $repoUrl -OutFile $download_location +Write-Host "Extracting $download_location to $unzip_location" +Expand-Archive -Path $download_location -DestinationPath $unzip_location +Remove-Item $download_location + +# Ensure we're inside repo folder +Set-Location $localPath + +$hostArch = Get-CpuArchitecture +$arch = $hostArch +$result = EnterVSDevShell -HostArch $hostArch -Arch $arch +if (-Not $result) { + return $false +} + +Write-Host "Locating MSBuild" +$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + +if (-not (Test-Path $vswhere)) { + throw "vswhere.exe not found! Path: $vswhere" +} + +$msbuildPath = & $vswhere ` + -latest ` + -products * ` + -requires Microsoft.Component.MSBuild ` + -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` + -find "MSBuild\**\Bin\MSBuild.exe" ` + +if ($LASTEXITCODE -ne 0 -or -not (Test-Path $msbuildPath)) { + throw "MSBuild NOT found. Make sure VS Build Tools are installed." +} +Write-Host "MSBuild found: $msbuildPath" + +Write-Host "Restoring NuGet packages" +& $nuget restore $solutionFile + +Write-Host "Building solution $solutionFile" +& "$msbuildPath" $solutionFile ` + /t:Build ` + /p:Configuration=$buildConfig ` + /p:Platform=$targetPlatform ` + /p:RestorePackagesConfig=true ` + /m + +if ($LASTEXITCODE -eq 0) { + Write-Host "Build succeeded" +} else { + Write-Host " Build failed with exit code $LASTEXITCODE" + exit $LASTEXITCODE +} + +Write-Host "Registering the Virtual Camera dll" +regsvr32 /s "$dllPath" + +if ($LASTEXITCODE -eq 0) { + Write-Host "Register succeeded" +} else { + Write-Host "Register failed with exit code $LASTEXITCODE" + exit $LASTEXITCODE +} + +Set-EnvironmentVariable "VCAM_PATH" "$localPath\$targetPlatform\$buildConfig" +Write-Host "Environment variable VCAM_PATH set to $localPath\$targetPlatform\$buildConfig" + +# Return to previous location +Set-Location $previousLocation diff --git a/coin/provisioning/qtci-windows-11_21H2-x86_64/89-install-vcam.ps1 b/coin/provisioning/qtci-windows-11_21H2-x86_64/89-install-vcam.ps1 new file mode 100644 index 00000000..068cf8aa --- /dev/null +++ b/coin/provisioning/qtci-windows-11_21H2-x86_64/89-install-vcam.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install_configure_vcam.ps1" diff --git a/coin/provisioning/qtci-windows-11_22H2-x86_64/89-install-vcam.ps1 b/coin/provisioning/qtci-windows-11_22H2-x86_64/89-install-vcam.ps1 new file mode 100644 index 00000000..068cf8aa --- /dev/null +++ b/coin/provisioning/qtci-windows-11_22H2-x86_64/89-install-vcam.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install_configure_vcam.ps1" diff --git a/coin/provisioning/qtci-windows-11_23H2-x86_64/89-install-vcam.ps1 b/coin/provisioning/qtci-windows-11_23H2-x86_64/89-install-vcam.ps1 new file mode 100644 index 00000000..068cf8aa --- /dev/null +++ b/coin/provisioning/qtci-windows-11_23H2-x86_64/89-install-vcam.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install_configure_vcam.ps1" diff --git a/coin/provisioning/qtci-windows-11_24H2-x86_64/89-install-vcam.ps1 b/coin/provisioning/qtci-windows-11_24H2-x86_64/89-install-vcam.ps1 new file mode 100644 index 00000000..068cf8aa --- /dev/null +++ b/coin/provisioning/qtci-windows-11_24H2-x86_64/89-install-vcam.ps1 @@ -0,0 +1 @@ +. "$PSScriptRoot\..\common\windows\install_configure_vcam.ps1"