Platform

Platform

  • Getting Started
  • API

›IOS 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

Iris iOS SDK supports video call between its users. Make sure that the app is logged in and connected to RTC server before initiating a call. If RTC connection got disconnected due to inactivity, the user should again request for connection to make a successful call.

Different APIs are used to create and join a video session. It also supports features like mute, hold and unhold local stream. Session related API requests have their respective callbacks to notify the user about the status of the request. IrisRtcVideoSessionDelegate interface handles the callbacks specific to video session, in addition to the generic callbacks for any session type (audio, video or chat).

Create Local Media Stream

The IrisRtcStream class manages the audio and video streams that can be created using Iris stream APIs. The IrisRtcStreamDelegate provides callbacks specific 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.

(id)initWithDelegate:(id<IrisRtcStreamDelegate>)delegate error:(NSError **)outError
Parameters
delegateThe delegate object for the stream that is used to receive messages during execution and upon completion or failure of the operation.
outErrorProvides error code and basic error description when any exception occur in api call

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

private var localStream: IrisRtcStream?
...
...
self.localStream = IrisRtcStream(delegate: self)

self.rtcStream!.startPreview()

Create Renderer for Media Stream

startPreview() will use the delegate method onLocalStream of IrisRtcStreamDelegate to send the local media track to the application. The application can create a renderer and add the same to this track. For remote stream, onAddRemoteStream of IrisRtcVideoSessionDelegate is triggered when media stream is received from remote end.

private var localRenderer : IrisRtcRenderer!
private var remoteRenderer : IrisRtcRenderer?
...
...
/**
    Note: The renderers should be created before creating IrisRtcStream instance 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.
**/

localRenderer =  createRenderer(self.view.bounds, self)
localRenderer.transform = CGAffineTransform(scaleX: CGFloat(1.0), y: 1)

remoteRenderer = createRenderer(CGRect.zero, self)

self.view.insertSubview(remoteRenderer!.videoView, at: 0)
self.view.insertSubview(localRenderer.videoView, at: 1)
...
...
private func createRenderer(_ size: CGRect, _ delegate: IrisRtcRendererDelegate) -> IrisRtcRenderer{
    return IrisRtcRenderer(view: size, delegate: delegate)!
}

//Invoked once local media stream is created
func onLocalStream(_ stream: IrisRtcStream!, mediaTrack: IrisRtcMediaTrack!) {
    localTrack = mediaTrack
    localTrack?.add(localRenderer, delegate: self)
}


//Invoked when media is received from remote peer.
func onAddRemoteStream(_ track: IrisRtcMediaTrack!, participantId: String!, roomId: String!, traceId: String!) {
    remoteTrack = track
    remoteTrack?.add(remoteRenderer, delegate: self)
}

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 RTC connection 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. createWithRoomId API is invoked to create a video session, which involves creating and starting a video session using the room id for the room which has been already allocated for the involved participants.

(BOOL)createWithRoomId:(NSString* )roomId notificationData:(NSString*)notificationData stream:(IrisRtcStream*)stream  sessionConfig:(IrisRtcSessionConfig *)sessionConfig delegate:(id<IrisRtcVideoSessionDelegate>)delegate error:(NSError**)outError
Parameters
roomIdRoom Id of the room allocated for the participants
notificationDataNotification Data
streamLocal media stream
sessionConfigIrisRtcSessionConfig object for setting additional optional session configuration parameters
delegateDelegate object for IrisRtcVideoSession,used to receive callbacks
outErrorProvides error code and basic error description when exceptions occur in api call
private var session: IrisRtcVideoSession?
private var sessionconfig: IrisRtcSessionConfig?
...
...
session = IrisRtcVideoSession()
sessionconfig = IrisRtcSessionConfig()

session!.create(withRoomId: roomId,
                notificationData: buildNotificationPayload(),
                stream: localStream,                            //Local media stream
                sessionConfig: sessionconfig,
                delegate: self)
...
...
 // build notification payload
 private func buildNotificationPayload() -> String{

    let data:[String: Any] = ["cname" : getUserName(),      // registered user name
                              "cid" : getUserName(),        // registered user name
                              "isVideoOnly" : true]

    let notificationPayload = ["type" : "video",
                               "topic": "<App domain>/video"]

    let userData = ["data": data, "notification" : notificationPayload]

    do{
        let jsonData = try JSONSerialization.data(withJSONObject: userData, options: JSONSerialization.WritingOptions.prettyPrinted)

        return String(data: jsonData, encoding: String.Encoding.utf8)!
    }catch {
        Log.e("Error creating notification payload")
    }

    return " "
}

Accept Incoming Call

A local stream should be created and passed along with other parameters received in the incoming call notification to joinWithSessionId API inorder to join a video session.

(BOOL)joinWithSessionId:(NSString*)sessionId roomToken:(NSString*)roomToken roomTokenExpiryTime:(NSInteger)roomTokenExpiry stream:(IrisRtcStream*)stream rtcServer:(NSString*)rtcServer sessionConfig:(IrisRtcSessionConfig *)sessionConfig delegate:(id<IrisRtcVideoSessionDelegate>)delegate error:(NSError **)outError
Parameters
sessionIdRoom name to be joined which is received in notification
roomTokenRoom token which is received in notification
roomTokenExpiryTimeRoom token expiry time which is received in notification
streamLocal media stream
rtcServerRTC server URL
sessionConfigIrisRtcSessionConfig object for setting additional optional session configuration parameters
delegateDelegate object for IrisRtcVideoSession,used to receive the callbacks
outErrorProvides error code and basic error description when any exception occured in api call
private var session: IrisRtcVideoSession?
private var sessionconfig: IrisRtcSessionConfig?
...
...
session = IrisRtcVideoSession()
sessionconfig = IrisRtcSessionConfig()

session!.join(withSessionId: roomId,
              roomToken: roomToken,
              roomTokenExpiryTime: roomTokenExpiryTime),
              stream: localStream,                          //Local media stream
              rtcServer: rtcServer,
              sessionConfig: sessionconfig,
              delegate: self)

End an Active Call

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.
private var session: IrisRtcVideoSession?
private var localStream: IrisRtcStream?
...
...
session?.close()
localStream?.close()

On-call Features

Features offered by iOS SDK for video 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, video) stream. stopPreview() API in IrisRtcStreamSession class is used to hold video in an active call.

private var localStream: IrisRtcStream?
...
...
localStream?.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. startPreview() API in IrisRtcStreamSession class is used to unhold video in an active call.

private var localStream: IrisRtcStream?
...
...
localStream?.startPreview()

Mute Local Audio

An user can mute his/her end to stop sharing audio from their end, but at the same time they can receive audio from other end. iOS SDK provides mute() API in IrisRtcStream class for the same.

private var localStream: IrisRtcStream?
...
...
localStream?.mute()

Unmute Local Audio

If an user is on mute he/she can unmute the call and resume conversation. unmute() API in IrisRtcStream class is used for this feature.

private var localStream: IrisRtcStream?
...
...
localStream?.unmute()

Video Call Related Callbacks

onAddRemoteStream

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

(void)onAddRemoteStream:(IrisRtcMediaTrack *)track participantId:(NSString*)participantId roomId:(NSString*)roomId traceId:(NSString *)traceId
Parameters
trackPointer to the IrisRtcMediaTrack containing remote track
participantIdRouting id of the participant
roomIdRoom id received from Iris backend
traceIdTrace id received from Iris backend

onRemoveRemoteStream

This callback gets invoked when the remote stream is removed from the peerconnection.

(void)onRemoveRemoteStream:(IrisRtcMediaTrack *)track participantId:(NSString*)participantId roomId:(NSString*)roomId traceId:(NSString *)traceId
Parameters
trackPointer to the IrisRtcMediaTrack containing remote track
participantIdRouting id of the participant
roomIdRoom id received from Iris backend
traceIdTrace id received from Iris backend
← 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