From 9bd41b7c3bf37eda8242d60c8eb82b5418e23282 Mon Sep 17 00:00:00 2001 From: Saxon Date: Wed, 3 Apr 2019 11:29:54 +1030 Subject: [PATCH] revid: simplified signature for setupPipeline and fixed commenting --- revid/revid.go | 12 +++++------- revid/revid_test.go | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index da5391bc..b8546bf6 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -177,10 +177,8 @@ func (r *Revid) setConfig(config Config) error { return nil } -// setupPipeline performs logic pertinent to setting up the data pipeline based -// on the current config. -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 { +// setupPipeline constructs a data pipeline. +func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.Writer, rate int) (io.Writer, error), multiWriter func(...io.Writer) io.Writer) error { r.buffer = (*buffer)(ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)) r.encoder = make([]io.Writer, 0) @@ -224,7 +222,7 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer, // as a destination. if len(mtsSenders) != 0 { mw := multiWriter(mtsSenders...) - e := mtsEnc(mw, int(r.config.FrameRate)) + e, _ := mtsEnc(mw, int(r.config.FrameRate)) r.encoder = append(r.encoder, e) } @@ -260,9 +258,9 @@ func (r *Revid) setupPipeline(mtsEnc func(io.Writer, int) io.Writer, 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)) - return e + return e, nil } func newFlvEncoder(dst io.Writer, fps int) (io.Writer, error) { diff --git a/revid/revid_test.go b/revid/revid_test.go index ff54d128..006cd679 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -75,8 +75,8 @@ type tstMtsEncoder struct { } // newTstMtsEncoder returns a pointer to a newTsMtsEncoder. -func newTstMtsEncoder(dst io.Writer, fps int) io.Writer { - return &tstMtsEncoder{dst: dst} +func newTstMtsEncoder(dst io.Writer, fps int) (io.Writer, error) { + return &tstMtsEncoder{dst: dst}, nil } func (e *tstMtsEncoder) Write(d []byte) (int, error) { return 0, nil }