mirror of https://bitbucket.org/ausocean/av.git
Added bitrate reporting to RTP sender.
This commit is contained in:
parent
cdd74c7a22
commit
1876fe9dea
|
@ -276,7 +276,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
)
|
)
|
||||||
mtsSenders = append(mtsSenders, w)
|
mtsSenders = append(mtsSenders, w)
|
||||||
case config.OutputRTP:
|
case config.OutputRTP:
|
||||||
w, err := newRtpSender(r.cfg.RTPAddress, r.cfg.Logger.Log, r.cfg.FrameRate)
|
w, err := newRtpSender(r.cfg.RTPAddress, r.cfg.Logger.Log, r.cfg.FrameRate, r.bitrate.Report)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.cfg.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
|
r.cfg.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,9 +413,10 @@ type rtpSender struct {
|
||||||
log func(lvl int8, msg string, args ...interface{})
|
log func(lvl int8, msg string, args ...interface{})
|
||||||
encoder *rtp.Encoder
|
encoder *rtp.Encoder
|
||||||
data []byte
|
data []byte
|
||||||
|
report func(sent int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRtpSender(addr string, log func(lvl int8, msg string, args ...interface{}), fps uint) (*rtpSender, error) {
|
func newRtpSender(addr string, log func(lvl int8, msg string, args ...interface{}), fps uint, report func(sent int)) (*rtpSender, error) {
|
||||||
conn, err := net.Dial("udp", addr)
|
conn, err := net.Dial("udp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -423,6 +424,7 @@ func newRtpSender(addr string, log func(lvl int8, msg string, args ...interface{
|
||||||
s := &rtpSender{
|
s := &rtpSender{
|
||||||
log: log,
|
log: log,
|
||||||
encoder: rtp.NewEncoder(conn, int(fps)),
|
encoder: rtp.NewEncoder(conn, int(fps)),
|
||||||
|
report: report,
|
||||||
}
|
}
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
@ -435,6 +437,7 @@ func (s *rtpSender) Write(d []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(logger.Warning, pkg+"rtpSender: write error", err.Error())
|
s.log(logger.Warning, pkg+"rtpSender: write error", err.Error())
|
||||||
}
|
}
|
||||||
|
s.report(len(d))
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue