@webex/web-client-media-engine 2.0.3 → 2.0.4

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
@@ -9067,22 +9067,6 @@ DefaultSdpGrammar.addParser('a', JmpLine.fromSdpLine);
9067
9067
  DefaultSdpGrammar.addParser('a', JmpSourceLine.fromSdpLine);
9068
9068
  DefaultSdpGrammar.addParser('a', JmpStreamIdModeLine.fromSdpLine);
9069
9069
 
9070
- function deepCopy(source) {
9071
- return Array.isArray(source)
9072
- ? source.map((item) => deepCopy(item))
9073
- : source instanceof Map
9074
- ? new Map(source)
9075
- : source instanceof Date
9076
- ? new Date(source.getTime())
9077
- : source && typeof source === 'object'
9078
- ? Object.getOwnPropertyNames(source).reduce((o, prop) => {
9079
- Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop));
9080
- o[prop] = deepCopy(source[prop]);
9081
- return o;
9082
- }, Object.create(Object.getPrototypeOf(source)))
9083
- : source;
9084
- }
9085
-
9086
9070
  function getMediaTypeForMline(mLine) {
9087
9071
  var _a, _b;
9088
9072
  let mediaFamily;
@@ -9152,42 +9136,6 @@ function filterRecvOnlyMlines(parsedSdp) {
9152
9136
  g.mids = g.mids.filter((m) => filteredMids.includes(m));
9153
9137
  });
9154
9138
  }
