Skip to content

Commit c372d88

Browse files
committed
linux-webrtc-reference-for-amazon-kinesis-video-streams: Add support to pass AWS keys into the recipe
This needs to be done before creating the image. Adding keys to build/config/local.conf: AWS_REGION:pn-linux-webrtc-reference-for-amazon-kinesis-video-streams = "xxx" AWS_KVS_CHANNEL_NAME:pn-linux-webrtc-reference-for-amazon-kinesis-video-streams = "xxx" AWS_ACCESS_KEY_ID:pn-linux-webrtc-reference-for-amazon-kinesis-video-streams = "xxx" AWS_SECRET_ACCESS_KEY:pn-linux-webrtc-reference-for-amazon-kinesis-video-streams = "xxx"
1 parent 2f2301d commit c372d88

File tree

2 files changed

+140
-70
lines changed

2 files changed

+140
-70
lines changed

recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/files/run-ptest

Lines changed: 59 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,63 @@ else
1616
echo "FAIL: linux-webrtc-reference-for-amazon-kinesis-video-streams simple test"
1717
fi
1818

19-
exit
19+
exit
20+
# todo
2021

21-
### todo
22-
#
23-
# rm -rf /tmp/master.log
24-
# rm -rf /tmp/viewer.log
25-
#
26-
# # Start the MASTER process with timeout 60s, kill after 10s if not responding to SIGTERM
27-
# cd /usr/bin/
28-
# timeout --preserve-status -k 10 60s ./WebRTCLinuxApplicationMaster 2>&1 | tee /tmp/master.log &
29-
#
30-
# # Setup and start Viewer
31-
# sleep 5
32-
# read ROLE_ALIAS < /etc/ROLE_ALIAS
33-
# read THING_NAME < /etc/THING_NAME
34-
# read CHANNEL_NAME < /etc/CHANNEL_NAME
35-
# read CREDENTIALS_ENDPOINT < /etc/CREDENTIALS_ENDPOINT
36-
# read AWS_DEFAULT_REGION < /etc/AWS_REGION
37-
#
38-
# export AWS_IOT_CORE_THING_NAME="$THING_NAME"
39-
# export AWS_KVS_CHANNEL_NAME="$CHANNEL_NAME"
40-
# export AWS_IOT_CORE_CREDENTIAL_ENDPOINT="$CREDENTIALS_ENDPOINT"
41-
# export AWS_IOT_CORE_ROLE_ALIAS="$ROLE_ALIAS"
42-
# export AWS_IOT_CORE_PRIVATE_KEY=/etc/private.key
43-
# export AWS_IOT_CORE_CERT=/etc/certificate.pem
44-
# export AWS_KVS_CACERT_PATH=/etc/cert.pem
45-
# export AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION"
46-
#
47-
# # INFO
48-
# export AWS_KVS_LOG_LEVEL=3
49-
#
50-
# # Start the VIEWER process with timeout 60s, kill after 10s if not responding to SIGTERM
51-
# timeout --preserve-status -k 10 60s /usr/bin/kvsWebrtcClientViewer $AWS_KVS_CHANNEL_NAME 2>&1 | tee /tmp/viewer.log
52-
#
53-
# echo -e "\n\n\nmaster.log:"
54-
# cat /tmp/master.log
55-
#
56-
# echo -e "\n\n\nviewer.log:"
57-
# cat /tmp/viewer.log
58-
#
59-
# if [ -e /master.log ]; then
60-
# if grep -A3 -E ' fail| error' /tmp/master.log; then
61-
# echo "Found failed or error in master.log"
62-
# echo "FAIL: amazon-kvs-webrtc-sdk-c: data test: $RETVAL"
63-
# fi
64-
# if grep -E ' Connection established' /tmp/master.log; then
65-
# echo "Connection established found - good"
66-
# echo "PASS: amazon-kvs-webrtc-sdk-c: data test"
67-
# fi
68-
# fi
69-
#
22+
if [ -e /etc/CHANNEL_NAME ] ; then
23+
rm -rf /tmp/master.log
24+
rm -rf /tmp/viewer.log
25+
26+
# Start the MASTER process with timeout 60s, kill after 10s if not responding to SIGTERM
27+
cd /usr/bin/
28+
timeout --preserve-status -k 10 60s ./WebRTCLinuxApplicationMaster 2>&1 | tee /tmp/master.log &
29+
30+
# Setup and start Viewer
31+
sleep 5
32+
# read ROLE_ALIAS < /etc/ROLE_ALIAS
33+
# read THING_NAME < /etc/THING_NAME
34+
read CHANNEL_NAME < /etc/CHANNEL_NAME
35+
# read CREDENTIALS_ENDPOINT < /etc/CREDENTIALS_ENDPOINT
36+
read AWS_DEFAULT_REGION < /etc/AWS_REGION
37+
read AWS_ACCESS_KEY_ID < /etc/AWS_ACCESS_KEY_ID
38+
read AWS_SECRET_ACCESS_KEY < /etc/AWS_SECRET_ACCESS_KEY
39+
40+
# export AWS_IOT_CORE_THING_NAME="$THING_NAME"
41+
42+
# export AWS_IOT_CORE_CREDENTIAL_ENDPOINT="$CREDENTIALS_ENDPOINT"
43+
# export AWS_IOT_CORE_ROLE_ALIAS="$ROLE_ALIAS"
44+
# export AWS_IOT_CORE_PRIVATE_KEY=/etc/private.key
45+
# export AWS_IOT_CORE_CERT=/etc/certificate.pem
46+
export AWS_KVS_CACERT_PATH=/etc/cert.pem
47+
export AWS_KVS_CHANNEL_NAME="$CHANNEL_NAME"
48+
export AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION"
49+
export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID"
50+
export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY"
51+
52+
# INFO
53+
export AWS_KVS_LOG_LEVEL=3
54+
55+
# Start the VIEWER process with timeout 60s, kill after 10s if not responding to SIGTERM
56+
timeout --preserve-status -k 10 60s /usr/bin/kvsWebrtcClientViewer $AWS_KVS_CHANNEL_NAME 2>&1 | tee /tmp/viewer.log
57+
58+
echo -e "\n\n\nmaster.log:"
59+
cat /tmp/master.log
60+
61+
echo -e "\n\n\nviewer.log:"
62+
cat /tmp/viewer.log
63+
64+
if [ -e /master.log ]; then
65+
if grep -A3 -E ' fail| error' /tmp/master.log; then
66+
echo "Found failed or error in master.log"
67+
echo "FAIL: amazon-kvs-webrtc-sdk-c: data test: $RETVAL"
68+
fi
69+
if grep -E ' Connection established' /tmp/master.log; then
70+
echo "Connection established found - good"
71+
echo "PASS: amazon-kvs-webrtc-sdk-c: data test"
72+
fi
73+
fi
74+
75+
else
76+
echo "no creadentials found, skipping connection test"
77+
echo "SKIP: amazon-kvs-webrtc-sdk-c: data test"
78+
fi

recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/linux-webrtc-reference-for-amazon-kinesis-video-streams_git.bb

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=34400b68072d710fecd0a2940a0d1658"
66

77
DEPENDS += "\
88
libwebsockets \
9-
gstreamer1.0 \
10-
gstreamer1.0-plugins-base \
11-
gstreamer1.0-plugins-good \
12-
gstreamer1.0-plugins-bad \
139
"
1410

1511
# default is stripped, we wanna do this by yocto
1612
EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo"
1713

18-
# set log message debug level
19-
EXTRA_OECMAKE:append = " -DLIBRARY_LOG_LEVEL=LOG_VERBOSE"
14+
# set log level
15+
EXTRA_OECMAKE:append = " -DLIBRARY_LOG_LEVEL=LOG_INFO"
2016

2117
###
2218
# Use this for development to specify a local folder as source dir (cloned repo)
@@ -33,7 +29,7 @@ EXTRA_OECMAKE:append = " -DLIBRARY_LOG_LEVEL=LOG_VERBOSE"
3329
# nooelint: oelint.vars.specific
3430
CFLAGS:append:arm = " -Wno-error=format="
3531

36-
SRC_URI = "\
32+
SRC_URI += "\
3733
gitsm://github.com/awslabs/linux-webrtc-reference-for-amazon-kinesis-video-streams.git;protocol=https;branch=main \
3834
file://run-ptest \
3935
"
@@ -48,31 +44,81 @@ PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sani
4844

4945
PACKAGECONFIG[sanitize] = ",, gcc-sanitizers"
5046

47+
# h264 gst plugin require setting: LICENSE_FLAGS_ACCEPTED += "commercial"
48+
# and enable opus codec
49+
# PACKAGECONFIG:append:pn-gstreamer1.0-plugins-base = " opus"
50+
# and enable x264 codec
51+
# PACKAGECONFIG:append:pn-gstreamer1.0-plugins-ugly = " x264"
52+
53+
PACKAGECONFIG:append = "${@bb.utils.contains("LICENSE_FLAGS_ACCEPTED", "commercial", "gstreamer", "", d)}"
54+
55+
PACKAGECONFIG[gstreamer] = ",,\
56+
gstreamer1.0 \
57+
gstreamer1.0-plugins-base \
58+
gstreamer1.0-plugins-good \
59+
gstreamer1.0-plugins-bad \
60+
gstreamer1.0-plugins-ugly \
61+
,\
62+
gstreamer1.0 \
63+
gstreamer1.0-plugins-base \
64+
gstreamer1.0-plugins-good \
65+
gstreamer1.0-plugins-bad \
66+
gstreamer1.0-plugins-ugly \
67+
gstreamer1.0-plugins-base-apps \
68+
"
69+
5170
RDEPENDS:${PN} += "ca-certificates"
5271

53-
#RDEPENDS:${PN}-ptest += "\
54-
# amazon-kvs-webrtc-sdk \
55-
# coreutils \
56-
# util-linux \
57-
#"
72+
RDEPENDS:${PN}-ptest += "\
73+
amazon-kvs-webrtc-sdk \
74+
coreutils \
75+
util-linux \
76+
"
5877

78+
# overwrite these variables to use your own AWS credentials in your local.conf
79+
AWS_REGION ?= "eu-central-1"
80+
AWS_KVS_CHANNEL_NAME ?= "test-channel"
81+
AWS_ACCESS_KEY_ID ?= ""
82+
AWS_SECRET_ACCESS_KEY ?= ""
83+
AWS_SESSION_TOKEN ?= ""
84+
AWS_CA_CERT_PATH ?= "/etc/cert.pem"
85+
86+
# this can be used for key based authentication
5987
do_configure:append() {
6088
cp ${S}/examples/demo_config/demo_config_template.h ${S}/examples/demo_config/demo_config.h
89+
sed -i '/#define AWS_REGION "us-west-2"/d' ${S}/examples/demo_config/demo_config.h
90+
sed -i '/#define AWS_KVS_CHANNEL_NAME ""/d' ${S}/examples/demo_config/demo_config.h
91+
sed -i '/#define AWS_CA_CERT_PATH "cert\/cert.pem"/d' ${S}/examples/demo_config/demo_config.h
6192
sed -i '/^#if defined( AWS_ACCESS_KEY_ID ) && defined( AWS_IOT_THING_ROLE_ALIAS )/i\
62-
#define AWS_CREDENTIALS_ENDPOINT ""\
63-
#define AWS_IOT_THING_NAME ""\
64-
#define AWS_IOT_THING_ROLE_ALIAS ""\
65-
#define AWS_IOT_THING_CERT_PATH "certificate.pem"\
66-
#define AWS_IOT_THING_PRIVATE_KEY_PATH "private.key"\
93+
#define AWS_REGION "${AWS_REGION}"\
94+
#define AWS_KVS_CHANNEL_NAME "${AWS_KVS_CHANNEL_NAME}"\
95+
#define AWS_REGION "${AWS_REGION}"\
96+
#define AWS_ACCESS_KEY_ID "${AWS_ACCESS_KEY_ID}"\
97+
#define AWS_SECRET_ACCESS_KEY "${AWS_SECRET_ACCESS_KEY}"\
98+
#define AWS_SESSION_TOKEN "${AWS_SESSION_TOKEN}"\
99+
#define AWS_CA_CERT_PATH "${AWS_CA_CERT_PATH}"\
67100
' ${S}/examples/demo_config/demo_config.h
68101
}
69102

