@@ -17,19 +17,19 @@ jobs:
1717 strategy :
1818 matrix :
1919 sample :
20- - name : kvs_gstreamer_audio_video_sample
21- args : -f sample.mp4
22- - name : kvs_gstreamer_file_uploader_sample
23- args : sample.mp4 0 audio-video
24- # - name: kvs_gstreamer_multistream_sample
25- # args: ""
26- - name : kvs_gstreamer_sample
27- args : sample.mp4
28- - name : kvssink_gstreamer_sample
29- args : sample.mp4
20+ # - name: kvs_gstreamer_audio_video_sample
21+ # args: -f sample.mp4
22+ # - name: kvs_gstreamer_file_uploader_sample
23+ # args: sample.mp4 0 audio-video
24+ - name : kvs_gstreamer_multistream_sample
25+ args : rtsp-urls.txt
26+ # - name: kvs_gstreamer_sample
27+ # args: sample.mp4
28+ # - name: kvssink_gstreamer_sample
29+ # args: sample.mp4
3030 runner :
31- - id : macos-latest
32- image : macos-latest
31+ - id : macos-13
32+ image : macos-13
3333
3434 - id : ubuntu-22.04
3535 image : ubuntu-latest
@@ -92,17 +92,14 @@ jobs:
9292
9393 - name : Build samples (Windows)
9494 if : runner.os == 'Windows'
95- shell : cmd
9695 run : |
97- @echo on
98- set PATH=%PATH%;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\a\amazon-kinesis-video-streams-producer-c\amazon-kinesis-video-streams-producer-c\open-source\lib;D:\a\amazon-kinesis-video-streams-producer-c\amazon-kinesis-video-streams-producer-c\open-source\bin
96+ $env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin'
97+ mkdir D:\producer
98+ Move-Item -Path "D:\a\amazon-kinesis-video-streams-producer-sdk-cpp\amazon-kinesis-video-streams-producer-sdk-cpp\*" -Destination "D:\producer"
99+ cd D:\producer
99100 git config --system core.longpaths true
100- "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
101- mkdir build
102- cd build
103- cmake -G "NMake Makefiles" -DBUILD_GSTREAMER_PLUGIN=ON -DPKG_CONFIG_EXECUTABLE="D:\\gstreamer\\1.0\\msvc_x86_64\\bin\\pkg-config.exe" ..
104- nmake
105- mkdir "%KVS_DEBUG_DUMP_DATA_FILE_DIR%"
101+ dir
102+ .github\build_windows.bat
106103
107104 - name : Configure AWS Credentials
108105 uses : aws-actions/configure-aws-credentials@v4
@@ -112,8 +109,151 @@ jobs:
112109 aws-region : ${{ secrets.AWS_REGION }}
113110 role-duration-seconds : 10800
114111
112+ - name : Run multistream sample (Linux & Mac)
113+ if : (runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
114+ working-directory : ./build
115+ run : |
116+ set -x
117+ if [[ "$RUNNER_OS" == "Linux" ]]; then
118+ apt-get install -y docker.io
119+ else
120+ brew install --cask docker
121+ open -a /Applications/Docker.app --args --unattended --accept-license
122+ echo "We are waiting for Docker to be up and running. It can take over 2 minutes..."
123+ while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1; done
124+
125+ sudo ln -s ~/.docker/run/docker.sock /var/run/docker.sock
126+ fi
127+
128+ docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8554:8554 bluenviron/mediamtx:latest
129+ docker run -d --rm -it -e RTSP_PROTOCOLS=tcp -p 8555:8554 bluenviron/mediamtx:latest
130+
131+ (
132+ ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8554/mystream
133+ ) &
134+ (
135+ ffmpeg -re -f lavfi -i "testsrc=size=640x480:rate=10" -vcodec libx264 -x264-params keyint=25:scenecut=0 -f rtsp rtsp://localhost:8555/mystream
136+ ) &
137+
138+ echo "rtsp://0.0.0.0:8554/mystream" > rtsp-urls.txt
139+ echo "rtsp://0.0.0.0:8555/mystream" >> rtsp-urls.txt
140+
141+ sleep 5
142+ gst-discoverer-1.0 rtsp://0.0.0.0:8554/mystream
143+ gst-discoverer-1.0 rtsp://0.0.0.0:8555/mystream
144+
145+ set +e # Disable exit on error for the timeout command
146+ timeout --preserve-status --signal=SIGINT --kill-after=15s 30s \
147+ ./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
148+ EXIT_CODE=$?
149+ set -e # Re-enable exit on error
150+
151+ # 0: Process exited after interrupt with code 0
152+ # 1: Process exited with error code 1
153+ # 137: Process killed by SIGKILL (if the --kill-after timeout is reached)
154+ echo "Command exited with code: $EXIT_CODE"
155+ if [ $EXIT_CODE -ne 0 ]; then
156+ echo "Command did not exit gracefully after interrupt."
157+ exit 1
158+ fi
159+
160+ shell : bash
161+ env :
162+ GST_PLUGIN_PATH : ${{ github.workspace }}/build
163+ KVS_DEBUG_DUMP_DATA_FILE_DIR : ${{ github.workspace }}/build/debug_output
164+
165+ - name : Run multistream sample (Windows)
166+ if : runner.os == 'Windows' && matrix.sample.name == 'kvs_gstreamer_multistream_sample'
167+ shell : pwsh
168+ working-directory : D:\producer\build
169+ run : |
170+ # Equivalent to set -x
171+ Set-PSDebug -Trace 1
172+
173+ Invoke-WebRequest -Uri "https://github.com/bluenviron/mediamtx/releases/download/v1.11.2/mediamtx_v1.11.2_windows_amd64.zip" -OutFile "mediamtx.zip"
174+ Expand-Archive -Path mediamtx.zip -DestinationPath .
175+
176+ $env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin;D:\gstreamer\1.0\msvc_x86_64\bin'
177+
178+ echo "paths:
179+ all:
180+ source: publisher
181+ stream1:
182+ runOnInit: `"gst-launch-1.0 videotestsrc pattern=ball ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96 ! udpsink host=127.0.0.1 port=5004`"
183+ runOnInitRestart: yes
184+ stream2:
185+ runOnInit: `"gst-launch-1.0 videotestsrc ! videoscale ! video/x-raw,width=640,height=480,framerate=10/1 ! x264enc tune=zerolatency bitrate=512 ! rtph264pay name=pay0 pt=96 ! udpsink host=127.0.0.1 port=5006`"
186+ runOnInitRestart: yes" | Out-File -FilePath mediamtx.yml -Encoding utf8
187+
188+ Start-Process -NoNewWindow -FilePath ".\mediamtx.exe" -ArgumentList "mediamtx.yml"
189+
190+ echo "rtsp://127.0.0.1:8554/stream1" | Out-File -FilePath rtsp-urls.txt -Encoding UTF8
191+ echo "rtsp://127.0.0.1:8554/stream2" | Out-File -FilePath rtsp-urls.txt -Append -Encoding UTF8
192+
193+ # Run the sample application
194+ Start-Sleep -Seconds 10 # Wait for server to be ready
195+
196+ mkdir D:\producer\debug_output
197+
198+ # Start the sample in a new console window
199+ $exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
200+ $process = Start-Process -FilePath $exePath -ArgumentList "demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}" -PassThru -NoNewWindow
201+
202+ # Wait for up to 30 seconds
203+ $timeout = 30
204+ $elapsed = 0
205+ while ($elapsed -lt $timeout) {
206+ Start-Sleep -Seconds 5
207+ $elapsed += 5
208+ if ($process.HasExited) {
209+ # In case there's a failure and it exits early
210+ break
211+ }
212+ }
213+
214+ # Check if the process is still running
215+ if (!$process.HasExited) {
216+ Write-Host "Process still running, sending Ctrl+C..."
217+
218+ # Send Ctrl+C by calling taskkill
219+ $processId = $process.Id
220+ Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
221+
222+ # Wait 15 more seconds for it to exit gracefully
223+ $gracePeriod = 15
224+ $graceElapsed = 0
225+ while ($graceElapsed -lt $gracePeriod) {
226+ Start-Sleep -Seconds 5
227+ $graceElapsed += 5
228+ if ($process.HasExited) {
229+ # In case it doesn't need the full 15 seconds, speed up the job
230+ break
231+ }
232+ }
233+ }
234+
235+ # If it's STILL running, force kill it
236+ if (!$process.HasExited) {
237+ Write-Host "Process did not exit after Ctrl+C, force killing..."
238+ Start-Process -NoNewWindow -FilePath "taskkill" -ArgumentList "/PID $processId /T /F"
239+ Start-Sleep -Seconds 5 # Allow some time for cleanup
240+ }
241+
242+ # Get exit code
243+ $exitCode = if ($process.HasExited) { $process.ExitCode } else { 137 } # 137: Forced termination
244+
245+ Write-Host "Command exited with code: $exitCode"
246+ if ($exitCode -ne 0) {
247+ Write-Host "Command did not exit gracefully."
248+ exit 1
249+ }
250+
251+ env :
252+ GST_PLUGIN_PATH : D:\producer\build
253+ KVS_DEBUG_DUMP_DATA_FILE_DIR : D:\producer\debug_output
254+
115255 - name : Run ${{ matrix.sample.name }} (Linux & Mac)
116- if : runner.os == 'Linux' || runner.os == 'macOS'
256+ if : ( runner.os == 'Linux' || runner.os == 'macOS') && matrix.sample.name != 'kvs_gstreamer_multistream_sample '
117257 env :
118258 GST_PLUGIN_PATH : ${{ github.workspace }}/build
119259 KVS_DEBUG_DUMP_DATA_FILE_DIR : ${{ github.workspace }}/build/debug_output
@@ -123,17 +263,23 @@ jobs:
123263 ./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
124264
125265 - name : Run ${{ matrix.sample.name }} (Windows)
126- if : runner.os == 'Windows'
266+ if : runner.os == 'Windows' && matrix.sample.name != 'kvs_gstreamer_multistream_sample'
127267 env :
128- GST_PLUGIN_PATH : ${{ github.workspace }}/ build
129- KVS_DEBUG_DUMP_DATA_FILE_DIR : ${{ github.workspace }}/build/ debug_output
130- working-directory : ./ build
268+ GST_PLUGIN_PATH : D:\producer\ build
269+ KVS_DEBUG_DUMP_DATA_FILE_DIR : D:\producer\ debug_output
270+ working-directory : D:\producer\ build
131271 run : |
272+ # Equivalent to set -x
273+ Set-PSDebug -Trace 1
274+
132275 $env:Path += ';C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Strawberry\c\bin;C:\Program Files\NASM;D:\producer\open-source\local\lib;D:\producer\open-source\local\bin;D:\gstreamer\1.0\msvc_x86_64\bin'
133276
277+ mkdir D:\producer\debug_output
278+
134279 Invoke-WebRequest -Uri https://awsj-iot-handson.s3-ap-northeast-1.amazonaws.com/kvs-workshop/sample.mp4 -OutFile sample.mp4
135- $exePath = Join-Path $PWD ${{ matrix.sample.name }}
136- & $exePath.exe demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
280+ dir
281+ $exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
282+ & $exePath demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
137283
138284 - name : Verify MKV dump (Mac & Linux)
139285 if : runner.os == 'Linux' || runner.os == 'macOS'
@@ -154,13 +300,13 @@ jobs:
154300 done
155301 shell : bash
156302
157- - name : Verify MKV dump
303+ - name : Verify MKV dump (Windows)
158304 if : runner.os == 'Windows'
159305 working-directory : D:\producer\build
160306 run : |
161307 $env:Path += ";C:\Program Files\MKVToolNix"
162- dir debug_output
163- $mkvFiles = Get-ChildItem -Path "D:\producer\build\ debug_output" -Filter *.mkv
308+ dir D:\producer\ debug_output
309+ $mkvFiles = Get-ChildItem -Path "D:\producer\debug_output" -Filter *.mkv
164310 if ($mkvFiles.Count -eq 0) {
165311 Write-Error "No MKV files found in D:\producer\build\debug_output"
166312 exit 1
0 commit comments