@stream-io/video-client 1.16.4 → 1.16.6
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 +30 -19
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +30 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +30 -19
- package/dist/index.es.js.map +1 -1
- package/dist/src/rtc/Publisher.d.ts +3 -0
- package/package.json +1 -1
- package/src/devices/CameraManager.ts +7 -10
- package/src/rtc/Publisher.ts +23 -6
- package/src/rtc/__tests__/Publisher.test.ts +19 -2
package/dist/index.cjs.js
CHANGED
|
@@ -5686,6 +5686,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5686
5686
|
constructor({ publishOptions, ...baseOptions }) {
|
|
5687
5687
|
super(PeerType.PUBLISHER_UNSPECIFIED, baseOptions);
|
|
5688
5688
|
this.transceiverCache = new TransceiverCache();
|
|
5689
|
+
this.clonedTracks = new Set();
|
|
5689
5690
|
/**
|
|
5690
5691
|
* Starts publishing the given track of the given media stream.
|
|
5691
5692
|
*
|
|
@@ -5704,7 +5705,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5704
5705
|
continue;
|
|
5705
5706
|
// create a clone of the track as otherwise the same trackId will
|
|
5706
5707
|
// appear in the SDP in multiple transceivers
|
|
5707
|
-
const trackToPublish =
|
|
5708
|
+
const trackToPublish = this.cloneTrack(track);
|
|
5708
5709
|
const transceiver = this.transceiverCache.get(publishOption);
|
|
5709
5710
|
if (!transceiver) {
|
|
5710
5711
|
this.addTransceiver(trackToPublish, publishOption);
|
|
@@ -5712,7 +5713,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5712
5713
|
else {
|
|
5713
5714
|
const previousTrack = transceiver.sender.track;
|
|
5714
5715
|
await transceiver.sender.replaceTrack(trackToPublish);
|
|
5715
|
-
previousTrack
|
|
5716
|
+
this.stopTrack(previousTrack);
|
|
5716
5717
|
}
|
|
5717
5718
|
}
|
|
5718
5719
|
};
|
|
@@ -5749,7 +5750,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5749
5750
|
continue;
|
|
5750
5751
|
// take the track from the existing transceiver for the same track type,
|
|
5751
5752
|
// clone it and publish it with the new publish options
|
|
5752
|
-
const track = item.transceiver.sender.track
|
|
5753
|
+
const track = this.cloneTrack(item.transceiver.sender.track);
|
|
5753
5754
|
this.addTransceiver(track, publishOption);
|
|
5754
5755
|
}
|
|
5755
5756
|
// stop publishing with options not required anymore -> [vp9]
|
|
@@ -5760,7 +5761,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5760
5761
|
if (hasPublishOption)
|
|
5761
5762
|
continue;
|
|
5762
5763
|
// it is safe to stop the track here, it is a clone
|
|
5763
|
-
transceiver.sender.track
|
|
5764
|
+
this.stopTrack(transceiver.sender.track);
|
|
5764
5765
|
await transceiver.sender.replaceTrack(null);
|
|
5765
5766
|
}
|
|
5766
5767
|
};
|
|
@@ -5801,7 +5802,7 @@ class Publisher extends BasePeerConnection {
|
|
|
5801
5802
|
const { publishOption, transceiver } = item;
|
|
5802
5803
|
if (!trackTypes.includes(publishOption.trackType))
|
|
5803
5804
|
continue;
|
|
5804
|
-
transceiver.sender.track
|
|
5805
|
+
this.stopTrack(transceiver.sender.track);
|
|
5805
5806
|
}
|
|
5806
5807
|
};
|
|
5807
5808
|
/**
|
|
@@ -5809,7 +5810,10 @@ class Publisher extends BasePeerConnection {
|
|
|
5809
5810
|
*/
|
|
5810
5811
|
this.stopAllTracks = () => {
|
|
5811
5812
|
for (const { transceiver } of this.transceiverCache.items()) {
|
|
5812
|
-
transceiver.sender.track
|
|
5813
|
+
this.stopTrack(transceiver.sender.track);
|
|
5814
|
+
}
|
|
5815
|
+
for (const track of this.clonedTracks) {
|
|
5816
|
+
this.stopTrack(track);
|
|
5813
5817
|
}
|
|
5814
5818
|
};
|
|
5815
5819
|
this.changePublishQuality = async (videoSender) => {
|
|
@@ -5989,6 +5993,17 @@ class Publisher extends BasePeerConnection {
|
|
|
5989
5993
|
publishOptionId: publishOption.id,
|
|
5990
5994
|
};
|
|
5991
5995
|
};
|
|
5996
|
+
this.cloneTrack = (track) => {
|
|
5997
|
+
const clone = track.clone();
|
|
5998
|
+
this.clonedTracks.add(clone);
|
|
5999
|
+
return clone;
|
|
6000
|
+
};
|
|
6001
|
+
this.stopTrack = (track) => {
|
|
6002
|
+
if (!track)
|
|
6003
|
+
return;
|
|
6004
|
+
track.stop();
|
|
6005
|
+
this.clonedTracks.delete(track);
|
|
6006
|
+
};
|
|
5992
6007
|
this.publishOptions = publishOptions;
|
|
5993
6008
|
this.pc.addEventListener('negotiationneeded', this.onNegotiationNeeded);
|
|
5994
6009
|
this.on('iceRestart', (iceRestart) => {
|
|
@@ -6026,6 +6041,7 @@ class Publisher extends BasePeerConnection {
|
|
|
6026
6041
|
dispose() {
|
|
6027
6042
|
super.dispose();
|
|
6028
6043
|
this.stopAllTracks();
|
|
6044
|
+
this.clonedTracks.clear();
|
|
6029
6045
|
}
|
|
6030
6046
|
}
|
|
6031
6047
|
|
|
@@ -7450,7 +7466,7 @@ const aggregate = (stats) => {
|
|
|
7450
7466
|
return report;
|
|
7451
7467
|
};
|
|
7452
7468
|
|
|
7453
|
-
const version = "1.16.
|
|
7469
|
+
const version = "1.16.6";
|
|
7454
7470
|
const [major, minor, patch] = version.split('.');
|
|
7455
7471
|
let sdkInfo = {
|
|
7456
7472
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -9309,19 +9325,14 @@ class CameraManager extends InputMediaDeviceManager {
|
|
|
9309
9325
|
if (this.isDirectionSupportedByDevice()) {
|
|
9310
9326
|
if (isReactNative()) {
|
|
9311
9327
|
const videoTrack = this.getTracks()[0];
|
|
9312
|
-
if (!videoTrack)
|
|
9328
|
+
if (!videoTrack) {
|
|
9329
|
+
this.logger('warn', 'No video track found to do direction selection');
|
|
9313
9330
|
return;
|
|
9314
|
-
// @ts-expect-error _switchCamera() is only present in react-native-webrtc 124 and below
|
|
9315
|
-
if (typeof videoTrack._switchCamera === 'function') {
|
|
9316
|
-
// @ts-expect-error for older versions of react-native-webrtc support
|
|
9317
|
-
videoTrack._switchCamera();
|
|
9318
|
-
}
|
|
9319
|
-
else {
|
|
9320
|
-
const constraints = {
|
|
9321
|
-
facingMode: direction === 'front' ? 'user' : 'environment',
|
|
9322
|
-
};
|
|
9323
|
-
await videoTrack.applyConstraints(constraints);
|
|
9324
9331
|
}
|
|
9332
|
+
const constraints = {
|
|
9333
|
+
facingMode: direction === 'front' ? 'user' : 'environment',
|
|
9334
|
+
};
|
|
9335
|
+
await videoTrack.applyConstraints(constraints);
|
|
9325
9336
|
this.state.setDirection(direction);
|
|
9326
9337
|
this.state.setDevice(undefined);
|
|
9327
9338
|
}
|
|
@@ -13056,7 +13067,7 @@ class StreamClient {
|
|
|
13056
13067
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
13057
13068
|
};
|
|
13058
13069
|
this.getUserAgent = () => {
|
|
13059
|
-
const version = "1.16.
|
|
13070
|
+
const version = "1.16.6";
|
|
13060
13071
|
return (this.userAgent ||
|
|
13061
13072
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
13062
13073
|
};
|