From 28ad293dfe0acd5fda5115097b55710cdccfa106 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sun, 7 Apr 2024 22:30:45 -0700 Subject: [PATCH] Support both livekit-client 2.0.x and 1.5.x (#646) * Support both livekit-client 2.0.x and 1.5.x * bump version * remove autoEnd - lifecycle should be controlled by server --- template-sdk/package.json | 6 +++--- template-sdk/pnpm-lock.yaml | 22 ++++++++++++++-------- template-sdk/src/index.ts | 19 +------------------ 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/template-sdk/package.json b/template-sdk/package.json index 311d3dd4..da1a82fc 100644 --- a/template-sdk/package.json +++ b/template-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@livekit/egress-sdk", - "version": "0.1.2", + "version": "0.2.0", "description": "A lightweight SDK for developing RoomComposite templates", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -12,11 +12,11 @@ "build": "tsc" }, "devDependencies": { - "livekit-client": "^1.7.0", + "livekit-client": "^1.15.13 || ^2.0.10", "prettier": "^2.8.4", "typescript": "^5.0.0" }, "peerDependencies": { - "livekit-client": "^1.7.0" + "livekit-client": "^1.15.13 || ^2.0.10" } } diff --git a/template-sdk/pnpm-lock.yaml b/template-sdk/pnpm-lock.yaml index faf8bd7f..b0f9e5d4 100644 --- a/template-sdk/pnpm-lock.yaml +++ b/template-sdk/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: devDependencies: livekit-client: - specifier: ^1.7.0 - version: 1.14.4 + specifier: ^1.15.13 || ^2.0.10 + version: 2.0.10 prettier: specifier: ^2.8.4 version: 2.8.8 @@ -17,8 +17,14 @@ devDependencies: packages: - /@bufbuild/protobuf@1.4.2: - resolution: {integrity: sha512-JyEH8Z+OD5Sc2opSg86qMHn1EM1Sa+zj/Tc0ovxdwk56ByVNONJSabuCUbLQp+eKN3rWNfrho0X+3SEqEPXIow==} + /@bufbuild/protobuf@1.8.0: + resolution: {integrity: sha512-qR9FwI8QKIveDnUYutvfzbC21UZJJryYrLuZGjeZ/VGz+vXelUkK+xgkOHsvPEdYEdxtgUUq4313N8QtOehJ1Q==} + dev: true + + /@livekit/protocol@1.10.4: + resolution: {integrity: sha512-7Occ6l5VqjsKsUjpLeVJXJkip4ce22iG9QR/haOkrDXYwGSY+TwCA4ubbJ81aQBt2z0kHVZuaQWdzJSDLI+Kag==} + dependencies: + '@bufbuild/protobuf': 1.8.0 dev: true /events@3.3.0: @@ -26,14 +32,15 @@ packages: engines: {node: '>=0.8.x'} dev: true - /livekit-client@1.14.4: - resolution: {integrity: sha512-sXNH+qhqkmXeCVsw3hcEbUsh9QfguBIGgM3glM0v0+YW4C2LdeGWD4pQBLR7USbkwbbVMEHDmqr/iY6XvEIoeQ==} + /livekit-client@2.0.10: + resolution: {integrity: sha512-V+EyTEd3kM1Vl9/TsE3nc7PEnJI2t21ZV0/nkqhGThszym1SJzmc61hKjmCJBnR199pskUxSjrwzMl9HrPQ85A==} dependencies: - '@bufbuild/protobuf': 1.4.2 + '@livekit/protocol': 1.10.4 events: 3.3.0 loglevel: 1.8.1 sdp-transform: 2.14.1 ts-debounce: 4.0.0 + tslib: 2.6.2 typed-emitter: 2.1.0 webrtc-adapter: 8.2.3 dev: true @@ -74,7 +81,6 @@ packages: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} requiresBuild: true dev: true - optional: true /typed-emitter@2.1.0: resolution: {integrity: sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==} diff --git a/template-sdk/src/index.ts b/template-sdk/src/index.ts index cc0f4960..41e97cad 100644 --- a/template-sdk/src/index.ts +++ b/template-sdk/src/index.ts @@ -16,11 +16,6 @@ import { ParticipantEvent, Room, RoomEvent } from 'livekit-client'; -export interface EgressOptions { - // automatically finish recording when the last participant leaves - autoEnd?: boolean; -} - const EgressHelper = { /** * RoomComposite will pass URL to your livekit's server instance. @@ -62,17 +57,13 @@ const EgressHelper = { * Call when successfully connected to the room * @param room */ - setRoom(room: Room, opts?: EgressOptions) { + setRoom(room: Room) { if (currentRoom) { - currentRoom.off(RoomEvent.ParticipantDisconnected, onParticipantDisconnected); currentRoom.off(RoomEvent.Disconnected, EgressHelper.endRecording); } currentRoom = room; currentRoom.localParticipant.on(ParticipantEvent.ParticipantMetadataChanged, onMetadataChanged); - if (opts?.autoEnd) { - currentRoom.on(RoomEvent.ParticipantDisconnected, onParticipantDisconnected); - } currentRoom.on(RoomEvent.Disconnected, EgressHelper.endRecording); onMetadataChanged(); }, @@ -124,14 +115,6 @@ function onMetadataChanged() { } } -function onParticipantDisconnected() { - if (currentRoom) { - if (currentRoom.participants.size === 0) { - EgressHelper.endRecording(); - } - } -} - function getURLParam(name: string): string | null { const query = new URLSearchParams(window.location.search); return query.get(name);