From 208aecfebefda062a56ff332a1136d494ae29e80 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Wed, 20 Mar 2024 21:56:28 -0700 Subject: [PATCH] Added more options to CreateRoom API: (#304) * max-playout-delay * empty-timeout * departure-timeout --- Makefile | 2 +- cmd/livekit-cli/room.go | 29 ++++++++++++++++++++++++++++- version.go | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index cd6d3eba..9557d5b1 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ GOBIN=$(shell go env GOBIN) endif cli: check_lfs - go build -o bin/livekit-cli ./cmd/livekit-cli + go build -ldflags "-w -s" -o bin/livekit-cli ./cmd/livekit-cli GOOS=linux GOARCH=amd64 go build -o bin/livekit-cli-linux ./cmd/livekit-cli install: cli diff --git a/cmd/livekit-cli/room.go b/cmd/livekit-cli/room.go index 5227b560..57ed1a51 100644 --- a/cmd/livekit-cli/room.go +++ b/cmd/livekit-cli/room.go @@ -56,12 +56,24 @@ var ( }, &cli.UintFlag{ Name: "min-playout-delay", - Usage: "minimum playout delay for video (in ms), unsupported for audio", + Usage: "minimum playout delay for video (in ms)", + }, + &cli.UintFlag{ + Name: "max-playout-delay", + Usage: "maximum playout delay for video (in ms)", }, &cli.BoolFlag{ Name: "sync-streams", Usage: "improve A/V sync by placing them in the same stream. when enabled, transceivers will not be reused", }, + &cli.UintFlag{ + Name: "empty-timeout", + Usage: "number of seconds to keep the room open before any participant joins", + }, + &cli.UintFlag{ + Name: "departure-timeout", + Usage: "number of seconds to keep the room open after the last participant leaves", + }, ), }, { @@ -259,11 +271,26 @@ func createRoom(c *cli.Context) error { req.MinPlayoutDelay = uint32(c.Uint("min-playout-delay")) } + if maxPlayoutDelay := c.Uint("max-playout-delay"); maxPlayoutDelay != 0 { + fmt.Printf("setting max playout delay: %d\n", maxPlayoutDelay) + req.MaxPlayoutDelay = uint32(maxPlayoutDelay) + } + if syncStreams := c.Bool("sync-streams"); syncStreams { fmt.Printf("setting sync streams: %t\n", syncStreams) req.SyncStreams = syncStreams } + if emptyTimeout := c.Uint("empty-timeout"); emptyTimeout != 0 { + fmt.Printf("setting empty timeout: %d\n", emptyTimeout) + req.EmptyTimeout = uint32(emptyTimeout) + } + + if departureTimeout := c.Uint("departure-timeout"); departureTimeout != 0 { + fmt.Printf("setting departure timeout: %d\n", departureTimeout) + req.DepartureTimeout = uint32(departureTimeout) + } + room, err := roomClient.CreateRoom(context.Background(), req) if err != nil { return err diff --git a/version.go b/version.go index 5aa5ad2c..c46e4e91 100644 --- a/version.go +++ b/version.go @@ -15,5 +15,5 @@ package livekitcli const ( - Version = "1.4.0" + Version = "1.4.1" )