diff --git a/revid/revid.go b/revid/revid.go index bcf0d759..e6bc2f3a 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -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) } } diff --git a/revid/revid_test.go b/revid/revid_test.go index 14519fd8..91f5d329 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -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 { diff --git a/revid/senders.go b/revid/senders.go index 959fba21..a8b77c35 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -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") diff --git a/revid/senders_test.go b/revid/senders_test.go index d327077e..a435e512 100644 --- a/revid/senders_test.go +++ b/revid/senders_test.go @@ -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)