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

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);