Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 129 additions & 47 deletions scripts/build_dlstreamer_dlls.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $OPENVINO_VERSION = "2026.0.0"
$OPENVINO_VERSION_SHORT = "2026.0"
$PYTHON_VERSION = "3.12.7"
$OPENVINO_DEST_FOLDER = "$env:LOCALAPPDATA\Programs\openvino"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer\1.0\msvc_x86_64"
$DLSTREAMER_TMP = "$env:TEMP\dlstreamer_tmp"

if ($useInternalProxy) {
Expand Down Expand Up @@ -81,6 +81,51 @@ function Invoke-DownloadFile {
}
}

function Uninstall-GStreamer {
# Check if this is an Inno installation (GStreamer 1.28+)
$innoUninstallKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\c20a66dc-b249-4e6d-a68a-d0f836b2b3cf_is1"
$quietUninstall = (Get-ItemProperty -Path $innoUninstallKey -Name "QuietUninstallString" -ErrorAction SilentlyContinue).QuietUninstallString

if ($quietUninstall) {
Write-Host "Uninstalling GStreamer (Inno)..."
if ($quietUninstall -match '^"([^"]+)"\s*(.*)$') {
$process = Start-Process -Wait -PassThru -FilePath $Matches[1] -ArgumentList $Matches[2]
if ($process.ExitCode -ne 0) {
Write-Host "GStreamer uninstall returned exit code: $($process.ExitCode)"
}
}
else {
Write-Host "Could not parse QuietUninstallString: $quietUninstall"
}
# Workaround: GStreamer 1.28.1 uninstaller does not remove registry entries
if (Test-Path "HKLM:\SOFTWARE\GStreamer1.0\x86_64") {
Remove-Item -Path "HKLM:\SOFTWARE\GStreamer1.0\x86_64" -Recurse -Force
Write-Host "Removed GStreamer registry entries"
}
}
else {
Write-Host "Uninstalling GStreamer (MSI)..."
try {
$installer = New-Object -ComObject "WindowsInstaller.Installer"
foreach ($upgradeCode in @("{c20a66dc-b249-4e6d-a68a-d0f836b2b3cf}", "{49c4a3aa-249f-453c-b82e-ecd05fac0693}")) {
$products = $installer.RelatedProducts($upgradeCode)
if ($products) {
foreach ($productCode in $products) {
$result = Start-Process -Wait -PassThru -FilePath "msiexec" -ArgumentList "/x", $productCode, "/qn", "/norestart"
if ($result.ExitCode -ne 0 -and $result.ExitCode -ne 1605) {
Write-Host "MSI uninstall returned exit code: $($result.ExitCode)"
}
}
}
}
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($installer) | Out-Null
}
catch {
Write-Host "Error during MSI uninstall: $_"
}
}
}

# ============================================================================
# WinGet
# ============================================================================
Expand Down Expand Up @@ -138,7 +183,6 @@ Write-Section "Done"
# GStreamer
# ============================================================================
$GSTREAMER_NEEDS_INSTALL = $false
$GSTREAMER_INSTALL_MODE = "none" # values: none | fresh | upgrade

