mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +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) {
|
func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPReceiver) {
|
||||||
|
buf := make([]byte, 1500)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
firstSR := false
|
firstSR := false
|
||||||
ps, err := r.ReadRTCP()
|
n, err := r.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
log.Printf("Read RTCP: %v", err)
|
log.Printf("Read RTCP: %v", err)
|
||||||
}
|
}
|
||||||
return
|
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 {
|
for _, p := range ps {
|
||||||
local := track.getLocal()
|
local := track.getLocal()
|
||||||
|
@ -642,7 +649,7 @@ func rtcpUpListener(conn *rtpUpConnection, track *rtpUpTrack, r *webrtc.RTPRecei
|
||||||
if track.srTime == 0 {
|
if track.srTime == 0 {
|
||||||
firstSR = true
|
firstSR = true
|
||||||
}
|
}
|
||||||
track.srTime = now
|
track.srTime = jiffies
|
||||||
track.srNTPTime = p.NTPTime
|
track.srNTPTime = p.NTPTime
|
||||||
track.srRTPTime = p.RTPTime
|
track.srRTPTime = p.RTPTime
|
||||||
track.mu.Unlock()
|
track.mu.Unlock()
|
||||||
|
@ -904,14 +911,22 @@ func rtcpDownListener(conn *rtpDownConnection, track *rtpDownTrack, s *webrtc.RT
|
||||||
var gotFir bool
|
var gotFir bool
|
||||||
lastFirSeqno := uint8(0)
|
lastFirSeqno := uint8(0)
|
||||||
|
|
||||||
|
buf := make([]byte, 1500)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
ps, err := s.ReadRTCP()
|
n, err := s.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
log.Printf("Read RTCP: %v", err)
|
log.Printf("Read RTCP: %v", err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ps, err := rtcp.Unmarshal(buf[:n])
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Unmarshal RTCP: %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
jiffies := rtptime.Jiffies()
|
jiffies := rtptime.Jiffies()
|
||||||
|
|
||||||
for _, p := range ps {
|
for _, p := range ps {
|
||||||
|
|
Loading…
Reference in a new issue