@stream-io/video-client 0.0.41 → 0.0.42

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.
@@ -18,6 +18,14 @@ export declare class Publisher {
18
18
  private pc;
19
19
  private readonly state;
20
20
  private readonly transceiverRegistry;
21
+ /**
22
+ * An array maintaining the order how transceivers were added to the peer connection.
23
+ * This is needed because some browsers (Firefox) don't reliably report
24
+ * trackId and `mid` parameters.
25
+ *
26
+ * @private
27
+ */
28
+ private transceiverInitOrder;
21
29
  private readonly trackKindMapping;
22
30
  private readonly trackLayersCache;
23
31
  private readonly isDtxEnabled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
@@ -55,6 +55,14 @@ export class Publisher {
55
55
  [TrackType.SCREEN_SHARE_AUDIO]: undefined,
56
56
  [TrackType.UNSPECIFIED]: undefined,
57
57
  };
58
+ /**
59
+ * An array maintaining the order how transceivers were added to the peer connection.
60
+ * This is needed because some browsers (Firefox) don't reliably report
61
+ * trackId and `mid` parameters.
62
+ *
63
+ * @private
64
+ */
65
+ private transceiverInitOrder: TrackType[] = [];
58
66
 
59
67
  private readonly trackKindMapping: {
60
68
  [key in TrackType]: 'video' | 'audio' | undefined;
@@ -225,6 +233,8 @@ export class Publisher {
225
233
  sendEncodings: videoEncodings,
226
234
  });
227
235
 
236
+ this.logger('debug', `Added ${TrackType[trackType]} transceiver`);
237
+ this.transceiverInitOrder.push(trackType);
228
238
  this.transceiverRegistry[trackType] = transceiver;
229
239
 
230
240
  if ('setCodecPreferences' in transceiver && codecPreferences) {
@@ -522,6 +532,7 @@ export class Publisher {
522
532
  const extractMid = (
523
533
  defaultMid: string | null,
524
534
  track: MediaStreamTrack,
535
+ trackType: TrackType,
525
536
  ): string => {
526
537
  if (defaultMid) return defaultMid;
527
538
  if (!sdp) {
@@ -529,7 +540,10 @@ export class Publisher {
529
540
  return '';
530
541
  }
531
542
 
532
- this.logger('warn', 'No mid found for track. Trying to find it from SDP');
543
+ this.logger(
544
+ 'debug',
545
+ `No 'mid' found for track. Trying to find it from the Offer SDP`,
546
+ );
533
547
 
534
548
  const parsedSdp = SDP.parse(sdp);
535
549
  const media = parsedSdp.media.find((m) => {
@@ -541,9 +555,16 @@ export class Publisher {
541
555
  });
542
556
  if (typeof media?.mid === 'undefined') {
543
557
  this.logger(
544
- 'warn',
545
- `No mid found in SDP for track type ${track.kind} and id ${track.id}`,
558
+ 'debug',
559
+ `No mid found in SDP for track type ${track.kind} and id ${track.id}. Attempting to find a heuristic mid`,
546
560
  );
561
+
562
+ const heuristicMid = this.transceiverInitOrder.indexOf(trackType);
563
+ if (heuristicMid !== -1) {
564
+ return String(heuristicMid);
565
+ }
566
+
567
+ this.logger('debug', 'No heuristic mid found. Returning empty mid');
547
568
  return '';
548
569
  }
549
570
  return String(media.mid);
@@ -596,7 +617,7 @@ export class Publisher {
596
617
  trackId: track.id,
597
618
  layers: layers,
598
619
  trackType,
599
- mid: extractMid(transceiver.mid, track),
620
+ mid: extractMid(transceiver.mid, track, trackType),
600
621
 
601
622
  // FIXME OL: adjust these values
602
623
  stereo: false,