From 312aa4644bec4b7cce1970d8b6594d2306a9e6d2 Mon Sep 17 00:00:00 2001 From: Nicolas Echezarreta Date: Tue, 9 Apr 2024 11:47:23 -0300 Subject: [PATCH] update livekit-client@2.0.10 --- browser-interface/package-lock.json | 151 +++++------------- browser-interface/package.json | 2 +- .../shared/comms/adapters/LivekitAdapter.ts | 23 +-- .../adapters/voice/liveKitVoiceHandler.ts | 6 +- .../packages/shared/comms/sagas.ts | 2 +- 5 files changed, 61 insertions(+), 123 deletions(-) diff --git a/browser-interface/package-lock.json b/browser-interface/package-lock.json index 1ae7f39ae8..426ec28d89 100644 --- a/browser-interface/package-lock.json +++ b/browser-interface/package-lock.json @@ -37,7 +37,7 @@ "fp-future": "^1.0.1", "gifuct-js": "^2.1.2", "hls.js": "^1.3.4", - "livekit-client": "^1.8.0", + "livekit-client": "^2.0.10", "mitt": "^3.0.0", "mz-observable": "^1.0.1", "redux": "^4.2.1", @@ -443,6 +443,11 @@ "node": ">=6.9.0" } }, + "node_modules/@bufbuild/protobuf": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.8.0.tgz", + "integrity": "sha512-qR9FwI8QKIveDnUYutvfzbC21UZJJryYrLuZGjeZ/VGz+vXelUkK+xgkOHsvPEdYEdxtgUUq4313N8QtOehJ1Q==" + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -896,6 +901,14 @@ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, + "node_modules/@livekit/protocol": { + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.10.4.tgz", + "integrity": "sha512-7Occ6l5VqjsKsUjpLeVJXJkip4ce22iG9QR/haOkrDXYwGSY+TwCA4ubbJ81aQBt2z0kHVZuaQWdzJSDLI+Kag==", + "dependencies": { + "@bufbuild/protobuf": "^1.7.2" + } + }, "node_modules/@matrix-org/matrix-sdk-crypto-js": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.4.tgz", @@ -1941,11 +1954,6 @@ "node": ">=12.0" } }, - "node_modules/async-await-queue": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/async-await-queue/-/async-await-queue-1.2.1.tgz", - "integrity": "sha512-v2j+/EMzAnuJZ8I4570KJMFhi6G9g3WZyFh6cPnmQSJh3nLao77XpRt01kyFegQazPSKvue1yaIYDp/NfV/b0g==" - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -5976,49 +5984,20 @@ "dev": true }, "node_modules/livekit-client": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-1.9.3.tgz", - "integrity": "sha512-GBZBRYYHI8POOCCQCSPjRwqVJX/jRmdZi1sE8ZZV0EFHB1OhgiWa/Uhng+t8E8HIolb9lf8Ela9WhzzsI8a8yA==", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.0.10.tgz", + "integrity": "sha512-V+EyTEd3kM1Vl9/TsE3nc7PEnJI2t21ZV0/nkqhGThszym1SJzmc61hKjmCJBnR199pskUxSjrwzMl9HrPQ85A==", "dependencies": { - "async-await-queue": "^1.2.1", + "@livekit/protocol": "1.10.4", "events": "^3.3.0", "loglevel": "^1.8.0", - "protobufjs": "^7.0.0", "sdp-transform": "^2.14.1", "ts-debounce": "^4.0.0", + "tslib": "2.6.2", "typed-emitter": "^2.1.0", - "ua-parser-js": "^1.0.2", "webrtc-adapter": "^8.1.1" } }, - "node_modules/livekit-client/node_modules/long": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", - "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" - }, - "node_modules/livekit-client/node_modules/protobufjs": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.5.tgz", - "integrity": "sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==", - "hasInstallScript": true, - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -9449,10 +9428,9 @@ } }, "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", - "devOptional": true + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -9584,24 +9562,6 @@ "typescript-compare": "^0.0.2" } }, - "node_modules/ua-parser-js": { - "version": "1.0.35", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.35.tgz", - "integrity": "sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/ua-parser-js" - }, - { - "type": "paypal", - "url": "https://paypal.me/faisalman" - } - ], - "engines": { - "node": "*" - } - }, "node_modules/uint8arrays": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.10.tgz", @@ -10373,6 +10333,11 @@ "to-fast-properties": "^2.0.0" } }, + "@bufbuild/protobuf": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@bufbuild/protobuf/-/protobuf-1.8.0.tgz", + "integrity": "sha512-qR9FwI8QKIveDnUYutvfzbC21UZJJryYrLuZGjeZ/VGz+vXelUkK+xgkOHsvPEdYEdxtgUUq4313N8QtOehJ1Q==" + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -10770,6 +10735,14 @@ } } }, + "@livekit/protocol": { + "version": "1.10.4", + "resolved": "https://registry.npmjs.org/@livekit/protocol/-/protocol-1.10.4.tgz", + "integrity": "sha512-7Occ6l5VqjsKsUjpLeVJXJkip4ce22iG9QR/haOkrDXYwGSY+TwCA4ubbJ81aQBt2z0kHVZuaQWdzJSDLI+Kag==", + "requires": { + "@bufbuild/protobuf": "^1.7.2" + } + }, "@matrix-org/matrix-sdk-crypto-js": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.4.tgz", @@ -11579,11 +11552,6 @@ "integrity": "sha512-Kd0o8r6CDazJGCRzs8Ivpn0xj19oNKrULhoJFzhGjRsLpekF2zyZs9Ukz+JvZhWD6smszfepakTFhAaYpsI12g==", "dev": true }, - "async-await-queue": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/async-await-queue/-/async-await-queue-1.2.1.tgz", - "integrity": "sha512-v2j+/EMzAnuJZ8I4570KJMFhi6G9g3WZyFh6cPnmQSJh3nLao77XpRt01kyFegQazPSKvue1yaIYDp/NfV/b0g==" - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -14641,45 +14609,18 @@ "dev": true }, "livekit-client": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-1.9.3.tgz", - "integrity": "sha512-GBZBRYYHI8POOCCQCSPjRwqVJX/jRmdZi1sE8ZZV0EFHB1OhgiWa/Uhng+t8E8HIolb9lf8Ela9WhzzsI8a8yA==", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/livekit-client/-/livekit-client-2.0.10.tgz", + "integrity": "sha512-V+EyTEd3kM1Vl9/TsE3nc7PEnJI2t21ZV0/nkqhGThszym1SJzmc61hKjmCJBnR199pskUxSjrwzMl9HrPQ85A==", "requires": { - "async-await-queue": "^1.2.1", + "@livekit/protocol": "1.10.4", "events": "^3.3.0", "loglevel": "^1.8.0", - "protobufjs": "^7.0.0", "sdp-transform": "^2.14.1", "ts-debounce": "^4.0.0", + "tslib": "2.6.2", "typed-emitter": "^2.1.0", - "ua-parser-js": "^1.0.2", "webrtc-adapter": "^8.1.1" - }, - "dependencies": { - "long": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", - "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" - }, - "protobufjs": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.5.tgz", - "integrity": "sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==", - "requires": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - } - } } }, "locate-path": { @@ -17241,10 +17182,9 @@ } }, "tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", - "devOptional": true + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "tsutils": { "version": "3.21.0", @@ -17344,11 +17284,6 @@ "typescript-compare": "^0.0.2" } }, - "ua-parser-js": { - "version": "1.0.35", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.35.tgz", - "integrity": "sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==" - }, "uint8arrays": { "version": "2.1.10", "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-2.1.10.tgz", diff --git a/browser-interface/package.json b/browser-interface/package.json index 0cb54b5953..db6d67d068 100644 --- a/browser-interface/package.json +++ b/browser-interface/package.json @@ -83,7 +83,7 @@ "fp-future": "^1.0.1", "gifuct-js": "^2.1.2", "hls.js": "^1.3.4", - "livekit-client": "^1.8.0", + "livekit-client": "^2.0.10", "mitt": "^3.0.0", "mz-observable": "^1.0.1", "redux": "^4.2.1", diff --git a/browser-interface/packages/shared/comms/adapters/LivekitAdapter.ts b/browser-interface/packages/shared/comms/adapters/LivekitAdapter.ts index d113c6cab0..efbde7d9f0 100644 --- a/browser-interface/packages/shared/comms/adapters/LivekitAdapter.ts +++ b/browser-interface/packages/shared/comms/adapters/LivekitAdapter.ts @@ -30,12 +30,15 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter { public readonly events = mitt() private disposed = false - private readonly room: Room private voiceHandler: VoiceHandler - constructor(private config: LivekitConfig) { - this.room = new Room() + static async init(config: LivekitConfig) { + const room = new Room() + const sid = await room.getSid() + return new LivekitAdapter(config, room, sid) + } + private constructor(private config: LivekitConfig, private readonly room: Room, private sid: string) { this.voiceHandler = createLiveKitVoiceHandler(this.room, this.config.globalAudioStream) this.room @@ -58,13 +61,13 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter { this.config.logger.log(this.room.name, 'disconnected from room', reason, { liveKitParticipantSid: this.room.localParticipant.sid, - liveKitRoomSid: this.room.sid + liveKitRoomSid: this.sid }) trackEvent('disconnection_cause', { context: 'livekit-adapter', message: `Got RoomEvent.Disconnected. Reason: ${reason}`, liveKitParticipantSid: this.room.localParticipant.sid, - liveKitRoomSid: this.room.sid + liveKitRoomSid: this.sid }) const kicked = reason === DisconnectReason.DUPLICATE_IDENTITY this.do_disconnect(kicked).catch((err) => { @@ -108,14 +111,14 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter { } try { - await this.room.localParticipant.publishData(data, reliable ? DataPacket_Kind.RELIABLE : DataPacket_Kind.LOSSY) + await this.room.localParticipant.publishData(data, { reliable }) } catch (err: any) { // NOTE: for tracking purposes only, this is not a "code" error, this is a failed connection or a problem with the livekit instance trackEvent('error', { context: 'livekit-adapter', message: `Error trying to send data. Reason: ${err.message}`, stack: err.stack, - saga_stack: `room session id: ${this.room.sid}, participant id: ${this.room.localParticipant.sid}, state: ${state}` + saga_stack: `room session id: ${this.sid}, participant id: ${this.room.localParticipant.sid}, state: ${state}` }) await this.disconnect() } @@ -144,12 +147,12 @@ export class LivekitAdapter implements MinimumCommunicationsAdapter { getActiveVideoStreams(): Map { const result = new Map() - const participants = this.room.participants + const participants = this.room.remoteParticipants for (const [sid, participant] of participants) { - if (participant.videoTracks.size > 0) { + if (participant.videoTrackPublications.size > 0) { const participantTracks = new Map() - for (const [videoSid, track] of participant.videoTracks) { + for (const [videoSid, track] of participant.videoTrackPublications) { if (track.videoTrack?.mediaStream) { participantTracks.set(videoSid, track.videoTrack) } diff --git a/browser-interface/packages/shared/comms/adapters/voice/liveKitVoiceHandler.ts b/browser-interface/packages/shared/comms/adapters/voice/liveKitVoiceHandler.ts index eb2111b613..c255747f80 100644 --- a/browser-interface/packages/shared/comms/adapters/voice/liveKitVoiceHandler.ts +++ b/browser-interface/packages/shared/comms/adapters/voice/liveKitVoiceHandler.ts @@ -54,7 +54,7 @@ export function createLiveKitVoiceHandler(room: Room, globalAudioStream: GlobalA participantsInfo.set(participant.identity, $) participant.on(ParticipantEvent.IsSpeakingChanged, (talking: boolean) => { - const audioPublication = participant.getTrack(Track.Source.Microphone) + const audioPublication = participant.getTrackPublication(Track.Source.Microphone) if (audioPublication && audioPublication.track) { const audioTrack = audioPublication.track as RemoteAudioTrack onUserTalkingCallback(participant.identity, audioTrack.isMuted ? false : talking) @@ -200,7 +200,7 @@ export function createLiveKitVoiceHandler(room: Room, globalAudioStream: GlobalA ) } - for (const [_, participant] of room.participants) { + for (const [_, participant] of room.remoteParticipants) { const address = participant.identity const peer = getPeer(address) const participantInfo = participantsInfo.get(address) @@ -209,7 +209,7 @@ export function createLiveKitVoiceHandler(room: Room, globalAudioStream: GlobalA const profile = getCurrentUserProfile(state) if (profile) { const muted = !shouldPlayVoice(state, profile, address) - const audioPublication = participant.getTrack(Track.Source.Microphone) + const audioPublication = participant.getTrackPublication(Track.Source.Microphone) if (audioPublication && audioPublication.track) { const audioTrack = audioPublication.track as RemoteAudioTrack audioTrack.setMuted(muted) diff --git a/browser-interface/packages/shared/comms/sagas.ts b/browser-interface/packages/shared/comms/sagas.ts index 420984a86a..d4fdc0d1dd 100644 --- a/browser-interface/packages/shared/comms/sagas.ts +++ b/browser-interface/packages/shared/comms/sagas.ts @@ -289,7 +289,7 @@ async function connectAdapter(connStr: string, identity: ExplorerIdentity): Prom throw new Error('No access token') } - const livekitAdapter = new LivekitAdapter({ + const livekitAdapter = await LivekitAdapter.init({ logger: commsLogger, url: theUrl.origin + theUrl.pathname, token,