livekit-server
Building
Ensure Go 1.14+ is installed, and GOPATH/bin is in your PATH.
Run `make proto && make
CLI
A CLI is provided to make debugging & testing easier. One of the utilities is the ability to publish tracks from static files.
To use the publish client, download the following files to your computer:
- happier.ivf - audio track in VP8
- happier.ogg - audio track in ogg
To run a peer publishing to a room, do the following:
-
Ensure server is running in dev mode
./bin/livekit-server --dev -
Create a room
./bin/livekit-cli create-room --room-id hello -
Join room as publishing client
./ bin/livekit-cli join --room-id hello --audio <path/to/ogg> --video <path/to/ivf>
That's it, join the room with another peer id and see it receiving those tracks
Protocol
LiveKit provides room based audio/video/data channels based on WebRTC. It provides a set of APIs to manipulate rooms, as well as its own signaling protocol to exchange room and participant information.
Room APIs are defined in room.proto, it's fairly straight forward with typical CRUD APIs. Room APIs are HTTP, built with Twirp and follows its the conventions.
The RTC service provides the signaling and everything else when the client interacts with the room. RTC service requires bidirectional
communication between the client and server, and exchanges messages via WebSocket. Messages are encoded in either JSON or binary protobuf,
see rtc.proto for the message structure.
The flow for interaction is:
- Establish WebSocket to ws://:/rtc
- Server will send back a
SignalResponsewith ajoinresponse. It'll include the new participant's details (and in the future, room info) - Client sends a
SignalRequestwith an WebRTCoffer - Server will send back a
SignalResponsewith ananswer - Client and server will exchange ice candidates via
tricklein the request & responses