livekit-egress-sdk
v0.1.0
Published
A lightweight SDK for developing RoomComposite templates
Downloads
4
Readme
Egress Recording Template SDK
This lightweight SDK makes it simple to build your own Room Composite templates.
Overview
LiveKit uses an instance of headless Chrome to composite the room. This means you can use the same application code to design an interactive experience that's livestreamed or recorded.
The general flow of events are as follows:
- You issue an
Egress.StartRoomCompositeEgress
request to LiveKit - LiveKit assigns an available instance of egress to handle it
- Egress recorder creates necessary connection & authentication details for your template, including
- url of livekit server
- an access token that's designed to join the specific room as a recorder
- desired layout passed to StartRoomCompositeEgress
- Egress recorder launches Chrome with
<baseurl>?url=<>&template=<>&token=<>
- Egress recorder waits for webapp to log
START_RECORDING
to record - Egress recorder waits for webapp to log
END_RECORDING
to terminate the stream
Your webapp will need to connect to a LiveKit room using the token provided. This mechanism provides authentication to your application as well as giving you information about the current room that's to be recorded.
This template SDK takes care of communicating with Egress recorder, performing the following:
- parses URL parameters: url, token, layout
- communicates with recorder by logging to console
- handles layout changes requested by UpdateLayout
Install
yarn add livekit-egress-sdk
Usage
import EgressHelper from 'livekit-egress-sdk'
import { Room } from 'livekit-client'
const room = new Room({
adaptiveStream: true,
})
EgressHelper.setRoom(room, {
autoEnd: true,
})
EgressHelper.onLayoutChanged((layout) => {
// handle layout changes
})
await room.connect(
EgressHelper.getLiveKitURL(),
EgressHelper.getAccessToken(),
);
EgressHelper.startRecording();
Example
We provide a few default templates/layouts here. It should serve as a good guide for creating your own templates.