revid: improved some naming

This commit is contained in:
Saxon 2019-03-29 16:22:51 +10:30
parent 7c724c9fc3
commit 8cc7f6e500
4 changed files with 17 additions and 17 deletions

View File

@ -189,30 +189,30 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer, flvEnc func
// We will go through our outputs and create the corresponding senders to add
// to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
// output requires FLV encoding.
var sender io.Writer
var w io.Writer
for _, out := range r.config.Outputs {
switch out {
case Http:
sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil)
mtsSenders = append(mtsSenders, sender)
w = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil)
mtsSenders = append(mtsSenders, w)
case Rtp:
sender, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
w, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
}
mtsSenders = append(mtsSenders, sender)
mtsSenders = append(mtsSenders, w)
case File:
sender, err := newFileSender(r.config.OutputPath)
w, err := newFileSender(r.config.OutputPath)
if err != nil {
return err
}
mtsSenders = append(mtsSenders, sender)
mtsSenders = append(mtsSenders, w)
case Rtmp:
sender, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
w, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
}
flvSenders = append(flvSenders, sender)
flvSenders = append(flvSenders, w)
}
}

View File

@ -237,7 +237,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
ms = e.(*tstFlvEncoder).dst
}
senders := ms.(*multiSender).senders
senders := ms.(*multiSender).dst
got = len(senders)
want = len(test.encoders[idx].destinations)
if got != want {

View File

@ -59,28 +59,28 @@ type Log func(level int8, message string, params ...interface{})
// multiSender implements io.Writer. It provides the capacity to send to multiple
// senders from a single Write call.
type multiSender struct {
senders []io.Writer
log Log
dst []io.Writer
log Log
}
// newMultiSender returns a pointer to a new multiSender.
func newMultiSender(senders []io.Writer, log Log) *multiSender {
return &multiSender{
senders: senders,
log: log,
dst: senders,
log: log,
}
}
// Write implements io.Writer. This will call load (with the passed slice), send
// and release on all senders of multiSender.
func (s *multiSender) Write(d []byte) (int, error) {
for i, sender := range s.senders {
for i, sender := range s.dst {
_, err := sender.Write(d)
if err != nil {
s.log(logger.Warning, pkg+"send failed", "sender", i, "error", err)
}
}
for _, sender := range s.senders {
for _, sender := range s.dst {
s, ok := sender.(loadSender)
if !ok {
panic("sender is not a loadSender")

View File

@ -335,7 +335,7 @@ func TestMultiSenderWrite(t *testing.T) {
// Check that the senders got the data correctly from the writes.
for i := byte(0); i < noOfWrites; i++ {
for j, dest := range ms.senders {
for j, dest := range ms.dst {
got := dest.(*dummyLoadSender).buf[i][0]
if got != i {
t.Errorf("Did not get expected result for sender: %v. \nGot: %v\nWant: %v\n", j, got, i)