Index


Class wsc.Call

Represents a call which 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 input as the second parameter in wsc.CallPackage#createCall

Class Summary
Constructor Attributes Constructor Name and Description
 
An Object that represents a call between two peers.
Method Summary
Method Attributes Method Name and Description
 
accept(callConfig, localMediaStreams, extHeaders)
Accepts the received Call invitation.
 
decline(code, extHeaders)
Decline the call with a reason code.
 
end(extHeaders)
Ends the current call.
 
Gets the CallConfig object of the current local call configuration.
 
Gets the callee of current call.
 
Gets the caller of current call.
 
Gets the current state of call.
 
Gets the DataTransfer object by label.
 
Gets the value of ICE check interval.
 
Gets the peerConnection of the 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.
 
Sets value of ICE check interval.
 
start(localMediaStreams, extHeaders)
Starts the call represented by itself.
 
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.
Event Summary
Event Attributes Event Name and Description
 
onCallStateChange(callState, extHeaders)
Event handler called when the call state is changed.
 
onDataTransfer(dataTransfer)
Event handler which is called when a DataTransfer object is created.
 
onMediaStreamEvent(mediaStreamEvent, mediaStream)
Event handler called when media state is changed.
 
onMessage(msg)
For extensibility - Processes messages received.
 
onUpdate(callConfig, extHeaders)
Event handler called when there is an update request for an established call.
Class Detail
wsc.Call()
An Object that represents a call between two peers. It is created by calling wsc.CallPackage#createCall function.
See:
wsc.Call
Method Detail
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:
{wsc.CallConfig} 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).
{Array} localMediaStreams
pre-created local media streams array
{Object} extHeaders
extension headers. If provided, they are inserted into the JSON message.
For example, an extHeaders formatted like this, {'customerKey1':'value1','customerKey2':'value2'}
will be in the message formatted like this :
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}
Throws:
{name: "InvalidCallConfig"|message: "The parameter 'callConfig' is invalid."}

decline(code, extHeaders)
Decline the call with a reason code. The default value is 603 decline.
The available reason codes are:
Parameters:
{String} code
The decline code reason.
{Object} extHeaders
extension headers. If provided, they are inserted into the JSON message.
For example, an extHeaders formatted like this, {'customerKey1':'value1','customerKey2':'value2'}
will be in the message formatted like this :
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

end(extHeaders)
Ends the current call.
Parameters:
{Object} extHeaders
extension headers. If provided, they are inserted into the JSON message.
For example, an extHeaders formatted like this, {'customerKey1':'value1','customerKey2':'value2'}
will be in the message formatted like this:
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

{wsc.CallConfig} getCallConfig()
Gets the CallConfig object of the current local call configuration.
Returns:
{wsc.CallConfig} the CallConfig object of current call

{String} getCallee()
Gets the callee of current call.
Returns:
{String} callee

{String} getCaller()
Gets the caller of current call.
Returns:
{String} caller

{wsc.CallState} getCallState()
Gets the current state of call.
Returns:
{wsc.CallState} the call state of current call

{wsc.DataTransfer} getDataTransfer(label)
Gets the DataTransfer object by label.
Parameters:
{String} label
The label of the dataChannel of DataTransfer object
Returns:
{wsc.DataTransfer} object with the label

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:
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:
{number} time
the interval value in milliseconds. Must be greater than 0.
Throws:
{name: "IllegalArgumentError"|message: "The ICE check Interval must be greater than zero."}

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:
{Array} localMediaStreams
local media streams array
{Object} extHeaders
extension headers. If provided, they will be inserted into JSON message.
For example an extHeaders formatted like this, {'customerKey1':'value1','customerKey2':'value2'}
will be in the message formatted like this :
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

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:
{wsc.CallConfig} callConfig
The call configuration used to update the current call.
localStreams
The local media streams.
{Object} extHeaders
extension headers. If provided, they will be inserted into the JSON message.
For example, an extHeaders formatted like this, {'customerKey1':'value1','customerKey2':'value2'}
will be in the message formatted like this :
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}
Event Detail
onCallStateChange(callState, extHeaders)
Event handler called when the call state is changed.
 function onCallStateChange(callState, extHeaders) {
   showResults('Call state changed:' + callState.state);
   if (callState.state == wsc.CALLSTATE.ESTABLISHED) {
     // show the call
     // display extention headers
   }
 }
Parameters:
{wsc.CallState} callState
The CallState object indicating latest call state.
{Object} extHeaders
extension headers. Extracted from the JSON message if they exist.
For example, extHeaders in this format, {'customerKey1':'value1','customerKey2':'value2'}
are extracted from a message in this format:
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

onDataTransfer(dataTransfer)
Event handler which 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()
 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;
 }
Parameters:
{wsc.DataTransfer} dataTransfer
The DataTransfer object created for the application

onMediaStreamEvent(mediaStreamEvent, mediaStream)
Event handler called when media state is changed.
 function onMediaStreamEvent(mediaStreamEvent, stream) {
   var rurl = webkitURL.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;
     }
   }
}
Parameters:
{wsc.MEDIASTREAMEVENT} mediaStreamEvent
the media stream event defined in client SDK.
{RTCMediaStream} mediaStream
the media stream

onMessage(msg)
For extensibility - Processes messages received.
This event handler handles and processes received messages for the current call. This is an SPI function which can be overridden when the Call object exposed by WebRTC Session Controller JavaScript API is extended.
Parameters:
{wsc.Message} msg
The message received

onUpdate(callConfig, extHeaders)
Event handler called when there is an update request for an established call.
Parameters:
{wsc.CallConfig} callConfig
The new CallConfig object used to update the call.
{Object} extHeaders
extension headers. Extracted from JSON message if they exist.
For example, extHeaders in this format, {'customerKey1':'value1','customerKey2':'value2'}
are extracted from a message in this format:
{ "control" : {}, "header" : {...,'customerKey1':'value1','customerKey2':'value2'}, "payload" : {}}

Copyright © 2005, 2013, Oracle and/or its affiliates. All rights reserved.