Skip to content

Commit

Permalink
Add list room and ability to set playout delay during room creation (#…
Browse files Browse the repository at this point in the history
…231)

Co-authored-by: Tom Berger <[email protected]>
  • Loading branch information
tab1293 and Tom Berger authored Oct 5, 2023
1 parent 80dfb06 commit 76dc7b7
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cmd/livekit-cli/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ var (
Usage: "AutoTrackEgress json file (see examples/auto-track-egress.json)",
Required: false,
},
&cli.UintFlag{
Name: "min-playout-delay",
Usage: "minimum playout delay",
Required: false,
},
),
},
{
Expand All @@ -61,6 +66,15 @@ var (
Category: roomCategory,
Flags: withDefaultFlags(),
},
{
Name: "list-room",
Before: createRoomClient,
Action: listRoom,
Category: roomCategory,
Flags: withDefaultFlags(
roomFlag,
),
},
{
Name: "delete-room",
Before: createRoomClient,
Expand Down Expand Up @@ -235,6 +249,11 @@ func createRoom(c *cli.Context) error {
req.Egress.Tracks = trackEgress
}

if c.Uint("min-playout-delay") != 0 {
fmt.Printf("setting min playout delay: %d\n", c.Uint("min-playout-delay"))
req.MinPlayoutDelay = uint32(c.Uint("min-playout-delay"))
}

room, err := roomClient.CreateRoom(context.Background(), req)
if err != nil {
return err
Expand All @@ -258,6 +277,26 @@ func listRooms(c *cli.Context) error {
return nil
}

func listRoom(c *cli.Context) error {
res, err := roomClient.ListRooms(context.Background(), &livekit.ListRoomsRequest{
Names: []string{c.String("room")},
})
if err != nil {
return err
}
if len(res.Rooms) == 0 {
fmt.Printf("there is no matching room with name: %s\n", c.String("room"))
return nil
}
rm := res.Rooms[0]
PrintJSON(rm)
playoutDelay := rm.GetPlayoutDelay()
if playoutDelay != nil {
fmt.Printf("playout delay: %s\n", playoutDelay.String())
}
return nil
}

func deleteRoom(c *cli.Context) error {
roomId := c.String("room")
_, err := roomClient.DeleteRoom(context.Background(), &livekit.DeleteRoomRequest{
Expand Down

0 comments on commit 76dc7b7

Please sign in to comment.