@webex/web-client-media-engine 3.5.1 → 3.6.0

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
@@ -6938,6 +6938,17 @@ var map2obj = function (report) {
6938
6938
  });
6939
6939
  return o;
6940
6940
  };
6941
+ var dumpStream = function (stream) { return ({
6942
+ id: stream.id,
6943
+ tracks: stream.getTracks().map(function (track) { return ({
6944
+ id: track.id,
6945
+ kind: track.kind,
6946
+ label: track.label,
6947
+ enabled: track.enabled,
6948
+ muted: track.muted,
6949
+ readyState: track.readyState
6950
+ }); })
6951
+ }); };
6941
6952
  var persistedKeys = ['type', 'id', 'timestamp'];
6942
6953
  /**
6943
6954
  * Check to see if the report consists of more than just the persisted metadata.
@@ -7032,6 +7043,7 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7032
7043
  var trace = function (name, payload, timestamp) {
7033
7044
  logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
7034
7045
  };
7046
+ var origPeerConnection = window.RTCPeerConnection;
7035
7047
  pc.addEventListener('icecandidate', function (e) {
7036
7048
  if (e.candidate) {
7037
7049
  trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
@@ -7064,6 +7076,139 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7064
7076
  pc.addEventListener('datachannel', function (event) {
7065
7077
  trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
7066
7078
  });
7079
+ ['createDataChannel', 'close'].forEach(function (method) {
7080
+ var nativeMethod = origPeerConnection.prototype[method];
7081
+ if (nativeMethod) {
7082
+ origPeerConnection.prototype[method] = function () {
7083
+ trace(method, makeEvent(method));
7084
+ return nativeMethod.apply(this, arguments);
7085
+ };
7086
+ }
7087
+ });
7088
+ ['addStream', 'removeStream'].forEach(function (method) {
7089
+ var nativeMethod = origPeerConnection.prototype[method];
7090
+ if (nativeMethod) {
7091
+ origPeerConnection.prototype[method] = function () {
7092
+ var stream = arguments[0];
7093
+ var streamInfo = stream
7094
+ .getTracks()
7095
+ .map(function (t) { return "".concat(t.kind, ":").concat(t.id); })
7096
+ .join(',');
7097
+ trace(method, makeEvent("".concat(stream.id, " ").concat(streamInfo)));
7098
+ return nativeMethod.apply(this, arguments);
7099
+ };
7100
+ }
7101
+ });
7102
+ ['addTrack'].forEach(function (method) {
7103
+ var nativeMethod = origPeerConnection.prototype[method];
7104
+ if (nativeMethod) {
7105
+ origPeerConnection.prototype[method] = function () {
7106
+ var track = arguments[0];
7107
+ var streams = [].slice.call(arguments, 1);
7108
+ trace(method, makeEvent("".concat(track.kind, ":").concat(track.id, " ").concat(streams.map(function (s) { return "stream:".concat(s.id); }).join(';') || '-')));
7109
+ return nativeMethod.apply(this, arguments);
7110
+ };
7111
+ }
7112
+ });
7113
+ ['removeTrack'].forEach(function (method) {
7114
+ var nativeMethod = origPeerConnection.prototype[method];
7115
+ if (nativeMethod) {
7116
+ origPeerConnection.prototype[method] = function () {
7117
+ var track = arguments[0].track;
7118
+ trace(method, makeEvent(track ? "".concat(track.kind, ":").concat(track.id) : 'null'));
7119
+ return nativeMethod.apply(this, arguments);
7120
+ };
7121
+ }
7122
+ });
7123
+ ['createOffer', 'createAnswer'].forEach(function (method) {
7124
+ var nativeMethod = origPeerConnection.prototype[method];
7125
+ if (nativeMethod) {
7126
+ origPeerConnection.prototype[method] = function () {
7127
+ var opts;
7128
+ var args = arguments;
7129
+ if (arguments.length === 1 && typeof arguments[0] === 'object') {
7130
+ // eslint-disable-next-line prefer-destructuring
7131
+ opts = arguments[0];
7132
+ }
7133
+ else if (arguments.length === 3 && typeof arguments[2] === 'object') {
7134
+ // eslint-disable-next-line prefer-destructuring
7135
+ opts = arguments[2];
7136
+ }
7137
+ trace(method, makeEvent(opts || ''));
7138
+ return nativeMethod.apply(this, opts ? [opts] : undefined).then(function (description) {
7139
+ trace("".concat(method, "OnSuccess"), makeEvent(description.sdp));
7140
+ if (args.length > 0 && typeof args[0] === 'function') {
7141
+ args[0].apply(null, [description]);
7142
+ return undefined;
7143
+ }
7144
+ return description;
7145
+ }, function (err) {
7146
+ trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
7147
+ if (args.length > 1 && typeof args[1] === 'function') {
7148
+ args[1].apply(null, [err]);
7149
+ return;
7150
+ }
7151
+ throw err;
7152
+ });
7153
+ };
7154
+ }
7155
+ });
7156
+ ['setLocalDescription', 'setRemoteDescription', 'addIceCandidate'].forEach(function (method) {
7157
+ var nativeMethod = origPeerConnection.prototype[method];
7158
+ if (nativeMethod) {
7159
+ origPeerConnection.prototype[method] = function () {
7160
+ var args = arguments;
7161
+ trace(method, makeEvent(method === 'addIceCandidate' ? arguments[0] : arguments[0].sdp));
7162
+ return nativeMethod.apply(this, [arguments[0]]).then(function () {
7163
+ trace("".concat(method, "OnSuccess"), makeEvent('success'));
7164
+ if (args.length >= 2 && typeof args[1] === 'function') {
7165
+ args[1].apply(null, []);
7166
+ return undefined;
7167
+ }
7168
+ return undefined;
7169
+ }, function (err) {
7170
+ trace("".concat(method, "OnFailure"), makeEvent(err.toString()));
7171
+ if (args.length >= 3 && typeof args[2] === 'function') {
7172
+ args[2].apply(null, [err]);
7173
+ return undefined;
7174
+ }
7175
+ throw err;
7176
+ });
7177
+ };
7178
+ }
7179
+ });
7180
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
7181
+ var origGetUserMedia_1 = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);
7182
+ var gum = function () {
7183
+ trace('navigator.mediaDevices.getUserMedia', makeEvent(JSON.stringify(arguments[0])));
7184
+ return origGetUserMedia_1
7185
+ .apply(navigator.mediaDevices, arguments)
7186
+ .then(function (stream) {
7187
+ trace('navigator.mediaDevices.getUserMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
7188
+ return stream;
7189
+ }, function (err) {
7190
+ trace('navigator.mediaDevices.getUserMediaOnFailure', makeEvent(err.name));
7191
+ return Promise.reject(err);
7192
+ });
7193
+ };
7194
+ navigator.mediaDevices.getUserMedia = gum.bind(navigator.mediaDevices);
7195
+ }
7196
+ if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
7197
+ var origGetDisplayMedia_1 = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
7198
+ var gdm = function () {
7199
+ trace('navigator.mediaDevices.getDisplayMedia', makeEvent(JSON.stringify(arguments[0])));
7200
+ return origGetDisplayMedia_1
7201
+ .apply(navigator.mediaDevices, arguments)
7202
+ .then(function (stream) {
7203
+ trace('navigator.mediaDevices.getDisplayMediaOnSuccess', makeEvent(JSON.stringify(dumpStream(stream))));
7204
+ return stream;
7205
+ }, function (err) {
7206
+ trace('navigator.mediaDevices.getDisplayMediaOnFailure', makeEvent(err.name));
7207
+ return Promise.reject(err);
7208
+ });
7209
+ };
7210
+ navigator.mediaDevices.getDisplayMedia = gdm.bind(navigator.mediaDevices);
7211
+ }
7067
7212
  var interval = window.setInterval(function () {
7068
7213
  if (pc.signalingState === 'closed') {
7069
7214
  window.clearInterval(interval);
@@ -10273,6 +10418,7 @@ class SendOnlyTransceiver extends Transceiver {
10273
10418
  this.streamMuteStateChange = new TypedEvent();
10274
10419
  this.streamPublishStateChange = new TypedEvent();
10275
10420
  this.negotiationNeeded = new TypedEvent();
10421
+ this.namedMediaGroupsChange = new TypedEvent();
10276
10422
  this.requested = false;
10277
10423
  this.requestedIdEncodingParamsMap = new Map();
10278
10424
  this.csi = csi;
@@ -10347,6 +10493,13 @@ class SendOnlyTransceiver extends Transceiver {
10347
10493
  }
10348
10494
  });
10349
10495
  }
10496
+ setNamedMediaGroups(namedMediaGroups) {
10497
+ if (this.mediaType !== MediaType.AudioMain) {
10498
+ throw new Error(`This interface does not allow media types other than AudioMain: ${this.mediaType}`);
10499
+ }
10500
+ this.namedMediaGroups = namedMediaGroups;
10501
+ this.namedMediaGroupsChange.emit();
10502
+ }
10350
10503
  publishStream(stream) {
10351
10504
  return this.replacePublishedStream(stream);
10352
10505
  }
@@ -10450,6 +10603,9 @@ class SendSlot {
10450
10603
  return this.sendTransceiver.unpublishStream();
10451
10604
  });
10452
10605
  }
10606
+ setNamedMediaGroups(namedMediaGroups) {
10607
+ this.sendTransceiver.setNamedMediaGroups(namedMediaGroups);
10608
+ }
10453
10609
  get active() {
10454
10610
  return this.sendTransceiver.active;
10455
10611
  }
@@ -13889,6 +14045,9 @@ class MultistreamConnection extends EventEmitter$2 {
13889
14045
  this.queueLocalOfferAnswer();
13890
14046
  }
13891
14047
  });
14048
+ transceiver.namedMediaGroupsChange.on(() => {
14049
+ this.sendSourceAdvertisement(mediaType);
14050
+ });
13892
14051
  this.sendTransceivers.set(mediaType, transceiver);
13893
14052
  this.createJmpSession(mediaType);
13894
14053
  }
@@ -14078,7 +14237,11 @@ class MultistreamConnection extends EventEmitter$2 {
14078
14237
  };
14079
14238
  }
14080
14239
  else {
14081
- task = () => { var _a; return (_a = this.jmpSessions.get(mediaType)) === null || _a === void 0 ? void 0 : _a.sendSourceAdvertisement(1, numLiveSources); };
14240
+ task = () => {
14241
+ var _a;
14242
+ return (_a = this.jmpSessions
14243
+ .get(mediaType)) === null || _a === void 0 ? void 0 : _a.sendSourceAdvertisement(1, numLiveSources, mediaType === MediaType.AudioMain ? transceiver.namedMediaGroups : []);
14244
+ };
14082
14245
  }
14083
14246
  if (((_b = this.dataChannel) === null || _b === void 0 ? void 0 : _b.readyState) === 'open') {
14084
14247
  task();