<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nishu Singh on Medium]]></title>
        <description><![CDATA[Stories by Nishu Singh on Medium]]></description>
        <link>https://medium.com/@nishu-singh?source=rss-8c8b24b1737e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ex_AMgA5QZbvu1dfVu2Pww.jpeg</url>
            <title>Stories by Nishu Singh on Medium</title>
            <link>https://medium.com/@nishu-singh?source=rss-8c8b24b1737e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:32:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nishu-singh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Group/Duo Video Calling in Android| Amazon Chime using JavaScript]]></title>
            <link>https://medium.com/mobcoder-llc/group-duo-video-calling-in-android-amazon-chime-using-javascript-b9a308d72c4f?source=rss-8c8b24b1737e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9a308d72c4f</guid>
            <category><![CDATA[duo-video-call]]></category>
            <category><![CDATA[chime-sdk]]></category>
            <category><![CDATA[group-video-call]]></category>
            <dc:creator><![CDATA[Nishu Singh]]></dc:creator>
            <pubDate>Wed, 16 Dec 2020 12:31:59 GMT</pubDate>
            <atom:updated>2020-12-16T12:31:59.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EM4EpHv2nP-9mhhQb_jhQg.png" /></figure><p>Mobile Applications with instant messaging and video conferencing based communications, builds an improved human interaction medium.</p><p>Moreover, in this pandemic situation by following social distancing rule, the most secure way to stay in touch with people right now is through a video conference, which resulted a uplift in video calling apps.<br>Through this post, I would like to show how to accomplish basic group-video calling tasks and handle real-time-scenario’s using Amazon Chime Android SDK. It will connect the user with other clients(Attendees) so that they can share a real-time audio-video chat session.</p><h4>Amazon Chime Overview</h4><p>Amazon Chime is a communications service that allows developers to use its communications infrastructure and services that power Amazon Chime, and add audio calling, video calling, and screen sharing capabilities directly to their applications.</p><blockquote><strong>Prerequisites</strong></blockquote><ul><li>You need to have basic to intermediate understanding of <a href="https://kotlinlang.org/">Kotlin</a> and Android development.</li><li>you need an <a href="https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fportal.aws.amazon.com%2Fbilling%2Fsignup%2Fresume&amp;client_id=signup">AWS account </a>and <a href="https://aws.amazon.com/iam/">Identity and Access Management (IAM)</a> role that has the AdministratorAccess policy. To build applications using the Amazon Chime SDK, development experience and familiarity with JavaScript is required. You have to read this<a href="https://aws.amazon.com/blogs/business-productivity/building-a-meeting-application-using-the-amazon-chime-sdk/"> Building a meeting application using the Amazon Chime SDK</a> to understand the basic architecture of Amazon Chime SDK and deployed a serverless/browser demo meeting application.</li></ul><blockquote><strong>AWS Security</strong></blockquote><p>Amazon operates AWS regions and networks to meet the requirements of some of the world’s most security-sensitive organizations.</p><h4>Access Controls</h4><p>To join a meeting on Amazon Chime you are required to have an authorization token. Get Authorization token from server along with meetingResponse and attendeeResponse objects. These objects contain all the information needed for a application using the Amazon Chime SDK for JavaScript to join the meeting.</p><h4>Modern Industry Standard Encryption</h4><p>When connected to an Amazon Chime meeting, your audio, messages, video, and content shared through screen sharing is encrypted while in transit using industry standard cryptographic protocols: Transport Layer Security (TLS), Datagram Transport Layer Security (DTLS), and Datagram Transport Layer Security-Secure Real-Time Transport Protocol (DTLS-SRTP).</p><h4>Keeping Your Meetings Secure</h4><p>Amazon Chime meetings are all based on 10-digit meeting IDs. In order to secure your meetings you need to ensure that only those that have been invited have the meeting ID.</p><p>Features for securing your meetings:</p><ul><li><a href="https://docs.aws.amazon.com/chime/latest/ug/personal-ID.html">Different meeting ID options</a></li><li><a href="https://aws.amazon.com/blogs/business-productivity/amazon-chime-adds-new-ways-to-increase-control-and-share-management-of-your-meetings/">Moderated Meetings</a></li><li><a href="https://docs.aws.amazon.com/chime/latest/ug/chime-organizer-call-controls.html#remove-actions">Remove Attendees</a></li><li><a href="https://docs.aws.amazon.com/chime/latest/ug/chime-organizer-call-controls.html#lock-actions">Lock Meeting</a></li></ul><blockquote><strong>AWS Pricing</strong></blockquote><p>Amazon Chime offers pay-per-use pricing which lets you pay for features you use, on the days that you use them. You can switch between Basic features that don’t include a charge, and Pro features that do include a charge.</p><blockquote><strong>Key steps</strong></blockquote><p>Here is an outline of the key steps involved in integrating the Amazon Chime SDK into your Android application.</p><ol><li>Configure your application</li><li>Create a meeting session</li><li>Access AudioVideoFacade</li><li>Handle real-time events</li><li>Render a video tile</li><li>Add RecyclerView to Render other attendees video tile</li><li>Cleanup</li></ol><h3>Configure your application :</h3><p>The Amazon Chime SDK for Android is similarly comprised of a common binary and Kotlin wrapper. It supports Android projects written in Kotlin or Java targeting API Level 21 (Android 5.0) or greater.</p><p><strong>Step 1.</strong> Open Android Studio and create New Project and set the minimum SDK for the app to be API Level 26.</p><p><strong>Step 2.</strong> To add Amazon chime Android SDK, you must complete the following steps-<br>i. Download <a href="https://amazon-chime-sdk.s3.amazonaws.com/android/amazon-chime-sdk-media/latest/amazon-chime-sdk-media.tar.gz">amazon-chime-sdk-media.tar.gz</a> and <a href="https://amazon-chime-sdk.s3.amazonaws.com/android/amazon-chime-sdk/latest/amazon-chime-sdk.tar.gz">amazon-chime-sdk.tar.gz</a></p><p>ii. Unzip the files and copy amazon-chime-sdk-media.aar and amazon-chime-sdk.aar into your application’s library directory.</p><p>iii. Open your project’s build.gradle and add the following under repositories in allprojects:</p><pre>repositories {<br>    google()<br>    jcenter()<br>    flatDir {<br>        dirs &#39;libs&#39;<br>    }<br>}</pre><p>iv. Add the following under dependencies section:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef46bb0af48bfa8ea0406b1023dc9dc5/href">https://medium.com/media/ef46bb0af48bfa8ea0406b1023dc9dc5/href</a></iframe><p>v. Use Java 8 features by adding the following under the android section.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4f06df6359d4e1d4575fe2034a37402/href">https://medium.com/media/c4f06df6359d4e1d4575fe2034a37402/href</a></iframe><p><strong>Step 3.</strong> Requesting permissions<br>Since our app uses audio and video from the user’s device, we’ll need to request audio and video permissions. We’ll use the Dexter Permission library to do this.</p><ul><li>Add the Dexter Permissions library to your app’s build.gradle.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b993962dc89ef2ade829bd3ce58011c/href">https://medium.com/media/4b993962dc89ef2ade829bd3ce58011c/href</a></iframe><p>it will check if the permissions have been granted or not, if haven’t, we prompt the user for camera and mic permissions with the else will redirect to settings screen of device. Once permissions have been granted, this method will trigger method to authenticate meeting url and make api-call.</p><p>Next we walk you through creating Meeting(can consider a meeting as a chat room, people with same meetingID will join same meeting) in order to have a basic audio, video experience. You can refer to the <a href="https://aws.github.io/amazon-chime-sdk-android/amazon-chime-sdk/">API document</a> or my GitHub <a href="https://github.com/nishusingh06/chimeDemo/tree/master">repository</a> for additional details.</p><p><a href="https://github.com/nishusingh06/chimeDemo/tree/master">nishusingh06/chimeDemo</a></p><p>Enough talk, let’s get coding.</p><h3>Create a meeting session</h3><ol><li>You need to make a API call(POST request) to meetingUrl to create a meeting (room) and an attendee by default. The meetingUrl is the URL of the serverless demo meeting application you deployed(see Prerequisites). Else you can get meetingResponseJson from server and directly use it for session configuration.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e64a75f3574807fb51f386b3acf6d4fa/href">https://medium.com/media/e64a75f3574807fb51f386b3acf6d4fa/href</a></iframe><p>2. We will use the response of above request to construct a MeetingSessionConfiguration. Convert the JSON response to the pre-defined CreateMeetingResponse and CreateAttendeeResponse types by using <a href="https://github.com/google/gson">Gson</a>, this can be done in a number of ways.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dced31504e566a4327e3a70144eef48/href">https://medium.com/media/0dced31504e566a4327e3a70144eef48/href</a></iframe><p>don’t forget to add Gson dependency to your app’s build.gradle.</p><pre>//Gson dependency<br>implementation &#39;com.google.code.gson:gson:2.8.6&#39;</pre><blockquote><strong>Request Audio Focus (Real time scenario) :</strong></blockquote><p>Our meeting session is created, now before accessing AudioVideoFacade we need to ensure that audio focus is granted to our application i.e, no other application running on our device should occupy it if we are in a meeting session, else that sound will also be passed in audio streams. So just request focus by adding below lines:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebdb126471c2bea52ecf0520164d8e39/href">https://medium.com/media/ebdb126471c2bea52ecf0520164d8e39/href</a></iframe><p>and register audio focus change listener, it will get called when audio focus changes after being requested with <a href="https://developer.android.com/reference/android/media/AudioManager#requestAudioFocus(android.media.AudioFocusRequest)">AudioManager#requestAudioFocus()</a>, and until being abandoned with <a href="https://developer.android.com/reference/android/media/AudioManager#abandonAudioFocusRequest(android.media.AudioFocusRequest)">AudioManager#abandonAudioFocusReques</a>().</p><h3>Access AudioVideoFacade :</h3><p>Now we can access the AudioVideoFacade instance and use it to control the audio and video experience.</p><pre>//get audioVideoFacade instance<br>audioVideo = meetingSessionModel.audioVideo</pre><pre>audioVideo.start()</pre><p><strong>audioVideo.</strong><a href="https://aws.github.io/amazon-chime-sdk-js/interfaces/audiovideofacade.html#start"><strong>start()</strong></a> -will start the meeting session. This method will initialize all underlying components, set up connections, and immediately start sending and receiving audio.</p><p>The video streaming does not start automatically. Call the following methods to start sending local video and receiving remote video.</p><pre>// Enable remote video to start receiving streams.<br> audioVideo.startRemoteVideo()</pre><pre>//share the local attendee’s video with remote attendees<br> audioVideo.startLocalVideo()</pre><pre>//Switch between front and back camera in the meeting.          audioVideo.switchCamera()</pre><p>You can control local audio on and off by calling the mute and unmute methods on the facade</p><pre>// Mute local audio input.<br>audioVideo.realtimeLocalMute()</pre><pre>// Unmute local audio input.<br> audioVideo.realtimeLocalUnmute()</pre><h3>Handle real-time events :</h3><p>We have to handle various real-time events during the meeting to update UI accordingly. Events are triggered when attendees join or leave the meeting, audio is muted or unmuted, or video is enabled or disabled. The Amazon Chime SDK for Android provides several observer interfaces including AudioVideoObserver, RealtimeObserver and VideoTileObserver. You can implement these as per your requirements.</p><p>1. <strong>AudioVideoObserver</strong> — provides status of audio and video client</p><p>AudioVideoObserver is used to monitor the status of audio or video sessions. The following code demonstrates some examples of the callbacks from AudioVideoObserver.</p><pre>override fun <strong>onAudioSessionStarted</strong>(reconnecting: Boolean) =<br>    logger.info(TAG, &quot;Audio successfully started. reconnecting: $reconnecting&quot;)</pre><pre>override fun <strong>onAudioSessionStopped</strong>(sessionStatus: MeetingSessionStatus) =<br>    logger.info(TAG, &quot;Audio stopped for reason: ${sessionStatus.statusCode}&quot;)</pre><pre>override fun <strong>onVideoSessionStarted</strong>() =<br>    logger.info(TAG, &quot;Video successfully started.&quot;)</pre><pre>override fun <strong>onVideoSessionStopped</strong>(sessionStatus: MeetingSessionStatus) =<br>    logger.info(TAG, &quot;Video stopped for reason: ${sessionStatus.statusCode}&quot;)</pre><pre>// Register the observer.<br><strong>audioVideo.addAudioVideoObserver</strong>(this)</pre><pre>// Un-Register the observer.<br><strong>audioVideo.removeAudioVideoObserver</strong>(this)</pre><p>the onAudioSessionStopped callback is triggered when streaming stops due to poor network, so we will stop meeting and clear resources in this callback.</p><p>2. <strong>RealtimeObserver</strong> — provide attendee status</p><pre>// Notifies when attendees joined the meeting.<br>override fun <strong>onAttendeesJoined</strong>(attendeeInfo: Array&lt;AttendeeInfo&gt;) {<br>    attendeeInfo.forEach {<br>        logger.debug(TAG, &quot;Attendee join. attendee Id: ${it.attendeeId} external user Id: ${it.externalUserId}&quot;)<br>    }<br>}</pre><pre>// Notifies when attendee(s) being dropped due to network.<br>override fun <strong>onAttendeesDropped</strong>(attendeeInfo: Array&lt;AttendeeInfo&gt;) {<br>    attendeeInfo.forEach {<br>        logger.debug(TAG, &quot;Attendee dropped. attendee Id: ${it.attendeeId} external user Id: ${it.externalUserId}&quot;)<br>    }<br>}</pre><pre>// Notifies when attendee(s) being removed.<br>override fun <strong>onAttendeesLeft</strong>(attendeeInfo: Array&lt;AttendeeInfo&gt;) {    attendeeInfo.forEach {<br>        logger.debug(TAG, &quot;Attendee left. attendee Id: ${it.attendeeId} external user Id: ${it.externalUserId}&quot;)<br>    }<br>}</pre><pre>// Notifies when attendee(s) whose <a href="https://aws.github.io/amazon-chime-sdk-android/amazon-chime-sdk/com.amazonaws.services.chime.sdk.meetings.audiovideo/-volume-level/index.html">VolumeLevel</a> has changed to muted.<br>override fun <strong>onAttendeesMuted</strong>(attendeeInfo: Array&lt;AttendeeInfo&gt;) {    attendeeInfo.forEach {<br>        logger.debug(TAG, &quot;Attendee muted. attendee Id: ${it.attendeeId} external user Id: ${it.externalUserId}&quot;)<br>    }<br>}</pre><pre>// Notifies when attendee(s) whose <a href="https://aws.github.io/amazon-chime-sdk-android/amazon-chime-sdk/com.amazonaws.services.chime.sdk.meetings.audiovideo/-volume-level/index.html">VolumeLevel</a> has changed from muted.<br>override fun <strong>onAttendeesUnmuted</strong>(attendeeInfo: Array&lt;AttendeeInfo&gt;) {  attendeeInfo.forEach {<br>        logger.debug(TAG, &quot;Attendee unmuted. attendee Id: ${it.attendeeId} external user Id: ${it.externalUserId}&quot;)<br>    }<br>}</pre><pre>// Notifies when signal strength changes for attendees whose <a href="https://aws.github.io/amazon-chime-sdk-android/amazon-chime-sdk/com.amazonaws.services.chime.sdk.meetings.audiovideo/-signal-strength/index.html">SignalStrength</a> has changed.<br>override fun <strong>onSignalStrengthChanged</strong>(signalUpdates: Array&lt;SignalUpdate&gt;) {<br>signalUpdates.forEach {<br>        logger.debug(TAG, &quot;Attendee signal strength changed&quot;)<br>    }<br>}</pre><pre>// Notifies when volume levels changed.<br>override fun <strong>onVolumeChanged</strong>(volumeUpdates: Array&lt;VolumeUpdate&gt;) {<br>    volumeUpdates.forEach { (attendeeInfo, volumeLevel) -&gt;<br>        logger.info(TAG, &quot;AttendeeId: ${attendeeInfo.attendeeId} externalUserId: ${attendeeInfo.externalUserId} volumeLevel: $volumeLevel&quot;)<br>    }<br>}</pre><pre>// Register the observer.<br><strong>audioVideo.addRealtimeObserver</strong>(this)</pre><pre>// Un-Register the observer.<br><strong>audioVideo.removeRealtimeObserver</strong>(this)</pre><p>We will receive above callbacks for local and remote user both, we will update recyclerView adapter for Remote user callbacks. Once you get a list of attendees, you can fetch the attendee name from the externalUserId by the following code.</p><pre>val attendeeName = attendeeInfo.externalUserId.split(&#39;#&#39;)[1]</pre><p>3. <strong>VideoTileObserver</strong> — video tile track</p><p>Some applications only need audio, so video events are handled by a separate observer. If you’re not going to render video, you can skip this step and the render video tile step below.</p><p>By implementing <strong>onVideoTileAdded</strong> and <strong>onVideoTileRemoved</strong>, you can track the currently active video tiles.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f0a21235fd4365a42d010b1535353ae/href">https://medium.com/media/0f0a21235fd4365a42d010b1535353ae/href</a></iframe><pre>// Register the observer.<br>audioVideo.addVideoTileObserver()</pre><pre>// Un-Register the observer.<br>audioVideo.removeVideoTileObserver()</pre><h3>Render video tile :</h3><p>To render a video tile (both local and remote), you have to define a VideoRenderView in the layout resource file.</p><pre>&lt;com.amazon.chime.sdk.media.mediacontroller.video.DefaultVideoRenderView<br>    android:id=&quot;@+id/video_surface&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot; /&gt;</pre><p>To display the new available video tile, bind the view to the tileId. In onVideoTileAdded(tileState: VideoTileState) observer callback</p><pre>audioVideo.bindVideoView(view.video_surface, videoTileState.tileId)</pre><p>Binds the video rendering view to Video Tile. The view will start displaying the video frame after the completion of this API.</p><h3>Add recyclerView to Render other attendees video tiles :</h3><p>We will add a horizontal recyclerView on top of SurfaceView that we used to render local users view on full screen. Add below code in <em>activity_meeting.xml :</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e5499245a8e2de398312818bdfb1780/href">https://medium.com/media/1e5499245a8e2de398312818bdfb1780/href</a></iframe><p>Add adapter for our recyclerView. We will pass audioVideo facade and mutable collection of VideoAudioCollectionTile in constructor. audioVideo facade will be used to bind video tile with Surface View.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34da80e46516d3e27aaf5bb76ea2dc9b/href">https://medium.com/media/34da80e46516d3e27aaf5bb76ea2dc9b/href</a></iframe><h3>Some other real time scenario’s :</h3><h4><strong>1. Receiving a phone call in between meeting (<em>Register TelephonyManager</em>)</strong></h4><p>We need to monitor PHONE STATE in order to observe incoming calls in between a meeting session, and manage audio streaming accordingly else that conversation will also be passed in our meeting streams. So just register PhoneStateListener provided by TelephonyManager by adding below lines:</p><pre><strong>val telephonyManager: TelephonyManager =<br>    getSystemService(Context.<em>TELEPHONY_SERVICE</em>) as TelephonyManager<br>telephonyManager.listen(phoneStateListener, PhoneStateListener.<em>LISTEN_CALL_STATE</em>)</strong></pre><p>we will mute and unmute local audio stream, accordingly onCallStateChange callbacks:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccd39a23f0483d5ec7bd73da0f673296/href">https://medium.com/media/ccd39a23f0483d5ec7bd73da0f673296/href</a></iframe><h4>2. Surface View of remote user hides behind Surface View Local user</h4><p>When creating a layout with a “picture in picture” type layout for remote user’s video stream, when the local video comes through, the video feed covers over the remote video of the person you’re having the meeting with as well. The “Wrapper” for the remote video feed continues to show up, it’s just the feed that gets overridden.</p><p>You need to callsetZOrderMediaOverlay(true) on the DefaultVideoRenderView of the remote video tiles.</p><pre>view.attendeeVideoSurface.setZOrderOnTop(true)<br></pre><h3>Cleanup :</h3><p>We need to clear resources we occupied and Unregister all listeners in onDestroy() of our activity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df9d20b07653d5de041d691188c58506/href">https://medium.com/media/df9d20b07653d5de041d691188c58506/href</a></iframe><p><strong>NOTE</strong>: Don’t forget to delete the two <a href="https://aws.amazon.com/cloudformation/">AWS CloudFormation</a> stacks created in the prerequisites, if you don’t want to keep the demo active in your account and wish to avoid incurring AWS charges. These stacks can be found in the <a href="https://console.aws.amazon.com/cloudformation/home">AWS CloudFormation console</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9a308d72c4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mobcoder-llc/group-duo-video-calling-in-android-amazon-chime-using-javascript-b9a308d72c4f">Group/Duo Video Calling in Android| Amazon Chime using JavaScript</a> was originally published in <a href="https://medium.com/mobcoder-llc">Mobcoder LLC</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>