Commit d3f53e6a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Move rate estimation into rtpDownTrack.WriteRTP.

parent c52e1f4c
......@@ -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
......
......@@ -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
}
......@@ -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
})
}
......
......@@ -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))
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment