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

Pass a track to the RTCP listener.

This commit is contained in:
Juliusz Chroboczek 2020-04-28 17:17:52 +02:00
parent d9a7f3d6c0
commit 151f37c062

View file

@ -481,7 +481,7 @@ func addDownTrack(c *client, id string, remoteTrack *upTrack, remoteConn *upConn
conn.tracks = append(conn.tracks, track) conn.tracks = append(conn.tracks, track)
remoteTrack.addLocal(track) remoteTrack.addLocal(track)
go rtcpListener(c.group, conn, s, track.maxBitrate) go rtcpListener(c.group, conn, track, s)
return conn, s, nil return conn, s, nil
} }
@ -492,7 +492,7 @@ func msSinceEpoch() uint64 {
return uint64(time.Since(epoch) / time.Millisecond) return uint64(time.Since(epoch) / time.Millisecond)
} }
func rtcpListener(g *group, c *downConnection, s *webrtc.RTPSender, bitrate *timeStampedBitrate) { func rtcpListener(g *group, conn *downConnection, track *downTrack, s *webrtc.RTPSender) {
for { for {
ps, err := s.ReadRTCP() ps, err := s.ReadRTCP()
if err != nil { if err != nil {
@ -505,7 +505,7 @@ func rtcpListener(g *group, c *downConnection, s *webrtc.RTPSender, bitrate *tim
for _, p := range ps { for _, p := range ps {
switch p := p.(type) { switch p := p.(type) {
case *rtcp.PictureLossIndication: case *rtcp.PictureLossIndication:
err := sendPLI(c.remote.pc, p.MediaSSRC) err := sendPLI(conn.remote.pc, p.MediaSSRC)
if err != nil { if err != nil {
log.Printf("sendPLI: %v", err) log.Printf("sendPLI: %v", err)
} }
@ -515,11 +515,11 @@ func rtcpListener(g *group, c *downConnection, s *webrtc.RTPSender, bitrate *tim
// data between the two writes. This shouldn't // data between the two writes. This shouldn't
// matter, we'll recover at the next sample. // matter, we'll recover at the next sample.
atomic.StoreUint64( atomic.StoreUint64(
&bitrate.bitrate, &track.maxBitrate.bitrate,
p.Bitrate, p.Bitrate,
) )
atomic.StoreUint64( atomic.StoreUint64(
&bitrate.timestamp, &track.maxBitrate.timestamp,
uint64(ms), uint64(ms),
) )
case *rtcp.ReceiverReport: case *rtcp.ReceiverReport: