1
0
Fork 0
forked from External/mediamtx

webrtc: return an error when proxying stream with no tracks (#3042)

This commit is contained in:
Alessandro Ros 2024-02-18 21:58:11 +01:00 committed by GitHub
parent 6e721201ed
commit a52f550ee6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 3 deletions

View file

@ -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
@ -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")
@ -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
}