1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-26 02:25:58 +01:00

Return an error when adding a duplicate down track.

This commit is contained in:
Juliusz Chroboczek 2021-02-02 19:06:37 +01:00
parent 73f72c45fc
commit d9e72f4fd0

View file

@ -403,6 +403,20 @@ func addDownTrack(c *webClient, conn *rtpDownConnection, remoteTrack conn.UpTrac
return nil, errors.New("unexpected up track type") 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( local, err := webrtc.NewTrackLocalStaticRTP(
remoteTrack.Codec(), remoteTrack.Codec(),
rt.track.ID(), rt.track.StreamID(), rt.track.ID(), rt.track.StreamID(),
@ -431,9 +445,7 @@ func addDownTrack(c *webClient, conn *rtpDownConnection, remoteTrack conn.UpTrac
atomics: &downTrackAtomics{}, atomics: &downTrackAtomics{},
} }
conn.mu.Lock()
conn.tracks = append(conn.tracks, track) conn.tracks = append(conn.tracks, track)
conn.mu.Unlock()
go rtcpDownListener(conn, track, sender) go rtcpDownListener(conn, track, sender)