Platform

Platform

  • Getting Started
  • API

›Android SDK

Getting Started

  • Create Your App

Quick Starts

  • 555 Samples

Mobile SDK (v1.0)

  • Overview
  • IOS SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept video call
    • How to set log level for SDK
    • Release Notes

    Android SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept video call
    • How to set log level for SDK
    • Release Notes

Mobile SDK (v2.0)

  • Overview
  • IOS SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to initiate or accept VIDEO call
    • How to initiate or join ANONYMOUS VIDEO call
    • Release Notes
    • Reference code - How to initiate or accept PSTN Call
    • Reference code - How to initiate or accept Video Call
    • Reference code - How to initiate or join Anonymous Video Call

    Android SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • How to intiate or accept Video Call
    • How to intiate or accept ANONYMOUS VIDEO Call
    • Release Notes
    • Reference code - How to initiate or accept PSTN Call
    • Reference code - How to initiate or accept Video Call
    • Reference code - How to initiate or join Anonymous Video Call

    React Native SDK

    • Getting started
    • Installation Guide
    • How to do user authentication
    • How to subscribe for notifications
    • How to initiate or accept PSTN call
    • Release Notes

WebRTC JS SDK

  • Overview
  • Getting Started
  • How to do user authentication
  • How to subscribe for notifications
  • How to initialize SDK
  • How to initiate or accept PSTN call
  • How to initiate or accept video call
  • How to create a screen share session
  • Release Notes

Video Call

555 Android SDK supports video calls between its users. It supports on-call features such as local hold and mute. Every session related API requests have their respective callbacks to notify the user about the status of the request. IrisRtcVideoSessionObserver interface provides the callbacks specific to audio session, in addition to the generic callbacks for any session type (audio, video or chat).

Before initiating or accepting a video call, make sure to have logged in and have an active Rtc Connection. If app has been disconnected from RTC server due to inactivity, user has to request for RTC connection. Before creating or joining a session, media(video and audio) stream should be created.

Create Local Media Stream

The IrisRtcStream class manages the audio and video streams that can be created using Iris stream APIs. The IrisRtcStreamObserver provides callbacks related to stream class. The following method is called to create a stream with default options. It will create stream with both audio and video with video quality as HD and make use of back camera.

  IrisRtcStream(IrisRtcStreamObserver observer, Context context)
Parameters
observerListener to receive the callbacks upon completion or failure of the operation.
contextApplication context

startPreview() API is called to start a local preview for the chosen camera.

    ... 
    ...    
    IrisRtcStream rtcStream = new IrisRtcStream(observer, context);    
    rtcStream.startPreview(eglBaseContext);
    ... 
    ... 
  }

Create Renderer for Media Stream

startPreview() will use the callback method onLocalStream of IrisRtcStreamObserver to send the "mediaTrack" to the application. The application can create a renderer and add the same to this track. For remote stream, onAddRemoteStream of IrisRtcVideoSessionObserver is triggered when media stream is received from the remote end.

   public void onLocalStream(final IrisRtcMediaTrack mediaTrack) {
        super.onLocalStream(mediaTrack);  
        ... 
        ...
        Handler.post(new Runnable() {  
           @Override
           public void run() {  
               mediaTrack.addRenderer(localRenderer);  
           }
        });  
        ... 
        ... 
   }
   
   //Triggered when media is received from remote peer.
   void onAddRemoteStream(final IrisRtcMediaTrack mediaTrack, String routingId, String sessionId) {   
      ... 
      ... 
      mHandler.post(new Runnable() {
         public void run() {
            localRenderer.updateRenderer(65, 60, 30, 25, IrisRtcRenderer.IrisSdkScaleType.SCALE_ASPECT_FIT, false, localRenderLayout);
            remoteRenderer.updateRenderer(0, 0, 100, 100, IrisRtcRenderer.IrisSdkScaleType.SCALE_ASPECT_FILL, false, remoteRenderLayout);
            mediaTrack.addRenderer(remoteRenderer);
         }
      });
      ... 
      ... 
   }   
   
   private IrisRtcRenderer localRenderer;   
   private IrisRtcRenderer remoteRenderer;
   
   /**
    Note: The renderers should be created before creating IrisRtcStream instance itself so that, the renderers are available when the videotracks for local and remote video are created. 
    Below code snippet shows how to create renderers for local and remote video streams.
   **/   
     
   {
      ... 
      ... 
      SurfaceViewRenderer localSurfaceViewRender = mContentLayout.localVideoView;     // localVideoView is SurfaceViewRenderer
      SurfaceViewRenderer remoteSurfaceViewRender = mContentLayout.remoteVideoView;    // remoteVideoView is SurfaceViewRenderer
      EglBase rootEglBase = EglBase.create();
      localSurfaceViewRender.init(rootEglBase.getEglBaseContext(), null);
      remoteSurfaceViewRender.init(rootEglBase.getEglBaseContext(), this);
      localSurfaceViewRender.setZOrderMediaOverlay(true);
      localRenderer = new IrisRtcRenderer(0, 0, 100, 100, IrisRtcRenderer.IrisSdkScaleType.SCALE_ASPECT_FIT, false, localSurfaceViewRender);
      remoteRenderer = new IrisRtcRenderer(0, 0, 100, 100, IrisRtcRenderer.IrisSdkScaleType.SCALE_ASPECT_FIT, false, remoteSurfaceViewRender);
      ... 
      ... 
   }

Note: When using the stream class, it will ask user to allow to use camera while running. Please make sure access is allowed. The run time permission dialog is shown in the app. When the stream is started, local preview will be shown even before the call gets connected.Hence the pop-up for camera access will be presented to the user the moment call starts.

Initiate an Outgoing Call

Once the Rtcconnection is made, enter a valid user id to make an outgoing call. A video session is then created with the local stream and other necessary values using IrisRtcVideoSession class.

Create the session for your video call using,

   void create(String roomId, String userData, IrisRtcStream stream, IrisRtcVideoSessionObserver observer)throws IrisRtcSDKException
Parameters
roomIdRoom Id of the session Initiater
userDataNotification payload data.
streamLocal media stream to be sent.
observerListener to receive the callbacks for audio session.
IrisRtcSDKExceptionException handler for SDK.
   ... 
   ... 
   IrisRtcVideoSession videoSession = new IrisRtcVideoSession(appContext);
   try{ 
       videoSession.create(roomid, userdata, rtcStream, observer);
   } catch (IrisRtcSDKException e) {
       Log.e(e, "Failed to create session");
   }
   ...
   ...  
    
   //build notification  payload
   String buildNotificationPayload() {
      Context context = mAppContext;
   
      JSONObject userdata = new JSONObject();
   
      JSONObject notification = new JSONObject();
      JSONObject data = new JSONObject();
   
      try {
   
         final String phoneNumber = PrefManager.getPhoneNumber(context);
         data.put("cname", userEmailId);
         data.put("cid", userEmailId);
         data.put("isVideoOnly", true);
   
         notification.put("type", "video");
         notification.put("topic", "<appDomain>/pstn");
   
         userdata.put("data", data);
         userdata.put("notification", notification);
   
      } catch (JSONException e) {
         e.printStackTrace();
      }
   }
   ... 
   ... 

Once the remote party has accepted your call request, audio and video streams from remote participant is as well available to the app.

Accept Incoming Call

To join the session, a local stream should be created and passed along with other parameters received in the incoming call notification to the below API:

    void join(String roomId, String roomToken, String roomTokenExpiry, IrisRtcStream stream, String rtcServer,IrisRtcVideoSessionObserver observer,IrisRtcSessionConfig sessionConfig) throws IrisRtcSDKException
Parameters
roomIdRoom name that needs to be joined which is recieved in notification payload.
roomTokenRoom token which is recieved in notification payload.
roomTokenExpiryRoom token expiry time retrieved from notification payload.
streamLocal Media stream to be sent.
rtcServerRTC server URL extracted from notification payload.
observerListener to receive the callbacks for video session.
sessionConfigIrisRtcSessionConfig object for setting additional, optional session configuration parameters.
IrisRtcSDKExceptionException handler for SDK.
    ... 
    ... 
    try{
       videoSession.join(roomId, roomToken, roomTokenExpiryTime, rtcStream, rtcServer, videoSessionObserver, sessionConfig);
    } catch (IrisRtcSDKException e) {
       Log.e(e, "Failed to join video call session");
    }
    ... 
    ... 

