1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 02:05:59 +01:00

Move rate estimation into rtpDownTrack.WriteRTP.

This commit is contained in:
Juliusz Chroboczek 2021-05-11 22:41:56 +02:00
parent c52e1f4ce0
commit d3f53e6ada
4 changed files with 8 additions and 13 deletions

View file

@ -39,7 +39,6 @@ type Down interface {
// Type DownTrack represents a track in the server to client direction.
type DownTrack interface {
WriteRTP(packat *rtp.Packet) error
Accumulate(bytes uint32)
SetTimeOffset(ntp uint64, rtp uint32)
SetCname(string)
GetMaxBitrate() uint64

View file

@ -603,7 +603,3 @@ func (conn *diskConn) initWriter(width, height uint32) error {
func (t *diskTrack) GetMaxBitrate() uint64 {
return ^uint64(0)
}
func (t *diskTrack) Accumulate(bytes uint32) {
return
}

View file

@ -90,11 +90,14 @@ type rtpDownTrack struct {
}
func (down *rtpDownTrack) WriteRTP(packet *rtp.Packet) error {
return down.track.WriteRTP(packet)
}
func (down *rtpDownTrack) Accumulate(bytes uint32) {
down.rate.Accumulate(bytes)
err := down.track.WriteRTP(packet)
if err == nil {
// we should account for extensions
down.rate.Accumulate(
uint32(12 + 4*len(packet.CSRC) + len(packet.Payload)),
)
}
return err
}
func (down *rtpDownTrack) SetTimeOffset(ntp uint64, rtp uint32) {
@ -650,7 +653,6 @@ func gotNACK(conn *rtpDownConnection, track *rtpDownTrack, p *rtcp.TransportLaye
log.Printf("WriteRTP: %v", err)
return false
}
track.rate.Accumulate(uint32(l))
return true
})
}

View file

@ -225,7 +225,6 @@ func sendKeyframe(kf []uint16, track conn.DownTrack, cache *packetcache.Cache) {
if err != nil {
return
}
track.Accumulate(uint32(bytes))
}
}
@ -321,7 +320,6 @@ func rtpWriterLoop(writer *rtpWriter, up *rtpUpConnection, track *rtpUpTrack) {
if err != nil {
continue
}
l.Accumulate(uint32(bytes))
}
}
}