Skip to content

Commit

Permalink
webrtc: return an error when proxying stream with no tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Feb 18, 2024
1 parent 6e72120 commit 26f8e68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/protocols/webrtc/peer_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ outer:
// GatherIncomingTracks gathers incoming tracks.
func (co *PeerConnection) GatherIncomingTracks(
ctx context.Context,
count int,
maxCount int,
) ([]*IncomingTrack, error) {
var tracks []*IncomingTrack

Expand All @@ -237,7 +237,7 @@ func (co *PeerConnection) GatherIncomingTracks(
for {
select {
case <-t.C:
if count == 0 {
if maxCount == 0 && len(tracks) != 0 {
return tracks, nil
}
return nil, fmt.Errorf("deadline exceeded while waiting tracks")
Expand All @@ -249,7 +249,7 @@ func (co *PeerConnection) GatherIncomingTracks(
}
tracks = append(tracks, track)

if len(tracks) == count || len(tracks) >= 2 {
if len(tracks) == maxCount || len(tracks) >= 2 {
return tracks, nil
}

Expand Down

0 comments on commit 26f8e68

Please sign in to comment.