Methods
This document lists the methods available in the Videoedge SDK Instance, along with descriptions and code examples for implementation.
const videoedgeInstance = await videoedge.JsSdk.joinRoom({
sessionToken,
roomId,
peerName,
produce: true, // Set to true to send audio/video streams
consume: true, // Set to true to receive audio/video streams
// Additional parameters can be added here as needed
});
joinRoom()
Description
Joins a specified room using the provided session token and parameters.
async function joinRoom() {
try {
await videoedge.JsSdk.joinRoom({
sessionToken,
roomId,
peerName,
produce: true, // Set to true to send audio/video streams
consume: true, // Set to true to receive audio/video streams
// Additional parameters can be added here as needed
});
console.log("Left the room.");
} catch (error) {
console.error("Error leaving the room:", error);
}
}
Parameters
sessionToken
: Token for authentication (required)roomId
: ID of the room you want to join (required)peerId
: PeerId of the peer who wants to join the room (required)peerName
: Name of the peer (optional)videoResolution
: The available values are "qvga" (320x240), "vga" (640x480), and "hd" (1280x720). Default value is "hd" (optional).produce
:Set to true if you want to send your audio and video streams to the room.consume
: Set to true if you want to receive audio and video streams from other participants in the room.forcePCMU
: This parameter forces the use of the PCMU audio codec.The default audio codec used in OPUS. PCMU is particulary useful in environments with varying network conditions, as it ensures stable audio quality and low latency. The default value of this setting is false.forcePCMA
: false/true, if the default audio codec need to be changed from opus to PCMA. THe default value of this setting is false.forceVp8
: This parameter forces the use of forceVp8 video codec. Genearlly, the default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.forceVp9
: This parameter forces the use of forceVp9 video codec. Generally, the default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.forceH264
: This parameter forces the use of H264 video codec for efficient compression and high-quality video streaming. The default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.h264Profile
: This parameter specifies the H264 profile for video encoding, which decides the video compression quality. Common profiles were low and high. The default value of this setting is high.forceFPS
: This parameter sets the video frame rate, which directly affects the smoothness of the video. A higher frame rate requires more processing power but provides smoother motion, while low frame rate uses less resources results in a less smoother video. The default value of this setting is 25.enableWebcamLayers
: This parameter enables simulcast layers for the webcam, which allows different resolutions to be sent simultaneously. This feature ensures that participants with varying network conditions can receive the most appropriate video quality. The default value of this setting is true.numSimulcastStreams
: This parameter specifies the number of simulcast streams to produce, The default value of this setting is 3.videoBitRates
: This parameter control the bit rates for different simulcast layers, affecting the video quality and bandwith usage. You can adjust the bit rates to change the video quality for different layers. By default this setting will take 500, 200, 75 for high, medium and low bitrates respectively.autoGainControl
: This parameter enables automatic gain control for the microphone.This helps maintain consistent audio level by adjusting the microphone sensitivity in response to changes in speaking volume. This will be veryuseful when you move closer or further from the microphone The default value of this setting is true.echoCancellation
: This parameter when enabled prevents the feedback loop by detecting and eliminating the echo from the audio signal. It ensures that when someone speaks, their voice is not picked up by their own microphone and sent back to them or others in the call. By default this setting is true.noiseSuppression
: This parameter when enabled reduces background noise, ensuring that your voice remains clear even in noisy environments. By default this setting is true.sampleRate
: This parameter specifies the audio sample rate, which determines the quality of the audio stream. Higher sample rates(1600Hz) result in better audio but requires more processing power, while lower sample rates are efficient but result in lower audio quality.For PCMU, this setting should be set to 8000. Otherwise, default setting for this parameter is 44000.channelCount
: This parameter refers to the number of audio channels that are captured and transmitted in an audio stream. It determines whether the audio is mono (a single audio channel with the same signal sent to all speakers) or stereo (two audio channels, with one for the left speaker and one for the right). The OPUS codec supports both mono and stereo signals. Depending on the device's capabilities and CPU performance, the channel count can be increased to 2. The default setting for this parameter is 1 (mono).share
:This parameter is used for enabling/ disabling screen share, by default falseshareAudio
: This parameter is used if audio also need to be shared along with screenshare wherever applicable. The default value of this setting is false. Share parameter should be true to consider this setting.enableSharingLayers
: true/false, if simulcast/svc needed to be enabled for better network speed based video quality adjustment, the default value is true. It advisable to keep this value as true for better screen sharing experience. Share parameter should be true to consider this setting.shareBitrates
:This parameter is applicable only if enablesharingLayers flag is true. Integer Array of 1 to 3 values to enforce a specific bitrate while transmitting the screen share video on the network. This is an advanced parameter for fine tuning screen sharing experience in case of a need. Don't changes this value if you are not very sure if fine tuning screen sharing is not an requirement for you. the default value is [2500,1250,500]audioDeviceId
: Provide the specific audiodeviceId from the audioInputs avaliable, with which you wish to start the callvideoDeviceId
: Provide the specific videodeviceId from the videoInputs avaliable, with which you wish to start the call
leaveRoom()
Description
The leaveRoom method takes the videoedge instance as a parameter and asynchronously leaves the current room, logging a success or error message.
async function leaveRoom(videoedgeInstance) {
try {
await videoedgeInstance.leaveRoom();
console.log("Left the room.");
} catch (error) {
console.error("Error leaving the room:", error);
}
}
mute()
Description
The mute method takes the videoedge instance as a parameter and mutes the local microphone, logging a success message.
function mute(videoedgeInstance) {
videoedgeInstance.muteMic();
console.log("Microphone muted.");
}
unMute()
Description
The unMute method takes the videoedge instance as a parameter and unmutes the local microphone, logging a success message.
function unMute(videoedgeInstance) {
videoedgeInstance.unmuteMic();
console.log("Microphone unmuted.");
}
cameraOn()
Description
The cameraOn method takes the videoedge instance as a parameter and turns on the local camera, logging a success message.
function cameraOn(videoedgeInstance) {
videoedgeInstance.enableCam();
console.log("Camera turned on.");
}
cameraOff()
Description
The cameraOff method takes the videoedge instance as a parameter and turns off the local camera, logging a success message.
function cameraOff(videoedgeInstance) {
videoedgeInstance.disableCam();
console.log("Camera turned off.");
}
listDevices()
Description
Get the list of currently available camera,Mic and speaker(in case of chrome!) in order to select a specific camera/mic before joining a room.
function listDevices() {
const vidScaleClient = await VidScale.JsSdk;
const availableDevices = await vidScaleClient.listDevices();
if (availableDevices.success) {
const audioDevices = availableDevices.deviceList.audioDevices;
const videoDevices = availableDevices.deviceList.videoDevices;
}
}
changeVideoInput()
Description
Switch camera which is already being shared by an user to a new camera while providing a specific deviceId from the array of videoInputs available in the deviceList. The resolution and fps values can also be updated while changing the camera source.
function changeVideoInput(videoedgeInstance) {
await videoedgeInstance.changeVideoInput({
resolution,
deviceId,
fps
})
}
Parameters
resolution
: The available values are "qvga" (320x240), "vga" (640x480), and "hd" (1280x720). Default value is "vga" (optional).deviceId
: deviceId of the videoInput selected by the user (required)fps
: This parameter sets the video frame rate, which directly affects the smoothness of the video. A higher frame rate requires more processing power but provides smoother motion, while low frame rate uses less resources results in a less smoother video. The default value of this setting is 25.
changeAudioInput()
Description
Switch mic which is already being shared by an user to a new mic while providing a specific deviceId from the array of audioInputs available in the deviceList. Optionally Other mic specific input parameters can also be applied to this new input device. These options are not mandatory. If these options are not provided, they will fallback to the provided values / default values used at joining time.
function changeAudioInput(videoedgeInstance) {
await videoedgeInstance.changeAudioInput({
autoGainControl,
echoCancellation,
noiseSuppression,
sampleRate,
channelCount,
deviceId
})
}
Parameters
deviceId
: deviceId of the audioInput selected by the user (required)autoGainControl
: This parameter enables automatic gain control for the microphone.This helps maintain consistent audio level by adjusting the microphone sensitivity in response to changes in speaking volume. This will be veryuseful when you move closer or further from the microphone The default value of this setting is true.echoCancellation
: This parameter when enabled prevents the feedback loop by detecting and eliminating the echo from the audio signal. It ensures that when someone speaks, their voice is not picked up by their own microphone and sent back to them or others in the call. By default this setting is true.noiseSuppression
: This parameter when enabled reduces background noise, ensuring that your voice remains clear even in noisy environments. By default this setting is true.sampleRate
: This parameter specifies the audio sample rate, which determines the quality of the audio stream. Higher sample rates(1600Hz) result in better audio but requires more processing power, while lower sample rates are efficient but result in lower audio quality.For PCMU, this setting should be set to 8000. Otherwise, default setting for this parameter is 44000.channelCount
: This parameter refers to the number of audio channels that are captured and transmitted in an audio stream. It determines whether the audio is mono (a single audio channel with the same signal sent to all speakers) or stereo (two audio channels, with one for the left speaker and one for the right). The OPUS codec supports both mono and stereo signals. Depending on the device's capabilities and CPU performance, the channel count can be increased to 2. The default setting for this parameter is 1 (mono).
enableCam()
Description
Enable camera either with a specific deviceId from the deviceList or with the 1st device available in the videoInput array of deviceList.
function enableCam(videoedgeInstance) {
await videoedgeInstance.enableCam({
deviceId,
videoResolution,
forceVp8,
forceVp9,
forceH264,
h264Profile,
forceFPS,
enableWebcamLayers,
numSimulcastStreams,
videoBitRates
})
}
Parameters
deviceId
: deviceId of the videoInput selected by the user (required)videoResolution
: The available values are "qvga" (320x240), "vga" (640x480), and "hd" (1280x720). Default value is "hd" (optional).forceVp8
: This parameter forces the use of forceVp8 video codec. Genearlly, the default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.forceVp9
: This parameter forces the use of forceVp9 video codec. Generally, the default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.forceH264
: This parameter forces the use of H264 video codec for efficient compression and high-quality video streaming. The default video codec is VP8. This codec works well across different devices and network conditions. The default value of this setting is false.h264Profile
: This parameter specifies the H264 profile for video encoding, which decides the video compression quality. Common profiles were low and high. The default value of this setting is high.forceFPS
: This parameter sets the video frame rate, which directly affects the smoothness of the video. A higher frame rate requires more processing power but provides smoother motion, while low frame rate uses less resources results in a less smoother video. The default value of this setting is 25.enableWebcamLayers
: This parameter enables simulcast layers for the webcam, which allows different resolutions to be sent simultaneously. This feature ensures that participants with varying network conditions can receive the most appropriate video quality. The default value of this setting is true.numSimulcastStreams
: This parameter specifies the number of simulcast streams to produce, The default value of this setting is 3.videoBitRates
: This parameter control the bit rates for different simulcast layers, affecting the video quality and bandwith usage. You can adjust the bit rates to change the video quality for different layers. By default this setting will take 500, 200, 75 for high, medium and low bitrates respectively.
disableCam()
Description
Disables the mic when no more required. Be careful when disabling the mic because it will close the audio comunication and release the mic so that it can be used by some other application. If you just wish to mute the audio rather than disabling to keep the mic acquisition, then use the mute/ unmute functionality instead. In mute/unmute, the audio channel as well as the mic acquisition is not destroyed but kept alive so that anytime a user can use it in the future. mute/unmute is instant where as enabling a disabled mic may take upto 1 sec based on the availability of the mic. If the mic is not available, then audio can't be enabled again until the mic becomes available.
function disableCam(videoedgeInstance) {
await videoedgeInstance.disableCam()
}
enableMic()
Description
Enable mic either with a specific deviceId from the deviceList or with the 1st device available in the audioInput array of deviceList.
function enableMic(videoedgeInstance) {
await videoedgeInstance.enableMic({
deviceId,
autoGainControl,
noiseSuppression,
echoCancellation,
channelCount,
sampleRate,
forcePCMU,
forcePCMA
})
}
Parameters
deviceId
: deviceId of the audioInput selected by the user, if not provided mic will be enabled with default audioInputautoGainControl
: This parameter enables automatic gain control for the microphone.This helps maintain consistent audio level by adjusting the microphone sensitivity in response to changes in speaking volume. This will be veryuseful when you move closer or further from the microphone The default value of this setting is true.noiseSuppression
: This parameter when enabled reduces background noise, ensuring that your voice remains clear even in noisy environments. By default this setting is true.echoCancellation
: This parameter when enabled prevents the feedback loop by detecting and eliminating the echo from the audio signal. It ensures that when someone speaks, their voice is not picked up by their own microphone and sent back to them or others in the call. By default this setting is true.channelCount
: This parameter refers to the number of audio channels that are captured and transmitted in an audio stream. It determines whether the audio is mono (a single audio channel with the same signal sent to all speakers) or stereo (two audio channels, with one for the left speaker and one for the right). The OPUS codec supports both mono and stereo signals. Depending on the device's capabilities and CPU performance, the channel count can be increased to 2. The default setting for this parameter is 1 (mono).sampleRate
: This parameter specifies the audio sample rate, which determines the quality of the audio stream. Higher sample rates(1600Hz) result in better audio but requires more processing power, while lower sample rates are efficient but result in lower audio quality.For PCMU, this setting should be set to 8000. Otherwise, default setting for this parameter is 44000.forcePCMU
: This parameter forces the use of the PCMU audio codec.The default audio codec used in OPUS. PCMU is particulary useful in environments with varying network conditions, as it ensures stable audio quality and low latency. The default value of this setting is false.forcePCMA
: false/true, if the default audio codec need to be changed from opus to PCMA. THe default value of this setting is false.
disableMic()
Description
Disables the mic when no more required. Be careful when disabling the mic because it will close the audio comunication and release the mic so that it can be used by some other application. If you just wish to mute the audio rather than disabling to keep the mic acquisition, then use the mute/ unmute functionality instead. In mute/unmute, the audio channel as well as the mic acquisition is not destroyed but kept alive so that anytime a user can use it in the future. mute/unmute is instant where as enabling a disabled mic may take upto 1 sec based on the availability of the mic. If the mic is not available, then audio can't be enabled again until the mic becomes available.
function disableMic(videoedgeInstance) {
await videoedgeInstance.disableMic()
}
enableShare()
Description
Call this function on the client object to start screen sharing. Screen share by default will be started with video only mode. If you wish to enable screen audio as well ,you need to set the shareAudio property to true. enableSharingLayers and sharingBitRates are for advance usage only when you wish to tweak the internal screen share video transmission capacity on the network. Leave these to default for optimal performance or check the advace usage section to know more about tweaking these parameters.
function enableShare(videoedgeInstance) {
await videoedgeInstance.enableShare({
shareAudio,
enableSharingLayers,
shareBitRates
})
}
Parameters
shareAudio
: If audio also need to be shared along with screenshare wherever applicable. The default value of this setting is 'false'.enableSharingLayers
: true/false, if simulcast/svc needed to be enabled for better network speed based video quality adjustment, the default value is true. It advisable to keep this value as true for better screen sharing experienceshareBitrates
:This parameter is applicable only if enablesharingLayers flag is true. Integer Array of 1 to 3 values to enforce a specific bitrate while transmitting the screen share video on the network. This is an advanced parameter for fine tuning screen sharing experience in case of a need. Don't changes this value if you are not very sure if fine tuning screen sharing is not an requirement for you. the default value is [2500,1250,500]
disableShare()
Description
Disable the screen share if already enbaled currently. If not enabled already, calling this function has no effect.
function disableShare(videoedgeInstance) {
await videoedgeInstance.disableShare()
}
Now that you know all the events and methods in our SDK, follow the setup steps to integrate this SDK into your application.