@webex/internal-media-core 1.38.3 → 1.38.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -6090,7 +6090,7 @@ FingerprintLine.regex = new RegExp("^fingerprint:(".concat(REST, ")"));
6090
6090
  function parseFmtpParams(fmtpParams) {
6091
6091
  fmtpParams = fmtpParams.replace(/^a=fmtp:\d+\x20/, '');
6092
6092
  var fmtpObj = new Map();
6093
- if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
6093
+ if (/^\d+([,/-]\d+)+$/.test(fmtpParams)) {
6094
6094
  fmtpObj.set(fmtpParams, undefined);
6095
6095
  return fmtpObj;
6096
6096
  }
@@ -6829,7 +6829,7 @@ class AvMediaDescription extends MediaDescription {
6829
6829
  constructor(mediaLine) {
6830
6830
  super(mediaLine.type, mediaLine.port, mediaLine.protocol);
6831
6831
  this.pts = [];
6832
- this.extMaps = [];
6832
+ this.extMaps = new Map();
6833
6833
  this.rids = [];
6834
6834
  this.codecs = new Map();
6835
6835
  this.rtcpMux = false;
@@ -6891,7 +6891,10 @@ class AvMediaDescription extends MediaDescription {
6891
6891
  return true;
6892
6892
  }
6893
6893
  if (line instanceof ExtMapLine) {
6894
- this.extMaps.push(line);
6894
+ if (this.extMaps.has(line.id)) {
6895
+ throw new Error("Tried to extension with duplicate ID: an extension already exists with ID ".concat(line.id));
6896
+ }
6897
+ this.extMaps.set(line.id, line);
6895
6898
  return true;
6896
6899
  }
6897
6900
  if (line instanceof RidLine) {
@@ -6936,6 +6939,32 @@ class AvMediaDescription extends MediaDescription {
6936
6939
  });
6937
6940
  this.pts = this.pts.filter(existingPt => allPtsToRemove.indexOf(existingPt) === -1);
6938
6941
  }
6942
+ addExtension(_ref) {
6943
+ var {
6944
+ uri,
6945
+ direction,
6946
+ attributes,
6947
+ id
6948
+ } = _ref;
6949
+ var getFirstFreeId = () => {
6950
+ var freeId = 1;
6951
+ for (;;) {
6952
+ if (!this.extMaps.has(freeId)) {
6953
+ break;
6954
+ }
6955
+ freeId += 1;
6956
+ }
6957
+ return freeId;
6958
+ };
6959
+ var extId = id || getFirstFreeId();
6960
+ if (this.extMaps.has(extId)) {
6961
+ throw new Error("Extension with ID ".concat(id, " already exists"));
6962
+ }
6963
+ if (extId === 0) {
6964
+ throw new Error("Extension ID 0 is reserved");
6965
+ }
6966
+ this.extMaps.set(extId, new ExtMapLine(extId, uri, direction, attributes));
6967
+ }
6939
6968
  }
6940
6969
  class SessionDescription {
6941
6970
  constructor() {
@@ -7212,7 +7241,7 @@ function addPeriodicKeyframes(sdp, value) {
7212
7241
  }
7213
7242
  function disableExtmap(sdp) {
7214
7243
  sdp.avMedia.forEach(media => {
7215
- media.extMaps.length = 0;
7244
+ media.extMaps.clear();
7216
7245
  });
7217
7246
  }
7218
7247
  function updateH264fmtpParams(sdp, paramsToUpdate) {
@@ -7348,183 +7377,541 @@ function mungeRemoteSdp(config, sdp) {
7348
7377
  return parsedSdp.toString();
7349
7378
  }
7350
7379
 
7351
- var Event$1;
7352
- (function (Event) {
7353
- Event["CONNECTION_STATE_CHANGED"] = "connectionState:changed";
7354
- Event["REMOTE_TRACK_ADDED"] = "remoteTrack:added";
7355
- Event["ROAP_MESSAGE_TO_SEND"] = "roap:messageToSend";
7356
- Event["ROAP_STARTED"] = "roap:started";
7357
- Event["ROAP_FAILURE"] = "roap:failure";
7358
- Event["ROAP_DONE"] = "roap:done";
7359
- Event["DTMF_TONE_CHANGED"] = "dtmfTone:changed";
7360
- Event["ACTIVE_SPEAKERS_CHANGED"] = "activeSpeakers:changed";
7361
- Event["VIDEO_SOURCES_COUNT_CHANGED"] = "videoSourcesCount:changed";
7362
- Event["AUDIO_SOURCES_COUNT_CHANGED"] = "audioSourcesCount:changed";
7363
- })(Event$1 || (Event$1 = {}));
7364
- var RemoteTrackType;
7365
- (function (RemoteTrackType) {
7366
- RemoteTrackType["AUDIO"] = "audio";
7367
- RemoteTrackType["VIDEO"] = "video";
7368
- RemoteTrackType["SCREENSHARE_VIDEO"] = "screenShareVideo";
7369
- })(RemoteTrackType || (RemoteTrackType = {}));
7370
- var ErrorType;
7371
- (function (ErrorType) {
7372
- ErrorType["DOUBLECONFLICT"] = "DOUBLECONFLICT";
7373
- ErrorType["CONFLICT"] = "CONFLICT";
7374
- ErrorType["FAILED"] = "FAILED";
7375
- ErrorType["INVALID_STATE"] = "INVALID_STATE";
7376
- ErrorType["NOMATCH"] = "NOMATCH";
7377
- ErrorType["OUT_OF_ORDER"] = "OUT_OF_ORDER";
7378
- ErrorType["REFUSED"] = "REFUSED";
7379
- ErrorType["RETRY"] = "RETRY";
7380
- ErrorType["TIMEOUT"] = "TIMEOUT";
7381
- })(ErrorType || (ErrorType = {}));
7380
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global$1 !== 'undefined' ? global$1 : typeof self !== 'undefined' ? self : {};
7381
+ var logger = {
7382
+ exports: {}
7383
+ };
7382
7384
 
7383
- function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7384
- function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7385
- var localTrackTypes = [{
7386
- type: 'audio',
7387
- kind: 'audio'
7388
- }, {
7389
- type: 'video',
7390
- kind: 'video'
7391
- }, {
7392
- type: 'screenShareVideo',
7393
- kind: 'video'
7394
- }];
7395
- class MediaConnection extends EventEmitter$3 {
7396
- constructor(mediaConnectionConfig, options, debugId) {
7397
- super();
7398
- _defineProperty(this, "id", void 0);
7399
- _defineProperty(this, "config", void 0);
7400
- _defineProperty(this, "pc", void 0);
7401
- _defineProperty(this, "localTracks", void 0);
7402
- _defineProperty(this, "transceivers", void 0);
7403
- _defineProperty(this, "mediaDirection", void 0);
7404
- _defineProperty(this, "remoteQualityLevel", void 0);
7405
- _defineProperty(this, "mediaConnectionState", void 0);
7406
- _defineProperty(this, "lastEmittedMediaConnectionState", void 0);
7407
- this.config = mediaConnectionConfig;
7408
- this.mediaDirection = _objectSpread$3({}, options.direction);
7409
- this.localTracks = _objectSpread$3({}, options.localTracks);
7410
- this.remoteQualityLevel = options.remoteQualityLevel;
7411
- this.id = debugId || 'MediaConnection';
7412
- this.transceivers = {};
7413
- this.mediaConnectionState = ConnectionState.New;
7414
- this.pc = new window.RTCPeerConnection({
7415
- iceServers: this.config.iceServers,
7416
- bundlePolicy: 'max-compat'
7417
- });
7418
- this.pc.ontrack = this.onTrack.bind(this);
7419
- this.pc.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this);
7420
- this.pc.onconnectionstatechange = this.onConnectionStateChange.bind(this);
7421
- }
7422
- log(action, description) {
7423
- getLogger().info("".concat(this.id, ":").concat(action, " ").concat(description));
7424
- }
7425
- warn(action, description) {
7426
- getLogger().warn("".concat(this.id, ":").concat(action, " ").concat(description));
7427
- }
7428
- error(action, description, error) {
7429
- getLogger().error("".concat(this.id, ":").concat(action, " ").concat(description, " ").concat(getErrorDescription(error)));
7430
- }
7431
- createTransceivers() {
7432
- localTrackTypes.forEach(_ref => {
7433
- var {
7434
- type,
7435
- kind
7436
- } = _ref;
7437
- var trackType = type;
7438
- var transceiverType = type;
7439
- var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
7440
- if (!this.config.skipInactiveTransceivers || trackInfo.direction !== 'inactive') {
7441
- this.transceivers[transceiverType] = this.pc.addTransceiver(trackInfo.trackOrKind, {
7442
- direction: trackInfo.direction
7443
- });
7444
- }
7445
- });
7446
- this.setupTransceiverListeners();
7447
- }
7448
- initializeTransceivers(incomingOffer) {
7449
- if (this.pc.getTransceivers().length > 0) {
7450
- this.error('initiateOffer()', 'SDP negotiation already started');
7451
- throw new Error('SDP negotiation already started');
7452
- }
7453
- if (incomingOffer) {
7454
- this.addLocalTracks();
7455
- } else {
7456
- this.createTransceivers();
7457
- }
7458
- }
7459
- close() {
7460
- this.pc.close();
7461
- this.pc.ontrack = null;
7462
- this.pc.oniceconnectionstatechange = null;
7463
- this.pc.onconnectionstatechange = null;
7464
- this.pc.onicegatheringstatechange = null;
7465
- this.pc.onicecandidate = null;
7466
- this.pc.onicecandidateerror = null;
7467
- }
7468
- getConfig() {
7469
- return this.config;
7470
- }
7471
- getSendReceiveOptions() {
7472
- return {
7473
- localTracks: this.localTracks,
7474
- direction: this.mediaDirection,
7475
- remoteQualityLevel: this.remoteQualityLevel
7385
+ /*!
7386
+ * js-logger - http://github.com/jonnyreeves/js-logger
7387
+ * Jonny Reeves, http://jonnyreeves.co.uk/
7388
+ * js-logger may be freely distributed under the MIT license.
7389
+ */
7390
+
7391
+ (function (module) {
7392
+ (function (global) {
7393
+ // Top level module for the global, static logger instance.
7394
+ var Logger = {};
7395
+
7396
+ // For those that are at home that are keeping score.
7397
+ Logger.VERSION = "1.6.1";
7398
+
7399
+ // Function which handles all incoming log messages.
7400
+ var logHandler;
7401
+
7402
+ // Map of ContextualLogger instances by name; used by Logger.get() to return the same named instance.
7403
+ var contextualLoggersByNameMap = {};
7404
+
7405
+ // Polyfill for ES5's Function.bind.
7406
+ var bind = function bind(scope, func) {
7407
+ return function () {
7408
+ return func.apply(scope, arguments);
7409
+ };
7476
7410
  };
7477
- }
7478
- updateRemoteQualityLevel(newValue) {
7479
- if (newValue !== this.remoteQualityLevel) {
7480
- this.remoteQualityLevel = newValue;
7481
- return true;
7482
- }
7483
- return false;
7484
- }
7485
- updateTransceivers(options) {
7486
- var newOfferNeeded = false;
7487
- this.mediaDirection.audio = options.direction.audio;
7488
- this.mediaDirection.video = options.direction.video;
7489
- this.mediaDirection.screenShareVideo = options.direction.screenShareVideo;
7490
- this.identifyTransceivers();
7491
- localTrackTypes.forEach(_ref2 => {
7492
- var {
7493
- type,
7494
- kind
7495
- } = _ref2;
7496
- var trackType = type;
7497
- var transceiverType = type;
7498
- var track = options.localTracks[trackType];
7499
- var transceiver = this.transceivers[transceiverType];
7500
- if (track !== undefined && track !== this.localTracks[trackType]) {
7501
- this.localTracks[trackType] = track;
7502
- if (transceiver) {
7503
- this.log('updateTransceivers()', "replacing sender track on \"".concat(type, "\" transceiver"));
7504
- transceiver.sender.replaceTrack(track);
7411
+
7412
+ // Super exciting object merger-matron 9000 adding another 100 bytes to your download.
7413
+ var merge = function merge() {
7414
+ var args = arguments,
7415
+ target = args[0],
7416
+ key,
7417
+ i;
7418
+ for (i = 1; i < args.length; i++) {
7419
+ for (key in args[i]) {
7420
+ if (!(key in target) && args[i].hasOwnProperty(key)) {
7421
+ target[key] = args[i][key];
7422
+ }
7505
7423
  }
7506
7424
  }
7507
- if (transceiver) {
7508
- var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
7509
- if (transceiver.direction !== trackInfo.direction) {
7510
- this.log('updateTransceivers()', "updating direction to ".concat(trackInfo.direction, " on \"").concat(type, "\" transceiver"));
7511
- transceiver.direction = trackInfo.direction;
7512
- newOfferNeeded = true;
7425
+ return target;
7426
+ };
7427
+
7428
+ // Helper to define a logging level object; helps with optimisation.
7429
+ var defineLogLevel = function defineLogLevel(value, name) {
7430
+ return {
7431
+ value: value,
7432
+ name: name
7433
+ };
7434
+ };
7435
+
7436
+ // Predefined logging levels.
7437
+ Logger.TRACE = defineLogLevel(1, 'TRACE');
7438
+ Logger.DEBUG = defineLogLevel(2, 'DEBUG');
7439
+ Logger.INFO = defineLogLevel(3, 'INFO');
7440
+ Logger.TIME = defineLogLevel(4, 'TIME');
7441
+ Logger.WARN = defineLogLevel(5, 'WARN');
7442
+ Logger.ERROR = defineLogLevel(8, 'ERROR');
7443
+ Logger.OFF = defineLogLevel(99, 'OFF');
7444
+
7445
+ // Inner class which performs the bulk of the work; ContextualLogger instances can be configured independently
7446
+ // of each other.
7447
+ var ContextualLogger = function ContextualLogger(defaultContext) {
7448
+ this.context = defaultContext;
7449
+ this.setLevel(defaultContext.filterLevel);
7450
+ this.log = this.info; // Convenience alias.
7451
+ };
7452
+
7453
+ ContextualLogger.prototype = {
7454
+ // Changes the current logging level for the logging instance.
7455
+ setLevel: function setLevel(newLevel) {
7456
+ // Ensure the supplied Level object looks valid.
7457
+ if (newLevel && "value" in newLevel) {
7458
+ this.context.filterLevel = newLevel;
7513
7459
  }
7514
- }
7515
- });
7516
- return newOfferNeeded;
7517
- }
7518
- updateLocalTracks(tracks) {
7519
- return this.updateTransceivers({
7520
- localTracks: tracks,
7521
- direction: _objectSpread$3({}, this.mediaDirection)
7522
- });
7523
- }
7524
- updateDirection(direction) {
7525
- return this.updateTransceivers({
7526
- localTracks: this.localTracks,
7527
- direction
7460
+ },
7461
+ // Gets the current logging level for the logging instance
7462
+ getLevel: function getLevel() {
7463
+ return this.context.filterLevel;
7464
+ },
7465
+ // Is the logger configured to output messages at the supplied level?
7466
+ enabledFor: function enabledFor(lvl) {
7467
+ var filterLevel = this.context.filterLevel;
7468
+ return lvl.value >= filterLevel.value;
7469
+ },
7470
+ trace: function trace() {
7471
+ this.invoke(Logger.TRACE, arguments);
7472
+ },
7473
+ debug: function debug() {
7474
+ this.invoke(Logger.DEBUG, arguments);
7475
+ },
7476
+ info: function info() {
7477
+ this.invoke(Logger.INFO, arguments);
7478
+ },
7479
+ warn: function warn() {
7480
+ this.invoke(Logger.WARN, arguments);
7481
+ },
7482
+ error: function error() {
7483
+ this.invoke(Logger.ERROR, arguments);
7484
+ },
7485
+ time: function time(label) {
7486
+ if (typeof label === 'string' && label.length > 0) {
7487
+ this.invoke(Logger.TIME, [label, 'start']);
7488
+ }
7489
+ },
7490
+ timeEnd: function timeEnd(label) {
7491
+ if (typeof label === 'string' && label.length > 0) {
7492
+ this.invoke(Logger.TIME, [label, 'end']);
7493
+ }
7494
+ },
7495
+ // Invokes the logger callback if it's not being filtered.
7496
+ invoke: function invoke(level, msgArgs) {
7497
+ if (logHandler && this.enabledFor(level)) {
7498
+ logHandler(msgArgs, merge({
7499
+ level: level
7500
+ }, this.context));
7501
+ }
7502
+ }
7503
+ };
7504
+
7505
+ // Protected instance which all calls to the to level `Logger` module will be routed through.
7506
+ var globalLogger = new ContextualLogger({
7507
+ filterLevel: Logger.OFF
7508
+ });
7509
+
7510
+ // Configure the global Logger instance.
7511
+ (function () {
7512
+ // Shortcut for optimisers.
7513
+ var L = Logger;
7514
+ L.enabledFor = bind(globalLogger, globalLogger.enabledFor);
7515
+ L.trace = bind(globalLogger, globalLogger.trace);
7516
+ L.debug = bind(globalLogger, globalLogger.debug);
7517
+ L.time = bind(globalLogger, globalLogger.time);
7518
+ L.timeEnd = bind(globalLogger, globalLogger.timeEnd);
7519
+ L.info = bind(globalLogger, globalLogger.info);
7520
+ L.warn = bind(globalLogger, globalLogger.warn);
7521
+ L.error = bind(globalLogger, globalLogger.error);
7522
+
7523
+ // Don't forget the convenience alias!
7524
+ L.log = L.info;
7525
+ })();
7526
+
7527
+ // Set the global logging handler. The supplied function should expect two arguments, the first being an arguments
7528
+ // object with the supplied log messages and the second being a context object which contains a hash of stateful
7529
+ // parameters which the logging function can consume.
7530
+ Logger.setHandler = function (func) {
7531
+ logHandler = func;
7532
+ };
7533
+
7534
+ // Sets the global logging filter level which applies to *all* previously registered, and future Logger instances.
7535
+ // (note that named loggers (retrieved via `Logger.get`) can be configured independently if required).
7536
+ Logger.setLevel = function (level) {
7537
+ // Set the globalLogger's level.
7538
+ globalLogger.setLevel(level);
7539
+
7540
+ // Apply this level to all registered contextual loggers.
7541
+ for (var key in contextualLoggersByNameMap) {
7542
+ if (contextualLoggersByNameMap.hasOwnProperty(key)) {
7543
+ contextualLoggersByNameMap[key].setLevel(level);
7544
+ }
7545
+ }
7546
+ };
7547
+
7548
+ // Gets the global logging filter level
7549
+ Logger.getLevel = function () {
7550
+ return globalLogger.getLevel();
7551
+ };
7552
+
7553
+ // Retrieve a ContextualLogger instance. Note that named loggers automatically inherit the global logger's level,
7554
+ // default context and log handler.
7555
+ Logger.get = function (name) {
7556
+ // All logger instances are cached so they can be configured ahead of use.
7557
+ return contextualLoggersByNameMap[name] || (contextualLoggersByNameMap[name] = new ContextualLogger(merge({
7558
+ name: name
7559
+ }, globalLogger.context)));
7560
+ };
7561
+
7562
+ // CreateDefaultHandler returns a handler function which can be passed to `Logger.setHandler()` which will
7563
+ // write to the window's console object (if present); the optional options object can be used to customise the
7564
+ // formatter used to format each log message.
7565
+ Logger.createDefaultHandler = function (options) {
7566
+ options = options || {};
7567
+ options.formatter = options.formatter || function defaultMessageFormatter(messages, context) {
7568
+ // Prepend the logger's name to the log message for easy identification.
7569
+ if (context.name) {
7570
+ messages.unshift("[" + context.name + "]");
7571
+ }
7572
+ };
7573
+
7574
+ // Map of timestamps by timer labels used to track `#time` and `#timeEnd()` invocations in environments
7575
+ // that don't offer a native console method.
7576
+ var timerStartTimeByLabelMap = {};
7577
+
7578
+ // Support for IE8+ (and other, slightly more sane environments)
7579
+ var invokeConsoleMethod = function invokeConsoleMethod(hdlr, messages) {
7580
+ Function.prototype.apply.call(hdlr, console, messages);
7581
+ };
7582
+
7583
+ // Check for the presence of a logger.
7584
+ if (typeof console === "undefined") {
7585
+ return function () {/* no console */};
7586
+ }
7587
+ return function (messages, context) {
7588
+ // Convert arguments object to Array.
7589
+ messages = Array.prototype.slice.call(messages);
7590
+ var hdlr = console.log;
7591
+ var timerLabel;
7592
+ if (context.level === Logger.TIME) {
7593
+ timerLabel = (context.name ? '[' + context.name + '] ' : '') + messages[0];
7594
+ if (messages[1] === 'start') {
7595
+ if (console.time) {
7596
+ console.time(timerLabel);
7597
+ } else {
7598
+ timerStartTimeByLabelMap[timerLabel] = new Date().getTime();
7599
+ }
7600
+ } else {
7601
+ if (console.timeEnd) {
7602
+ console.timeEnd(timerLabel);
7603
+ } else {
7604
+ invokeConsoleMethod(hdlr, [timerLabel + ': ' + (new Date().getTime() - timerStartTimeByLabelMap[timerLabel]) + 'ms']);
7605
+ }
7606
+ }
7607
+ } else {
7608
+ // Delegate through to custom warn/error loggers if present on the console.
7609
+ if (context.level === Logger.WARN && console.warn) {
7610
+ hdlr = console.warn;
7611
+ } else if (context.level === Logger.ERROR && console.error) {
7612
+ hdlr = console.error;
7613
+ } else if (context.level === Logger.INFO && console.info) {
7614
+ hdlr = console.info;
7615
+ } else if (context.level === Logger.DEBUG && console.debug) {
7616
+ hdlr = console.debug;
7617
+ } else if (context.level === Logger.TRACE && console.trace) {
7618
+ hdlr = console.trace;
7619
+ }
7620
+ options.formatter(messages, context);
7621
+ invokeConsoleMethod(hdlr, messages);
7622
+ }
7623
+ };
7624
+ };
7625
+
7626
+ // Configure and example a Default implementation which writes to the `window.console` (if present). The
7627
+ // `options` hash can be used to configure the default logLevel and provide a custom message formatter.
7628
+ Logger.useDefaults = function (options) {
7629
+ Logger.setLevel(options && options.defaultLevel || Logger.DEBUG);
7630
+ Logger.setHandler(Logger.createDefaultHandler(options));
7631
+ };
7632
+
7633
+ // Createa an alias to useDefaults to avoid reaking a react-hooks rule.
7634
+ Logger.setDefaults = Logger.useDefaults;
7635
+
7636
+ // Export to popular environments boilerplate.
7637
+ if (module.exports) {
7638
+ module.exports = Logger;
7639
+ } else {
7640
+ Logger._prevLogger = global.Logger;
7641
+ Logger.noConflict = function () {
7642
+ global.Logger = Logger._prevLogger;
7643
+ return Logger;
7644
+ };
7645
+ global.Logger = Logger;
7646
+ }
7647
+ })(commonjsGlobal);
7648
+ })(logger);
7649
+ var Logger = logger.exports;
7650
+ Logger.useDefaults({
7651
+ defaultLevel: Logger.DEBUG,
7652
+ formatter: (messages, context) => {
7653
+ messages.unshift("[".concat(context.name, "] "));
7654
+ }
7655
+ });
7656
+ class ActiveSpeakerInfo {
7657
+ constructor(priority, crossPriorityDuplication, crossPolicyDuplication, preferLiveVideo, namedMediaGroups) {
7658
+ this.priority = priority;
7659
+ this.crossPriorityDuplication = crossPriorityDuplication;
7660
+ this.crossPolicyDuplication = crossPolicyDuplication;
7661
+ this.preferLiveVideo = preferLiveVideo;
7662
+ this.namedMediaGroups = namedMediaGroups;
7663
+ }
7664
+ toString() {
7665
+ return "ActiveSpeakerInfo(priority=".concat(this.priority, ", crossPriorityDuplication=").concat(this.crossPriorityDuplication, ", crossPolicyDuplication=").concat(this.crossPolicyDuplication, ", preferLiveVideo=").concat(this.preferLiveVideo, "), namedMediaGroups=").concat(this.namedMediaGroups);
7666
+ }
7667
+ }
7668
+ var HomerMsgType;
7669
+ (function (HomerMsgType) {
7670
+ HomerMsgType["Multistream"] = "multistream";
7671
+ })(HomerMsgType || (HomerMsgType = {}));
7672
+ var JmpMsgType;
7673
+ (function (JmpMsgType) {
7674
+ JmpMsgType["MediaRequest"] = "mediaRequest";
7675
+ JmpMsgType["MediaRequestAck"] = "mediaRequestAck";
7676
+ JmpMsgType["MediaRequestStatus"] = "mediaRequestStatus";
7677
+ JmpMsgType["MediaRequestStatusAck"] = "mediaRequestStatusAck";
7678
+ JmpMsgType["SourceAdvertisement"] = "sourceAdvertisement";
7679
+ JmpMsgType["SourceAdvertisementAck"] = "sourceAdvertisementAck";
7680
+ JmpMsgType["ActiveSpeakerNotification"] = "activeSpeakerNotification";
7681
+ })(JmpMsgType || (JmpMsgType = {}));
7682
+ class CodecInfo {
7683
+ constructor(payloadType, h264) {
7684
+ this.payloadType = payloadType;
7685
+ this.h264 = h264;
7686
+ }
7687
+ }
7688
+ class H264Codec {
7689
+ constructor(maxFs, maxFps, maxMbps, maxWidth, maxHeight) {
7690
+ this.maxFs = maxFs;
7691
+ this.maxFps = maxFps;
7692
+ this.maxMbps = maxMbps;
7693
+ this.maxWidth = maxWidth;
7694
+ this.maxHeight = maxHeight;
7695
+ }
7696
+ }
7697
+ class ReceiverSelectedInfo {
7698
+ constructor(csi) {
7699
+ this.csi = csi;
7700
+ }
7701
+ toString() {
7702
+ return "ReceiverSelectedInfo(csi=".concat(this.csi, ")");
7703
+ }
7704
+ }
7705
+ var MediaFamily;
7706
+ (function (MediaFamily) {
7707
+ MediaFamily["Audio"] = "AUDIO";
7708
+ MediaFamily["Video"] = "VIDEO";
7709
+ })(MediaFamily || (MediaFamily = {}));
7710
+ var MediaContent;
7711
+ (function (MediaContent) {
7712
+ MediaContent["Main"] = "MAIN";
7713
+ MediaContent["Slides"] = "SLIDES";
7714
+ })(MediaContent || (MediaContent = {}));
7715
+ var Policy;
7716
+ (function (Policy) {
7717
+ Policy["ActiveSpeaker"] = "active-speaker";
7718
+ Policy["ReceiverSelected"] = "receiver-selected";
7719
+ })(Policy || (Policy = {}));
7720
+ var MediaType;
7721
+ (function (MediaType) {
7722
+ MediaType["VideoMain"] = "VIDEO-MAIN";
7723
+ MediaType["VideoSlides"] = "VIDEO-SLIDES";
7724
+ MediaType["AudioMain"] = "AUDIO-MAIN";
7725
+ MediaType["AudioSlides"] = "AUDIO-SLIDES";
7726
+ })(MediaType || (MediaType = {}));
7727
+ function getMediaFamily(mediaType) {
7728
+ return [MediaType.VideoMain, MediaType.VideoSlides].includes(mediaType) ? MediaFamily.Video : MediaFamily.Audio;
7729
+ }
7730
+ var JmpSessionEvents;
7731
+ (function (JmpSessionEvents) {
7732
+ JmpSessionEvents["ActiveSpeaker"] = "active-speaker";
7733
+ JmpSessionEvents["MediaRequestReceived"] = "media-request-received";
7734
+ JmpSessionEvents["MediaRequestStatusReceived"] = "media-request-status-received";
7735
+ JmpSessionEvents["SourceAdvertisementReceived"] = "source-advertisement-received";
7736
+ })(JmpSessionEvents || (JmpSessionEvents = {}));
7737
+
7738
+ var Event$1;
7739
+ (function (Event) {
7740
+ Event["CONNECTION_STATE_CHANGED"] = "connectionState:changed";
7741
+ Event["REMOTE_TRACK_ADDED"] = "remoteTrack:added";
7742
+ Event["ROAP_MESSAGE_TO_SEND"] = "roap:messageToSend";
7743
+ Event["ROAP_STARTED"] = "roap:started";
7744
+ Event["ROAP_FAILURE"] = "roap:failure";
7745
+ Event["ROAP_DONE"] = "roap:done";
7746
+ Event["DTMF_TONE_CHANGED"] = "dtmfTone:changed";
7747
+ Event["ACTIVE_SPEAKERS_CHANGED"] = "activeSpeakers:changed";
7748
+ Event["VIDEO_SOURCES_COUNT_CHANGED"] = "videoSourcesCount:changed";
7749
+ Event["AUDIO_SOURCES_COUNT_CHANGED"] = "audioSourcesCount:changed";
7750
+ })(Event$1 || (Event$1 = {}));
7751
+ var RemoteTrackType;
7752
+ (function (RemoteTrackType) {
7753
+ RemoteTrackType["AUDIO"] = "audio";
7754
+ RemoteTrackType["VIDEO"] = "video";
7755
+ RemoteTrackType["SCREENSHARE_VIDEO"] = "screenShareVideo";
7756
+ })(RemoteTrackType || (RemoteTrackType = {}));
7757
+ var ErrorType;
7758
+ (function (ErrorType) {
7759
+ ErrorType["DOUBLECONFLICT"] = "DOUBLECONFLICT";
7760
+ ErrorType["CONFLICT"] = "CONFLICT";
7761
+ ErrorType["FAILED"] = "FAILED";
7762
+ ErrorType["INVALID_STATE"] = "INVALID_STATE";
7763
+ ErrorType["NOMATCH"] = "NOMATCH";
7764
+ ErrorType["OUT_OF_ORDER"] = "OUT_OF_ORDER";
7765
+ ErrorType["REFUSED"] = "REFUSED";
7766
+ ErrorType["RETRY"] = "RETRY";
7767
+ ErrorType["TIMEOUT"] = "TIMEOUT";
7768
+ })(ErrorType || (ErrorType = {}));
7769
+
7770
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7771
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7772
+ var localTrackTypes = [{
7773
+ type: 'audio',
7774
+ kind: 'audio'
7775
+ }, {
7776
+ type: 'video',
7777
+ kind: 'video'
7778
+ }, {
7779
+ type: 'screenShareVideo',
7780
+ kind: 'video'
7781
+ }];
7782
+ class MediaConnection extends EventEmitter$3 {
7783
+ constructor(mediaConnectionConfig, options, debugId) {
7784
+ super();
7785
+ _defineProperty(this, "id", void 0);
7786
+ _defineProperty(this, "config", void 0);
7787
+ _defineProperty(this, "pc", void 0);
7788
+ _defineProperty(this, "localTracks", void 0);
7789
+ _defineProperty(this, "transceivers", void 0);
7790
+ _defineProperty(this, "mediaDirection", void 0);
7791
+ _defineProperty(this, "remoteQualityLevel", void 0);
7792
+ _defineProperty(this, "mediaConnectionState", void 0);
7793
+ _defineProperty(this, "lastEmittedMediaConnectionState", void 0);
7794
+ this.config = mediaConnectionConfig;
7795
+ this.mediaDirection = _objectSpread$3({}, options.direction);
7796
+ this.localTracks = _objectSpread$3({}, options.localTracks);
7797
+ this.remoteQualityLevel = options.remoteQualityLevel;
7798
+ this.id = debugId || 'MediaConnection';
7799
+ this.transceivers = {};
7800
+ this.mediaConnectionState = ConnectionState.New;
7801
+ this.pc = new window.RTCPeerConnection({
7802
+ iceServers: this.config.iceServers,
7803
+ bundlePolicy: 'max-compat'
7804
+ });
7805
+ this.pc.ontrack = this.onTrack.bind(this);
7806
+ this.pc.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this);
7807
+ this.pc.onconnectionstatechange = this.onConnectionStateChange.bind(this);
7808
+ }
7809
+ log(action, description) {
7810
+ getLogger().info("".concat(this.id, ":").concat(action, " ").concat(description));
7811
+ }
7812
+ warn(action, description) {
7813
+ getLogger().warn("".concat(this.id, ":").concat(action, " ").concat(description));
7814
+ }
7815
+ error(action, description, error) {
7816
+ getLogger().error("".concat(this.id, ":").concat(action, " ").concat(description, " ").concat(getErrorDescription(error)));
7817
+ }
7818
+ createTransceivers() {
7819
+ localTrackTypes.forEach(_ref => {
7820
+ var {
7821
+ type,
7822
+ kind
7823
+ } = _ref;
7824
+ var trackType = type;
7825
+ var transceiverType = type;
7826
+ var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
7827
+ if (!this.config.skipInactiveTransceivers || trackInfo.direction !== 'inactive') {
7828
+ this.transceivers[transceiverType] = this.pc.addTransceiver(trackInfo.trackOrKind, {
7829
+ direction: trackInfo.direction
7830
+ });
7831
+ }
7832
+ });
7833
+ this.setupTransceiverListeners();
7834
+ }
7835
+ initializeTransceivers(incomingOffer) {
7836
+ if (this.pc.getTransceivers().length > 0) {
7837
+ this.error('initiateOffer()', 'SDP negotiation already started');
7838
+ throw new Error('SDP negotiation already started');
7839
+ }
7840
+ if (incomingOffer) {
7841
+ this.addLocalTracks();
7842
+ } else {
7843
+ this.createTransceivers();
7844
+ }
7845
+ }
7846
+ close() {
7847
+ this.pc.close();
7848
+ this.pc.ontrack = null;
7849
+ this.pc.oniceconnectionstatechange = null;
7850
+ this.pc.onconnectionstatechange = null;
7851
+ this.pc.onicegatheringstatechange = null;
7852
+ this.pc.onicecandidate = null;
7853
+ this.pc.onicecandidateerror = null;
7854
+ }
7855
+ getConfig() {
7856
+ return this.config;
7857
+ }
7858
+ getSendReceiveOptions() {
7859
+ return {
7860
+ localTracks: this.localTracks,
7861
+ direction: this.mediaDirection,
7862
+ remoteQualityLevel: this.remoteQualityLevel
7863
+ };
7864
+ }
7865
+ updateRemoteQualityLevel(newValue) {
7866
+ if (newValue !== this.remoteQualityLevel) {
7867
+ this.remoteQualityLevel = newValue;
7868
+ return true;
7869
+ }
7870
+ return false;
7871
+ }
7872
+ updateTransceivers(options) {
7873
+ var newOfferNeeded = false;
7874
+ this.mediaDirection.audio = options.direction.audio;
7875
+ this.mediaDirection.video = options.direction.video;
7876
+ this.mediaDirection.screenShareVideo = options.direction.screenShareVideo;
7877
+ this.identifyTransceivers();
7878
+ localTrackTypes.forEach(_ref2 => {
7879
+ var {
7880
+ type,
7881
+ kind
7882
+ } = _ref2;
7883
+ var trackType = type;
7884
+ var transceiverType = type;
7885
+ var track = options.localTracks[trackType];
7886
+ var transceiver = this.transceivers[transceiverType];
7887
+ if (track !== undefined && track !== this.localTracks[trackType]) {
7888
+ this.localTracks[trackType] = track;
7889
+ if (transceiver) {
7890
+ this.log('updateTransceivers()', "replacing sender track on \"".concat(type, "\" transceiver"));
7891
+ transceiver.sender.replaceTrack(track);
7892
+ }
7893
+ }
7894
+ if (transceiver) {
7895
+ var trackInfo = getLocalTrackInfo(kind, this.mediaDirection[trackType], this.localTracks[trackType]);
7896
+ if (transceiver.direction !== trackInfo.direction) {
7897
+ this.log('updateTransceivers()', "updating direction to ".concat(trackInfo.direction, " on \"").concat(type, "\" transceiver"));
7898
+ transceiver.direction = trackInfo.direction;
7899
+ newOfferNeeded = true;
7900
+ }
7901
+ }
7902
+ });
7903
+ return newOfferNeeded;
7904
+ }
7905
+ updateLocalTracks(tracks) {
7906
+ return this.updateTransceivers({
7907
+ localTracks: tracks,
7908
+ direction: _objectSpread$3({}, this.mediaDirection)
7909
+ });
7910
+ }
7911
+ updateDirection(direction) {
7912
+ return this.updateTransceivers({
7913
+ localTracks: this.localTracks,
7914
+ direction
7528
7915
  });
7529
7916
  }
7530
7917
  update(options) {
@@ -15858,450 +16245,92 @@ class RoapMediaConnection extends EventEmitter$3 {
15858
16245
  this.mediaConnection = this.createMediaConnection(config, options, this.debugId);
15859
16246
  this.roap = this.createRoap(this.debugId, seq);
15860
16247
  if (initiateOffer) {
15861
- return this.initiateOffer();
15862
- }
15863
- return Promise.resolve();
15864
- }
15865
- updateLocalTracks(tracks) {
15866
- this.log('updateLocalTracks()', "called with ".concat(JSON.stringify(tracks)));
15867
- var newOfferNeeded = this.mediaConnection.updateLocalTracks(tracks);
15868
- if (newOfferNeeded) {
15869
- this.log('updateLocalTracks()', 'triggering offer...');
15870
- return this.roap.initiateOffer();
15871
- }
15872
- return Promise.resolve();
15873
- }
15874
- updateDirection(direction) {
15875
- this.log('updateDirection()', "called with ".concat(JSON.stringify(direction)));
15876
- var newOfferNeeded = this.mediaConnection.updateDirection(direction);
15877
- if (newOfferNeeded) {
15878
- this.log('updateDirection()', 'triggering offer...');
15879
- return this.roap.initiateOffer();
15880
- }
15881
- return Promise.resolve();
15882
- }
15883
- updateRemoteQualityLevel(newValue) {
15884
- this.log('updateRemoteQualityLevel()', "called with ".concat(newValue));
15885
- var newOfferNeeded = this.mediaConnection.updateRemoteQualityLevel(newValue);
15886
- if (newOfferNeeded) {
15887
- this.log('updateRemoteQualityLevel()', 'triggering offer...');
15888
- return this.roap.initiateOffer();
15889
- }
15890
- return Promise.resolve();
15891
- }
15892
- update(options) {
15893
- this.log('update()', "called with ".concat(JSON.stringify(options)));
15894
- var newOfferNeeded = this.mediaConnection.update(options);
15895
- if (newOfferNeeded) {
15896
- this.log('update()', 'triggering offer...');
15897
- return this.roap.initiateOffer();
15898
- }
15899
- return Promise.resolve();
15900
- }
15901
- getConnectionState() {
15902
- return this.mediaConnection.getConnectionState();
15903
- }
15904
- getStats() {
15905
- return this.mediaConnection.getStats();
15906
- }
15907
- getTransceiverStats() {
15908
- return this.mediaConnection.getTransceiverStats();
15909
- }
15910
- insertDTMF(tones, duration, interToneGap) {
15911
- this.log('insertDTMF()', "called with tones=\"".concat(tones, "\", duration=").concat(duration, ", interToneGap=").concat(interToneGap));
15912
- this.mediaConnection.insertDTMF(tones, duration, interToneGap);
15913
- }
15914
- roapMessageReceived(roapMessage) {
15915
- this.log('roapMessageReceived()', "called with messageType=".concat(roapMessage.messageType, ", seq=").concat(roapMessage.seq));
15916
- if (!this.sdpNegotiationStarted) {
15917
- if (roapMessage.messageType === 'OFFER') {
15918
- this.sdpNegotiationStarted = true;
15919
- this.mediaConnection.initializeTransceivers(true);
15920
- }
15921
- if (roapMessage.messageType === 'OFFER_REQUEST') {
15922
- this.sdpNegotiationStarted = true;
15923
- this.mediaConnection.initializeTransceivers(false);
15924
- }
15925
- }
15926
- this.roap.roapMessageReceived(roapMessage);
15927
- }
15928
- onRemoteTrack(event) {
15929
- this.emit(Event$1.REMOTE_TRACK_ADDED, event);
15930
- }
15931
- onConnectionStateChanged(event) {
15932
- this.emit(Event$1.CONNECTION_STATE_CHANGED, event);
15933
- }
15934
- onDtmfToneChanged(event) {
15935
- this.emit(Event$1.DTMF_TONE_CHANGED, event);
15936
- }
15937
- createLocalOffer() {
15938
- return this.mediaConnection.createLocalOffer();
15939
- }
15940
- handleRemoteOffer(sdp) {
15941
- return this.mediaConnection.handleRemoteOffer(sdp);
15942
- }
15943
- handleRemoteAnswer(sdp) {
15944
- return this.mediaConnection.handleRemoteAnswer(sdp);
15945
- }
15946
- }
15947
-
15948
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global$1 !== 'undefined' ? global$1 : typeof self !== 'undefined' ? self : {};
15949
- var logger = {
15950
- exports: {}
15951
- };
15952
-
15953
- /*!
15954
- * js-logger - http://github.com/jonnyreeves/js-logger
15955
- * Jonny Reeves, http://jonnyreeves.co.uk/
15956
- * js-logger may be freely distributed under the MIT license.
15957
- */
15958
-
15959
- (function (module) {
15960
- (function (global) {
15961
- // Top level module for the global, static logger instance.
15962
- var Logger = {};
15963
-
15964
- // For those that are at home that are keeping score.
15965
- Logger.VERSION = "1.6.1";
15966
-
15967
- // Function which handles all incoming log messages.
15968
- var logHandler;
15969
-
15970
- // Map of ContextualLogger instances by name; used by Logger.get() to return the same named instance.
15971
- var contextualLoggersByNameMap = {};
15972
-
15973
- // Polyfill for ES5's Function.bind.
15974
- var bind = function bind(scope, func) {
15975
- return function () {
15976
- return func.apply(scope, arguments);
15977
- };
15978
- };
15979
-
15980
- // Super exciting object merger-matron 9000 adding another 100 bytes to your download.
15981
- var merge = function merge() {
15982
- var args = arguments,
15983
- target = args[0],
15984
- key,
15985
- i;
15986
- for (i = 1; i < args.length; i++) {
15987
- for (key in args[i]) {
15988
- if (!(key in target) && args[i].hasOwnProperty(key)) {
15989
- target[key] = args[i][key];
15990
- }
15991
- }
15992
- }
15993
- return target;
15994
- };
15995
-
15996
- // Helper to define a logging level object; helps with optimisation.
15997
- var defineLogLevel = function defineLogLevel(value, name) {
15998
- return {
15999
- value: value,
16000
- name: name
16001
- };
16002
- };
16003
-
16004
- // Predefined logging levels.
16005
- Logger.TRACE = defineLogLevel(1, 'TRACE');
16006
- Logger.DEBUG = defineLogLevel(2, 'DEBUG');
16007
- Logger.INFO = defineLogLevel(3, 'INFO');
16008
- Logger.TIME = defineLogLevel(4, 'TIME');
16009
- Logger.WARN = defineLogLevel(5, 'WARN');
16010
- Logger.ERROR = defineLogLevel(8, 'ERROR');
16011
- Logger.OFF = defineLogLevel(99, 'OFF');
16012
-
16013
- // Inner class which performs the bulk of the work; ContextualLogger instances can be configured independently
16014
- // of each other.
16015
- var ContextualLogger = function ContextualLogger(defaultContext) {
16016
- this.context = defaultContext;
16017
- this.setLevel(defaultContext.filterLevel);
16018
- this.log = this.info; // Convenience alias.
16019
- };
16020
-
16021
- ContextualLogger.prototype = {
16022
- // Changes the current logging level for the logging instance.
16023
- setLevel: function setLevel(newLevel) {
16024
- // Ensure the supplied Level object looks valid.
16025
- if (newLevel && "value" in newLevel) {
16026
- this.context.filterLevel = newLevel;
16027
- }
16028
- },
16029
- // Gets the current logging level for the logging instance
16030
- getLevel: function getLevel() {
16031
- return this.context.filterLevel;
16032
- },
16033
- // Is the logger configured to output messages at the supplied level?
16034
- enabledFor: function enabledFor(lvl) {
16035
- var filterLevel = this.context.filterLevel;
16036
- return lvl.value >= filterLevel.value;
16037
- },
16038
- trace: function trace() {
16039
- this.invoke(Logger.TRACE, arguments);
16040
- },
16041
- debug: function debug() {
16042
- this.invoke(Logger.DEBUG, arguments);
16043
- },
16044
- info: function info() {
16045
- this.invoke(Logger.INFO, arguments);
16046
- },
16047
- warn: function warn() {
16048
- this.invoke(Logger.WARN, arguments);
16049
- },
16050
- error: function error() {
16051
- this.invoke(Logger.ERROR, arguments);
16052
- },
16053
- time: function time(label) {
16054
- if (typeof label === 'string' && label.length > 0) {
16055
- this.invoke(Logger.TIME, [label, 'start']);
16056
- }
16057
- },
16058
- timeEnd: function timeEnd(label) {
16059
- if (typeof label === 'string' && label.length > 0) {
16060
- this.invoke(Logger.TIME, [label, 'end']);
16061
- }
16062
- },
16063
- // Invokes the logger callback if it's not being filtered.
16064
- invoke: function invoke(level, msgArgs) {
16065
- if (logHandler && this.enabledFor(level)) {
16066
- logHandler(msgArgs, merge({
16067
- level: level
16068
- }, this.context));
16069
- }
16070
- }
16071
- };
16072
-
16073
- // Protected instance which all calls to the to level `Logger` module will be routed through.
16074
- var globalLogger = new ContextualLogger({
16075
- filterLevel: Logger.OFF
16076
- });
16077
-
16078
- // Configure the global Logger instance.
16079
- (function () {
16080
- // Shortcut for optimisers.
16081
- var L = Logger;
16082
- L.enabledFor = bind(globalLogger, globalLogger.enabledFor);
16083
- L.trace = bind(globalLogger, globalLogger.trace);
16084
- L.debug = bind(globalLogger, globalLogger.debug);
16085
- L.time = bind(globalLogger, globalLogger.time);
16086
- L.timeEnd = bind(globalLogger, globalLogger.timeEnd);
16087
- L.info = bind(globalLogger, globalLogger.info);
16088
- L.warn = bind(globalLogger, globalLogger.warn);
16089
- L.error = bind(globalLogger, globalLogger.error);
16090
-
16091
- // Don't forget the convenience alias!
16092
- L.log = L.info;
16093
- })();
16094
-
16095
- // Set the global logging handler. The supplied function should expect two arguments, the first being an arguments
16096
- // object with the supplied log messages and the second being a context object which contains a hash of stateful
16097
- // parameters which the logging function can consume.
16098
- Logger.setHandler = function (func) {
16099
- logHandler = func;
16100
- };
16101
-
16102
- // Sets the global logging filter level which applies to *all* previously registered, and future Logger instances.
16103
- // (note that named loggers (retrieved via `Logger.get`) can be configured independently if required).
16104
- Logger.setLevel = function (level) {
16105
- // Set the globalLogger's level.
16106
- globalLogger.setLevel(level);
16107
-
16108
- // Apply this level to all registered contextual loggers.
16109
- for (var key in contextualLoggersByNameMap) {
16110
- if (contextualLoggersByNameMap.hasOwnProperty(key)) {
16111
- contextualLoggersByNameMap[key].setLevel(level);
16112
- }
16248
+ return this.initiateOffer();
16249
+ }
16250
+ return Promise.resolve();
16251
+ }
16252
+ updateLocalTracks(tracks) {
16253
+ this.log('updateLocalTracks()', "called with ".concat(JSON.stringify(tracks)));
16254
+ var newOfferNeeded = this.mediaConnection.updateLocalTracks(tracks);
16255
+ if (newOfferNeeded) {
16256
+ this.log('updateLocalTracks()', 'triggering offer...');
16257
+ return this.roap.initiateOffer();
16258
+ }
16259
+ return Promise.resolve();
16260
+ }
16261
+ updateDirection(direction) {
16262
+ this.log('updateDirection()', "called with ".concat(JSON.stringify(direction)));
16263
+ var newOfferNeeded = this.mediaConnection.updateDirection(direction);
16264
+ if (newOfferNeeded) {
16265
+ this.log('updateDirection()', 'triggering offer...');
16266
+ return this.roap.initiateOffer();
16267
+ }
16268
+ return Promise.resolve();
16269
+ }
16270
+ updateRemoteQualityLevel(newValue) {
16271
+ this.log('updateRemoteQualityLevel()', "called with ".concat(newValue));
16272
+ var newOfferNeeded = this.mediaConnection.updateRemoteQualityLevel(newValue);
16273
+ if (newOfferNeeded) {
16274
+ this.log('updateRemoteQualityLevel()', 'triggering offer...');
16275
+ return this.roap.initiateOffer();
16276
+ }
16277
+ return Promise.resolve();
16278
+ }
16279
+ update(options) {
16280
+ this.log('update()', "called with ".concat(JSON.stringify(options)));
16281
+ var newOfferNeeded = this.mediaConnection.update(options);
16282
+ if (newOfferNeeded) {
16283
+ this.log('update()', 'triggering offer...');
16284
+ return this.roap.initiateOffer();
16285
+ }
16286
+ return Promise.resolve();
16287
+ }
16288
+ getConnectionState() {
16289
+ return this.mediaConnection.getConnectionState();
16290
+ }
16291
+ getStats() {
16292
+ return this.mediaConnection.getStats();
16293
+ }
16294
+ getTransceiverStats() {
16295
+ return this.mediaConnection.getTransceiverStats();
16296
+ }
16297
+ insertDTMF(tones, duration, interToneGap) {
16298
+ this.log('insertDTMF()', "called with tones=\"".concat(tones, "\", duration=").concat(duration, ", interToneGap=").concat(interToneGap));
16299
+ this.mediaConnection.insertDTMF(tones, duration, interToneGap);
16300
+ }
16301
+ roapMessageReceived(roapMessage) {
16302
+ this.log('roapMessageReceived()', "called with messageType=".concat(roapMessage.messageType, ", seq=").concat(roapMessage.seq));
16303
+ if (!this.sdpNegotiationStarted) {
16304
+ if (roapMessage.messageType === 'OFFER') {
16305
+ this.sdpNegotiationStarted = true;
16306
+ this.mediaConnection.initializeTransceivers(true);
16113
16307
  }
16114
- };
16115
-
16116
- // Gets the global logging filter level
16117
- Logger.getLevel = function () {
16118
- return globalLogger.getLevel();
16119
- };
16120
-
16121
- // Retrieve a ContextualLogger instance. Note that named loggers automatically inherit the global logger's level,
16122
- // default context and log handler.
16123
- Logger.get = function (name) {
16124
- // All logger instances are cached so they can be configured ahead of use.
16125
- return contextualLoggersByNameMap[name] || (contextualLoggersByNameMap[name] = new ContextualLogger(merge({
16126
- name: name
16127
- }, globalLogger.context)));
16128
- };
16129
-
16130
- // CreateDefaultHandler returns a handler function which can be passed to `Logger.setHandler()` which will
16131
- // write to the window's console object (if present); the optional options object can be used to customise the
16132
- // formatter used to format each log message.
16133
- Logger.createDefaultHandler = function (options) {
16134
- options = options || {};
16135
- options.formatter = options.formatter || function defaultMessageFormatter(messages, context) {
16136
- // Prepend the logger's name to the log message for easy identification.
16137
- if (context.name) {
16138
- messages.unshift("[" + context.name + "]");
16139
- }
16140
- };
16141
-
16142
- // Map of timestamps by timer labels used to track `#time` and `#timeEnd()` invocations in environments
16143
- // that don't offer a native console method.
16144
- var timerStartTimeByLabelMap = {};
16145
-
16146
- // Support for IE8+ (and other, slightly more sane environments)
16147
- var invokeConsoleMethod = function invokeConsoleMethod(hdlr, messages) {
16148
- Function.prototype.apply.call(hdlr, console, messages);
16149
- };
16150
-
16151
- // Check for the presence of a logger.
16152
- if (typeof console === "undefined") {
16153
- return function () {/* no console */};
16308
+ if (roapMessage.messageType === 'OFFER_REQUEST') {
16309
+ this.sdpNegotiationStarted = true;
16310
+ this.mediaConnection.initializeTransceivers(false);
16154
16311
  }
16155
- return function (messages, context) {
16156
- // Convert arguments object to Array.
16157
- messages = Array.prototype.slice.call(messages);
16158
- var hdlr = console.log;
16159
- var timerLabel;
16160
- if (context.level === Logger.TIME) {
16161
- timerLabel = (context.name ? '[' + context.name + '] ' : '') + messages[0];
16162
- if (messages[1] === 'start') {
16163
- if (console.time) {
16164
- console.time(timerLabel);
16165
- } else {
16166
- timerStartTimeByLabelMap[timerLabel] = new Date().getTime();
16167
- }
16168
- } else {
16169
- if (console.timeEnd) {
16170
- console.timeEnd(timerLabel);
16171
- } else {
16172
- invokeConsoleMethod(hdlr, [timerLabel + ': ' + (new Date().getTime() - timerStartTimeByLabelMap[timerLabel]) + 'ms']);
16173
- }
16174
- }
16175
- } else {
16176
- // Delegate through to custom warn/error loggers if present on the console.
16177
- if (context.level === Logger.WARN && console.warn) {
16178
- hdlr = console.warn;
16179
- } else if (context.level === Logger.ERROR && console.error) {
16180
- hdlr = console.error;
16181
- } else if (context.level === Logger.INFO && console.info) {
16182
- hdlr = console.info;
16183
- } else if (context.level === Logger.DEBUG && console.debug) {
16184
- hdlr = console.debug;
16185
- } else if (context.level === Logger.TRACE && console.trace) {
16186
- hdlr = console.trace;
16187
- }
16188
- options.formatter(messages, context);
16189
- invokeConsoleMethod(hdlr, messages);
16190
- }
16191
- };
16192
- };
16193
-
16194
- // Configure and example a Default implementation which writes to the `window.console` (if present). The
16195
- // `options` hash can be used to configure the default logLevel and provide a custom message formatter.
16196
- Logger.useDefaults = function (options) {
16197
- Logger.setLevel(options && options.defaultLevel || Logger.DEBUG);
16198
- Logger.setHandler(Logger.createDefaultHandler(options));
16199
- };
16200
-
16201
- // Createa an alias to useDefaults to avoid reaking a react-hooks rule.
16202
- Logger.setDefaults = Logger.useDefaults;
16203
-
16204
- // Export to popular environments boilerplate.
16205
- if (module.exports) {
16206
- module.exports = Logger;
16207
- } else {
16208
- Logger._prevLogger = global.Logger;
16209
- Logger.noConflict = function () {
16210
- global.Logger = Logger._prevLogger;
16211
- return Logger;
16212
- };
16213
- global.Logger = Logger;
16214
16312
  }
16215
- })(commonjsGlobal);
16216
- })(logger);
16217
- var Logger = logger.exports;
16218
- Logger.useDefaults({
16219
- defaultLevel: Logger.DEBUG,
16220
- formatter: (messages, context) => {
16221
- messages.unshift("[".concat(context.name, "] "));
16313
+ this.roap.roapMessageReceived(roapMessage);
16222
16314
  }
16223
- });
16224
- class ActiveSpeakerInfo {
16225
- constructor(priority, crossPriorityDuplication, crossPolicyDuplication, preferLiveVideo, namedMediaGroups) {
16226
- this.priority = priority;
16227
- this.crossPriorityDuplication = crossPriorityDuplication;
16228
- this.crossPolicyDuplication = crossPolicyDuplication;
16229
- this.preferLiveVideo = preferLiveVideo;
16230
- this.namedMediaGroups = namedMediaGroups;
16315
+ onRemoteTrack(event) {
16316
+ this.emit(Event$1.REMOTE_TRACK_ADDED, event);
16231
16317
  }
16232
- toString() {
16233
- return "ActiveSpeakerInfo(priority=".concat(this.priority, ", crossPriorityDuplication=").concat(this.crossPriorityDuplication, ", crossPolicyDuplication=").concat(this.crossPolicyDuplication, ", preferLiveVideo=").concat(this.preferLiveVideo, "), namedMediaGroups=").concat(this.namedMediaGroups);
16318
+ onConnectionStateChanged(event) {
16319
+ this.emit(Event$1.CONNECTION_STATE_CHANGED, event);
16234
16320
  }
16235
- }
16236
- var HomerMsgType;
16237
- (function (HomerMsgType) {
16238
- HomerMsgType["Multistream"] = "multistream";
16239
- })(HomerMsgType || (HomerMsgType = {}));
16240
- var JmpMsgType;
16241
- (function (JmpMsgType) {
16242
- JmpMsgType["MediaRequest"] = "mediaRequest";
16243
- JmpMsgType["MediaRequestAck"] = "mediaRequestAck";
16244
- JmpMsgType["MediaRequestStatus"] = "mediaRequestStatus";
16245
- JmpMsgType["MediaRequestStatusAck"] = "mediaRequestStatusAck";
16246
- JmpMsgType["SourceAdvertisement"] = "sourceAdvertisement";
16247
- JmpMsgType["SourceAdvertisementAck"] = "sourceAdvertisementAck";
16248
- JmpMsgType["ActiveSpeakerNotification"] = "activeSpeakerNotification";
16249
- })(JmpMsgType || (JmpMsgType = {}));
16250
- class CodecInfo {
16251
- constructor(payloadType, h264) {
16252
- this.payloadType = payloadType;
16253
- this.h264 = h264;
16321
+ onDtmfToneChanged(event) {
16322
+ this.emit(Event$1.DTMF_TONE_CHANGED, event);
16254
16323
  }
16255
- }
16256
- class H264Codec {
16257
- constructor(maxFs, maxFps, maxMbps, maxWidth, maxHeight) {
16258
- this.maxFs = maxFs;
16259
- this.maxFps = maxFps;
16260
- this.maxMbps = maxMbps;
16261
- this.maxWidth = maxWidth;
16262
- this.maxHeight = maxHeight;
16324
+ createLocalOffer() {
16325
+ return this.mediaConnection.createLocalOffer();
16263
16326
  }
16264
- }
16265
- class ReceiverSelectedInfo {
16266
- constructor(csi) {
16267
- this.csi = csi;
16327
+ handleRemoteOffer(sdp) {
16328
+ return this.mediaConnection.handleRemoteOffer(sdp);
16268
16329
  }
16269
- toString() {
16270
- return "ReceiverSelectedInfo(csi=".concat(this.csi, ")");
16330
+ handleRemoteAnswer(sdp) {
16331
+ return this.mediaConnection.handleRemoteAnswer(sdp);
16271
16332
  }
16272
16333
  }
16273
- var MediaFamily;
16274
- (function (MediaFamily) {
16275
- MediaFamily["Audio"] = "AUDIO";
16276
- MediaFamily["Video"] = "VIDEO";
16277
- })(MediaFamily || (MediaFamily = {}));
16278
- var MediaContent;
16279
- (function (MediaContent) {
16280
- MediaContent["Main"] = "MAIN";
16281
- MediaContent["Slides"] = "SLIDES";
16282
- })(MediaContent || (MediaContent = {}));
16283
- var Policy;
16284
- (function (Policy) {
16285
- Policy["ActiveSpeaker"] = "active-speaker";
16286
- Policy["ReceiverSelected"] = "receiver-selected";
16287
- })(Policy || (Policy = {}));
16288
- var MediaType;
16289
- (function (MediaType) {
16290
- MediaType["VideoMain"] = "VIDEO-MAIN";
16291
- MediaType["VideoSlides"] = "VIDEO-SLIDES";
16292
- MediaType["AudioMain"] = "AUDIO-MAIN";
16293
- MediaType["AudioSlides"] = "AUDIO-SLIDES";
16294
- })(MediaType || (MediaType = {}));
16295
- function getMediaFamily(mediaType) {
16296
- return [MediaType.VideoMain, MediaType.VideoSlides].includes(mediaType) ? MediaFamily.Video : MediaFamily.Audio;
16297
- }
16298
- var JmpSessionEvents;
16299
- (function (JmpSessionEvents) {
16300
- JmpSessionEvents["ActiveSpeaker"] = "active-speaker";
16301
- JmpSessionEvents["MediaRequestReceived"] = "media-request-received";
16302
- JmpSessionEvents["MediaRequestStatusReceived"] = "media-request-status-received";
16303
- JmpSessionEvents["SourceAdvertisementReceived"] = "source-advertisement-received";
16304
- })(JmpSessionEvents || (JmpSessionEvents = {}));
16305
16334
 
16306
16335
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16307
16336
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -16505,4 +16534,4 @@ var Media = {
16505
16534
  isBrowserSupported
16506
16535
  };
16507
16536
 
16508
- export { ActiveSpeakerInfo, CodecInfo, ConnectionState, ErrorType, Errors, Event$1 as Event, H264Codec, LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, LocalTrackEvents, Media, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamRoapMediaConnection, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteTrackType, RoapMediaConnection, StreamRequest, WcmeError, configureWcmeLogger, createCameraTrack, createDisplayTrack, createMicrophoneTrack, getAudioInputDevices, getAudioOutputDevices, getDevices, getErrorDescription, getLogger, getMediaFamily, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, isBrowserSupported, setLogger, setOnDeviceChangeHandler };
16537
+ export { ActiveSpeakerInfo, CodecInfo, ConnectionState, ErrorType, Errors, Event$1 as Event, H264Codec, LocalCameraTrack, LocalDisplayTrack, LocalMicrophoneTrack, LocalTrack, LocalTrackEvents, Media, MediaContent, MediaFamily, MediaStreamTrackKind, MediaType, MultistreamRoapMediaConnection, PeerConnection, Policy, ReceiveSlot, ReceiveSlotEvents, ReceiverSelectedInfo, RecommendedOpusBitrates, RemoteTrackType, RoapMediaConnection, StreamRequest, WcmeError, configureWcmeLogger, createCameraTrack, createDisplayTrack, createMicrophoneTrack, getAudioInputDevices, getAudioOutputDevices, getDevices, getErrorDescription, getLogger, getMediaFamily, getRecommendedMaxBitrateForFrameSize, getVideoInputDevices, isBrowserSupported, setLogger, setOnDeviceChangeHandler };