Skip to content

Instantly share code, notes, and snippets.

@dave-malone
Last active March 24, 2021 14:51
Show Gist options
  • Save dave-malone/7d18c490d5a99acaa3f6ac77173a0bda to your computer and use it in GitHub Desktop.
Save dave-malone/7d18c490d5a99acaa3f6ac77173a0bda to your computer and use it in GitHub Desktop.
Just a simple echo script
#!/bin/bash
RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "installing amazon-kinesis-video-streams-webrtc-sdk-c build dependencies"
sudo apt-get install -y \
pkg-config \
cmake \
zip \
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
echo "cloning the amazon-kinesis-video-streams-webrtc-sdk-c repository"
git -C $HOME clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c.git
# TODO - modify samples/Common.c
# replace
# PCHAR pAccessKey, pSecretKey, pSessionToken, pLogLevel;
# with
# PCHAR pCredentialsProviderEndpoint, pCertPath, pPrivateKeyPath, pCaCertPath, pIoTRoleAlias, pLogLevel;
#
# replace
# CHK_ERR((pAccessKey = getenv(ACCESS_KEY_ENV_VAR)) != NULL, STATUS_INVALID_OPERATION, "AWS_ACCESS_KEY_ID must be set");
# CHK_ERR((pSecretKey = getenv(SECRET_KEY_ENV_VAR)) != NULL, STATUS_INVALID_OPERATION, "AWS_SECRET_ACCESS_KEY must be set");
# pSessionToken = getenv(SESSION_TOKEN_ENV_VAR);
# with
# CHK_ERR((pCredentialsProviderEndpoint = getenv("AWS_IOT_CREDENTIALS_ENDPOINT")) != NULL, STATUS_INVALID_OPERATION, "AWS_IOT_CREDENTIALS_ENDPOINT must be set");
# CHK_ERR((pCertPath = getenv("IOT_CERT_PATH")) != NULL, STATUS_INVALID_OPERATION, "IOT_CERT_PATH must be set");
# CHK_ERR((pPrivateKeyPath = getenv("IOT_PRIVATE_KEY_PATH")) != NULL, STATUS_INVALID_OPERATION, "IOT_PRIVATE_KEY_PATH must be set");
# CHK_ERR((pCaCertPath = getenv("IOT_CA_CERT_PATH")) != NULL, STATUS_INVALID_OPERATION, "IOT_CA_CERT_PATH must be set");
# CHK_ERR((pIoTRoleAlias = getenv("AWS_IOT_ROLE_ALIAS")) != NULL, STATUS_INVALID_OPERATION, "AWS_IOT_ROLE_ALIAS must be set");
#
#
# replace
# createStaticCredentialProvider(pAccessKey, 0, pSecretKey, 0, pSessionToken, 0, MAX_UINT64, &pSampleConfiguration->pCredentialProvider));
# with
# createLwsIotCredentialProvider(pCredentialsProviderEndpoint, pCertPath, pPrivateKeyPath, pCaCertPath, pIoTRoleAlias, channelName, &pSampleConfiguration->pCredentialProvider));
#
mkdir -p $HOME/amazon-kinesis-video-streams-webrtc-sdk-c/build
cd $HOME/amazon-kinesis-video-streams-webrtc-sdk-c/build
cmake .. -DBUILD_TEST=TRUE
make
cd $RUN_DIR
echo "installing amazon-kinesis-video-streams-webrtc-sdk-c runtime dependencies"
sudo apt-get install -y \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-pulseaudio
ulimit -c unlimited
echo "Running webrtc client test to confirm device support"
$HOME/amazon-kinesis-video-streams-webrtc-sdk-c/build/tst/webrtc_client_test
# generate run-kvs-webrtc.sh
cat > run-kvs-webrtc.sh <<EOF
export AWS_DEFAULT_REGION=$AWS_REGION
export AWS_IOT_CREDENTIALS_ENDPOINT=$(aws iot describe-endpoint --endpoint-type iot:CredentialProvider --output text)
export AWS_IOT_ROLE_ALIAS=KvsCameraIoTRoleAlias
export IOT_CERT_PATH=$DEVICE_CERT_PATH
export IOT_PRIVATE_KEY_PATH=$PRIVATE_KEY_PATH
export IOT_CA_CERT_PATH=$ROOT_CERT_PATH
export AWS_KVS_CACERT_PATH=$PWD/amazon-kinesis-video-streams-webrtc-sdk-c/certs/cert.pem
export LD_LIBRARY_PATH=$HOME/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/:$HOME/amazon-kinesis-video-streams-webrtc-sdk-c/build/
$HOME/amazon-kinesis-video-streams-webrtc-sdk-c/build/kvsWebrtcClientMasterGstSample $THING_NAME
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment