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