Class: Call

wsc. Call

Represents a call that could have any combination of audio/video/dataChannel capabilities. The capability of a Call is determined when it is created. This capability is configured in the CallConfig object and is input as the second parameter in wsc.CallPackage#createCall

new Call()

An Object that represents a call between two peers. It is created by calling wsc.CallPackage#createCall function.

See:

Methods

accept(callConfig, localMediaStreams, extHeaders)

Accepts the received Call invitation. If the parameter localMediaStreams is not null, the Call will use the localMediaStreams, or the call will create a new mediaStream based on the {CallConfig} object in first parameter.

Parameters:
Name Type Description
callConfig wsc.CallConfig

Local capability configuration of the Call. This callConfig must not conflict with rules of RFC 3264. For example, if callConfig of call.onIncomingCall or call.onUpdate is (SENDONLY, NONE), this callConfig cannot be (SENDONLY, NONE), and it can be (RECVONLY, NONE) or (NONE, NONE).

localMediaStreams Array

pre-created local media streams array

extHeaders JSON

extension headers.

decline(code, extHeaders)

Decline the call with a reason code. The default value is 603 decline.
The available reason codes are:

  • 486: busy here
  • 603: decline
  • 600: busy everywhere
Parameters:
Name Type Description
code Number

The decline code reason.

extHeaders JSON

extension headers.

end(extHeaders)

Ends the current call.

Parameters:
Name Type Description
extHeaders JSON

extension headers.

getCallConfig() → {wsc.CallConfig}

Gets the CallConfig object of the current local call configuration.

Returns:

the CallConfig object of current call

Type
wsc.CallConfig

getCallee() → {String}

Gets the callee of current call.

Returns:

callee

Type
String

getCaller() → {String}

Gets the caller of current call.

Returns:

caller

Type
String

getCallState() → {wsc.CallState}

Gets the current state of call.

Returns:

the call state of current call

Type
wsc.CallState

getDataTransfer(label) → {wsc.DataTransfer}

Gets the DataTransfer object by label.

Parameters:
Name Type Description
label String

The label of the dataChannel of DataTransfer object

Returns:

object with the label

Type
wsc.DataTransfer

getIceCheckInterval()

Gets the value of ICE check interval. If not set, the default is 2000 milliseconds. The ICE candidate status is checked periodically. If new candidates are gathered, an attempt is made to send them to the other peer using a JSON START message.

getPeerConnection()

Gets the peerConnection of the current call. Note: The peerConnection may change. When using it, execute call.getPeerConnection() each time.

Returns:

RTCPeerConnection the RTCPeerConnection of current call

resume(successCallback, failureCallback)

If a Call object was resurrected through wsc.CallPackage#event:onResurrect, application can use this method to resume the call.

Parameters:
Name Type Description
successCallback

Callback function invoked when resuming succeeds. Its interface is void().

failureCallback

Callback function invoked when resuming fails. Its interface is void().

setIceCheckInterval(time)

Sets value of ICE check interval. If not set, the default value is 2000 milliseconds. The ICE candidate status is checked periodically. If new candidates are gathered, an attempt is made to send them to the other peer using a JSON START message.

Parameters:
Name Type Description
time Number

the interval value in milliseconds. Must be greater than 0.

Throws:
The ICE check Interval must be greater than zero.
Type
IllegalArgumentError

start(localMediaStreams, extHeaders)

Starts the call represented by itself. The call will use the given localMediaStreams if it is not null, or create new mediaStream according the CallConfig of the current Call.

Parameters:
Name Type Description
localMediaStreams Array

local media streams array

extHeaders JSON

extension headers.

update(callConfig, localStreams, extHeaders)

Updates the call, for instance to add video, remove video, mute audio and unmute audio, or mute and unmute video and so on.

Parameters:
Name Type Description
callConfig wsc.CallConfig

The call configuration used to update the current call.

localStreams

The local media streams.

extHeaders JSON

extension headers.

Events

onCallStateChange

Event handler that is called when the call state is changed.

Parameters:
Name Type Description
callState wsc.CallState

The CallState object indicating the latest call state.

extHeaders JSON

extension headers.

Example
 function onCallStateChange(callState, extHeaders) {
   showResults('Call state changed:' + callState.state);
   if (callState.state == wsc.CALLSTATE.ESTABLISHED) {
     // show the call
     // display extention headers
   }
 }

onDataTransfer

Event handler that is called when a DataTransfer object is created. The application should set this callback function to get the DataTransfer object for a Call's data channel.
For the caller, the application should set it before invoking Call.start().
For the callee, the application should set it when it has obtained the call object in onIncomingCall().

Parameters:
Name Type Description
dataTransfer wsc.DataTransfer

The DataTransfer object created for the application

Example
 function onDataTransfer(dataTransfer) {
   console.log("Data transfer call back is called.");
   //keep the reference of dataTransfer, and initial the callback functions of dataTransfer.
   myDataTransfer = dataTransfer;
   myDataTransfer.onOpen = onDCOpen;
   myDataTransfer.onError = onDCError;
   myDataTransfer.onClose = onDCClose;
 }

onMediaStreamEvent

Event handler called when media state is changed.

Parameters:
Name Type Description
mediaStreamEvent wsc.MEDIASTREAMEVENT

the media stream event defined in client SDK.

mediaStream RTCMediaStream

the media stream

Example
 function onMediaStreamEvent(mediaStreamEvent, stream) {
   var rurl = URL.createObjectURL(stream);
   var audioTracks = null;
   var videoTracks = null;
   if(stream.audioTracks) {
     // Old version
     audioTracks = stream.audioTracks;
     videoTracks = stream.videoTracks;
   } else {
     // New version
     audioTracks = stream.getAudioTracks();
     videoTracks = stream.getVideoTracks();
   }
   if (mediaStreamEvent == wsc.MEDIASTREAMEVENT.LOCAL_STREAM_ADDED) {
     if (videoTracks.length > 0) {
       //Local video stream is added.
       selfView.src = rurl;
     } else if (audioTracks.length > 0) {
       //Local audio stream is added.
       selfAudio.src = rurl;
     }
   } else if (mediaStreamEvent == wsc.MEDIASTREAMEVENT.REMOTE_STREAM_ADDED) {
     if (videoTracks.length > 0) {
        // Remote video stream is added.
        remoteView.src = rurl;
     } else if (audioTracks.length > 0) {
        // Remote audio stream is added.
        remoteAudio.src = rurl;
     }
   }
}

onMessage

For extensibility - Processes the received JSON message between client and WebRTC Session Controller server.
Application can override this method to handle the JSON message directly.

Parameters:
Name Type Description
msg wsc.Message

The message received

onUpdate

Event handler called when there is an update request for an established call.

Parameters:
Name Type Description
callConfig wsc.CallConfig

The new CallConfig object used to update the call.

extHeaders JSON

extension headers.

Oracle® Communications WebRTC Session Controller JavaScript API Reference, E55131-03
Copyright © 2013, 2015, Oracle and/or its affiliates. All rights reserved.