Skip to content

add --auto-subscribe cli option to enable auto-subscribe to published tracks in a room #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2025

Conversation

chenosaurus
Copy link
Contributor

When using LK CLI to directly publish tracks into a room, it defaults to also auto-subscribing to other participant's tracks. This is undesirable as most use cases of the CLI does not need to receive any tracks and will waste bandwidth. This adds a --auto-subscribe parameter to the CLI when using the join room functionality to explicitly enable auto-subscribing to published tracks.

@CLAassistant
Copy link

CLAassistant commented May 5, 2025

CLA assistant check
All committers have signed the CLA.

&cli.BoolFlag{
Name: "auto-subscribe",
Usage: "Automatically subscribe to published tracks. Default is false.",
Value: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm hesitant to change the default behavior in this PR. maybe best as true

Copy link
Member

@rektdeckard rektdeckard May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded. Also, when Value is set on a flag, the CLI will display (default: $value) so you can remove it from the usage string.

EDIT: and then I read the note below, false makes sense.

cmd/lk/room.go Outdated
&cli.BoolFlag{
Name: "auto-subscribe",
Usage: "Automatically subscribe to published tracks. Default is true.",
Value: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should probably be false by default. the CLI client cannot really consume any tracks

Copy link
Member

@rektdeckard rektdeckard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor changes based on how we normally do CLI flags!

&cli.BoolFlag{
Name: "auto-subscribe",
Usage: "Automatically subscribe to published tracks. Default is false.",
Value: false,
Copy link
Member

@rektdeckard rektdeckard May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded. Also, when Value is set on a flag, the CLI will display (default: $value) so you can remove it from the usage string.

EDIT: and then I read the note below, false makes sense.

cmd/lk/utils.go Outdated
Comment on lines 145 to 151
func extractFlagAsBool(c *cli.Command, flag string) (bool, error) {
if c.IsSet(flag) {
return c.Bool(flag), nil
}

return false, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything that could possibly error here, so it doesn't need to return one

cmd/lk/room.go Outdated
Comment on lines 792 to 795
autoSubscribe, err := extractFlagAsBool(cmd, "auto-subscribe")
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just read cmd.Bool("auto-subscribe") directly, since we are setting a default value for it.

version.go Outdated
@@ -15,5 +15,5 @@
package livekitcli

const (
Version = "2.4.5"
Version = "2.4.6"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need a rebase, we're at 2.4.6 already

@rektdeckard rektdeckard merged commit f0ffd06 into livekit:main May 12, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants