From 1c75867ba5c03cd580625d1733d2d616b9b807b1 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 12 Mar 2019 12:59:10 +1030 Subject: [PATCH] revid: simplified logic for setup of senders and encoders in revid.reset --- revid/revid.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index c007ce5c..c74e1a3d 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -187,30 +187,27 @@ func (r *Revid) reset(config Config) error { // 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 loadSender for _, out := range r.config.Outputs { switch out { case Http: - s := newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil) - mtsSenders = append(mtsSenders, s) + sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil) case Rtp: - s, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) - if err != nil { - return err - } - mtsSenders = append(mtsSenders, s) + sender, err = newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) case File: - s, err := newFileSender(r.config.OutputPath) - if err != nil { - return err - } - mtsSenders = append(mtsSenders, s) + sender, err = newFileSender(r.config.OutputPath) case Rtmp: - s, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log) + sender, err = newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log) if err != nil { return err } - flvSenders = append(flvSenders, s) + flvSenders = append(flvSenders, sender) + continue } + if err != nil { + return err + } + mtsSenders = append(mtsSenders, sender) } // If we have some senders that require MPEGTS encoding then add an MPEGTS