- Added LiveKitRoomService to manage meeting room creation and recording functionalities. - Updated CollaborationSessionSchema to create a LiveKit room upon new collaboration session creation. - Introduced meetingRoomJoinInfo field in MeetingRoomSchema to provide join tokens and server URLs for meeting rooms. - Improved LiveKitService to include user metadata in token generation and added a method to retrieve the server URL. - Enhanced error handling and authorization checks across schemas to ensure proper access control for collaboration sessions and meeting rooms.
33 lines
956 B
TypeScript
33 lines
956 B
TypeScript
import { Injectable } from '@nestjs/common'
|
|
// @ts-expect-error
|
|
import { Room, RoomServiceClient } from 'livekit-server-sdk'
|
|
import { LiveKitEgressService } from './livekit.egress'
|
|
|
|
@Injectable()
|
|
export class LiveKitRoomService {
|
|
private readonly roomServiceClient = new RoomServiceClient(
|
|
process.env.LIVEKIT_URL as string,
|
|
process.env.LIVEKIT_API_KEY as string,
|
|
process.env.LIVEKIT_API_SECRET as string,
|
|
)
|
|
constructor(private readonly egressService: LiveKitEgressService) {}
|
|
|
|
async createServiceMeetingRoom(roomId: string) {
|
|
const room = await this.roomServiceClient.createRoom({
|
|
name: roomId,
|
|
maxParticipants: 2,
|
|
})
|
|
// start recording
|
|
await this.egressService.startRecording(roomId)
|
|
return room
|
|
}
|
|
|
|
async createWorkshopRoom(roomId: string, maxParticipants: number) {
|
|
const room = await this.roomServiceClient.createRoom({
|
|
name: roomId,
|
|
maxParticipants,
|
|
})
|
|
return room
|
|
}
|
|
}
|