Commit d9e72f4f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Return an error when adding a duplicate down track.

parent 73f72c45
......@@ -403,6 +403,20 @@ func addDownTrack(c *webClient, conn *rtpDownConnection, remoteTrack conn.UpTrac
return nil, errors.New("unexpected up track type")
}
conn.mu.Lock()
defer conn.mu.Unlock()
remoteSSRC := rt.track.SSRC()
for _, t := range conn.tracks {
tt, ok := t.remote.(*rtpUpTrack)
if !ok {
return nil, errors.New("unexpected up track type")
}
if tt.track.SSRC() == remoteSSRC {
return nil, os.ErrExist
}
}
local, err := webrtc.NewTrackLocalStaticRTP(
remoteTrack.Codec(),
rt.track.ID(), rt.track.StreamID(),
......@@ -431,9 +445,7 @@ func addDownTrack(c *webClient, conn *rtpDownConnection, remoteTrack conn.UpTrac
atomics: &downTrackAtomics{},
}
conn.mu.Lock()
conn.tracks = append(conn.tracks, track)
conn.mu.Unlock()
go rtcpDownListener(conn, track, sender)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment