Skip to content
Open
Changes from all 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
34 changes: 34 additions & 0 deletions cmd/lk/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"regexp"
"strings"
"syscall"
"time"

"github.com/pion/webrtc/v4"
"github.com/urfave/cli/v3"
Expand Down Expand Up @@ -199,6 +200,15 @@ var (
Name: "metadata",
Usage: "`JSON` metadata which will be passed to participant",
},
&cli.BoolFlag{
Name: "stats",
Usage: "Periodically log publisher WebRTC GetStats as one JSON object per line to stderr",
},
&cli.FloatFlag{
Name: "stats-interval",
Usage: "Seconds between stats logs when --stats is set",
Value: 5.0,
},
},
},
{
Expand Down Expand Up @@ -1060,6 +1070,30 @@ func joinRoom(ctx context.Context, cmd *cli.Command) error {
}
}

if cmd.Bool("stats") {
interval := cmd.Float("stats-interval")
if interval <= 0 {
interval = 5.0
}
ticker := time.NewTicker(time.Duration(interval * float64(time.Second)))
go func() {
defer ticker.Stop()
for {
select {
case <-done:
return
case <-ticker.C:
pc := room.LocalParticipant.GetPublisherPeerConnection()
if pc == nil {
continue
}
report := pc.GetStats()
logger.Infow("stats", "stats", report)
}
}
}()
}

if cmd.IsSet("open") {
switch cmd.String("open") {
case string(util.OpenTargetMeet):
Expand Down