Skip to content
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

Adopt v2.0 APIs #286

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cmd/livekit-cli/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ func joinRoom(c *cli.Context) error {
done := make(chan os.Signal, 1)
roomCB := &lksdk.RoomCallback{
ParticipantCallback: lksdk.ParticipantCallback{
OnDataReceived: func(data []byte, rp *lksdk.RemoteParticipant) {
identity := ""
if rp != nil {
identity = rp.Identity()
}
OnDataReceived: func(data []byte, params lksdk.DataReceiveParams) {
identity := params.SenderIdentity
logger.Infow("received data", "data", data, "participant", identity)
},
OnConnectionQualityChanged: func(update *livekit.ConnectionQualityInfo, p lksdk.Participant) {
Expand Down
18 changes: 13 additions & 5 deletions cmd/livekit-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ import (

livekitcli "github.com/livekit/livekit-cli"
"github.com/livekit/protocol/logger"
lksdk "github.com/livekit/server-sdk-go"
)

func main() {
logConfig := &logger.Config{
Level: "info",
}
app := &cli.App{
Name: "livekit-cli",
Usage: "CLI client to LiveKit",
Expand All @@ -52,9 +50,19 @@ func main() {
},
},
},
}
Before: func(c *cli.Context) error {
logConfig := &logger.Config{
Level: "info",
}
if c.Bool("verbose") {
logConfig.Level = "debug"
}
logger.InitFromConfig(logConfig, "livekit-cli")
lksdk.SetLogger(logger.GetLogger())
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe switch to v2 is a good moment to use slog? It seems like uber-go/zap#1333 is not there yet, but other options like https://github.com/samber/slog-zap already exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

we can wait till things stabilizes a bit before updating to it


logger.InitFromConfig(logConfig, "livekit-cli")
return nil
},
}

app.Commands = append(app.Commands, TokenCommands...)
app.Commands = append(app.Commands, RoomCommands...)
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/frostbyte73/core v0.0.9
github.com/ggwhite/go-masker v1.1.0
github.com/go-logr/logr v1.4.1
github.com/livekit/protocol v1.9.5
github.com/livekit/protocol v1.9.7
github.com/livekit/server-sdk-go v1.1.7
github.com/manifoldco/promptui v0.9.0
github.com/olekukonko/tablewriter v0.0.5
Expand All @@ -23,6 +23,8 @@ require (
gopkg.in/yaml.v3 v3.0.1
)

replace github.com/livekit/server-sdk-go => ../server-sdk-go
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to remove it!


require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bep/debounce v1.2.1 // indirect
Expand Down Expand Up @@ -73,7 +75,6 @@ require (
github.com/prometheus/procfs v0.12.0 // indirect
github.com/redis/go-redis/v9 v9.4.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/thoas/go-funk v0.9.3 // indirect
github.com/twitchtv/twirp v8.1.3+incompatible // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
github.com/livekit/mediatransportutil v0.0.0-20231213075826-cccbf2b93d3f h1:XHrwGwLNGQB3ZqolH1YdMH/22hgXKr4vm+2M7JKMMGg=
github.com/livekit/mediatransportutil v0.0.0-20231213075826-cccbf2b93d3f/go.mod h1:GBzn9xL+mivI1pW+tyExcKgbc0VOc29I9yJsNcAVaAc=
github.com/livekit/protocol v1.9.5 h1:/I6maM05euoUxrV6je16Qj5yCnCSPZ+nhHzm8akLCVk=
github.com/livekit/protocol v1.9.5/go.mod h1:daddOPw85C9nq6f9w1uiuc1i/He6X2gArlFcKUPELI4=
github.com/livekit/protocol v1.9.7 h1:5pYAMS/rzOStpIfRGnhXETPH/NyoFJtbV7FW4NHxg7o=
github.com/livekit/protocol v1.9.7/go.mod h1:daddOPw85C9nq6f9w1uiuc1i/He6X2gArlFcKUPELI4=
github.com/livekit/psrpc v0.5.3-0.20231214055026-06ce27a934c9 h1:kXXV/NLVDHZ+Gn7xrR+UPpdwbH48n7WReBjLHAzqzhY=
github.com/livekit/psrpc v0.5.3-0.20231214055026-06ce27a934c9/go.mod h1:cQjxg1oCxYHhxxv6KJH1gSvdtCHQoRZCHgPdm5N8v2g=
github.com/livekit/server-sdk-go v1.1.7 h1:fuNQgCpul4O32nJXRgeRRSSWuesubVfeOzzZ47ji2E8=
github.com/livekit/server-sdk-go v1.1.7/go.mod h1:bq1JRg0NpID0unZ0u66Ss0yU3777QqO0VQRWjQEKIck=
github.com/mackerelio/go-osstat v0.2.4 h1:qxGbdPkFo65PXOb/F/nhDKpF2nGmGaCFDLXoZjJTtUs=
github.com/mackerelio/go-osstat v0.2.4/go.mod h1:Zy+qzGdZs3A9cuIqmgbJvwbmLQH9dJvtio5ZjJTbdlQ=
github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg=
Expand Down Expand Up @@ -189,7 +187,6 @@ github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZ
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand All @@ -198,8 +195,6 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU=
github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
Expand Down
8 changes: 4 additions & 4 deletions pkg/loadtester/loadtester.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (t *LoadTester) Start() error {
}

identity := fmt.Sprintf("%s_%d", t.params.IdentityPrefix, t.params.Sequence)
t.room = lksdk.CreateRoom(&lksdk.RoomCallback{
t.room = lksdk.NewRoom(&lksdk.RoomCallback{
ParticipantCallback: lksdk.ParticipantCallback{
OnTrackSubscribed: t.onTrackSubscribed,
OnTrackSubscriptionFailed: func(sid string, rp *lksdk.RemoteParticipant) {
Expand Down Expand Up @@ -132,8 +132,8 @@ func (t *LoadTester) Start() error {
}

t.running.Store(true)
for _, p := range t.room.GetParticipants() {
for _, pub := range p.Tracks() {
for _, p := range t.room.GetRemoteParticipants() {
for _, pub := range p.TrackPublications() {
if remotePub, ok := pub.(*lksdk.RemoteTrackPublication); ok {
t.onTrackPublished(remotePub, p)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ func (t *LoadTester) onTrackSubscribed(track *webrtc.TrackRemote, pub *lksdk.Rem
numTotal := 0
t.lock.Lock()
for _, p := range t.subscribedParticipants {
tracks := p.Tracks()
tracks := p.TrackPublications()
numTotal += len(tracks)
for _, t := range tracks {
if t.IsSubscribed() {
Expand Down
Loading