mirror of https://bitbucket.org/ausocean/av.git
revid: newMultiSender returns error if the passed active function is nil
This commit is contained in:
parent
e2a6d9f4bd
commit
53382c5774
|
@ -219,7 +219,10 @@ func (r *Revid) reset(config Config) error {
|
||||||
if len(mtsSenders) != 1 && len(flvSenders) != 0 {
|
if len(mtsSenders) != 1 && len(flvSenders) != 0 {
|
||||||
retry = false
|
retry = false
|
||||||
}
|
}
|
||||||
ms := newMultiSender(mtsSenders, retry, r.IsRunning)
|
ms, _ := newMultiSender(mtsSenders, retry, r.IsRunning)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
e := mts.NewEncoder(ms, float64(r.config.FrameRate))
|
e := mts.NewEncoder(ms, float64(r.config.FrameRate))
|
||||||
r.encoder = append(r.encoder, e)
|
r.encoder = append(r.encoder, e)
|
||||||
}
|
}
|
||||||
|
@ -228,7 +231,7 @@ func (r *Revid) reset(config Config) error {
|
||||||
// encoder to revid's encoder slice, and give this encoder the flvSenders
|
// encoder to revid's encoder slice, and give this encoder the flvSenders
|
||||||
// as a destination.
|
// as a destination.
|
||||||
if len(flvSenders) != 0 {
|
if len(flvSenders) != 0 {
|
||||||
ms := newMultiSender(flvSenders, false, r.IsRunning)
|
ms, _ := newMultiSender(flvSenders, false, r.IsRunning)
|
||||||
e, err := flv.NewEncoder(ms, true, true, int(r.config.FrameRate))
|
e, err := flv.NewEncoder(ms, true, true, int(r.config.FrameRate))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -63,12 +63,16 @@ type multiSender struct {
|
||||||
// newMultiSender returns a pointer to a new multiSender. active is a function
|
// newMultiSender returns a pointer to a new multiSender. active is a function
|
||||||
// to indicate the state of the multiSenders owner i.e. whether it is running
|
// to indicate the state of the multiSenders owner i.e. whether it is running
|
||||||
// or not.
|
// or not.
|
||||||
func newMultiSender(senders []loadSender, retry bool, active func() bool) *multiSender {
|
func newMultiSender(senders []loadSender, retry bool, active func() bool) (*multiSender, error) {
|
||||||
return &multiSender{
|
if active == nil {
|
||||||
|
return nil, errors.New("multi sender requires that active func is provided")
|
||||||
|
}
|
||||||
|
s := &multiSender{
|
||||||
senders: senders,
|
senders: senders,
|
||||||
retry: retry,
|
retry: retry,
|
||||||
active: active,
|
active: active,
|
||||||
}
|
}
|
||||||
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write implements io.Writer. The written slice will be sent to each loadSender
|
// Write implements io.Writer. The written slice will be sent to each loadSender
|
||||||
|
|
Loading…
Reference in New Issue