Skip to content

Commit

Permalink
Avoid crash when invalid samples have been read (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao authored Jul 27, 2023
1 parent 26ce479 commit bb0ef2b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cmd/livekit-cli/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ func joinRoom(c *cli.Context) error {
roomCB := &lksdk.RoomCallback{
ParticipantCallback: lksdk.ParticipantCallback{
OnDataReceived: func(data []byte, rp *lksdk.RemoteParticipant) {
logger.Infow("received data", "data", data)
identity := ""
if rp != nil {
identity = rp.Identity()
}
logger.Infow("received data", "data", data, "participant", identity)
},
OnConnectionQualityChanged: func(update *livekit.ConnectionQualityInfo, p lksdk.Participant) {
logger.Debugw("connection quality changed", "participant", p.Identity(), "quality", update.Quality)
Expand Down Expand Up @@ -109,6 +113,15 @@ func joinRoom(c *cli.Context) error {
OnRoomMetadataChanged: func(metadata string) {
logger.Infow("room metadata changed", "metadata", metadata)
},
OnReconnecting: func() {
logger.Infow("reconnecting to room")
},
OnReconnected: func() {
logger.Infow("reconnected to room")
},
OnDisconnected: func() {
logger.Infow("disconnected from room")
},
}
room, err := lksdk.ConnectToRoom(pc.URL, lksdk.ConnectInfo{
APIKey: pc.APIKey,
Expand Down
3 changes: 3 additions & 0 deletions pkg/provider/h264looper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (l *H264VideoLooper) nextSample(rewindEOF bool) (media.Sample, error) {
l.reader = nil
return l.nextSample(false)
}
if err != nil {
return sample, err
}

isFrame := false
switch nal.UnitType {
Expand Down

0 comments on commit bb0ef2b

Please sign in to comment.