revid: simplified signature for setupPipeline and fixed commenting

This commit is contained in:
Saxon 2019-04-03 11:29:54 +10:30
parent dbcac80d1f
commit 9bd41b7c3b
2 changed files with 7 additions and 9 deletions

View File

@ -177,10 +177,8 @@ func (r *Revid) setConfig(config Config) error {
return nil return nil
} }
// setupPipeline performs logic pertinent to setting up the data pipeline based // setupPipeline constructs a data pipeline.
// on the current config. func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.Writer, rate int) (io.Writer, error), multiWriter func(...io.Writer) io.Writer) error {
func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer,
flvEnc func(io.Writer, int) (io.Writer, error), multiWriter func(...io.Writer) io.Writer) error {
r.buffer = (*buffer)(ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)) r.buffer = (*buffer)(ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout))
r.encoder = make([]io.Writer, 0) r.encoder = make([]io.Writer, 0)
@ -224,7 +222,7 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer,
// as a destination. // as a destination.
if len(mtsSenders) != 0 { if len(mtsSenders) != 0 {
mw := multiWriter(mtsSenders...) mw := multiWriter(mtsSenders...)
e := mtsEnc(mw, int(r.config.FrameRate)) e, _ := mtsEnc(mw, int(r.config.FrameRate))
r.encoder = append(r.encoder, e) r.encoder = append(r.encoder, e)
} }
@ -260,9 +258,9 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer,
return nil return nil
} }
func newMtsEncoder(dst io.Writer, fps int) io.Writer { func newMtsEncoder(dst io.Writer, fps int) (io.Writer, error) {
e := mts.NewEncoder(dst, float64(fps)) e := mts.NewEncoder(dst, float64(fps))
return e return e, nil
} }
func newFlvEncoder(dst io.Writer, fps int) (io.Writer, error) { func newFlvEncoder(dst io.Writer, fps int) (io.Writer, error) {

View File

@ -75,8 +75,8 @@ type tstMtsEncoder struct {
} }
// newTstMtsEncoder returns a pointer to a newTsMtsEncoder. // newTstMtsEncoder returns a pointer to a newTsMtsEncoder.
func newTstMtsEncoder(dst io.Writer, fps int) io.Writer { func newTstMtsEncoder(dst io.Writer, fps int) (io.Writer, error) {
return &tstMtsEncoder{dst: dst} return &tstMtsEncoder{dst: dst}, nil
} }
func (e *tstMtsEncoder) Write(d []byte) (int, error) { return 0, nil } func (e *tstMtsEncoder) Write(d []byte) (int, error) { return 0, nil }