103+
# this can be used for iot cert based authentication
104+
#do_configure:append() {
105+
# cp ${S}/examples/demo_config/demo_config_template.h ${S}/examples/demo_config/demo_config.h
106+
# sed -i '/^#if defined( AWS_ACCESS_KEY_ID ) && defined( AWS_IOT_THING_ROLE_ALIAS )/i\
107+
# #define AWS_CREDENTIALS_ENDPOINT ""\
108+
# #define AWS_IOT_THING_NAME ""\
109+
# #define AWS_IOT_THING_ROLE_ALIAS ""\
110+
# #define AWS_IOT_THING_CERT_PATH "certificate.pem"\
111+
# #define AWS_IOT_THING_PRIVATE_KEY_PATH "private.key"\
112+
# ' ${S}/examples/demo_config/demo_config.h
113+
#}
114+
#
115+
70116
inherit cmake pkgconfig ptest
71117

72118
do_install() {
73119
install -d ${D}${bindir}
74120
install -m 0755 ${B}/WebRTCLinuxApplicationMaster ${D}${bindir}
75-
install -m 0755 ${B}/WebRTCLinuxApplicationGstMaster ${D}${bindir}
121+
${@bb.utils.contains("PACKAGECONFIG", "gstreamer", "install -m 0755 ${B}/WebRTCLinuxApplicationGstMaster ${D}${bindir}", "", d)}
76122

77123
install -d ${D}${bindir}/examples/app_media_source/samples/h264SampleFrames
78124
cp -r ${S}/examples/app_media_source/samples/h264SampleFrames/* ${D}${bindir}/examples/app_media_source/samples/h264SampleFrames/
@@ -82,10 +128,25 @@ do_install() {
82128

83129
install -d ${D}${sysconfdir}
84130
install -m 0664 ${S}/cert/cert.pem ${D}${sysconfdir}/
85-
# install -m 0664 ${S}/certificate.pem ${D}${sysconfdir}/
86-
# install -m 0664 ${S}/private.key ${D}${sysconfdir}/
87131
}
88132

133+
do_install_ptest:append() {
134+
install -d ${D}${sysconfdir}
135+
echo "${AWS_ACCESS_KEY_ID}" > ${D}${sysconfdir}/AWS_ACCESS_KEY_ID
136+
echo "${AWS_SECRET_ACCESS_KEY}" > ${D}${sysconfdir}/AWS_SECRET_ACCESS_KEY
137+
echo "${AWS_KVS_CHANNEL_NAME}" > ${D}${sysconfdir}/CHANNEL_NAME
138+
echo "${AWS_REGION}" > ${D}${sysconfdir}/AWS_REGION
139+
140+
# cert based authentication
141+
if [ -f ${S}/cert/private.key ]; then
142+
install -m 0664 ${S}/cert/private.key ${D}${sysconfdir}/
143+
fi
144+
if [ -f ${S}/cert/certificate.pem ]; then
145+
install -m 0664 ${S}/cert/certificate.pem ${D}${sysconfdir}/
146+
fi
147+
}
148+
149+
#TODO: add suport for cert based authentication
89150
# do_install_ptest:append() {
90151
# install -d ${D}${sysconfdir}
91152
# install ${S}/tests/iot-credentials/THING_NAME ${D}${sysconfdir}/

0 commit comments

Comments
 (0)