-
Notifications
You must be signed in to change notification settings - Fork 343
481 lines (407 loc) · 16.7 KB
/
samples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
name: Producer CPP Sample Checks
on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master
env:
SAMPLE_MP4_LOCATION: https://raw.githubusercontent.com/aws-samples/amazon-kinesis-video-streams-demos/refs/heads/master/sample-video/sample.mp4
jobs:
prep-assets:
runs-on: ubuntu-latest
outputs:
sample-artifact-name: ${{ steps.set-output.outputs.artifact-name }}
steps:
- name: Restore cached sample.mp4
uses: actions/cache@v4
with:
path: sample.mp4
key: sample-mp4-v1
- name: Download sample.mp4 if not cached
if: steps.cache.outputs.cache-hit != 'true'
run: curl -fsSL -o sample.mp4 "$SAMPLE_MP4_LOCATION"
- name: Save to cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: sample.mp4
key: sample-mp4-v1
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sample-mp4
path: sample.mp4
sample-checks:
name: ${{ matrix.runner.id }} - ${{ matrix.sample.name }}
needs: prep-assets
strategy:
matrix:
sample:
- name: kvs_gstreamer_audio_video_sample
args: -f sample.mp4
- name: kvs_gstreamer_file_uploader_sample
args: sample.mp4 0 audio-video
- name: kvs_gstreamer_sample
args: sample.mp4
- name: kvssink_gstreamer_sample
args: sample.mp4
runner:
- id: macos-13
image: macos-13
- id: ubuntu-22.04
image: ubuntu-latest
docker: public.ecr.aws/ubuntu/ubuntu:22.04_stable
- id: ubuntu-20.04
image: ubuntu-latest
docker: public.ecr.aws/ubuntu/ubuntu:20.04_stable
- id: windows-2022
image: windows-2022
fail-fast: false
runs-on: ${{ matrix.runner.image }}
container: ${{ matrix.runner.docker || '' }}
timeout-minutes: 30
env:
AWS_KVS_LOG_LEVEL: 2
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
DEBIAN_FRONTEND: noninteractive
GST_PLUGIN_PATH: ${{ github.workspace }}/build
permissions:
id-token: write
contents: read
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install gstreamer log4cplus mkvtoolnix
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
apt-get update
apt-get install -y git cmake build-essential pkg-config libssl-dev libcurl4-openssl-dev \
liblog4cplus-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-bad gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly gstreamer1.0-tools curl mkvtoolnix
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install nasm strawberryperl pkgconfiglite mkvtoolnix
choco install gstreamer --version=1.22.8
choco install gstreamer-devel --version=1.22.8
- name: Build samples (Linux & Mac)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
mkdir build && cd build
mkdir -p $KVS_DEBUG_DUMP_DATA_FILE_DIR
cmake .. -DBUILD_GSTREAMER_PLUGIN=ON -DBUILD_DEPENDENCIES=OFF
make -j$(nproc)
- name: Build samples (Windows)
if: runner.os == 'Windows'
run: |
$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'
mkdir D:\producer
Move-Item -Path "D:\a\amazon-kinesis-video-streams-producer-sdk-cpp\amazon-kinesis-video-streams-producer-sdk-cpp\*" -Destination "D:\producer"
cd D:\producer
git config --system core.longpaths true
dir
.github\build_windows.bat
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ secrets.AWS_REGION }}
role-duration-seconds: 900
- name: Download sample.mp4 artifact
uses: actions/download-artifact@v4
with:
name: sample-mp4
path: ./assets
- name: Run ${{ matrix.sample.name }} (Linux & Mac)
if: runner.os == 'Linux' || runner.os == 'macOS'
working-directory: ./build
run: |
mv ../assets/*.mp4 .
./${{ matrix.sample.name }} demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
- name: Run ${{ matrix.sample.name }} (Windows)
if: runner.os == 'Windows'
env:
GST_PLUGIN_PATH: D:\producer\build
KVS_DEBUG_DUMP_DATA_FILE_DIR: D:\producer\debug_output
working-directory: D:\producer\build
run: |
# Equivalent to set -x
Set-PSDebug -Trace 1
$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'
mkdir D:\producer\debug_output
cp -r D:\a\amazon-kinesis-video-streams-producer-sdk-cpp\amazon-kinesis-video-streams-producer-sdk-cpp\assets\*.mp4 .
dir
$exePath = Join-Path $PWD ${{ matrix.sample.name }}.exe
& $exePath demo-stream-producer-cpp-${{ matrix.runner.id }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
- name: Verify MKV dump exists (Mac & Linux)
if: runner.os == 'Linux' || runner.os == 'macOS'
working-directory: ./build/debug_output
run: |
shopt -s nullglob # Ensure globbing works correctly and avoids errors when no files are found
ls -tlrh
mkvfiles=(*.mkv)
if [ ${#mkvfiles[@]} -eq 0 ]; then
echo "No MKV files found in debug_output"
exit 1
fi
for file in "${mkvfiles[@]}"; do
echo "Verifying $file with mkvinfo (verbose and hexdump):"
mkvinfo -v -X "$file"
done
shell: bash
- name: Verify MKV dump exists (Windows)
if: runner.os == 'Windows'
working-directory: D:\producer\build
run: |
$env:Path += ";C:\Program Files\MKVToolNix"
dir D:\producer\debug_output
$mkvFiles = Get-ChildItem -Path "D:\producer\debug_output" -Filter *.mkv
if ($mkvFiles.Count -eq 0) {
Write-Error "No MKV files found in D:\producer\build\debug_output"
exit 1
}
# Run mkvinfo on each MKV file
foreach ($file in $mkvFiles) {
Write-Output "Verifying $($file.FullName) with mkvinfo (verbose and hexdump):"
mkvinfo.exe -v -X "$($file.FullName)"
}
multistream-sample:
name: Multistream sample on Ubuntu 22.04
runs-on: ubuntu-latest
container: public.ecr.aws/ubuntu/ubuntu:22.04_stable
timeout-minutes: 30
env:
AWS_KVS_LOG_LEVEL: 2
KVS_DEBUG_DUMP_DATA_FILE_DIR: ${{ github.workspace }}/build/debug_output
GST_PLUGIN_PATH: ${{ github.workspace }}/build
KVS_STREAM_NAME_BASE: demo-stream-producer-cpp-ubuntu-22.04-ci-kvs_gstreamer_multistream_sample
permissions:
id-token: write
contents: read
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
apt-get update
apt-get install -y git cmake build-essential pkg-config libssl-dev libcurl4-openssl-dev \
liblog4cplus-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-bad gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly gstreamer1.0-tools curl mkvtoolnix libgstrtspserver-1.0
- name: Build GST RTSP Server Test Launch Sample
run: |
set -x
git clone --no-checkout --filter=blob:none --depth=1 -b 1.22 https://github.com/GStreamer/gstreamer.git
cd gstreamer
git sparse-checkout init cone
git sparse-checkout set "subprojects/gst-rtsp-server/examples/test-launch.c"
git checkout
cd subprojects/gst-rtsp-server/examples
gcc -o test-launch test-launch.c `pkg-config --cflags --libs gstreamer-rtsp-server-1.0`
mv ./test-launch $GITHUB_WORKSPACE
cd $GITHUB_WORKSPACE
rm -rf gstreamer
- name: Build samples
run: |
mkdir build && cd build
mkdir -p $KVS_DEBUG_DUMP_DATA_FILE_DIR
cmake .. -DBUILD_GSTREAMER_PLUGIN=ON -DBUILD_DEPENDENCIES=OFF -DALIGNED_MEMORY_MODEL=ON
make -j$(nproc)
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ secrets.AWS_REGION }}
role-duration-seconds: 900
- name: Run multistream sample
working-directory: ./build
run: |
set -x
export PIPELINE_8554="videotestsrc is-live=true \
! textoverlay text=rtsp://127.0.0.1:8554/test \
! video/x-raw,height=480,width=640,framerate=10/1 \
! x264enc tune=zerolatency bitrate=512 key-int-max=25 \
! h264parse \
! rtph264pay name=pay0 pt=96"
export PIPELINE_8555="videotestsrc is-live=true \
! textoverlay text=rtsp://127.0.0.1:8555/test \
! video/x-raw,height=480,width=640,framerate=10/1 \
! x264enc tune=zerolatency bitrate=512 key-int-max=25 \
! h264parse \
! rtph264pay name=pay0 pt=96"
"$GITHUB_WORKSPACE"/test-launch -p 8554 "${PIPELINE_8554}" &
"$GITHUB_WORKSPACE"/test-launch -p 8555 "${PIPELINE_8555}" &
echo "rtsp://127.0.0.1:8554/test" > rtsp-urls.txt
echo "rtsp://127.0.0.1:8555/test" >> rtsp-urls.txt
sleep 10
gst-discoverer-1.0 "rtsp://127.0.0.1:8554/test"
gst-discoverer-1.0 "rtsp://127.0.0.1:8555/test"
set +e # Disable exit on error for the timeout command
timeout --preserve-status --signal=SIGINT --kill-after=15s 30s \
./kvs_gstreamer_multistream_sample "${KVS_STREAM_NAME_BASE}" rtsp-urls.txt
EXIT_CODE=$?
set -e # Re-enable exit on error
# 130 (128 + 2): Process killed by SIGINT
# 137: Process killed by SIGKILL (if the --kill-after timeout is reached)
echo "Command exited with code: $EXIT_CODE"
if [ $EXIT_CODE -ne 130 ]; then
echo "Command did not exit gracefully after interrupt."
exit 1
fi
shell: bash
- name: Verify MKV dump exists
working-directory: ./build/debug_output
run: |
shopt -s nullglob # Ensure globbing works correctly and avoids errors when no files are found
ls -tlrh
mkvfiles=(*.mkv)
if [ ${#mkvfiles[@]} -eq 0 ]; then
echo "No MKV files found in debug_output"
exit 1
fi
# Since there are 2 streams, check for the presence of two different prefixed MKV files
found_0=0
found_1=0
for file in "${mkvfiles[@]}"; do
if [[ "$file" == ${KVS_STREAM_NAME_BASE}_0* ]]; then
found_0=1
elif [[ "$file" == ${KVS_STREAM_NAME_BASE}_1* ]]; then
found_1=1
fi
done
if [ $found_0 -eq 0 ] || [ $found_1 -eq 0 ]; then
echo "Expected at least one file starting with each prefix:"
echo " - ${KVS_STREAM_NAME_BASE}_0"
echo " - ${KVS_STREAM_NAME_BASE}_1"
exit 1
fi
for file in "${mkvfiles[@]}"; do
echo "Verifying $file with mkvinfo (verbose and hexdump):"
mkvinfo -v -X "$file"
done
shell: bash
wsl-sample-checks:
name: WSL ${{ matrix.image }} - ${{ matrix.sample.name }}
needs: prep-assets
strategy:
matrix:
sample:
- name: kvs_gstreamer_audio_video_sample
args: -f sample.mp4
- name: kvs_gstreamer_file_uploader_sample
args: sample.mp4 0 audio-video
- name: kvs_gstreamer_sample
args: sample.mp4
- name: kvssink_gstreamer_sample
args: sample.mp4
image:
- Ubuntu-22.04
- Ubuntu-24.04
fail-fast: false
runs-on: windows-2022
timeout-minutes: 30
permissions:
id-token: write
contents: read
defaults:
run:
shell: wsl-bash {0} # Automatically uses wsl-bash for each run step
steps:
- uses: Vampire/setup-wsl@v4
with:
distribution: ${{ matrix.image }}
additional-packages: |
automake
build-essential
cmake
git
gstreamer1.0-plugins-base-apps
gstreamer1.0-plugins-bad
gstreamer1.0-plugins-good
gstreamer1.0-plugins-ugly
gstreamer1.0-tools
libcurl4-openssl-dev
libgstreamer1.0-dev
libgstreamer-plugins-base1.0-dev
liblog4cplus-dev
libssl-dev
pkg-config
mkvtoolnix
use-cache: 'false' # Cache entry for Ubuntu 22.04 and 24.04 are the same (conflict)
- name: Clone repository
uses: actions/checkout@v4
- name: Download sample.mp4 artifact
uses: actions/download-artifact@v4
with:
name: sample-mp4
path: ./assets
- name: Move repository in WSL
run: |
# Copy to ~/kvs-cpp-repo for simplicity
# Note: Can't move due to no permissions
REPO_NAME=$(basename ${{ github.repository }})
cp -r /mnt/d/a/$REPO_NAME/$REPO_NAME ~/kvs-cpp-repo
mkdir -p ~/kvs-cpp-repo/build
cp -r /mnt/d/a/$REPO_NAME/$REPO_NAME/assets/*.mp4 ~/kvs-cpp-repo/build
- name: Build samples in WSL
run: |
cd ~/kvs-cpp-repo/build
cmake .. -DBUILD_GSTREAMER_PLUGIN=ON -DALIGNED_MEMORY_MODEL=ON -DBUILD_DEPENDENCIES=OFF
make -j$(nproc)
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ secrets.AWS_REGION }}
role-duration-seconds: 900
- name: Run ${{ matrix.sample.name }} (WSL)
run: |
cd ~/kvs-cpp-repo/build
export KVS_DEBUG_DUMP_DATA_FILE_DIR=~/kvs-cpp-repo/build/debug_output
mkdir "$KVS_DEBUG_DUMP_DATA_FILE_DIR"
export GST_PLUGIN_PATH=~/kvs-cpp-repo/build
export AWS_KVS_LOG_LEVEL=2
# Note: `env.` syntax to reference credentials to have GitHub Actions inject
# the secret values into these environment variables before the command runs,
# since the WSL shell doesn't have access to GitHub's environment variables
export AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }}
export AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }}
export AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }}
export AWS_DEFAULT_REGION=${{ env.AWS_DEFAULT_REGION }}
set +e # Disable exit on error for the timeout command
./${{ matrix.sample.name }} demo-stream-producer-cpp-wsl-${{ matrix.image }}-ci-${{ matrix.sample.name }} ${{ matrix.sample.args }}
EXIT_CODE=$?
set -e # Re-enable exit on error
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
if [[ EXIT_CODE -ne 0 ]]; then
echo "${{ matrix.sample.name }} exited with code: $EXIT_CODE"
exit $EXIT_CODE
fi
- name: Verify MKV dump exists (WSL)
run: |
cd ~/kvs-cpp-repo/build/debug_output
shopt -s nullglob # Ensure globbing works correctly and avoids errors when no files are found
ls -tlrh
mkvfiles=(*.mkv)
if [ ${#mkvfiles[@]} -eq 0 ]; then
echo "No MKV files found in debug_output"
exit 1
fi
for file in "${mkvfiles[@]}"; do
echo "Verifying $file with mkvinfo (verbose and hexdump):"
mkvinfo -v -X "$file"
done