@fishjam-cloud/ts-client 0.8.1 → 0.9.0
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/src/FishjamClient.d.ts +1 -2
- package/dist/src/FishjamClient.js +2 -3
- package/dist/src/webrtc/ConnectionManager.d.ts +1 -0
- package/dist/src/webrtc/ConnectionManager.js +8 -2
- package/dist/src/webrtc/tracks/Local.js +10 -4
- package/dist/src/webrtc/tracks/LocalTrack.d.ts +1 -2
- package/dist/src/webrtc/tracks/LocalTrack.js +1 -8
- package/dist/src/webrtc/tracks/Remote.d.ts +1 -1
- package/dist/src/webrtc/webRTCEndpoint.js +9 -4
- package/package.json +2 -2
|
@@ -315,7 +315,6 @@ export declare class FishjamClient<PeerMetadata, TrackMetadata> extends FishjamC
|
|
|
315
315
|
* ```
|
|
316
316
|
*
|
|
317
317
|
* @param track - Audio or video track e.g. from your microphone or camera.
|
|
318
|
-
* @param stream - Stream that this track belongs to.
|
|
319
318
|
* @param trackMetadata - Any information about this track that other peers will receive in
|
|
320
319
|
* {@link MessageEvents.peerJoined}. E.g. this can source of the track - wheather it's screensharing, webcam or some
|
|
321
320
|
* other media device.
|
|
@@ -462,7 +461,7 @@ export declare class FishjamClient<PeerMetadata, TrackMetadata> extends FishjamC
|
|
|
462
461
|
* ```
|
|
463
462
|
*
|
|
464
463
|
* @param {string} trackId - Id of track
|
|
465
|
-
* @param {
|
|
464
|
+
* @param {Encoding} encoding - Encoding that will be disabled
|
|
466
465
|
*/
|
|
467
466
|
disableTrackEncoding(trackId: string, encoding: Encoding): Promise<void>;
|
|
468
467
|
/**
|
|
@@ -5,7 +5,7 @@ import { ReconnectManager } from './reconnection';
|
|
|
5
5
|
import { isAuthError } from './auth';
|
|
6
6
|
import { connectEventsHandler } from './connectEventsHandler';
|
|
7
7
|
const STATISTICS_INTERVAL = 10_000;
|
|
8
|
-
const isPeer = (endpoint) => endpoint.type === 'webrtc';
|
|
8
|
+
const isPeer = (endpoint) => endpoint.type === 'webrtc' || endpoint.type === 'exwebrtc';
|
|
9
9
|
const isComponent = (endpoint) => endpoint.type === 'recording' ||
|
|
10
10
|
endpoint.type === 'hls' ||
|
|
11
11
|
endpoint.type === 'file' ||
|
|
@@ -400,7 +400,6 @@ export class FishjamClient extends EventEmitter {
|
|
|
400
400
|
* ```
|
|
401
401
|
*
|
|
402
402
|
* @param track - Audio or video track e.g. from your microphone or camera.
|
|
403
|
-
* @param stream - Stream that this track belongs to.
|
|
404
403
|
* @param trackMetadata - Any information about this track that other peers will receive in
|
|
405
404
|
* {@link MessageEvents.peerJoined}. E.g. this can source of the track - wheather it's screensharing, webcam or some
|
|
406
405
|
* other media device.
|
|
@@ -581,7 +580,7 @@ export class FishjamClient extends EventEmitter {
|
|
|
581
580
|
* ```
|
|
582
581
|
*
|
|
583
582
|
* @param {string} trackId - Id of track
|
|
584
|
-
* @param {
|
|
583
|
+
* @param {Encoding} encoding - Encoding that will be disabled
|
|
585
584
|
*/
|
|
586
585
|
disableTrackEncoding(trackId, encoding) {
|
|
587
586
|
if (!this.webrtc)
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export class ConnectionManager {
|
|
2
2
|
connection;
|
|
3
|
+
isExWebRTC;
|
|
3
4
|
constructor(turnServers) {
|
|
5
|
+
this.isExWebRTC = turnServers.length === 0;
|
|
6
|
+
const iceServers = this.isExWebRTC
|
|
7
|
+
? [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:stun.l.google.com:5349' }]
|
|
8
|
+
: this.getIceServers(turnServers);
|
|
9
|
+
const iceTransportPolicy = this.isExWebRTC ? 'all' : 'relay';
|
|
4
10
|
this.connection = new RTCPeerConnection({
|
|
5
11
|
bundlePolicy: 'max-bundle',
|
|
6
|
-
iceServers:
|
|
7
|
-
iceTransportPolicy:
|
|
12
|
+
iceServers: iceServers,
|
|
13
|
+
iceTransportPolicy: iceTransportPolicy,
|
|
8
14
|
});
|
|
9
15
|
}
|
|
10
16
|
isConnectionUnstable = () => {
|
|
@@ -229,10 +229,16 @@ export class Local {
|
|
|
229
229
|
}), {});
|
|
230
230
|
};
|
|
231
231
|
getTrackIdToTrackBitrates = () => {
|
|
232
|
-
return Object.values(this.localTracks).reduce((previousValue, localTrack) =>
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
return Object.values(this.localTracks).reduce((previousValue, localTrack) => {
|
|
233
|
+
const bitrates = localTrack.getTrackBitrates();
|
|
234
|
+
if (bitrates) {
|
|
235
|
+
return {
|
|
236
|
+
...previousValue,
|
|
237
|
+
[localTrack.id]: bitrates,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return previousValue;
|
|
241
|
+
}, {});
|
|
236
242
|
};
|
|
237
243
|
getMidToTrackId = () => {
|
|
238
244
|
if (!this.connection)
|
|
@@ -54,9 +54,8 @@ export declare class LocalTrack<EndpointMetadata, TrackMetadata> implements Trac
|
|
|
54
54
|
setEncodingBandwidth(rid: Encoding, bandwidth: BandwidthLimit): Promise<void>;
|
|
55
55
|
updateTrackMetadata: (metadata: unknown) => void;
|
|
56
56
|
enableTrackEncoding: (encoding: Encoding) => Promise<void>;
|
|
57
|
-
getDisabledEncodings: () => Encoding[];
|
|
58
57
|
setMLineId: (mLineId: MLineId) => void;
|
|
59
58
|
private isNotSimulcastTrack;
|
|
60
|
-
getTrackBitrates: () => Bitrates;
|
|
59
|
+
getTrackBitrates: () => Bitrates | undefined;
|
|
61
60
|
createTrackVariantBitratesEvent: () => import("..").MediaEvent;
|
|
62
61
|
}
|
|
@@ -81,7 +81,6 @@ export class LocalTrack {
|
|
|
81
81
|
this.updateEncodings();
|
|
82
82
|
this.connection.addTransceiver(this.trackContext.track, transceiverConfig);
|
|
83
83
|
};
|
|
84
|
-
// 1
|
|
85
84
|
updateEncodings = () => {
|
|
86
85
|
if (this.trackContext?.track?.kind === 'video' && this.trackContext.simulcastConfig?.activeEncodings) {
|
|
87
86
|
const activeEncodings = this.trackContext.simulcastConfig.activeEncodings;
|
|
@@ -177,12 +176,6 @@ export class LocalTrack {
|
|
|
177
176
|
this.encodings[encoding] = true;
|
|
178
177
|
return this.sender.setParameters(params);
|
|
179
178
|
};
|
|
180
|
-
getDisabledEncodings = () => {
|
|
181
|
-
return Object.entries(this.encodings)
|
|
182
|
-
.filter(([_, value]) => !value)
|
|
183
|
-
.map(([encoding]) => encoding)
|
|
184
|
-
.reduce((acc, encoding) => [...acc, encoding], []);
|
|
185
|
-
};
|
|
186
179
|
setMLineId = (mLineId) => {
|
|
187
180
|
this.mLineId = mLineId;
|
|
188
181
|
};
|
|
@@ -197,7 +190,7 @@ export class LocalTrack {
|
|
|
197
190
|
return defaultBitrates[trackContext.trackKind];
|
|
198
191
|
}
|
|
199
192
|
if (!this.sender)
|
|
200
|
-
|
|
193
|
+
return undefined;
|
|
201
194
|
const encodings = this.sender.getParameters().encodings;
|
|
202
195
|
if (this.isNotSimulcastTrack(encodings)) {
|
|
203
196
|
return encodings[0].maxBitrate || (kind ? defaultBitrates[kind] : UNLIMITED_BANDWIDTH);
|
|
@@ -18,7 +18,7 @@ export declare class Remote<EndpointMetadata, TrackMetadata> {
|
|
|
18
18
|
getTrackByMid: (mid: string) => RemoteTrack<EndpointMetadata, TrackMetadata>;
|
|
19
19
|
addTracks: (endpointId: EndpointId, tracks: Record<TrackId, SDPTrack>, trackIdToMetadata: Record<TrackId, any>) => void;
|
|
20
20
|
removeTracks: (trackIds: TrackId[]) => void;
|
|
21
|
-
removeRemoteTrack
|
|
21
|
+
private removeRemoteTrack;
|
|
22
22
|
addRemoteEndpoint: (endpoint: any, sendNotification?: boolean) => void;
|
|
23
23
|
private addEndpoint;
|
|
24
24
|
updateRemoteEndpoint: (data: any) => void;
|
|
@@ -159,8 +159,8 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
159
159
|
break;
|
|
160
160
|
}
|
|
161
161
|
case 'sdpAnswer':
|
|
162
|
-
await this.onSdpAnswer(deserializedMediaEvent.data);
|
|
163
162
|
this.localTrackManager.ongoingRenegotiation = false;
|
|
163
|
+
await this.onSdpAnswer(deserializedMediaEvent.data);
|
|
164
164
|
this.commandsQueue.processNextCommand();
|
|
165
165
|
break;
|
|
166
166
|
case 'candidate':
|
|
@@ -215,6 +215,9 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
215
215
|
await this.handleMediaEvent(deserializedMediaEvent.data);
|
|
216
216
|
break;
|
|
217
217
|
case 'error':
|
|
218
|
+
console.warn('signaling error', {
|
|
219
|
+
message: deserializedMediaEvent.data.message,
|
|
220
|
+
});
|
|
218
221
|
this.emit('signalingError', {
|
|
219
222
|
message: deserializedMediaEvent.data.message,
|
|
220
223
|
});
|
|
@@ -575,6 +578,7 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
575
578
|
if (!connection)
|
|
576
579
|
return;
|
|
577
580
|
try {
|
|
581
|
+
this.localTrackManager.updateSenders();
|
|
578
582
|
const offer = await connection.getConnection().createOffer();
|
|
579
583
|
if (!this.connectionManager) {
|
|
580
584
|
console.warn('RTCPeerConnection stopped or restarted');
|
|
@@ -595,10 +599,10 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
595
599
|
}
|
|
596
600
|
onOfferData = async (offerData) => {
|
|
597
601
|
const connection = this.connectionManager;
|
|
598
|
-
if (connection) {
|
|
602
|
+
if (connection && !connection.isExWebRTC) {
|
|
599
603
|
connection.getConnection().restartIce();
|
|
600
604
|
}
|
|
601
|
-
else {
|
|
605
|
+
else if (!connection) {
|
|
602
606
|
this.setConnection(offerData.data.integratedTurnServers);
|
|
603
607
|
const onIceCandidate = (event) => this.onLocalCandidate(event);
|
|
604
608
|
const onIceCandidateError = (event) => this.onIceCandidateError(event);
|
|
@@ -620,7 +624,6 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
620
624
|
this.commandsQueue.initConnection(connection);
|
|
621
625
|
this.local.addAllTracksToConnection();
|
|
622
626
|
}
|
|
623
|
-
this.localTrackManager.updateSenders();
|
|
624
627
|
const tracks = new Map(Object.entries(offerData.data.tracksTypes));
|
|
625
628
|
this.connectionManager?.addTransceiversIfNeeded(tracks);
|
|
626
629
|
await this.createAndSendOffer();
|
|
@@ -649,6 +652,8 @@ export class WebRTCEndpoint extends EventEmitter {
|
|
|
649
652
|
data: {
|
|
650
653
|
candidate: event.candidate.candidate,
|
|
651
654
|
sdpMLineIndex: event.candidate.sdpMLineIndex,
|
|
655
|
+
sdpMid: event.candidate.sdpMid,
|
|
656
|
+
usernameFragment: event.candidate.usernameFragment,
|
|
652
657
|
},
|
|
653
658
|
});
|
|
654
659
|
this.sendMediaEvent(mediaEvent);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/ts-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Typescript client library for Fishjam Cloud",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fishjam Cloud Team",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@bufbuild/protobuf": "^2.2.0",
|
|
49
49
|
"events": "^3.3.0",
|
|
50
50
|
"typed-emitter": "^2.1.0",
|
|
51
|
-
"uuid": "^
|
|
51
|
+
"uuid": "^11.0.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@playwright/test": "^1.47.2",
|