new videoCall(onEvents, domElements, options)
VideoCall usecase
Parameters:
Name | Type | Description |
---|---|---|
onEvents |
object | Event handlers: onEvents |
domElements |
object | DOM elements: domElements |
options |
object | Available options: options |
Returns:
VideoCall actions
- Type
- Promise
Example
var onEvents = { onAccepted: userName => { // Call accepted }, onCalling: () => { // Calling a peer }, onDataReceived: (type, data, filename) => { // Data received by the datachannel if(type === 'notification') { } else if(type === 'application/x-chat') { } else if(type === 'text/plain') { } else if(type === 'application/pdf') { } else if(type === 'application/zip') { } else if(type === 'application/x-rar') { } else if(type === 'image/jpeg') {} else if(type === 'image/png') {} else if(type === 'application/x-docx') {} else if(type === 'application/x-pptx') {} else if(type === 'application/x-xlsx') {} else if(type === 'application/vnd.oasis.opendocument.text') {} }, onGotPeers: list => { // List of registered peers }, onHangUp: (userName, reason) => { // Hang up call }, onIncomingCall: userName => { // Incoming call from a peer }, onRegistered: (userName, isRegistered) => { // Successful or unsuccessful registration }, onSetCall: () => { // Configured call }, onFileTransferOk: fileId => { // File Transfer OK }, onFileTransferKo: fileId => { // File Transfer KO }, onRemoteStreamReady: (isReady, stream) => { // The remote stream is ready } }; var domElements = { videos: document.getElementById('videos') }; var options = { // Optional stream: { aDeviceId: null, vDeviceId: null, resolution: 'vga' // 'qvga', 'vga', 'hd', 'full-hd', '4k', '8k', frameRate: 30, }, dataChannel: { dataEnabled: true, allowedTypes: ['notification', application/x-chat', 'image/jpeg', 'image/png', 'application/pdf'], maxSize: 5, // In MB fileTransmission: { timeout: 5, // Minutes retransmissionDelay: 15 // Seconds } }, display: { namePattern: /^__default__/i }, account: "******", // Multiple mode recordingPrefix: '' // Recording Prefix }; usecases.videoCall(onEvents, domElements, options) .then(action => { // Use Case has been atacched succesfully ... }) .catch(cause => { // Error attaching the Use Case console.log("Error Attach " + cause ); })
Methods
-
acceptCall()
-
Accept an incoming call
Returns:
- Type
- nothing
Example
action.acceptCall();
-
call(userName, record)
-
Call to peer registered
Parameters:
Name Type Description userName
string Name of a peer registered
record
boolean Flag to record the call ('notification' type must be allowed in DataChannel)
Returns:
- Type
- nothing
Example
action.call('Simon', true);
-
closeUsecase()
-
Close the current UseCase. It's recommended combine with disconnect method
Returns:
- Type
- nothing
Example
action.closeUsecase(); myVideoApp.disconnect(); // Recommended
-
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
Returns:
-
- Type
- nothing
-
- Type
- nothing
Example
action.getPeers(/^__default__/i, "ASC");
-
-
hangUp()
-
Hang up/Decline a call
Returns:
- Type
- nothing
Example
action.hangUp();
-
notify(action, data)
-
Send a notification to the other peer via the DataChannel
Parameters:
Name Type Description action
string Identifies the notification type
data
string Useful for sending extra data (Optional)
Example
action.notify('open-map', 'data');
-
register(userName)
-
Register a peer in the VideoCall Usecase
Parameters:
Name Type Description userName
string (Alphanumeric)
Returns:
- Type
- nothing
Example
action.register('Mike');
-
replaceVideo(type)
-
Replace the local Video track
Parameters:
Name Type Description type
string ('user', 'environment', 'left', 'right' or 'next')
Example
action.replaceVideo('environment');
-
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)
Returns:
- Type
- nothing
Example
action.sendData('application/x-chat', 'Hello Mike!', function(cOk) { // Success }, function(error) { // Error console.log(error); } )
-
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"
Returns:
- Type
- nothing
Example
action.setCall(true, true, "medium");
-
toggleAudio()
-
Toggle local Audio stream (Mute/Unmute)
Returns:
Is audio muted?
- Type
- boolean
Example
action.toggleAudio(); // true or false
-
toggleVideo()
-
Toggle local Video stream (Mute/Unmute)
Returns:
Is video muted?
- Type
- boolean
Example
action.toggleVideo(); // true or false