From 820dae7b4c12a4e77e29ecc5613b4693a391fdc5 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Sat, 9 Jun 2018 14:58:33 +0930 Subject: [PATCH] revid: various cleanups --- revid/revid.go | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/revid/revid.go b/revid/revid.go index fc34877b..df4e4916 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -1,6 +1,6 @@ /* NAME - Revid.go + revid.go DESCRIPTION See Readme.md @@ -187,7 +187,7 @@ func (r *Revid) reset(config Config) error { // no packetisation - Revid output chan grabs raw data straight from parser r.parser.SetOutputChan(r.outputChan) r.getFrame = r.getFrameNoPacketization - goto noPacketizationSetup + return nil case Mpegts: r.Log(Info, "Using MPEGTS packetisation!") frameRateAsInt, _ := strconv.Atoi(r.config.FrameRate) @@ -201,7 +201,6 @@ func (r *Revid) reset(config Config) error { // to perform packetization r.getFrame = r.getFramePacketization r.parser.SetOutputChan(r.generator.GetInputChan()) -noPacketizationSetup: return nil } @@ -218,20 +217,21 @@ func (r *Revid) ChangeConfig(c Config) error { return err } r.Start() - return err + return nil } // Log takes a logtype and message and tries to send this information to the // logger provided in the revid config - if there is one, otherwise the message // is sent to stdout func (r *Revid) Log(logType, m string) { - if r.config.Verbosity == Yes { - if r.config.Logger != nil { - r.config.Logger.Log("revid", logType, m) - return - } - fmt.Println(logType + ": " + m) + if r.config.Verbosity != Yes { + return } + if r.config.Logger != nil { + r.config.Logger.Log("revid", logType, m) + return + } + fmt.Println(logType + ": " + m) } // IsRunning returns true if the revid is currently running and false otherwise @@ -286,7 +286,6 @@ func (r *Revid) Stop() { if r.cmd != nil && r.cmd.Process != nil { r.cmd.Process.Kill() } - } // getFrameNoPacketization gets a frame directly from the revid output chan @@ -298,22 +297,7 @@ func (r *Revid) getFrameNoPacketization() []byte { // getFramePacketization gets a frame from the generators output chan - the // the generator being an mpegts or flv generator depending on the config func (r *Revid) getFramePacketization() []byte { - return <-(r.generator.GetOutputChan()) -} - -// flushDataPacketization removes data from the Revid inst's coutput chan -func (r *Revid) flushData() { - switch r.config.Packetization { - case Flv: - for { - select { - case <-(r.generator.GetOutputChan()): - default: - goto done - } - } - } -done: + return <-r.generator.GetOutputChan() } // packClips takes data segments; whether that be tsPackets or mjpeg frames and