Class: videoCall

videoCall

VideoCall Use Case


new videoCall(onEvents, domElements, options)

A VideoCall Usecase is started

Parameters:
Name Type Description
onEvents object

Event handlers: onAccepted, onCalling, onDataReceived, onGotPeers, onHangUp, onIncomingCall, onRegistered, onSetCall

domElements object

DOM elements: videos

options object

Available options: dataChannel, display

Source:
Returns:

VideoCall methods: call, acceptCall, closeUsecase, getPeers, hangUp, register, sendData, setCall, toggleAudio, toggleVideo

Type
Promise
Example
var onEvents = {
    onAccepted: function(userName) {
         // Accepted
    },
    onCalling: function() {
         // Calling
    },
    onDataReceived: function(type, data, filename) {
        // Data received
        if(type === 'application/x-chat') { }
        if(type === 'text/plain') { }
        if(type === 'application/pdf') { }
        if(type === 'application/zip') { }
        if(type === 'application/x-rar') { }
        if(type === 'image/jpeg') {}
        if(type === 'image/png') {}
        if(type === 'application/x-docx') {}
        if(type === 'application/x-pptx') {}
        if(type === 'application/x-xlsx') {}
        if(type === 'application/vnd.oasis.opendocument.text') {}
    },
    onGotPeers: function(list) {
         // Peers registered ready
    },
    onHangUp: function(userName, reason) {
         // HangUp / Decline
    },
    onIncomingCall: function(userName) {
         // Incoming call
    },
    onRegistered: function(userName, isRegistered) {
         // Registered
    },
    onSetCall: function() {
         // Set
    }
};

var domElements = {
    videos: document.getElementById('videos')
};

var options = { // Optional
     dataChannel: {
         dataEnabled: true,
         allowedTypes: ['application/x-chat', 'image/jpeg', 'image/png', 'application/pdf'],
         maxSize: 5 // In MB
     },
     display: {
         namePattern: /^__default__/i
     }
};

usecases.videoCall(onEvents, domElements, options)
    .then(function(action) {
         // Use Case has been atacched succesfully
         ...
    })
    .catch(function(cause) {
        // Error attaching the Use Case
        console.log("Error Attach " + cause );
    })

Methods


<inner> acceptCall()

Accept an incoming call

Source:
Returns:
Type
nothing

<inner> call(userName)

Call to peer registered

Parameters:
Name Type Description
userName string

Name of a peer registered

Source:
Returns:
Type
nothing

<inner> closeUsecase()

Close the current UseCase. It's recommended combine with disconnect method

Source:
Returns:
Type
nothing
Example
action.closeUsecase();
myVideoApp.disconnect(); // Recommended

<inner> getPeers(filter, order)

Get list of peers registered/incall (Array)

Parameters:
Name Type Description
filter RegExp

RegExp to filter the list of peers. e.g: /^default/i

order string

["ASC"|"DESC"] Order array of peers

Source:
Returns:
Type
nothing

<inner> hangUp()

Hang up/Decline a call

Source:
Returns:
Type
nothing

<inner> register(userName)

Register a peer in the VideoCall Usecase

Parameters:
Name Type Description
userName string

(Alphanumeric)

Source:
Returns:
Type
nothing

<inner> sendData(type, data, cOk, cKo, (Optional))

Sends a message (Chat or File) through the DataChannel

Parameters:
Name Type Description
type string

MIME Type (e.g: 'application/x-chat', 'text/plain', 'application/pdf', 'application/zip', 'application/x-rar', 'image/jpeg', 'image/png', 'application/x-docx', 'application/x-pptx', 'application/x-xlsx', 'application/vnd.oasis.opendocument.text')

data string

Data Content

cOk function

Callback success function

cKo function

Callback failed function

(Optional) string

filename File Name (e.g: file.zip)

Source:
Returns:
Type
nothing
Example
action.sendData('application/x-chat', 'Hello Mike!',
 function(cOk) {
     // Success
 },
 function(error) {
     // Error
     console.log(error);
 }
)

<inner> setCall(audio, video, quality)

Configure the call settings on the fly

Parameters:
Name Type Description
audio boolean

Audio Enabled

video boolean

Video Enabled

quality string

Call Quality: "high", "medium", "low"

Source:
Returns:
Type
nothing

<inner> toggleAudio()

Toggle local Audio stream (Mute/Unmute)

Source:
Returns:

Is audio muted?

Type
boolean
Example
action.toggleAudio(); // true or false

<inner> toggleVideo()

Toggle local Video stream (Mute/Unmute)

Source:
Returns:

Is video muted?

Type
boolean
Example
action.toggleVideo(); // true or false