mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Reuse single buffer in RTCP listeners.
This commit is contained in:
parent
0a49dc4569
commit
3083b89db9
1 changed files with 21 additions and 6 deletions
|
@ -622,17 +622,24 @@ func sendRecovery(p *rtcp.TransportLayerNack, track *rtpDownTrack) {
|
|||
}
|
||||
|
||||
func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPReceiver) {
|
||||
buf := make([]byte, 1500)
|
||||
|
||||
for {
|
||||
firstSR := false
|
||||
ps, err := r.ReadRTCP()
|
||||
n, err := r.Read(buf)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Printf("Read RTCP: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ps, err := rtcp.Unmarshal(buf[:n])
|
||||
if err != nil {
|
||||
log.Printf("Unmarshal RTCP: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
now := rtptime.Jiffies()
|
||||
jiffies := rtptime.Jiffies()
|
||||
|
||||
for _, p := range ps {
|
||||
local := track.getLocal()
|
||||
|
@ -642,7 +649,7 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
|
|||
if track.srTime == 0 {
|
||||
firstSR = true
|
||||
}
|
||||
track.srTime = now
|
||||
track.srTime = jiffies
|
||||
track.srNTPTime = p.NTPTime
|
||||
track.srRTPTime = p.RTPTime
|
||||
track.mu.Unlock()
|
||||
|
@ -904,14 +911,22 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
|
|||
var gotFir bool
|
||||
lastFirSeqno := uint8(0)
|
||||
|
||||
buf := make([]byte, 1500)
|
||||
|
||||
for {
|
||||
ps, err := s.ReadRTCP()
|
||||
n, err := s.Read(buf)
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
log.Printf("Read RTCP: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ps, err := rtcp.Unmarshal(buf[:n])
|
||||
if err != nil {
|
||||
log.Printf("Unmarshal RTCP: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
jiffies := rtptime.Jiffies()
|
||||
|
||||
for _, p := range ps {
|
||||
|
|
Loading…
Reference in a new issue