9155
- function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
9156
- parsedAnswer.session.groups = parsedOffer.session.groups;
9157
- parsedAnswer.media = parsedOffer.media.map((offerMline) => {
9158
- if (!offerMline.mid) {
9159
- throw new Error(`Offer mline is missing MID`);
9160
- }
9161
- const answerMline = parsedAnswer.media.find((m) => m.mid === offerMline.mid);
9162
- if (answerMline) {
9163
- if (answerMline instanceof AvMediaDescription) {
9164
- [...answerMline.codecs.values()].forEach((ci) => {
9165
- ci.fmtParams.set('x-google-start-bitrate', '60000');
9166
- });
9167
- }
9168
- return answerMline;
9169
- }
9170
- if (!(offerMline instanceof AvMediaDescription)) {
9171
- throw new Error(`Answer is missing a non-media mline: ${offerMline.mid}`);
9172
- }
9173
- const startingMline = parsedAnswer.avMedia.find((m) => m.type === offerMline.type);
9174
- if (!startingMline) {
9175
- throw new Error(`Answer has no mline of type ${offerMline.type}, can't generate synthetic answer mline for mid ${offerMline.mid}`);
9176
- }
9177
- const fakeCorrespondingMline = deepCopy(startingMline);
9178
- fakeCorrespondingMline.mid = offerMline.mid;
9179
- fakeCorrespondingMline.simulcast = undefined;
9180
- if (offerMline.direction === 'sendrecv' || offerMline.direction === 'sendonly') {
9181
- fakeCorrespondingMline.direction = 'recvonly';
9182
- }
9183
- if (offerMline.direction === 'recvonly') {
9184
- fakeCorrespondingMline.direction = 'sendonly';
9185
- const ingressSignaler = streamSignalerManager.getIngressStreamSignalerOrThrow(offerMline.mid);
9186
- ingressSignaler.signalRemoteStreams(fakeCorrespondingMline);
9187
- }
9188
- return fakeCorrespondingMline;
9189
- });
9190
- }
9191
9139
  function injectContentTypes(sdp, contentTypeMap) {
9192
9140
  contentTypeMap.forEach((mediaContent, mid) => {
9193
9141
  const mline = sdp.media.find((m) => m.mid === mid);
@@ -9221,6 +9169,14 @@ function injectJmpAttributes(parsedSdp, csiMap, streamSignalingMode) {
9221
9169
  }
9222
9170
  function hasSimulcast(av) {
9223
9171
  return !!av.simulcast || av.ssrcGroups.map((sg) => sg.semantics).some((sem) => sem === 'SIM');
9172
+ }
9173
+ function addVlaExtension(mLine) {
9174
+ const vlaUri = 'http://www.webrtc.org/experiments/rtp-hdrext/video-layers-allocation00';
9175
+ if (mLine.extMaps.findIndex((extMapLine) => extMapLine.uri === vlaUri) === -1) {
9176
+ const maxIdValue = Math.max(...mLine.extMaps.map((extMapLine) => extMapLine.id), 0);
9177
+ const videoLayersAllocationLine = new ExtMapLine(maxIdValue + 1, vlaUri, undefined);
9178
+ mLine.extMaps.push(videoLayersAllocationLine);
9179
+ }
9224
9180
  }
9225
9181
 
9226
9182
  class SendOnlyTransceiver extends Transceiver {
@@ -9382,6 +9338,7 @@ class RidEgressStreamSignaler {
9382
9338
  if (simulcastEnabled) {
9383
9339
  mLine.rids = this.streamIds.map((streamId, index) => new RidLine(streamId.rid, 'send', `max-fs=${simulcastMaxFrameSizes[index]}`));
9384
9340
  mLine.simulcast = new SimulcastLine(SimulcastLayerList.fromString('low;medium;high'), new SimulcastLayerList());
9341
+ addVlaExtension(mLine);
9385
9342
  }
9386
9343
  }
9387
9344
  getSenderIds() {
@@ -9488,6 +9445,7 @@ class SsrcEgressStreamSignaler {
9488
9445
  });
9489
9446
  if (simulcastEnabled) {
9490
9447
  mLine.addLine(new SsrcGroupLine('SIM', this.streamIds.map((streamId) => streamId.ssrc)));
9448
+ addVlaExtension(mLine);
9491
9449
  }
9492
9450
  }
9493
9451
  getSenderIds() {
@@ -13143,6 +13101,59 @@ function setLogHandler(logHandler) {
13143
13101
  Logger$2.setHandler(logHandler);
13144
13102
  }
13145
13103
 
13104
+ function deepCopy(source) {
13105
+ return Array.isArray(source)
13106
+ ? source.map((item) => deepCopy(item))
13107
+ : source instanceof Map
13108
+ ? new Map(source)
13109
+ : source instanceof Date
13110
+ ? new Date(source.getTime())
13111
+ : source && typeof source === 'object'
13112
+ ? Object.getOwnPropertyNames(source).reduce((o, prop) => {
13113
+ Object.defineProperty(o, prop, Object.getOwnPropertyDescriptor(source, prop));
13114
+ o[prop] = deepCopy(source[prop]);
13115
+ return o;
13116
+ }, Object.create(Object.getPrototypeOf(source)))
13117
+ : source;
13118
+ }
13119
+
13120
+ function matchMlinesInAnswer(parsedOffer, parsedAnswer, streamSignalerManager) {
13121
+ parsedAnswer.session.groups = parsedOffer.session.groups;
13122
+ parsedAnswer.media = parsedOffer.media.map((offerMline) => {
13123
+ if (!offerMline.mid) {
13124
+ throw new Error(`Offer mline is missing MID`);
13125
+ }
13126
+ const answerMline = parsedAnswer.media.find((m) => m.mid === offerMline.mid);
13127
+ if (answerMline) {
13128
+ if (answerMline instanceof AvMediaDescription) {
13129
+ [...answerMline.codecs.values()].forEach((ci) => {
13130
+ ci.fmtParams.set('x-google-start-bitrate', '60000');
13131
+ });
13132
+ }
13133
+ return answerMline;
13134
+ }
13135
+ if (!(offerMline instanceof AvMediaDescription)) {
13136
+ throw new Error(`Answer is missing a non-media mline: ${offerMline.mid}`);
13137
+ }
13138
+ const startingMline = parsedAnswer.avMedia.find((m) => m.type === offerMline.type);
13139
+ if (!startingMline) {
13140
+ throw new Error(`Answer has no mline of type ${offerMline.type}, can't generate synthetic answer mline for mid ${offerMline.mid}`);
13141
+ }
13142
+ const fakeCorrespondingMline = deepCopy(startingMline);
13143
+ fakeCorrespondingMline.mid = offerMline.mid;
13144
+ fakeCorrespondingMline.simulcast = undefined;
13145
+ if (offerMline.direction === 'sendrecv' || offerMline.direction === 'sendonly') {
13146
+ fakeCorrespondingMline.direction = 'recvonly';
13147
+ }
13148
+ if (offerMline.direction === 'recvonly') {
13149
+ fakeCorrespondingMline.direction = 'sendonly';
13150
+ const ingressSignaler = streamSignalerManager.getIngressStreamSignalerOrThrow(offerMline.mid);
13151
+ ingressSignaler.signalRemoteStreams(fakeCorrespondingMline);
13152
+ }
13153
+ return fakeCorrespondingMline;
13154
+ });
13155
+ }
13156
+
13146
13157
  function toMediaStreamTrackKind(mediaType) {
13147
13158
  return [MediaType.VideoMain, MediaType.VideoSlides].includes(mediaType)
13148
13159
  ? MediaStreamTrackKind.Video