try {
$regPath = "HKLM:\SOFTWARE\GStreamer1.0\x86_64"
Expand All @@ -148,11 +192,14 @@ try {
if ($regInstallDir -and $regVersion) {
Write-Host "GStreamer found in registry - InstallDir: $regInstallDir, Version: $regVersion"
$GSTREAMER_DEST_FOLDER = $regInstallDir.TrimEnd('\')
# Check for conflicting architectures first
$expectedPath = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64"
# Backward compatibility with 1.26
if (-Not $GSTREAMER_DEST_FOLDER.EndsWith('\1.0\msvc_x86_64')) {
$GSTREAMER_DEST_FOLDER = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64"
}
# Check for conflicting architectures
$envMsvcX64 = [Environment]::GetEnvironmentVariable('GSTREAMER_1_0_ROOT_MSVC_X86_64', 'Machine')

if ($envMsvcX64 -and ($envMsvcX64.TrimEnd('\') -ne $expectedPath)) {
if ($envMsvcX64 -and ($envMsvcX64.TrimEnd('\') -ne $GSTREAMER_DEST_FOLDER)) {
Write-Host "Warning: GSTREAMER_1_0_ROOT_MSVC_X86_64 points to unexpected location: $envMsvcX64"
}
$conflictingArchs = @()
Expand All @@ -170,69 +217,75 @@ try {
Write-Host "Multiple GStreamer architectures may cause conflicts. Only msvc_x86_64 is supported."
}

# Parse and compare versions
$installedParts = $regVersion.Split('.') | ForEach-Object { [int]$_ }
$requiredParts = $GSTREAMER_VERSION.Split('.') | ForEach-Object { [int]$_ }
$needsUpgrade = $false
for ($i = 0; $i -lt [Math]::Max($installedParts.Length, $requiredParts.Length); $i++) {
$installedPart = if ($i -lt $installedParts.Length) { $installedParts[$i] } else { 0 }
$requiredPart = if ($i -lt $requiredParts.Length) { $requiredParts[$i] } else { 0 }
if ($installedPart -lt $requiredPart) {
$needsUpgrade = $true
break
}
elseif ($installedPart -gt $requiredPart) {
# Installed version is newer, no upgrade needed
break
}
}

if ($needsUpgrade) {
Write-Host "GStreamer upgrade available - installed: $regVersion, required: $GSTREAMER_VERSION - upgrading"
if ($regVersion -ne $GSTREAMER_VERSION) {
Write-Host "GStreamer version mismatch - installed: $regVersion, required: $GSTREAMER_VERSION"
Uninstall-GStreamer
$GSTREAMER_NEEDS_INSTALL = $true
$GSTREAMER_INSTALL_MODE = "upgrade"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer\1.0\msvc_x86_64"
}
else {
# Verify installation directory structure exists
$VERSION_SPECIFIC_PATH = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64"
if (-Not (Test-Path $VERSION_SPECIFIC_PATH)) {
Write-Host "GStreamer installation incomplete - msvc_x86_64 directory not found - reinstallation needed"
if (-Not (Test-Path $GSTREAMER_DEST_FOLDER)) {
Write-Host "GStreamer installation incomplete - $GSTREAMER_DEST_FOLDER not found - reinstallation needed"
$GSTREAMER_NEEDS_INSTALL = $true
$GSTREAMER_INSTALL_MODE = "fresh"
}
else {
Write-Host "GStreamer version $regVersion verified (compatible with $GSTREAMER_VERSION)"
Write-Host "GStreamer version $regVersion verified (matches required $GSTREAMER_VERSION)"
$GSTREAMER_NEEDS_INSTALL = $false
}
}
}
else {
else {
Write-Host "GStreamer not found in registry - installation needed"
$GSTREAMER_NEEDS_INSTALL = $true
$GSTREAMER_INSTALL_MODE = "fresh"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer\1.0\msvc_x86_64"
}
}
catch {
Write-Host "GStreamer registry check failed - assuming not installed"
$GSTREAMER_NEEDS_INSTALL = $true
$GSTREAMER_INSTALL_MODE = "fresh"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer"
$GSTREAMER_DEST_FOLDER = "$env:ProgramFiles\gstreamer\1.0\msvc_x86_64"
}

if ($GSTREAMER_NEEDS_INSTALL) {
Write-Section "Preparing GStreamer ${GSTREAMER_VERSION}"
# Determine installer type based on target version
$vParts = $GSTREAMER_VERSION.Split('.') | ForEach-Object { [int]$_ }
$useExeInstaller = ($vParts[0] -gt 1) -or ($vParts[0] -eq 1 -and $vParts[1] -ge 28)

if ($useExeInstaller) {
Write-Section "Installing GStreamer ${GSTREAMER_VERSION} (Inno)"
$GSTREAMER_INSTALLER = "${DLSTREAMER_TMP}\gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.exe"
Write-Host "Downloading GStreamer installer..."
Invoke-DownloadFile -UserAgent "curl/8.5.0" -OutFile $GSTREAMER_INSTALLER -Uri "https://gstreamer.freedesktop.org/data/pkg/windows/${GSTREAMER_VERSION}/msvc/gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.exe"

Write-Host "Installing GStreamer..."
$process = Start-Process -Wait -PassThru -FilePath $GSTREAMER_INSTALLER -ArgumentList "/SILENT", "/LOG", "/TYPE=full", "/ALLUSERS"
if ($process.ExitCode -ne 0) {
Write-Error "GStreamer installation failed with exit code: $($process.ExitCode)"
}

$GSTREAMER_RUNTIME_INSTALLER = "${DLSTREAMER_TMP}\gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.msi"
$GSTREAMER_DEVEL_INSTALLER = "${DLSTREAMER_TMP}\gstreamer-1.0-devel-msvc-x86_64-${GSTREAMER_VERSION}.msi"
# Workaround: GStreamer 1.28.1 writes GSTREAMER_1_0_ROOT_MSVC_X86_64 to wrong registry location, fixed in 1.28.2 https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/574
$wrongRegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager"
$rightRegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
$envVarName = "GSTREAMER_1_0_ROOT_MSVC_X86_64"
$wrongValue = (Get-ItemProperty -Path $wrongRegKey -Name $envVarName -ErrorAction SilentlyContinue).$envVarName
if ($wrongValue) {
Write-Host "Fixing $envVarName registry location..."
Set-ItemProperty -Path $rightRegKey -Name $envVarName -Value $wrongValue
Remove-ItemProperty -Path $wrongRegKey -Name $envVarName
}
}
else {
Write-Section "Installing GStreamer ${GSTREAMER_VERSION} (MSI)"
$GSTREAMER_RUNTIME_INSTALLER = "${DLSTREAMER_TMP}\gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.msi"
$GSTREAMER_DEVEL_INSTALLER = "${DLSTREAMER_TMP}\gstreamer-1.0-devel-msvc-x86_64-${GSTREAMER_VERSION}.msi"

Write-Host "Downloading GStreamer runtime installer..."
Invoke-DownloadFile -UserAgent "curl/8.5.0" -OutFile $GSTREAMER_RUNTIME_INSTALLER -Uri "https://gstreamer.freedesktop.org/data/pkg/windows/${GSTREAMER_VERSION}/msvc/gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.msi"
Write-Host "Downloading GStreamer runtime installer..."
Invoke-DownloadFile -UserAgent "curl/8.5.0" -OutFile $GSTREAMER_RUNTIME_INSTALLER -Uri "https://gstreamer.freedesktop.org/data/pkg/windows/${GSTREAMER_VERSION}/msvc/gstreamer-1.0-msvc-x86_64-${GSTREAMER_VERSION}.msi"

Write-Host "Downloading GStreamer development installer..."
Invoke-DownloadFile -UserAgent "curl/8.5.0" -OutFile $GSTREAMER_DEVEL_INSTALLER -Uri "https://gstreamer.freedesktop.org/data/pkg/windows/${GSTREAMER_VERSION}/msvc/gstreamer-1.0-devel-msvc-x86_64-${GSTREAMER_VERSION}.msi"
Write-Host "Downloading GStreamer development installer..."
Invoke-DownloadFile -UserAgent "curl/8.5.0" -OutFile $GSTREAMER_DEVEL_INSTALLER -Uri "https://gstreamer.freedesktop.org/data/pkg/windows/${GSTREAMER_VERSION}/msvc/gstreamer-1.0-devel-msvc-x86_64-${GSTREAMER_VERSION}.msi"

if ($GSTREAMER_INSTALL_MODE -eq "fresh" -or $GSTREAMER_INSTALL_MODE -eq "upgrade") {
Write-Host "Installing GStreamer runtime package..."
$process = Start-Process -Wait -PassThru -FilePath "msiexec" -ArgumentList "/passive", "/i", $GSTREAMER_RUNTIME_INSTALLER, "/qn"
if ($process.ExitCode -ne 0) {
Expand All @@ -244,12 +297,22 @@ if ($GSTREAMER_NEEDS_INSTALL) {
Write-Error "GStreamer development installation failed with exit code: $($process.ExitCode)"
}
# FIXME: Remove this section after GStreamer 1.28
$pkgConfigFile = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64\lib\pkgconfig\gstreamer-analytics-1.0.pc"
$pkgConfigFile = "$GSTREAMER_DEST_FOLDER\lib\pkgconfig\gstreamer-analytics-1.0.pc"
if (Test-Path $pkgConfigFile) {
(Get-Content $pkgConfigFile).Replace('-lm', '') | Set-Content $pkgConfigFile
}
Write-Section "GStreamer installation completed"
}

# Re-read registry to get actual install location
$regInstallDir = (Get-ItemProperty -Path "HKLM:\SOFTWARE\GStreamer1.0\x86_64" -Name "InstallDir" -ErrorAction SilentlyContinue).InstallDir
if ($regInstallDir) {
$GSTREAMER_DEST_FOLDER = $regInstallDir.TrimEnd('\')
# Backward compatibility with 1.26
if (-Not $GSTREAMER_DEST_FOLDER.EndsWith('\1.0\msvc_x86_64')) {
$GSTREAMER_DEST_FOLDER = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64"
}
}
Write-Section "GStreamer installation completed"
}
else {
Write-Section "GStreamer ${GSTREAMER_VERSION} already installed"
Expand Down Expand Up @@ -383,10 +446,29 @@ else {
# Final environment setup
# ============================================================================
Write-Section "Setting paths"
# Ensure GStreamer bin is in user PATH for GStreamer 1.28+
$GSTREAMER_BIN = "$GSTREAMER_DEST_FOLDER\bin"
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$vParts = $GSTREAMER_VERSION.Split('.') | ForEach-Object { [int]$_ }
if ($vParts[0] -eq 1 -and $vParts[1] -ge 28) {
if ($userPath -split ';' -notcontains $GSTREAMER_BIN) {
[Environment]::SetEnvironmentVariable('Path', "$userPath;$GSTREAMER_BIN", [System.EnvironmentVariableTarget]::User)
Write-Host "Added to user PATH: $GSTREAMER_BIN"
}
}
else {
$pathEntries = $userPath -split ';' | Where-Object { $_ -ne $GSTREAMER_BIN }
$newPath = $pathEntries -join ';'
if ($newPath -ne $userPath) {
[Environment]::SetEnvironmentVariable('Path', $newPath, [System.EnvironmentVariableTarget]::User)
Write-Host "Removed from user PATH: $GSTREAMER_BIN"
}
}

Update-Path
$DLSTREAMER_SRC_LOCATION = $PWD.Path
setx PKG_CONFIG_PATH "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64\lib\pkgconfig"
$env:PKG_CONFIG_PATH = "$GSTREAMER_DEST_FOLDER\1.0\msvc_x86_64\lib\pkgconfig"
setx PKG_CONFIG_PATH "$GSTREAMER_DEST_FOLDER\lib\pkgconfig"
$env:PKG_CONFIG_PATH = "$GSTREAMER_DEST_FOLDER\lib\pkgconfig"
# Setup OpenVINO environment variables
. "$OPENVINO_DEST_FOLDER\setupvars.ps1"
# Setup VS environment variables
Expand Down
54 changes: 40 additions & 14 deletions scripts/remove_dls_env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,46 @@ if ($RemoveSoftware) {

if ($regInstallDir -and $regVersion) {
Write-Host " Found GStreamer $regVersion at $regInstallDir"

# WiX upgrade codes for GStreamer packages (x86_64)
$GSTREAMER_RUNTIME_UPGRADE_CODE = "{c20a66dc-b249-4e6d-a68a-d0f836b2b3cf}"
$GSTREAMER_DEVEL_UPGRADE_CODE = "{49c4a3aa-249f-453c-b82e-ecd05fac0693}"

# Use Windows Installer COM object to find related products
$installer = New-Object -ComObject "WindowsInstaller.Installer"

# Uninstall packages
Uninstall-GStreamerPackage -Installer $installer -UpgradeCode $GSTREAMER_RUNTIME_UPGRADE_CODE -PackageName "runtime package"
Uninstall-GStreamerPackage -Installer $installer -UpgradeCode $GSTREAMER_DEVEL_UPGRADE_CODE -PackageName "development package"

# Release COM object
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($installer) | Out-Null

# Check if this is an Inno installation (GStreamer 1.28+)
$innoUninstallKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\c20a66dc-b249-4e6d-a68a-d0f836b2b3cf_is1"
$quietUninstall = (Get-ItemProperty -Path $innoUninstallKey -Name "QuietUninstallString" -ErrorAction SilentlyContinue).QuietUninstallString

if ($quietUninstall) {
Write-Host " Uninstalling GStreamer (Inno)..."
if ($quietUninstall -match '^"([^"]+)"\s*(.*)$') {
$process = Start-Process -Wait -PassThru -FilePath $Matches[1] -ArgumentList $Matches[2]
if ($process.ExitCode -eq 0) {
Write-Host " GStreamer uninstalled successfully"
}
else {
Write-Host " GStreamer uninstall returned exit code: $($process.ExitCode)"
}
}
else {
Write-Host " Could not parse QuietUninstallString: $quietUninstall"
}
# Workaround: GStreamer 1.28.1 uninstaller does not remove registry entries
if (Test-Path "HKLM:\SOFTWARE\GStreamer1.0\x86_64") {
Remove-Item -Path "HKLM:\SOFTWARE\GStreamer1.0\x86_64" -Recurse -Force
Write-Host " Removed GStreamer registry entries"
}
}
else {
# MSI uninstall (GStreamer < 1.28)
$GSTREAMER_RUNTIME_UPGRADE_CODE = "{c20a66dc-b249-4e6d-a68a-d0f836b2b3cf}"
$GSTREAMER_DEVEL_UPGRADE_CODE = "{49c4a3aa-249f-453c-b82e-ecd05fac0693}"

# Use Windows Installer COM object to find related products
$installer = New-Object -ComObject "WindowsInstaller.Installer"

# Uninstall packages
Uninstall-GStreamerPackage -Installer $installer -UpgradeCode $GSTREAMER_RUNTIME_UPGRADE_CODE -PackageName "runtime package"
Uninstall-GStreamerPackage -Installer $installer -UpgradeCode $GSTREAMER_DEVEL_UPGRADE_CODE -PackageName "development package"

# Release COM object
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($installer) | Out-Null
}
}
else {
Write-Host " GStreamer not found in registry"
Expand Down
Loading