Skip to content

Latest commit

 

History

History
executable file
·
83 lines (42 loc) · 3.47 KB

index.md

File metadata and controls

executable file
·
83 lines (42 loc) · 3.47 KB

Documentation

API

The main module callstatssipjs is a function that receives a SIP.UA instance and parameters for callstats.initialize().

The main module also exports a setCallstatsModule() function.

callstatssipjs(ua, AppID, AppSecretOrTokenGenerator, localUserID, csInitCallback, csStatsCallback, configParams)

Params Argument Type Description
ua Required SIP.UA SIP.js UA instance.

The rest of parameters match those in callstats.initialize(), with a small difference:

  • localUserID is not required. If null, the library fills it with an object containing the SIP URI and display name of the given SIP.UA instance.

callstatssipjs.setCallstatsModule(module)

Params Argument Type Description
module Required function The callstats main module.

By default this library uses window.callstats (assuming that the callstats.io library has been previously loaded via a <script> tag.

However, the callstats.io library can also be loaded using loaders such as require.js meaning that it may be not exposed as a global window.callstats. In that case, callstatssipjs.setCallstatsModule() can be used to provide the callstats-sipjs library with the callstats.io main module.

SessionHandler class

When a SIP.js Session is created, the callstats-sipjs library creates an instance of SessionHandler and stores it into session.data.callstatsSessionHandler to make it available to the application.

The SessionHandler class provides a wrapper over the API exposed by the callstats object, making it simpler by not requiring some parameters such as conferenceID.

sessionHandler.callstats

A getter that provides the already initialized callstats object.

sessionHandler.associateMstWithUserID(userID, SSRC, usageLabel, associatedVideoTag)

Arguments match those in callstats.associateMstWithUserID().

sessionHandler.reportUserIDChange(newUserID, userIDType)

Arguments match those in callstats.reportUserIDChange().

sessionHandler.sendUserFeedback(feedback, pcCallback)

Arguments match those in callstats.sendUserFeedback().

Tricks

Custom conferenceID value

By default, when a new SIP.Session is created, the Call-ID value of the incoming/outgoing INVITE request is used as callstats's conferenceID. This won't work in case the SIP server is a B2BUA that handles a different Call-ID for each peer within the same call/conference. In that case, the application can set a custom conferenceID by setting session.data.conferenceID as follows:

// Create a SIP.UA instance
var ua = new SIP.UA(config);

// Set custom conferenceID for created sessions
ua.on('invite', function(data) {
  var session = data.session;

  // Read our desired conferenceID from a custom X-Conference-ID set by the server
  session.data.conferenceID = session.getHeader('X-Conference-ID');
});

// Run the callstats-sipjs library for this UA
callstatssipjs(ua, AppID, AppSecret);