From 78c4897592362edc5c52de47eca7fa27fd01df98 Mon Sep 17 00:00:00 2001 From: bdhandap <34078957+bdhandap@users.noreply.github.com> Date: Fri, 22 Sep 2023 00:50:27 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20awslabs/?= =?UTF-8?q?amazon-kinesis-video-streams-webrtc-sdk-js@a8b21d21361b407ff45e?= =?UTF-8?q?526e0a6aa7e33a66bbba=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/app.js | 13 +++++++++++++ examples/createStream.js | 33 +++++++++++++++++++++++++++++++++ examples/index.html | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 examples/createStream.js diff --git a/examples/app.js b/examples/app.js index 0bea128..0fc9f4b 100644 --- a/examples/app.js +++ b/examples/app.js @@ -493,6 +493,19 @@ $('#describe-media-storage-configuration-button').on('click', async function() { describeMediaStorageConfiguration(formValues); }); +$('#create-stream-modal').on('show.bs.modal', function() { + // Set the stream name in the modal to the stream name. + $('#create-stream-modal-stream-input').val($('#streamName').val()); +}); + +$('#create-stream-modal-create-stream-button').on('click', async function() { + await createStream({ + ...getFormValues(), + streamName: $('#create-stream-modal-stream-input').val(), + retentionInHours: $('#create-stream-modal-retention-input').val(), + }); +}); + // Enable tooltips $(document).ready(function() { $('[data-toggle="tooltip"]').tooltip(); diff --git a/examples/createStream.js b/examples/createStream.js new file mode 100644 index 0000000..f742af1 --- /dev/null +++ b/examples/createStream.js @@ -0,0 +1,33 @@ +/** + * This file demonstrates the process of creating a Kinesis Video Stream. + */ +async function createStream(formValues) { + try { + console.log( + '[CREATE_STREAM] Attempting to create a Kinesis Video Stream with name', + formValues.streamName, + 'with', + formValues.retentionInHours, + 'hours of retention.', + ); + // Create KVS client + const kinesisVideoClient = new AWS.KinesisVideo({ + region: formValues.region, + accessKeyId: formValues.accessKeyId, + secretAccessKey: formValues.secretAccessKey, + sessionToken: formValues.sessionToken, + endpoint: formValues.endpoint, + }); + + const createStreamResponse = await kinesisVideoClient + .createStream({ + StreamName: formValues.streamName, + DataRetentionInHours: formValues.retentionInHours, + }) + .promise(); + + console.log('[CREATE_STREAM] Success! Stream ARN:', createStreamResponse.StreamARN); + } catch (e) { + console.error('[CREATE_STREAM] Encountered error:', e); + } +} diff --git a/examples/index.html b/examples/index.html index a906222..d56d95d 100644 --- a/examples/index.html +++ b/examples/index.html @@ -91,6 +91,37 @@

Tracks

Configure which stream to ingest and store media to. Call update media storage configuration with an empty Stream name to disable this feature.

+
+ + +
@@ -104,7 +135,7 @@

Tracks

- + Logs +