Skip to content

Commit

Permalink
Added more options to CreateRoom API: (#304)
Browse files Browse the repository at this point in the history
* max-playout-delay
* empty-timeout
* departure-timeout
  • Loading branch information
davidzhao authored Mar 21, 2024
1 parent 7bac6cb commit 208aecf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion cmd/livekit-cli/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
),
},
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
package livekitcli

const (
Version = "1.4.0"
Version = "1.4.1"
)

0 comments on commit 208aecf

Please sign in to comment.