mirror of https://bitbucket.org/ausocean/av.git
revid/senders.go: reportSent -> report
This commit is contained in:
parent
9a0fa09879
commit
cdd74c7a22
|
@ -59,17 +59,17 @@ const (
|
||||||
// httpSender provides an implemntation of io.Writer to perform sends to a http
|
// httpSender provides an implemntation of io.Writer to perform sends to a http
|
||||||
// destination.
|
// destination.
|
||||||
type httpSender struct {
|
type httpSender struct {
|
||||||
client *netsender.Sender
|
client *netsender.Sender
|
||||||
log func(lvl int8, msg string, args ...interface{})
|
log func(lvl int8, msg string, args ...interface{})
|
||||||
reportSent func(sent int)
|
report func(sent int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// newHttpSender returns a pointer to a new httpSender.
|
// newHttpSender returns a pointer to a new httpSender.
|
||||||
func newHttpSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{}), reportSent func(sent int)) *httpSender {
|
func newHttpSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...interface{}), report func(sent int)) *httpSender {
|
||||||
return &httpSender{
|
return &httpSender{
|
||||||
client: ns,
|
client: ns,
|
||||||
log: log,
|
log: log,
|
||||||
reportSent: reportSent,
|
report: report,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ func newHttpSender(ns *netsender.Sender, log func(lvl int8, msg string, args ...
|
||||||
func (s *httpSender) Write(d []byte) (int, error) {
|
func (s *httpSender) Write(d []byte) (int, error) {
|
||||||
err := httpSend(d, s.client, s.log)
|
err := httpSend(d, s.client, s.log)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s.reportSent(len(d))
|
s.report(len(d))
|
||||||
}
|
}
|
||||||
return len(d), err
|
return len(d), err
|
||||||
}
|
}
|
||||||
|
@ -274,18 +274,18 @@ func (s *mtsSender) Close() error {
|
||||||
|
|
||||||
// rtmpSender implements loadSender for a native RTMP destination.
|
// rtmpSender implements loadSender for a native RTMP destination.
|
||||||
type rtmpSender struct {
|
type rtmpSender struct {
|
||||||
conn *rtmp.Conn
|
conn *rtmp.Conn
|
||||||
url string
|
url string
|
||||||
timeout uint
|
timeout uint
|
||||||
retries int
|
retries int
|
||||||
log func(lvl int8, msg string, args ...interface{})
|
log func(lvl int8, msg string, args ...interface{})
|
||||||
ring *vring.Buffer
|
ring *vring.Buffer
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
reportSent func(sent int)
|
report func(sent int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRtmpSender(url string, timeout uint, retries int, rb *vring.Buffer, log func(lvl int8, msg string, args ...interface{}), reportSent func(sent int)) (*rtmpSender, error) {
|
func newRtmpSender(url string, timeout uint, retries int, rb *vring.Buffer, log func(lvl int8, msg string, args ...interface{}), report func(sent int)) (*rtmpSender, error) {
|
||||||
var conn *rtmp.Conn
|
var conn *rtmp.Conn
|
||||||
var err error
|
var err error
|
||||||
for n := 0; n < retries; n++ {
|
for n := 0; n < retries; n++ {
|
||||||
|
@ -299,14 +299,14 @@ func newRtmpSender(url string, timeout uint, retries int, rb *vring.Buffer, log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s := &rtmpSender{
|
s := &rtmpSender{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
url: url,
|
url: url,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
retries: retries,
|
retries: retries,
|
||||||
log: log,
|
log: log,
|
||||||
ring: rb,
|
ring: rb,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
reportSent: reportSent,
|
report: report,
|
||||||
}
|
}
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
go s.output()
|
go s.output()
|
||||||
|
@ -372,7 +372,7 @@ func (s *rtmpSender) Write(d []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(logger.Warning, pkg+"rtmpSender: ring buffer write error", "error", err.Error())
|
s.log(logger.Warning, pkg+"rtmpSender: ring buffer write error", "error", err.Error())
|
||||||
}
|
}
|
||||||
s.reportSent(len(d))
|
s.report(len(d))
|
||||||
return len(d), nil
|
return len(d), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue