Avaya Client SDK

< Back to Package Overview

Answering a Video Call

Using the Avaya Client SDK, you can easily integrate the ability for users of your application to make and receive audio or video calls.

To receive and answer an incoming video call, you must complete the following activities.

  • Subscribe for call events
  • Detect the presence of offered video
  • Obtain resources for answering a video call
  • Accept the incoming video call
  • Activate video resources
  • End the call

Subscribe for call events

In order to track accepted call's lifecycle, you can subscribe for different events of the Call object. In order to transmit local video and render incoming video you can subscribe for VideoChannelsUpdated event.

call.VideoChannelsUpdated += CallVideoChannelsUpdated;

Detect the presence of offered video

Any incoming call may include video, and the App needs to use the IncomingVideoStatus API on the Call to determine the call's offer status. The API returns one of three values which the application must handle

  • SUPPORTED. The calling party included video when making the call. If desired, the application can answer with bi-directional or reception-only video.
  • INDEFINITE. The calling party may or may not have included video when making the call. Due to requirements of some calling endpoints, it's highly recommended that the application answer with reception-only video. If this is not done, some endpoints will never be able to establish a video session with the application.
  • OFF. The calling party did not include video when making the call. The application should not answer the call with video.
IncomingVideoStatus videoStatus = call.IncomingVideoStatus;

Obtain resources for the video stream

The application needs to obtain two resources when making a call with video. A video camera. Camera availability is verified through the CameraVideoSource class. This class manages most aspects of camera operation, including verification of available hardware. A video inerface.

CameraVideoSource cameraVideoSource = new CameraVideoSource();
VideoInterface videoInterface = media.getVideoInterface();

Accept the incoming video call

The application specifies a video call by setting video mode prior to invoking call.start() or when using call.accept().

call.SetVideoMode(MediaDirection.SendReceive, handler);
call.Start();

Activate video resources

// Main event to track video updates and start/stop video
void CallVideoChannelsUpdated(object sender, VideoChannelsEventArgs e)
{
    Call call = (Call)sender;
    // First check if video channels are not empty
    if (e.VideoChannels.Count > 0)
    {
        if (videoChannel.IsEnabled)
        {
            // Start video transmition
            try
            {
                // Capture form could be different
                cameraVideoSource.Start(
                    cameraVideoSource.Cameras.First(),
                    new VideoCaptureFormat(1280, 720, 0, 30), null);
                VideoSink sink = 
                    videoInterface.getLocalVideoSink(channelId);
                cameraVideoSource.setVideoSink(sink);
            }
            catch (Exception ex)
            {
            // Handle exception here
            }
            // Start video rendering
            try
            {
                // An object on the view that is responsible for video render
                VideoRenderer2 remoteRendererSink = new VideoRenderer2();
                VideoSource videoSource = 
                    videoInterface.getRemoteVideoSource(channelId);
                videoSource.setVideoSink(remoteRendererSink);
            }
            catch (Exception ex)
            {
                // Handle exception here
            }
        }
        else
        {
            // Stop video transmission
            if (cameraVideoSource != null)
            {
                cameraVideoSource.setVideoSink(null);
            }
            // Stop video rendering
            VideoSource videoSource = 
                videoInterface.getRemoteVideoSource(channelId);
            if (videoSource != null)
            {
                videoInterface.getRemoteVideoSource(channelId).
                    setVideoSink(null);
            }
        }
    }

End the call

To terminate the call from the application, you can use the end() function on the call object.

call.End();

The onCallEnded callback event is sent to the call listener when the call has been ended. Use this event to update the UI of your application. Ending the call will deallocate the video channel and release the video camera automatically, but any render surface allocated by the application will need to be released by it. Again, see SdkSampleApp for the steps.