How to Use AWS Kinesis Video Streams WebRTC for Peer-to-Peer Live Streaming

July 11, 2022 | Comments(0) |
TABLE OF CONTENT

1. Architecture of AWS Kinesis

2. Configuring Amazon Cognito

3. Set Up a User Pool

4. Set Up an Identity Pool

5. About CloudThat

5. FAQs

 

Architecture of AWS Kinesis

The onslaught of pandemics has opened up a new normal way of life with which remote working and online classes took the driving seat. Today organizations and educational institutes have started using peer-to-peer and multi-peer live stream video connections in real-time. In this blog, we will look at how to set up peer-to-peer live video streaming with the AWS Kinesis video streams Service.

Amazon Kinesis video streams service is an AWS media service that allows users to connect to peer-to-peer and multi-peer live streaming video connections. It is also used in the majority of IoT (Internet of Things) camera applications to allow users to access their video streams from anywhere in the world.

Configuring Amazon Cognito

Log in to the AWS console, type Cognito into the search box, and then choose and navigate to the Cognito service.

 

Set Up a User Pool

At the Amazon Cognito console choose the Manage user pools

After clicking Create a user pool

Enter Live_stream_user_pool at Pool name 

Then choose Review defaults 

After reviewing click create a pool 

In a short time, a pool will be created. Make note of the Pool Id that we will use later. 

On the page of the pool, choose App Client then click Add an app client option.

 

On the app-client page, enter the app client name as Live_stream_app_client then scroll down and choose the create app client button.

Created app client will be displayed, note down the App client id and App client secret these ids will be used later. 

Set Up an Identity Pool

At the Amazon Cognito console choose Manage Identity pools

 

Enter Identity pool name as Live_stream_identity_pool. Extend the section Authentication providers. Add the User Pool ID and App Client ID data from the previous method to the Cognito tab, then choose to create the pool.

 

Next page, expand the Show Details part. Choose View Policy Document in the section that has a value for Role name that ends in Auth_Role. Select Edit, and then accept the Edit Policy dialogue box. Then copy and paste the following JSON into the editor. 

{ 

    “Version”: “2012-10-17”, 

    “Statement”: [ 

    { 

      “Effect”: “Allow”, 

      “Action”: [ 

        “cognito-identity:*”, 

        “kinesisvideo:*” 

      ], 

      “Resource”: [ 

        “*” 

      ] 

    } 

  ] 

} 

After clicking Allow. Copy, and save the Identity pool ID value from the Get AWS Credentials code snippet on the next page. This value will be required while configuring the Android application.

Android application development: 

To create the mobile application for video streaming, we will require the Android studio IDE (https://developer.android.com/studio/index.html) From this link you can download and install it. We recommend at least version 3.0.0, which was released in October of 2017.  

AWS provides SDKs (Software Development Kit) readily available to developers. Run the following command in your system to get the WebRTC SDK for Android (git clone https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-android.git) Before executing this command, make sure. git has been installed. 

  Open Amazon-kinesis-video-streams-webrtc-sdk-android/build.gradle with Open as Project to import the Android WebRTC SDK into the Android Studio integrated development environment (IDE). When you launch Studio for the first time, it will install all the missing packages and select Accept to proceed with the installation. 

To configure AWS Cognito credentials, open awsconfiguration.json (from **/src/main/res/raw/) in your Android IDE. The file appears as indicated in the image below. 

Testing: 

Open the Kinesis video app on your mobile and select Create new account, then complete, select Create new account, complete the form, and sign up. Then, use the username and password to log in. To start a live stream, enter the demo channel at the channel name location and select Start Master. The live stream will begin.

To test the live stream, go to the AWS kinesis video streams interface and select the streaming channel. You should be able to see the demo-channel that was created when we launched Start Master from the mobile app. Open the demo-channel by clicking it.

Choose Media playback viewer from the demo-channel portal, then click the play button to view the live streaming video. To establish a peer-to-peer connection, install the same Android app on another device, enter the demo-channel at the channel name location and select the Start Viewer option, after which the video stream will begin from both ends.

About CloudThat

CloudThat is the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding Github Integration, AWS CodePipeline, and DevOps best practices and I will get back to you quickly. To get started, go through our consulting offerings page

FAQs

 

1. What is Amazon Kinesis video streams with WebRTC?

Amazon Kinesis Video Streams for WebRTC is a fully managed service. It makes developers life easy by freeing them from activities like procuring, installing and maintaining their own media servers.

2. What is WebRTC technology?

WebRTC or Web Real-Time Communications is an open source project that helps to accomplish real-time voice, text and video communications between web browsers and devices.


Leave a Reply