From 0ca75538d2d9614ad09f5966eb07e62e379df373 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 12 Mar 2019 15:18:02 +1030 Subject: [PATCH] revid: created multiSender retry field and setting based on outputs Added a retry field for the multiSender which will be used to decide whether to retry sending or not. This is being set true if we have a http sender and no other senders. --- revid/revid.go | 9 +++++++-- revid/senders.go | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index c74e1a3d..1345e191 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -188,9 +188,11 @@ func (r *Revid) reset(config Config) error { // to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the // output requires FLV encoding. var sender loadSender + var retry bool for _, out := range r.config.Outputs { switch out { case Http: + retry = true sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil) case Rtp: sender, err = newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) @@ -214,7 +216,10 @@ func (r *Revid) reset(config Config) error { // encoder to revid's encoder slice, and give this encoder the mtsSenders // as a destination. if len(mtsSenders) != 0 { - ms := newMultiSender(r, mtsSenders) + if len(mtsSenders) != 1 && len(flvSenders) != 0 { + retry = false + } + ms := newMultiSender(r, mtsSenders, retry) e := mts.NewEncoder(ms, float64(r.config.FrameRate)) r.encoder = append(r.encoder, e) } @@ -223,7 +228,7 @@ func (r *Revid) reset(config Config) error { // encoder to revid's encoder slice, and give this encoder the flvSenders // as a destination. if len(flvSenders) != 0 { - ms := newMultiSender(r, flvSenders) + ms := newMultiSender(r, flvSenders, false) e, err := flv.NewEncoder(ms, true, true, int(r.config.FrameRate)) if err != nil { return err diff --git a/revid/senders.go b/revid/senders.go index 4a96ad2f..7c2ed9b1 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -61,8 +61,8 @@ type multiSender struct { } // newMultiSender returns a pointer to a new multiSender. -func newMultiSender(owner *Revid, senders []loadSender) *multiSender { - return &multiSender{owner: owner, senders: senders} +func newMultiSender(owner *Revid, senders []loadSender, retry bool) *multiSender { + return &multiSender{owner: owner, senders: senders, retry: retry} } // Write implements io.Writer. The written slice will be sent to each loadSender