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
// 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