@stream-io/video-client 0.0.41 → 0.0.43
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/CHANGELOG.md +14 -0
- package/dist/index.browser.es.js +40 -6
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +40 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +40 -6
- package/dist/index.es.js.map +1 -1
- package/dist/src/rtc/Publisher.d.ts +12 -0
- package/dist/src/rtc/Subscriber.d.ts +4 -0
- package/package.json +1 -1
- package/src/rtc/Publisher.ts +42 -9
- package/src/rtc/Subscriber.ts +8 -0
package/dist/index.es.js
CHANGED
|
@@ -6056,6 +6056,14 @@ class Publisher {
|
|
|
6056
6056
|
[TrackType.SCREEN_SHARE_AUDIO]: undefined,
|
|
6057
6057
|
[TrackType.UNSPECIFIED]: undefined,
|
|
6058
6058
|
};
|
|
6059
|
+
/**
|
|
6060
|
+
* An array maintaining the order how transceivers were added to the peer connection.
|
|
6061
|
+
* This is needed because some browsers (Firefox) don't reliably report
|
|
6062
|
+
* trackId and `mid` parameters.
|
|
6063
|
+
*
|
|
6064
|
+
* @private
|
|
6065
|
+
*/
|
|
6066
|
+
this.transceiverInitOrder = [];
|
|
6059
6067
|
this.trackKindMapping = {
|
|
6060
6068
|
[TrackType.AUDIO]: 'audio',
|
|
6061
6069
|
[TrackType.VIDEO]: 'video',
|
|
@@ -6149,6 +6157,8 @@ class Publisher {
|
|
|
6149
6157
|
: undefined,
|
|
6150
6158
|
sendEncodings: videoEncodings,
|
|
6151
6159
|
});
|
|
6160
|
+
this.logger('debug', `Added ${TrackType[trackType]} transceiver`);
|
|
6161
|
+
this.transceiverInitOrder.push(trackType);
|
|
6152
6162
|
this.transceiverRegistry[trackType] = transceiver;
|
|
6153
6163
|
if ('setCodecPreferences' in transceiver && codecPreferences) {
|
|
6154
6164
|
this.logger('info', `Setting ${TrackType[trackType]} codec preferences`, codecPreferences);
|
|
@@ -6308,6 +6318,13 @@ class Publisher {
|
|
|
6308
6318
|
yield this.negotiate({ iceRestart: true });
|
|
6309
6319
|
}
|
|
6310
6320
|
});
|
|
6321
|
+
/**
|
|
6322
|
+
* Restarts the ICE connection and renegotiates with the SFU.
|
|
6323
|
+
*/
|
|
6324
|
+
this.restartIce = () => {
|
|
6325
|
+
this.logger('debug', 'Restarting ICE connection');
|
|
6326
|
+
this.pc.restartIce();
|
|
6327
|
+
};
|
|
6311
6328
|
this.onNegotiationNeeded = () => __awaiter(this, void 0, void 0, function* () {
|
|
6312
6329
|
yield this.negotiate();
|
|
6313
6330
|
});
|
|
@@ -6371,14 +6388,14 @@ class Publisher {
|
|
|
6371
6388
|
this.getCurrentTrackInfos = (sdp) => {
|
|
6372
6389
|
var _a;
|
|
6373
6390
|
sdp = sdp || ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp);
|
|
6374
|
-
const extractMid = (defaultMid, track) => {
|
|
6391
|
+
const extractMid = (defaultMid, track, trackType) => {
|
|
6375
6392
|
if (defaultMid)
|
|
6376
6393
|
return defaultMid;
|
|
6377
6394
|
if (!sdp) {
|
|
6378
6395
|
this.logger('warn', 'No SDP found. Returning empty mid');
|
|
6379
6396
|
return '';
|
|
6380
6397
|
}
|
|
6381
|
-
this.logger('
|
|
6398
|
+
this.logger('debug', `No 'mid' found for track. Trying to find it from the Offer SDP`);
|
|
6382
6399
|
const parsedSdp = SDP.parse(sdp);
|
|
6383
6400
|
const media = parsedSdp.media.find((m) => {
|
|
6384
6401
|
var _a, _b;
|
|
@@ -6387,7 +6404,12 @@ class Publisher {
|
|
|
6387
6404
|
((_b = (_a = m.msid) === null || _a === void 0 ? void 0 : _a.includes(track.id)) !== null && _b !== void 0 ? _b : true));
|
|
6388
6405
|
});
|
|
6389
6406
|
if (typeof (media === null || media === void 0 ? void 0 : media.mid) === 'undefined') {
|
|
6390
|
-
this.logger('
|
|
6407
|
+
this.logger('debug', `No mid found in SDP for track type ${track.kind} and id ${track.id}. Attempting to find a heuristic mid`);
|
|
6408
|
+
const heuristicMid = this.transceiverInitOrder.indexOf(trackType);
|
|
6409
|
+
if (heuristicMid !== -1) {
|
|
6410
|
+
return String(heuristicMid);
|
|
6411
|
+
}
|
|
6412
|
+
this.logger('debug', 'No heuristic mid found. Returning empty mid');
|
|
6391
6413
|
return '';
|
|
6392
6414
|
}
|
|
6393
6415
|
return String(media.mid);
|
|
@@ -6429,7 +6451,7 @@ class Publisher {
|
|
|
6429
6451
|
trackId: track.id,
|
|
6430
6452
|
layers: layers,
|
|
6431
6453
|
trackType,
|
|
6432
|
-
mid: extractMid(transceiver.mid, track),
|
|
6454
|
+
mid: extractMid(transceiver.mid, track, trackType),
|
|
6433
6455
|
// FIXME OL: adjust these values
|
|
6434
6456
|
stereo: false,
|
|
6435
6457
|
dtx: TrackType.AUDIO === trackType && this.isDtxEnabled,
|
|
@@ -6443,7 +6465,12 @@ class Publisher {
|
|
|
6443
6465
|
this.logger('error', `ICE Candidate error`, errorMessage);
|
|
6444
6466
|
};
|
|
6445
6467
|
this.onIceConnectionStateChange = () => {
|
|
6446
|
-
|
|
6468
|
+
const state = this.pc.iceConnectionState;
|
|
6469
|
+
this.logger('debug', `ICE Connection state changed`, state);
|
|
6470
|
+
if (state === 'failed' || state === 'disconnected') {
|
|
6471
|
+
this.logger('warn', `ICE Connection state changed to ${state}. Attempting to restart ICE`);
|
|
6472
|
+
this.restartIce();
|
|
6473
|
+
}
|
|
6447
6474
|
};
|
|
6448
6475
|
this.onIceGatheringStateChange = () => {
|
|
6449
6476
|
this.logger('debug', `ICE Gathering State`, this.pc.iceGatheringState);
|
|
@@ -6570,6 +6597,13 @@ class Subscriber {
|
|
|
6570
6597
|
// replace the PeerConnection instance
|
|
6571
6598
|
this.pc = pc;
|
|
6572
6599
|
};
|
|
6600
|
+
/**
|
|
6601
|
+
* Restarts the ICE connection and renegotiates with the SFU.
|
|
6602
|
+
*/
|
|
6603
|
+
this.restartIce = () => {
|
|
6604
|
+
logger$1('debug', 'Restarting ICE connection');
|
|
6605
|
+
this.pc.restartIce();
|
|
6606
|
+
};
|
|
6573
6607
|
this.handleOnTrack = (e) => {
|
|
6574
6608
|
const [primaryStream] = e.streams;
|
|
6575
6609
|
// example: `e3f6aaf8-b03d-4911-be36-83f47d37a76a:TRACK_TYPE_VIDEO`
|
|
@@ -11757,7 +11791,7 @@ class StreamClient {
|
|
|
11757
11791
|
};
|
|
11758
11792
|
this.getUserAgent = () => {
|
|
11759
11793
|
return (this.userAgent ||
|
|
11760
|
-
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.
|
|
11794
|
+
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.42"}`);
|
|
11761
11795
|
};
|
|
11762
11796
|
this.setUserAgent = (userAgent) => {
|
|
11763
11797
|
this.userAgent = userAgent;
|