3.41.1
The SDK creation factory. Create an instance of the SDK by calling this factory with the desired configurations. The SDK instance will be referred as 'api' throughout the rest of the documentation content.
(config)
The configuration object.
api
:
The SDK instance.
// Instantiate the SDK.
import { create } from 'kandy'
const client = create({
authentication: { ... },
logs: { ... },
...
});
// Use the SDK's API.
client.on( ... );
The configuration object. This object defines what different configuration values you can use when instantiating the SDK using the create function.
Configuration options for the Logs feature.
The SDK will log information about the operations it is performing. The amount of information will depend on how the Logs feature is configured.
The format of logs can also be customized by providing a LogHandler. This function will receive a LogEntry which it can handle as it sees fit. By default, the SDK will log information to the console. For more information, see the Logs feature description.
(Object)
Logs configs.
Name | Description |
---|---|
logs.logLevel string
(default 'debug' )
|
Log level to be set. See logger.levels . |
logs.handler logger.LogHandler?
|
The function to receive log entries from the SDK. If not provided, a default handler will be used that logs entries to the console. |
logs.enableFcsLogs boolean
(default true )
|
Enable the detailed call logger for v3.X. Requires log level debug. |
logs.logActions (Object | boolean)
(default false )
|
Options specifically for action logs when logLevel is at DEBUG+ levels. Set this to false to not output action logs. |
logs.logActions.handler logger.LogHandler?
|
The function to receive action log entries from the SDK. If not provided, a default handler will be used that logs actions to the console. |
logs.logActions.actionOnly boolean
(default false )
|
Only output information about the action itself. Omits the SDK context for when it occurred. |
logs.logActions.collapsed boolean
(default false )
|
Whether logs should be minimized when initially output. The full log is still output and can be inspected on the console. |
logs.logActions.diff boolean
(default false )
|
Include a diff of what SDK context was changed by the action. |
logs.logActions.level string
(default 'debug' )
|
Log level to be set on the action logs |
logs.logActions.exposePayloads boolean
(default true )
|
Allow action payloads to be exposed in the logs, potentially displaying sensitive information. |
Configuration options for the CallMe Authentication feature.
(Object)
Authentication configs.
Name | Description |
---|---|
authentication.subscription Object
|
|
authentication.subscription.protocol string
(default 'https' )
|
Protocol to be used for subscription requests. |
authentication.subscription.server string
|
Server to be used for subscription requests. |
authentication.subscription.port Number
(default 443 )
|
Port to be used for subscription requests. |
authentication.subscription.service Array?
|
Services to subscribe to for notifications. |
authentication.websocket Object
|
|
authentication.websocket.protocol string
(default 'wss' )
|
Protocol to be used for websocket notifications. |
authentication.websocket.server string
|
Server to be used for websocket notifications. |
authentication.websocket.port Number
(default 443 )
|
Port to be used for websocket notifications. |
Configuration options for the call feature.
(Object)
The call configuration object.
Name | Description |
---|---|
call.callDefaults Object?
|
Default options to be used when making/answering a call. |
call.callDefaults.isAudioEnabled boolean
(default true )
|
Specifies whether audio is enabled or not. |
call.callDefaults.isVideoEnabled boolean
(default true )
|
Specifies whether video is enabled or not. |
call.callDefaults.sendInitialVideo boolean
(default false )
|
Specifies whether to send an initial video stream or not. |
call.callDefaults.remoteVideoContainer Object?
|
Specifies the container where video (coming from remote party) is rendered. |
call.callDefaults.localVideoContainer Object?
|
Specifies the container where video (coming from local party) is rendered. |
call.chromeExtensionId string?
|
ID of the screenshare extension being used for screenshare of Google Chrome. |
call.recordCallStats boolean
(default false )
|
Whether to enable the recording of call statistics as part of app's local storage. |
call.earlyMedia boolean
(default false )
|
Whether to use early media (e.g. for playing incoming tones) as part of an outgoing call. |
call.callAuditTimer number
(default 30000 )
|
Audit time value for calls, as a positive number in milliseconds. |
call.activeCallTimeoutMS number
(default 120000 )
|
Timeout for an existing ringing call before it gets terminated, as a positive number in milliseconds. |
call.ringingFeedback boolean?
|
When enabled, inform Spidr that RingingFeedback is supported. |
call.codecsToReplace string?
|
Specifies alternative audio/video codecs to use for a given call. It has been deprecated so pipeline parameter should be used instead. |
call.videoInactiveOnHold boolean
(default false )
|
Sets the video as "inactive" instead of "sendonly" when holding a call. |
call.forceDisableMediaOnHold boolean
(default false )
|
Disables any type of media (e.g. Comfort Noise) from transmitting when call is held locally. |
call.iceCandidateCollectionTimeoutInterval number
(default 3000 )
|
When provided (in milliseconds), ice candidate collection is assumed to be completed if at least one candidate is received within the interval. |
call.relayCandidateCollectionTimeoutCycle boolean
(default false )
|
When enabled, iceCandidateCollectionTimeoutInterval is restarted until receiving first relay candidate. If the provided cycle limit is reached, ice candidate collection assumed to be completed. |
call.recordCallStats boolean
(default false )
|
When enabled, call statistics are recorded in app's localstorage after the call is terminated. |
call.callConstraints Object?
|
Custom RTCPeerConnection constraints to use for calls. Will cause errors if malformed. |
call.callConstraints.chrome Object?
|
Custom constraints to be used on Google Chrome. |
call.callConstraints.firefox Object?
|
Custom constraints to be used on Mozilla Firefox. |
call.bundlePolicy string
(default 'DISABLED' )
|
The bundle policy to use for peer connections. Value can be fcs.SDP_CONSTANTS.BUNDLE_POLICY.MAX_COMPAT, fcs.SDP_CONSTANTS.BUNDLE_POLICY.MAX_BUNDLE, fcs.SDP_CONSTANTS.BUNDLE_POLICY.BALANCED or fcs.SDP_CONSTANTS.BUNDLE_POLICY.DISABLED. The DISABLED option means that bundle group lines will be removed from every SDP. |
call.opusConfig Object?
|
Bandwidth controls to add for Opus audio codec. |
call.opusConfig.maxPlaybackRate number?
|
Maximum playback rate, in bits per second. Must be a positive value between 8000 and 48000. |
call.opusConfig.maxAverageBitrate number?
|
A bitrate encoding value between 6000 and 510000 bits per second. |
call.opusConfig.fec number?
|
Specifies whether Forward Error Correction is enabled or not. When enabled, FEC provides robustness against packet loss. Acceptable values can only be 0 or 1. |
call.opusConfig.dtx number?
|
Specifies whether Discontinuous Transmission mode is enabled or not. When enabled, DTX reduces the bitrate during silence or background noise. Acceptable values can only be 0 or 1. |
call.opusConfig.ptime number?
|
Packet (i.e. frame) duration in milliseconds. Frames will be combined into packets to achieve the maximum of 120 ms duration. A positive value between 2.5 and 120. |
call.webrtcLogCollectionInterval number
(default 3000 )
|
Interval at which to collect WebRTC logs for calls, in milliseconds. |
call.useRelay boolean
(default false )
|
Whether we should force connection through the relay candidates (i.e. TURN server). Mostly used for testing. |
call.trickleIceSupport string
(default 'none' )
|
Whether we should advertise and use Trickle ICE. Accepted value is one of: 'none', 'half' or 'full'. |
call.continuity boolean
(default false )
|
Whether an existing voice call can be persisted, as a mobile phone moves between circuit switched and packet switched domains (e.g. GSM to WiFi). |
call.resyncOnConnect boolean
(default false )
|
Whether all active calls should be resynched upon connecting or reconnecting to the websocket (requires Kandy Link 4.7.1+). |
Configuration options for the Connectivity feature. The SDK can only use keepalive as the connectivity check.
Keep Alive: The client sends "keepalive" messages (to the server) on the websocket at regular intervals. This lets the server know that the client is still connected, and that it should "keep the connection alive".
For more information on keepalive see here: https://en.wikipedia.org/wiki/Keepalive
(Object)
Connectivity configs.
Name | Description |
---|---|
connectivity.pingInterval Number
(default 30000 )
|
Time in between websocket ping attempts (milliseconds). |
connectivity.reconnectLimit Number
(default 5 )
|
Number of failed reconnect attempts before reporting an error. Can be set to 0 to not limit reconnection attempts. |
connectivity.reconnectDelay Number
(default 5000 )
|
Base time between websocket reconnect attempts (milliseconds). |
connectivity.reconnectTimeMultiplier Number
(default 1 )
|
Reconnect delay multiplier for subsequent attempts. The reconnect delay time will be multiplied by this after each failed reconnect attempt to increase the delay between attempts. eg. 5000ms then 10000ms then 20000ms delay if value is 2. |
connectivity.reconnectTimeLimit Number
(default 640000 )
|
Maximum time delay between reconnect attempts (milliseconds). Used in conjunction with the reconnect time multiplier to prevent overly long delays between reconnection attempts. |
connectivity.autoReconnect Boolean
(default true )
|
Flag to determine whether the SDK will attempt to automatically reconnect after connectivity disruptions. |
connectivity.maxMissedPings Number
(default 3 )
|
Maximum pings sent (without receiving a response) before reporting an error. |
connectivity.checkConnectivity Boolean
(default true )
|
Flag to determine whether the SDK should check connectivity. |
connectivity.webSocketOAuthMode string
(default query )
|
query will send the bearer access token to authenticate the websocket and none will not send it. |
Configuration options for the notification feature.
(Object)
The notifications configuration object.
Name | Description |
---|---|
notifications.idCacheLength number
(default 100 )
|
Default amount of event ids to remember for de-duplication purposes. |
notifications.incomingCallNotificationMode string
(default 'any-channel' )
|
Communication channel mode used for incoming call notifications. Supported values are 'any-channel' or 'push-channel-only'. |
notifications.pushRegistration Object?
|
Object describing the server to use for push services. |
notifications.pushRegistration.server string?
|
Hostname for the push registration server. |
notifications.pushRegistration.port string?
|
Port for the push registration server. |
notifications.pushRegistration.protocol string?
|
Protocol for the push registration server. |
notifications.pushRegistration.version string?
|
Version for the push registration server. |
Available media devices have been changed.
A change has been made to default devices used for calls.
Media support has been checked.
(Object)
Name | Description |
---|---|
params.result Object
|
Results of initializing media. |
params.result.error boolean
|
Whether the initialization was successful or not. |
params.result.code number
|
A unique code describing the result scenario. |
params.result.message string
|
Human readable message of the result. |
The 'api' is the type returned by the create function. It contains various top-level functions that pertain to SDK global instance as well as several nested namespaces that pertain to various features (e.g. call, contacts, presence, etc).
Returns the current version of the API.
Destroys the SDK, and removes its state, rendering the SDK unusable. Useful when a user logs out and their call data needs to be destroyed. The SDK must be recreated to be usable again. The destroy command is async, and will happen on the next tick so as not to interfere with any ongoing events.
// Instantiate the SDK.
import { create } from 'kandy'
const config = {
authentication: { ... },
logs: { ... },
...
}
let client = create(config);
client.on( ... )
// Use the SDK
...
// Destroy the SDK, then recreate on the next step
client.destroy()
client = create(config)
client.on( ... )
Update the configuration values for the SDK to use.
This API will only modify the configurations provided, leaving other configurations as they were originally set, by performing a merge of the new values into the previous values.
Please note that updating the call.removeH264Codecs configuration will not immediately change the SDP handlers used for a call. If you want to add or remove the h264 codec remover sdp handler you should follow this procedure:
Update the config for removeH264Codecs using the updateConfig API.
Update the sdp handler list using the setSdpHandlers API and provide any client defined SDP handler functions.
NOTE: You can get the currently defined SDP handler functions with the getConfig API.
Please note that the object provided to the updateConfig
API may be different
than the object retrieved from the getConfig API. This may happen when a format
change has happened and the SDK modifies the provided format to alleviate
backwards-compatibility issues. We recommend ensuring the configurations you
provide are as described by the config section.
// Instantiate the SDK with certain configs.
const client = create({
authentication: { ... },
logs: { ... },
...
})
// Modify a subsection of the configs at a later time.
// This will only update the specified configurations.
client.updateConfig({
logs: {
loglevel: 'DEBUG'
}
})
Add an event listener for the specified event type. The event is emitted by the SDK instance.
(string)
The event type for which to add the listener.
(Function)
The listener for the event type. The parameters of the listener depend on the event type.
// Listen for events of a specific type emitted by the SDK.
client.on('dummy:event', function (params) {
// Handle the event.
})
Retrieves information about the current user.
Object
:
user The user data.
string
:
user.username The username of the current user. Note that this username can take different encoded forms.
It's not meant to be displayed to a user.
string
:
user.token The current access token.
The Calls feature is used to make audio and video calls to and from SIP users and PSTN phones.
Call functions are all part of the 'call' namespace.
Whenever 'user' is mentioned as input parameter within this API, it needs to be provided in the user@domain format.
States of a call.
(string)
: The call is on-going.
(string)
: The call has been established and is waiting for a user response.
(string)
: The call has been terminated.
(string)
: The call has been put on hold locally.
(string)
: The call has been put on hold remotely.
client.on('call:stateChange', function(callInfo) {
if(callInfo.state === client.call.states.ENDED) {
// Call has ended.
}
});
State of the media connection within a call.
(string)
: A new media connection process has started.
(string)
: Media is searching for a connection.
(string)
: Media has found a connection, but may still be searching for a better connection to use.
(string)
: Media has finished searching and been established. Audio/video should now be flowing on the call.
(string)
: Media was not able to find a connection. Audio/video will not flow.
(string)
: The media connection has lost its connection and is trying to recover.
(string)
: The media connection has shut down.
Set custom parameters on an ongoing call.
(string)
The ID of the call being acted on.
// Set custom parameters for call.
client.call.setCustomParameters(
callId,
[
{ "name": "X-GPS",
"value": "42.686032,23.344565"
}
]
});
Start local video stream for an ongoing call.
(string)
Id of the call being acted on.
(Object?)
Options for the video stream.
Name | Description |
---|---|
options.videoResolution Object?
|
The video resolution configuration object. |
options.videoResolution.height number?
|
The height of the outgoing video in pixels. |
options.videoResolution.width number?
|
The width of the outgoing video in pixels. |
Starts sharing a screen over a call.
(string)
Id of the call being acted on.
(Object)
Name | Description |
---|---|
options.mediaSourceId string
|
Id of the media screen to share. |
options.height Number
(default 768 )
|
The height of the video stream to send. |
options.width Number
(default 1024 )
|
The width of the video stream to send. |
options.frameRate Number
(default 15 )
|
The number of frames per second to request. |
The 'connection' namespace is used to connect and maintain connections between the SDK and one or more backend servers.
Information about a websocket connection.
Can be retrieved using the connection.getSocketState API.
Type: Object
(boolean)
: The state of the websocket connection.
(boolean)
: True if the client has sent a ping to the server and is still waiting for a pong response.
(Object)
: Information about how the websocket is being used.
(string)
: The SDK platform being used.
(number)
: How often the client will ping the server to test for websocket connectivity.
(number)
: How many times the SDK will try to reconnect a disconnected websocket.
(number)
: How long the SDK will wait before retrying websocket reconnection.
(number)
: Reconnect delay multiplier for subsequent attempts. The reconnect delay time will be multiplied by this after each failed reconnect attempt to increase the delay between attempts. eg. 5000ms then 10000ms then 20000ms delay if value is 2.
(number)
: Maximum time delay between reconnect attempts (milliseconds). Used in conjunction with
reconnectTimeMultiplier
to prevent overly long delays between reconnection attempts.
(boolean)
: Indicates if the SDK should automatically try reconnecting a disconnected websocket.
(number)
: How many missed pings before the SDK stops trying to reconnect a disconnected websocket.
(string)
: The mode used for authenticating with the server.
(Object)
: Information required to connect a websocket to the server.
wsInfo.protocol
string?
The protocol to use to connect a websocket.
wsInfo.server
string?
The domain name or IP address of the server to connect to.
wsInfo.port
number?
The port of the server to connect to.
wsInfo.url
string?
The URL path to use to request a websocket connection.
wsInfo.params
string?
Any additional params that might be required by the server to establish the websocket connection.
(number)
: The date and time that the last known contact with the server was.
Get the state of the websocket.
(string
= 'link'
)
Backend platform for which to request the websocket's state.
connection.WSConnectionObject
:
Details about the current websocket connection, including state and configuration.
Triggers a reset in the connection to the WebSocket being used for notifications. This can be used in scenarios where a network issue (undetectable by the SDK) is detected by an application.
If there is no WebSocket currently connected, this function has no effect. Calling this function will trigger all the normal WebSocket and connectivity lifecycle events as well as trigger re-connection processing that follows the configuration of the SDK. Calling this function always has the potential of causing some events being lost by the SDK and preventing proper operation.
An error occurred while performing a device operation.
Type: string
(Object)
Name | Description |
---|---|
params.error api.BasicError
|
The Basic error object. |
Retrieves the available media devices for use.
The SDK has an internal logging system for providing information about its behaviour. The SDK will generate logs, at different levels for different types of information, which are routed to a "Log Handler" for consumption. An application can provide their own Log Handler (see config.logs) to customize how the logs are handled, or allow the default Log Handler to print the logs to the console.
The SDK's default Log Handler is merely a thin wrapper around the browser's
console API (ie. window.console
). It receives the log generated by the
SDK, called a "Log Entry", formats a
human-readable message with it, then uses the console to log it at the
appropriate level. This is important to be aware of, since your browser's
console may affect how you see the SDK's default log messages. Since the
default Log Handler uses the console's levels, the browser may filter
which messages are shown depending on which levels it has configured. For
a user that understands console log levels, this can be helpful for
filtering the logs to only the relevant information. But it can equally
be a hindrance by hiding the more detailed log messages (at the 'debug'
level), since browser can have this level hidden by default. For this
reason, we recommend providing a custom Log Handler to the SDK that is
better suited for your application and its users.
A LogEntry object is the data that the SDK compiles when information is logged. It contains both the logged information and meta-info about when and who logged it.
A LogHandler provided to the SDK (see config.logs) will need to handle LogEntry objects.
Type: Object
(number)
: When the log was created, based on UNIX epoch.
(string)
: The log function that was used to create the log.
(string)
: The level of severity the log.
(Object)
: The subject that the log is about.
(Array)
: The logged information, given to the Logger
method as parameters.
(Object?)
: Timing data, if the log method was a timer method.
function defaultLogHandler (logEntry) {
// Compile the meta info of the log for a prefix.
const { timestamp, level, target } = logEntry
let { method } = logEntry
const logInfo = `${timestamp} - ${target.type} - ${level}`
// Assume that the first message parameter is a string.
const [log, ...extra] = logEntry.messages
// For the timer methods, don't actually use the console methods.
// The Logger already did the timing, so simply log out the info.
if (['time', 'timeLog', 'timeEnd'].includes(method)) {
method = 'debug'
}
console[method](`${logInfo} - ${log}`, ...extra)
}
A LogHandler can be used to customize how the SDK should log information. By default, the SDK will log information to the console, but a LogHandler can be configured to change this behaviour.
A LogHandler can be provided to the SDK as part of its configuration (see config.logs). The SDK will then provide this function with the logged information.
Type: Function
(Object)
The LogEntry to be logged.
// Define a custom function to handle logs.
function logHandler (logEntry) {
// Compile the meta info of the log for a prefix.
const { timestamp, level, target } = logEntry
let { method } = logEntry
const logInfo = `${timestamp} - ${target.type} - ${level}`
// Assume that the first message parameter is a string.
const [log, ...extra] = logEntry.messages
// For the timer methods, don't actually use the console methods.
// The Logger already did the timing, so simply log out the info.
if (['time', 'timeLog', 'timeEnd'].includes(method)) {
method = 'debug'
}
console[method](`${logInfo} - ${log}`, ...extra)
}
// Provide the LogHandler as part of the SDK configurations.
const configs = { ... }
configs.logs.handler = logHandler
const client = create(configs)
Possible levels for the SDK logger.
The SDK will provide Log Entries to the Log Handler for all logs at or above the set log level. 'debug' is considered the lowest level and 'silent' the highest level. For example, if the current level is 'info', then the Log Handler will receive Log Entries for logs at 'info', 'warn', and 'error', but not for the 'debug' level.
(string)
: Nothing will be logged.
(string)
: Unhandled error information will be logged. If
the SDK encounters an issue it cannot resolve, the error will be included
in the logs. This likely points to an issue with the SDK itself or an
issue with how the SDK is being used.
(string)
: Warning messages for the application developer will
be logged. If the SDK encounters an issue that it can recover and continue,
a warning about the issue will be included in the logs. These logs point
to issues that need to be handled by the application. For example, providing
an invalid configuration to the SDK will cause a warning log that explains
the issue.
(string)
: General information about the SDK's operations will
be logged, outlining how the SDK is handling the operations. Reading through
these logs should provide a high-level view of what the SDK is doing,
and why it is doing it.
(string)
: Detailed information about the SDK's operations,
meant for debugging issues, will be logged. Specific information and relevant
operation data are provided for understanding the scenario that the SDK
was in during the operation.
The SDK's media features are used to control WebRTC Media Devices.
Media functions are all part of the 'media' namespace.
The 'notification' namespace allows user to register/deregister for/from push notifications as well as enabling/disabling the processing of websocket notifications.
Registers with Apple push notification service. Once registration is successful, the application will be able to receive standard and/or voip push notifications. It can then send these notifications to the SDK with api.notifications.process in order for the SDK to process them.
(Object)
Name | Description |
---|---|
params.services Array<string>
|
Array of services for which we wish to receive notifications. |
params.voipDeviceToken string
|
The voip device token used for voip push on iOS. This token is required if registering for call service notifications on iOS. |
params.standardDeviceToken string
|
The standardDevice token used for standard push on iOS . This token is required when registering for non-call service notifications. |
params.bundleId string
|
The bundleId to identify the application receiving the push notification. |
params.clientCorrelator string
|
Unique identifier for a client device. |
params.realm string
|
The realm used by the push registration service to identify and establish a connection with the service gateway. |
params.isProduction boolean
|
If true, push notification will be sent to production. If false, push notification will be sent to sandbox. |
Promise
:
When successful, the information of the registration.
Promise will reject with error object otherwise.
Registers with Google push notification service. Once registration is successful, the application will be able to receive standard and/or voip push notifications. It can then send these notifications to the SDK with api.notifications.process in order for the SDK to process them.
(Object)
Name | Description |
---|---|
params.services Array<string>
|
Array of services to register for. |
params.deviceToken string
|
The device token used for standard push on Android. This token is required when registering for all related services notifications. |
params.bundleId string
|
The bundleId to identify the application receiving the push notification. |
params.clientCorrelator string
|
Unique identifier for a client device. |
params.realm string
|
The realm used by the push registration service to identify and establish a connection with the service gateway. |
Promise
:
When successful, the information of the registration.
Promise will reject with error object otherwise.
An error occurred with push notifications.
(Object)
Name | Description |
---|---|
params.error api.BasicError
|
The Basic error object. |
params.channel string
|
The channel for the notification. |
The 'request' namespace (within the 'api' type) is used to make network requests to the server.
Send a request to the underlying REST service with the appropriate configuration and authentication. This is a wrapper on top of the browser's fetch API and behaves very similarly but using SDK configuration for the base URL and authentication as well as SDK logging.
(string)
The full path of the resource to fetch from the underlying service. This should include any REST version
or user information. This path will be appended to the base URL according to SDK configuration.
(RequestInit)
An object containing any custom settings that you want to apply to the request. See
fetch API
for a full description and defaults.
// Send a REST request to the server
// Create a request options object following [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/fetch)
const requestOptions = {
method: 'POST',
body: JSON.stringify({
test: 123
})
}
// Note that you will need to subscribe for the `custom` service in order to
// receive notifications from the `externalnotification` service.
const response = await client.request.fetch('/rest/version/1/user/xyz@test.com/externalnotification', requestOptions)
A set of SdpHandlerFunctions for manipulating SDP information. These handlers are used to customize low-level call behaviour for very specific environments and/or scenarios.
Note that SDP handlers are exposed on the entry point of the SDK. They can be added during initialization of the SDK using the config.call.sdpHandlers configuration parameter. They can also be set after the SDK's creation by using the call.setSdpHandlers function.
import { create, sdpHandlers } from 'kandy';
const codecRemover = sdpHandlers.createCodecRemover(['VP8', 'VP9'])
const client = create({
call: {
sdpHandlers: [ codecRemover, <Your-SDP-Handler-Function>, ...]
}
})
// Through the Call API post-instantiation
client.call.setSdpHandlers([ codecRemover, <Your-SDP-Handler-Function>, ...])
This function creates an SDP handler that will remove codecs matching the selectors specified for SDP offers and answers.
In some scenarios it's necessary to remove certain codecs being offered by the SDK to remote parties. For example, some legacy call services limit the SDP length (usually to 4KB) and will reject calls that have SDP size above this amount.
While creating an SDP handler would allow a user to perform this type of manipulation, it is a non-trivial task that requires in-depth knowledge of WebRTC SDP.
To facilitate this common task, the createCodecRemover function creates a codec removal handler that can be used for this purpose. Applications can use this codec removal handler in combination with the call.getAvailableCodecs function in order to build logic to determine the best codecs to use for their application.
call.SdpHandlerFunction
:
The resulting SDP handler that will remove the codec.
import { create, sdpHandlers } from 'kandy';
const codecRemover = sdpHandlers.createCodecRemover([
// Remove all VP8 and VP9 codecs.
'VP8',
'VP9',
// Remove all H264 codecs with the specified FMTP parameters.
{
name: 'H264',
fmtpParams: ['profile-level-id=4d0032', 'packetization-mode=1']
}
])
const client = create({
call: {
sdpHandlers: [codecRemover]
}
})
Sets the selected devices as the default devices. They will be used for audio output for future calls. Changing speaker is supported on browser's that support HTMLMediaElement.setSinkId().
// Set only the default microphone and camera.
client.media.setDefaultDevices({
camera: 'abc123...',
microphone: 'def456...'
});