1515
1616env :
1717 OPENCV_VERSION : " 5.0.0"
18+ MEDIAMTX_VERSION : " 1.19.3"
1819
1920jobs :
2021 build :
@@ -174,6 +175,55 @@ jobs:
174175 -D NO_INSTALL_TO_TEST=ON
175176 cmake --build src/build_slim --config Release -j 4
176177
178+ - name : Start local RTSP test server
179+ shell : pwsh
180+ run : |
181+ $ErrorActionPreference = "Stop"
182+ $version = $env:MEDIAMTX_VERSION
183+ $archiveName = "mediamtx_v${version}_windows_amd64.zip"
184+ $downloadBase = "https://github.com/bluenviron/mediamtx/releases/download/v${version}"
185+ $serverDir = Join-Path $env:RUNNER_TEMP "mediamtx"
186+ $archivePath = Join-Path $env:RUNNER_TEMP $archiveName
187+ $checksumsPath = Join-Path $env:RUNNER_TEMP "mediamtx-checksums.sha256"
188+
189+ Invoke-WebRequest "$downloadBase/$archiveName" -OutFile $archivePath
190+ Invoke-WebRequest "$downloadBase/checksums.sha256" -OutFile $checksumsPath
191+
192+ $checksumLine = Get-Content $checksumsPath | Where-Object { $_ -match "[ *]$([regex]::Escape($archiveName))$" }
193+ if (-not $checksumLine) { throw "Checksum not found for $archiveName" }
194+ $expectedChecksum = ($checksumLine -split "\s+")[0].ToLowerInvariant()
195+ $actualChecksum = (Get-FileHash $archivePath -Algorithm SHA256).Hash.ToLowerInvariant()
196+ if ($actualChecksum -ne $expectedChecksum) {
197+ throw "Checksum mismatch for ${archiveName}: expected $expectedChecksum, got $actualChecksum"
198+ }
199+
200+ Expand-Archive $archivePath -DestinationPath $serverDir
201+ $stdoutPath = Join-Path $env:RUNNER_TEMP "mediamtx.stdout.log"
202+ $stderrPath = Join-Path $env:RUNNER_TEMP "mediamtx.stderr.log"
203+ $server = Start-Process `
204+ (Join-Path $serverDir "mediamtx.exe") `
205+ -ArgumentList "${env:GITHUB_WORKSPACE}\test\rtsp\mediamtx.yml" `
206+ -RedirectStandardOutput $stdoutPath `
207+ -RedirectStandardError $stderrPath `
208+ -WindowStyle Hidden `
209+ -PassThru
210+
211+ for ($attempt = 1; $attempt -le 30; $attempt++) {
212+ if ($server.HasExited) {
213+ Get-Content $stdoutPath, $stderrPath -ErrorAction SilentlyContinue
214+ throw "MediaMTX exited with code $($server.ExitCode)"
215+ }
216+ if ((Get-Content $stdoutPath -Raw -ErrorAction SilentlyContinue) -match "stream is available") {
217+ "OPENCVSHARP_TEST_RTSP_URL=rtsp://127.0.0.1:8554/test" | Out-File $env:GITHUB_ENV -Append
218+ "OPENCVSHARP_RTSP_SERVER_PID=$($server.Id)" | Out-File $env:GITHUB_ENV -Append
219+ exit 0
220+ }
221+ Start-Sleep -Seconds 1
222+ }
223+
224+ Get-Content $stdoutPath, $stderrPath -ErrorAction SilentlyContinue
225+ throw "Timed out waiting for MediaMTX"
226+
177227 - name : Test
178228 shell : cmd
179229 # --blame-crash* collects a full memory dump and a Sequence_*.xml (listing tests executed,
@@ -182,6 +232,14 @@ jobs:
182232 # re-run. See "Upload crash dumps on failure" below.
183233 run : dotnet test test\OpenCvSharp.Tests -c Release -f net10.0 --runtime win-x64 --blame-crash --blame-crash-dump-type full
184234
235+ - name : Stop local RTSP test server
236+ if : always()
237+ shell : pwsh
238+ run : |
239+ if ($env:OPENCVSHARP_RTSP_SERVER_PID) {
240+ Stop-Process -Id $env:OPENCVSHARP_RTSP_SERVER_PID -Force -ErrorAction SilentlyContinue
241+ }
242+
185243 - name : Upload crash dumps on failure
186244 if : failure()
187245 uses : actions/upload-artifact@v7
0 commit comments