From 81e61929749d5f06e8fe840525de15139adcb7b0 Mon Sep 17 00:00:00 2001 From: Ly Tuan Kiet Date: Tue, 3 Dec 2024 17:42:18 +0700 Subject: [PATCH] feat: add room egress functionality to LiveKitRoomService - Introduced RoomEgress to enable recording of meeting rooms with S3 storage configuration. - Updated createServiceMeetingRoom method to include egress settings for room recording. - Enhanced integration with LiveKit by allowing dynamic file path generation for recordings. --- src/LiveKit/livekit.room.service.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/LiveKit/livekit.room.service.ts b/src/LiveKit/livekit.room.service.ts index 348ffde..1e312b1 100644 --- a/src/LiveKit/livekit.room.service.ts +++ b/src/LiveKit/livekit.room.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common' // @ts-expect-error -import { Room, RoomServiceClient } from 'livekit-server-sdk' +import { Room, RoomServiceClient, RoomEgress } from 'livekit-server-sdk' import { LiveKitEgressService } from './livekit.egress' @Injectable() @@ -10,15 +10,28 @@ export class LiveKitRoomService { process.env.LIVEKIT_API_KEY as string, process.env.LIVEKIT_API_SECRET as string, ) + private readonly roomEgress = new RoomEgress({ + tracks: { + output: { + case: 's3', + value: { + bucket: process.env.RECORDING_BUCKET_NAME as string, + accessKey: process.env.MINIO_ACCESS_KEY as string, + secret: process.env.MINIO_SECRET_KEY as string, + endpoint: process.env.MINIO_ENDPOINT as string, + }, + }, + filepath: '${roomName}/${roomName}-${start_time}', + }, + }) constructor(private readonly egressService: LiveKitEgressService) {} async createServiceMeetingRoom(roomId: string) { const room = await this.roomServiceClient.createRoom({ name: roomId, maxParticipants: 2, + egress: this.roomEgress, }) - // start recording - await this.egressService.startRecording(roomId) return room }