revid: rename GetBitrate to Bitrate

Also change to int; when we get more than 2Gbs^-1, we'll probably be
using 64 bit devices.
This commit is contained in:
Dan Kortschak 2018-06-17 20:57:50 +09:30
parent 5bdd66e22b
commit 6de4f8c9a6
2 changed files with 24 additions and 24 deletions

View File

@ -306,7 +306,7 @@ func sendTo(ns *netsender.Sender) error {
inputs := netsender.MakePins(ns.GetConfigParam("ip"), "X") inputs := netsender.MakePins(ns.GetConfigParam("ip"), "X")
for i, pin := range inputs { for i, pin := range inputs {
if pin.Name == "X23" { if pin.Name == "X23" {
inputs[i].Value = int(revidInst.GetBitrate()) inputs[i].Value = revidInst.Bitrate()
} }
} }

View File

@ -99,7 +99,7 @@ type Revid struct {
getFrame func() []byte getFrame func() []byte
destination loadSender destination loadSender
rtmpInst rtmp.Session rtmpInst rtmp.Session
currentBitrate int64 bitrate int
} }
// NewRevid returns a pointer to a new Revid with the desired // NewRevid returns a pointer to a new Revid with the desired
@ -116,10 +116,9 @@ func New(c Config) (*Revid, error) {
return &r, nil return &r, nil
} }
// Returns the currently saved bitrate from the most recent bitrate check // Bitrate returns the result of the most recent bitrate check.
// check bitrate output delay in consts for this period func (r *Revid) Bitrate() int {
func (r *Revid) GetBitrate() int64 { return r.bitrate
return r.currentBitrate
} }
// GetConfigRef returns a pointer to the revidInst's Config struct object // GetConfigRef returns a pointer to the revidInst's Config struct object
@ -417,8 +416,9 @@ func (r *Revid) outputClips() {
now = time.Now() now = time.Now()
deltaTime := now.Sub(prevTime) deltaTime := now.Sub(prevTime)
if deltaTime > bitrateTime { if deltaTime > bitrateTime {
r.currentBitrate = int64(float64(bytes*8) / float64(deltaTime/1e9)) // FIXME(kortschak): For subsecond deltaTime, this will give infinite bitrate.
r.Log(Debug, fmt.Sprintf("Bitrate: %v bits/s\n", r.currentBitrate)) r.bitrate = int(float64(bytes*8) / float64(deltaTime/time.Second))
r.Log(Debug, fmt.Sprintf("Bitrate: %v bits/s\n", r.bitrate))
r.Log(Debug, fmt.Sprintf("Ring buffer size: %v\n", r.ringBuffer.Len())) r.Log(Debug, fmt.Sprintf("Ring buffer size: %v\n", r.ringBuffer.Len()))
prevTime = now prevTime = now
bytes = 0 bytes = 0