revid: simplified logic for setup of senders and encoders in revid.reset

This commit is contained in:
Saxon 2019-03-12 12:59:10 +10:30
parent cce05db3f2
commit 1c75867ba5
1 changed files with 11 additions and 14 deletions

View File

@ -187,30 +187,27 @@ func (r *Revid) reset(config Config) error {
// We will go through our outputs and create the corresponding senders to add // 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 // to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
// output requires FLV encoding. // output requires FLV encoding.
var sender loadSender
for _, out := range r.config.Outputs { for _, out := range r.config.Outputs {
switch out { switch out {
case Http: case Http:
s := newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil) sender = newMtsSender(newMinimalHttpSender(r.ns, r.config.Logger.Log), nil)
mtsSenders = append(mtsSenders, s)
case Rtp: case Rtp:
s, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) sender, err = newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
if err != nil {
return err
}
mtsSenders = append(mtsSenders, s)
case File: case File:
s, err := newFileSender(r.config.OutputPath) sender, err = newFileSender(r.config.OutputPath)
if err != nil {
return err
}
mtsSenders = append(mtsSenders, s)
case Rtmp: 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 { if err != nil {
return err 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 // If we have some senders that require MPEGTS encoding then add an MPEGTS