End an Active Call

On end call, all data and objects associated with that particular call must be cleared to avoid memory leak and efficiency. On end call, all data and objects associated with that particular call must be cleared for efficiency and to avoid memory leak. While closing a video call session following things must be kept in mind.

  • Close video session
    By invoking close() API in IrisRtcVideoSession, video session will get closed by releasing all objects associated with it.
  • Close stream
    The close() operation of stream class is synchronous and can take time while closing the stream. Closing the stream during a session can cause an error in video or audio sessions. Hence it is advisable to close the stream after the session is closed.
   ... 
   ... 
   videoSession.close();
   rtcStream.close();
   ... 
   ... 

On-call Features

Features offered by Iris Android SDK for PSTN call are:

  • Hold Local Stream
  • Unhold Local Stream
  • Mute Local Audio
  • Unmute Local Audio

Hold Local Stream

Either caller or callee can hold local video stream in a call. When user holds the local video stream, other party will receive the audio stream but not the video stream. The user who had put the call on hold will not be able to see the preview of local camera but will be able to receive the remote media (audio and video) stream. stopPreview() API in IrisRtcStreamSession class is used to hold video in an active call.

    ... 
    private IrisRtcStream rtcStream;  
    ... 
    ... 
    rtcStream.stopPreview();
    ... 
    ... 

Unhold Local Stream

The user who kept the video stream on hold can unhold the same and resume sharing the video stream to remote participant.

  ... 
  private IrisRtcStream rtcStream; 
  ... 
  ... 
  rtcStream.startPreview(eglBaseContext);
  ... 
  ... 

Mute Local Audio

The participant can mute his end to stop sharing audio from their end, but at the same time they can receive audio from the other end. Iris Android SDK provides mute() API in IrisRtcStream class for the same.

  ... 
  private IrisRtcStream rtcStream; 
  ... 
  ... 
  rtcStream.mute();
  ... 
  ... 

Unmute Local Audio

If a participant is on mute, he can unmute the call. Only then the other party can hear the audio. Iris Android SDK provides unmute() API in IrisRtcStream class for the same.

  ... 
  private IrisRtcStream rtcStream; 
  ... 
  ... 
  rtcStream.unmute();
  ... 
  ... 

Video Call Related Callbacks

onAddRemoteStream

This callback is called when the remote stream is added to peerconnection (the mechanism in WebRTC that provides all the communication capabilities of WebRTC).

   void onAddRemoteStream(IrisRtcMediaTrack mediaTrack, String participantId, String roomId, String traceId);
Parameters
mediaTrackInstance of IrisRtcMediaTrack containing remote track
participantIdParticipant Id
roomIdRoom id received from backend
traceIdTrace id

onRemoveRemoteStream

This callback is called when the remote stream is removed from peerconnection.

   void onRemoveRemoteStream(IrisRtcMediaTrack mediaTrack, String participantId, String roomId, String traceId);
Parameters
mediaTrackInstance of IrisRtcMediaTrack containing remote track
participantIdParticipant Id
roomIdRoom id received from backend
traceIdTrace id
← How to initiate or accept PSTN callHow to set log level for SDK →
  • Create Local Media Stream
    • Create Renderer for Media Stream
  • Initiate an Outgoing Call
  • Accept Incoming Call
  • End an Active Call
  • On-call Features
    • Hold Local Stream
    • Unhold Local Stream
    • Mute Local Audio
    • Unmute Local Audio
  • Video Call Related Callbacks
    • onAddRemoteStream
    • onRemoveRemoteStream
Docs
Getting StartedGuidesAPI Reference
More
BlogGitHub
555 Platform
Copyright © 2024 555 Platform ™
555docs-v0.0.94