diff --git a/generator/flv_generator.go b/generator/flv_generator.go index 7c6d6ddd..375e2154 100644 --- a/generator/flv_generator.go +++ b/generator/flv_generator.go @@ -62,15 +62,15 @@ type flvGenerator struct { isGenerating bool } -// GetInputChan returns the input channel to the generator. This is where the +// InputChan returns the input channel to the generator. This is where the // raw data frames are entered into the generator -func (g *flvGenerator) GetInputChan() chan []byte { +func (g *flvGenerator) InputChan() chan []byte { return g.inputChan } -// GetOutputChan retuns the output chan of the generator - this is where the +// OutputChan retuns the output chan of the generator - this is where the // flv packets (more specifically tags) are outputted. -func (g *flvGenerator) GetOutputChan() chan []byte { +func (g *flvGenerator) OutputChan() <-chan []byte { return g.outputChan } diff --git a/generator/generator.go b/generator/generator.go index 5e04fb3d..50bace43 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -28,8 +28,8 @@ LICENSE package generator type Generator interface { - GetInputChan() chan []byte - GetOutputChan() chan []byte + InputChan() chan []byte + OutputChan() <-chan []byte Start() Stop() } diff --git a/generator/mpegts_generator.go b/generator/mpegts_generator.go index 2cc4792e..4b9d7e0b 100644 --- a/generator/mpegts_generator.go +++ b/generator/mpegts_generator.go @@ -86,15 +86,15 @@ type tsGenerator struct { isGenerating bool } -// getInputChan returns a handle to the nalInputChan (inputChan) so that nal units +// InputChan returns a handle to the nalInputChan (inputChan) so that nal units // can be passed to the generator and processed -func (g *tsGenerator) GetInputChan() chan []byte { +func (g *tsGenerator) InputChan() chan []byte { return g.nalInputChan } -// GetOutputChan returns a handle to the generator output chan where the mpegts +// OutputChan returns a handle to the generator output chan where the mpegts // packets will show up once ready to go -func (g *tsGenerator) GetOutputChan() chan []byte { +func (g *tsGenerator) OutputChan() <-chan []byte { return g.outputChan } diff --git a/parser/h264.go b/parser/h264.go index 0ad65c6a..922066b3 100644 --- a/parser/h264.go +++ b/parser/h264.go @@ -77,22 +77,22 @@ func (p *h264Parser) SetDelay(delay uint) { p.delay = delay } -// GetInputChan returns a handle to the input channel of the parser -func (p *h264Parser) GetInputChan() chan byte { +// InputChan returns a handle to the input channel of the parser +func (p *h264Parser) InputChan() chan byte { return p.inputChan } -// GetOutputChan returns a handle to the output chan of the parser -func (p *h264Parser) GetOutputChan() chan []byte { +// OutputChan returns a handle to the output chan of the parser +func (p *h264Parser) OutputChan() <-chan []byte { return p.userOutputChanRef } // SetOutputChan sets the parser output chan to the passed output chan. This is // useful if we want the parser output to go directly to a generator of some sort // for packetization. -func (p *h264Parser) SetOutputChan(aChan chan []byte) { - p.parserOutputChanRef = aChan - p.userOutputChanRef = aChan +func (p *h264Parser) SetOutputChan(o chan []byte) { + p.parserOutputChanRef = o + p.userOutputChanRef = o } // parse interprets an incoming h264 stream and extracts individual frames diff --git a/parser/mjpeg.go b/parser/mjpeg.go index 2c9a8736..70901658 100644 --- a/parser/mjpeg.go +++ b/parser/mjpeg.go @@ -57,17 +57,17 @@ func (p *mjpegParser) SetDelay(delay uint) { p.delay = delay } -func (p *mjpegParser) GetInputChan() chan byte { +func (p *mjpegParser) InputChan() chan byte { return p.inputChan } -func (p *mjpegParser) GetOutputChan() chan []byte { +func (p *mjpegParser) OutputChan() <-chan []byte { return p.userOutputChanRef } -func (p *mjpegParser) SetOutputChan(aChan chan []byte) { - p.parserOutputChanRef = aChan - p.userOutputChanRef = aChan +func (p *mjpegParser) SetOutputChan(o chan []byte) { + p.parserOutputChanRef = o + p.userOutputChanRef = o } func (p *mjpegParser) parse() { diff --git a/parser/parser.go b/parser/parser.go index 59ac5448..157b27c1 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -43,8 +43,8 @@ var ( type Parser interface { Stop() Start() - GetInputChan() chan byte - GetOutputChan() chan []byte + InputChan() chan byte + OutputChan() <-chan []byte SetOutputChan(achan chan []byte) SetDelay(delay uint) } diff --git a/revid/revid.go b/revid/revid.go index 4332e987..235b96eb 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -203,7 +203,7 @@ func (r *Revid) reset(config Config) error { // We have packetization of some sort, so we want to send data to Generator // to perform packetization r.getFrame = r.getFramePacketization - r.parser.SetOutputChan(r.generator.GetInputChan()) + r.parser.SetOutputChan(r.generator.InputChan()) return nil } @@ -300,7 +300,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() + return <-r.generator.OutputChan() } // packClips takes data segments; whether that be tsPackets or mjpeg frames and @@ -312,7 +312,7 @@ func (r *Revid) packClips() { select { // TODO: This is temporary, need to work out how to make this work // for cases when there is not packetisation. - case frame := <-r.generator.GetOutputChan(): + case frame := <-r.generator.OutputChan(): lenOfFrame := len(frame) if lenOfFrame > ringBufferElementSize { r.Log(Warning, fmt.Sprintf("Frame was too big: %v bytes, getting another one!", lenOfFrame)) @@ -518,7 +518,7 @@ func (r *Revid) readCamera() { r.Log(Error, "No data from camera!") time.Sleep(cameraRetryPeriod) default: - r.parser.GetInputChan() <- data[0] + r.parser.InputChan() <- data[0] } } r.Log(Info, "Not trying to read from camera anymore!") @@ -547,7 +547,7 @@ func (r *Revid) readFile() error { return err } for i := range data { - r.parser.GetInputChan() <- data[i] + r.parser.InputChan() <- data[i] } r.inputFile.Close() return nil