diff --git a/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/files/run-ptest b/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/files/run-ptest index b50711eac..d03c661e7 100644 --- a/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/files/run-ptest +++ b/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/files/run-ptest @@ -16,54 +16,63 @@ else echo "FAIL: linux-webrtc-reference-for-amazon-kinesis-video-streams simple test" fi -exit +exit +# todo -### todo -# -# rm -rf /tmp/master.log -# rm -rf /tmp/viewer.log -# -# # Start the MASTER process with timeout 60s, kill after 10s if not responding to SIGTERM -# cd /usr/bin/ -# timeout --preserve-status -k 10 60s ./WebRTCLinuxApplicationMaster 2>&1 | tee /tmp/master.log & -# -# # Setup and start Viewer -# sleep 5 -# read ROLE_ALIAS < /etc/ROLE_ALIAS -# read THING_NAME < /etc/THING_NAME -# read CHANNEL_NAME < /etc/CHANNEL_NAME -# read CREDENTIALS_ENDPOINT < /etc/CREDENTIALS_ENDPOINT -# read AWS_DEFAULT_REGION < /etc/AWS_REGION -# -# export AWS_IOT_CORE_THING_NAME="$THING_NAME" -# export AWS_KVS_CHANNEL_NAME="$CHANNEL_NAME" -# export AWS_IOT_CORE_CREDENTIAL_ENDPOINT="$CREDENTIALS_ENDPOINT" -# export AWS_IOT_CORE_ROLE_ALIAS="$ROLE_ALIAS" -# export AWS_IOT_CORE_PRIVATE_KEY=/etc/private.key -# export AWS_IOT_CORE_CERT=/etc/certificate.pem -# export AWS_KVS_CACERT_PATH=/etc/cert.pem -# export AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" -# -# # INFO -# export AWS_KVS_LOG_LEVEL=3 -# -# # Start the VIEWER process with timeout 60s, kill after 10s if not responding to SIGTERM -# timeout --preserve-status -k 10 60s /usr/bin/kvsWebrtcClientViewer $AWS_KVS_CHANNEL_NAME 2>&1 | tee /tmp/viewer.log -# -# echo -e "\n\n\nmaster.log:" -# cat /tmp/master.log -# -# echo -e "\n\n\nviewer.log:" -# cat /tmp/viewer.log -# -# if [ -e /master.log ]; then -# if grep -A3 -E ' fail| error' /tmp/master.log; then -# echo "Found failed or error in master.log" -# echo "FAIL: amazon-kvs-webrtc-sdk-c: data test: $RETVAL" -# fi -# if grep -E ' Connection established' /tmp/master.log; then -# echo "Connection established found - good" -# echo "PASS: amazon-kvs-webrtc-sdk-c: data test" -# fi -# fi -# \ No newline at end of file +if [ -e /etc/CHANNEL_NAME ] ; then + rm -rf /tmp/master.log + rm -rf /tmp/viewer.log + + # Start the MASTER process with timeout 60s, kill after 10s if not responding to SIGTERM + cd /usr/bin/ + timeout --preserve-status -k 10 60s ./WebRTCLinuxApplicationMaster 2>&1 | tee /tmp/master.log & + + # Setup and start Viewer + sleep 5 +# read ROLE_ALIAS < /etc/ROLE_ALIAS +# read THING_NAME < /etc/THING_NAME + read CHANNEL_NAME < /etc/CHANNEL_NAME +# read CREDENTIALS_ENDPOINT < /etc/CREDENTIALS_ENDPOINT + read AWS_DEFAULT_REGION < /etc/AWS_REGION + read AWS_ACCESS_KEY_ID < /etc/AWS_ACCESS_KEY_ID + read AWS_SECRET_ACCESS_KEY < /etc/AWS_SECRET_ACCESS_KEY + +# export AWS_IOT_CORE_THING_NAME="$THING_NAME" + +# export AWS_IOT_CORE_CREDENTIAL_ENDPOINT="$CREDENTIALS_ENDPOINT" +# export AWS_IOT_CORE_ROLE_ALIAS="$ROLE_ALIAS" +# export AWS_IOT_CORE_PRIVATE_KEY=/etc/private.key +# export AWS_IOT_CORE_CERT=/etc/certificate.pem + export AWS_KVS_CACERT_PATH=/etc/cert.pem + export AWS_KVS_CHANNEL_NAME="$CHANNEL_NAME" + export AWS_DEFAULT_REGION="$AWS_DEFAULT_REGION" + export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" + export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" + + # INFO + export AWS_KVS_LOG_LEVEL=3 + + # Start the VIEWER process with timeout 60s, kill after 10s if not responding to SIGTERM + timeout --preserve-status -k 10 60s /usr/bin/kvsWebrtcClientViewer $AWS_KVS_CHANNEL_NAME 2>&1 | tee /tmp/viewer.log + + echo -e "\n\n\nmaster.log:" + cat /tmp/master.log + + echo -e "\n\n\nviewer.log:" + cat /tmp/viewer.log + + if [ -e /master.log ]; then + if grep -A3 -E ' fail| error' /tmp/master.log; then + echo "Found failed or error in master.log" + echo "FAIL: amazon-kvs-webrtc-sdk-c: data test: $RETVAL" + fi + if grep -E ' Connection established' /tmp/master.log; then + echo "Connection established found - good" + echo "PASS: amazon-kvs-webrtc-sdk-c: data test" + fi + fi + +else + echo "no creadentials found, skipping connection test" + echo "SKIP: amazon-kvs-webrtc-sdk-c: data test" +fi \ No newline at end of file diff --git a/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/linux-webrtc-reference-for-amazon-kinesis-video-streams_git.bb b/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/linux-webrtc-reference-for-amazon-kinesis-video-streams_git.bb index 1979fd28d..d16975e62 100644 --- a/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/linux-webrtc-reference-for-amazon-kinesis-video-streams_git.bb +++ b/recipes-sdk/linux-webrtc-reference-for-amazon-kinesis-video-streams/linux-webrtc-reference-for-amazon-kinesis-video-streams_git.bb @@ -6,17 +6,13 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=34400b68072d710fecd0a2940a0d1658" DEPENDS += "\ libwebsockets \ - gstreamer1.0 \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - gstreamer1.0-plugins-bad \ " # default is stripped, we wanna do this by yocto EXTRA_OECMAKE:append = " -DCMAKE_BUILD_TYPE=RelWithDebInfo" -# set log message debug level -EXTRA_OECMAKE:append = " -DLIBRARY_LOG_LEVEL=LOG_VERBOSE" +# set log level +EXTRA_OECMAKE:append = " -DLIBRARY_LOG_LEVEL=LOG_INFO" ### # 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" # nooelint: oelint.vars.specific CFLAGS:append:arm = " -Wno-error=format=" -SRC_URI = "\ +SRC_URI += "\ gitsm://github.com/awslabs/linux-webrtc-reference-for-amazon-kinesis-video-streams.git;protocol=https;branch=main \ file://run-ptest \ " @@ -48,31 +44,81 @@ PACKAGECONFIG:append:x86-64 = " ${@bb.utils.contains('PTEST_ENABLED', '1', 'sani PACKAGECONFIG[sanitize] = ",, gcc-sanitizers" +# h264 gst plugin require setting: LICENSE_FLAGS_ACCEPTED += "commercial" +# and enable opus codec +# PACKAGECONFIG:append:pn-gstreamer1.0-plugins-base = " opus" +# and enable x264 codec +# PACKAGECONFIG:append:pn-gstreamer1.0-plugins-ugly = " x264" + +PACKAGECONFIG:append = " ${@bb.utils.contains("LICENSE_FLAGS_ACCEPTED", "commercial", "gstreamer", "", d)}" + +PACKAGECONFIG[gstreamer] = ",,\ + gstreamer1.0 \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + ,\ + gstreamer1.0 \ + gstreamer1.0-plugins-base \ + gstreamer1.0-plugins-good \ + gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly \ + gstreamer1.0-plugins-base-apps \ + " + RDEPENDS:${PN} += "ca-certificates" -#RDEPENDS:${PN}-ptest += "\ -# amazon-kvs-webrtc-sdk \ -# coreutils \ -# util-linux \ -#" +RDEPENDS:${PN}-ptest += "\ + amazon-kvs-webrtc-sdk \ + coreutils \ + util-linux \ +" +# overwrite these variables to use your own AWS credentials in your local.conf +AWS_REGION ?= "eu-central-1" +AWS_KVS_CHANNEL_NAME ?= "test-channel" +AWS_ACCESS_KEY_ID ?= "" +AWS_SECRET_ACCESS_KEY ?= "" +AWS_SESSION_TOKEN ?= "" +AWS_CA_CERT_PATH ?= "/etc/cert.pem" + +# this can be used for key based authentication do_configure:append() { cp ${S}/examples/demo_config/demo_config_template.h ${S}/examples/demo_config/demo_config.h + sed -i '/#define AWS_REGION "us-west-2"/d' ${S}/examples/demo_config/demo_config.h + sed -i '/#define AWS_KVS_CHANNEL_NAME ""/d' ${S}/examples/demo_config/demo_config.h + sed -i '/#define AWS_CA_CERT_PATH "cert\/cert.pem"/d' ${S}/examples/demo_config/demo_config.h sed -i '/^#if defined( AWS_ACCESS_KEY_ID ) && defined( AWS_IOT_THING_ROLE_ALIAS )/i\ - #define AWS_CREDENTIALS_ENDPOINT ""\ - #define AWS_IOT_THING_NAME ""\ - #define AWS_IOT_THING_ROLE_ALIAS ""\ - #define AWS_IOT_THING_CERT_PATH "certificate.pem"\ - #define AWS_IOT_THING_PRIVATE_KEY_PATH "private.key"\ +#define AWS_REGION "${AWS_REGION}"\ +#define AWS_KVS_CHANNEL_NAME "${AWS_KVS_CHANNEL_NAME}"\ +#define AWS_REGION "${AWS_REGION}"\ +#define AWS_ACCESS_KEY_ID "${AWS_ACCESS_KEY_ID}"\ +#define AWS_SECRET_ACCESS_KEY "${AWS_SECRET_ACCESS_KEY}"\ +#define AWS_SESSION_TOKEN "${AWS_SESSION_TOKEN}"\ +#define AWS_CA_CERT_PATH "${AWS_CA_CERT_PATH}"\ ' ${S}/examples/demo_config/demo_config.h } +# this can be used for iot cert based authentication +#do_configure:append() { +# cp ${S}/examples/demo_config/demo_config_template.h ${S}/examples/demo_config/demo_config.h +# sed -i '/^#if defined( AWS_ACCESS_KEY_ID ) && defined( AWS_IOT_THING_ROLE_ALIAS )/i\ +# #define AWS_CREDENTIALS_ENDPOINT ""\ +# #define AWS_IOT_THING_NAME ""\ +# #define AWS_IOT_THING_ROLE_ALIAS ""\ +# #define AWS_IOT_THING_CERT_PATH "certificate.pem"\ +# #define AWS_IOT_THING_PRIVATE_KEY_PATH "private.key"\ +# ' ${S}/examples/demo_config/demo_config.h +#} +# + inherit cmake pkgconfig ptest do_install() { install -d ${D}${bindir} install -m 0755 ${B}/WebRTCLinuxApplicationMaster ${D}${bindir} - install -m 0755 ${B}/WebRTCLinuxApplicationGstMaster ${D}${bindir} + ${@bb.utils.contains("PACKAGECONFIG", "gstreamer", "install -m 0755 ${B}/WebRTCLinuxApplicationGstMaster ${D}${bindir}", "", d)} install -d ${D}${bindir}/examples/app_media_source/samples/h264SampleFrames cp -r ${S}/examples/app_media_source/samples/h264SampleFrames/* ${D}${bindir}/examples/app_media_source/samples/h264SampleFrames/ @@ -82,10 +128,25 @@ do_install() { install -d ${D}${sysconfdir} install -m 0664 ${S}/cert/cert.pem ${D}${sysconfdir}/ -# install -m 0664 ${S}/certificate.pem ${D}${sysconfdir}/ -# install -m 0664 ${S}/private.key ${D}${sysconfdir}/ } +do_install_ptest:append() { + install -d ${D}${sysconfdir} + echo "${AWS_ACCESS_KEY_ID}" > ${D}${sysconfdir}/AWS_ACCESS_KEY_ID + echo "${AWS_SECRET_ACCESS_KEY}" > ${D}${sysconfdir}/AWS_SECRET_ACCESS_KEY + echo "${AWS_KVS_CHANNEL_NAME}" > ${D}${sysconfdir}/CHANNEL_NAME + echo "${AWS_REGION}" > ${D}${sysconfdir}/AWS_REGION + + # cert based authentication + if [ -f ${S}/cert/private.key ]; then + install -m 0664 ${S}/cert/private.key ${D}${sysconfdir}/ + fi + if [ -f ${S}/cert/certificate.pem ]; then + install -m 0664 ${S}/cert/certificate.pem ${D}${sysconfdir}/ + fi +} + +#TODO: add suport for cert based authentication # do_install_ptest:append() { # install -d ${D}${sysconfdir} # install ${S}/tests/iot-credentials/THING_NAME ${D}${sysconfdir}/