From c73afb65f3985301aec6fc4ece5b6ec648755295 Mon Sep 17 00:00:00 2001 From: Jack Richardson Date: Wed, 31 Jan 2018 16:43:04 +1030 Subject: [PATCH] Just updating remote --- revid/RevidInstance.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index fb0f66de..a4fbd54b 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -58,12 +58,13 @@ const ( clipDuration = 1 // s mp2tPacketSize = 188 // MPEG-TS packet size mp2tMaxPackets = 2016 * clipDuration // # first multiple of 7 and 8 greater than 2000 - bufferSize = 100 / clipDuration + ringBufferSize = 100 / clipDuration + ringBufferElementSize = 500000 httpTimeOut = 5 // s packetsPerFrame = 7 h264BufferSize = 500000 bitrateTime = 60 - mjpegParserInChanLen = 10000 + mjpegParserInChanLen = 100000 ) // Log Types @@ -149,7 +150,7 @@ type revidInst struct { // successful. func NewRevidInstance(config Config) (r *revidInst, err error) { r = new(revidInst) - r.ringBuffer = ringbuffer.NewRingBuffer(bufferSize, mp2tPacketSize*mp2tMaxPackets) + r.ringBuffer = ringbuffer.NewRingBuffer(ringBufferSize, ringBufferElementSize) err = r.ChangeState(config) if err != nil { return nil, err @@ -175,6 +176,7 @@ func NewRevidInstance(config Config) (r *revidInst, err error) { case Mjpeg: r.parser = parser.NewMJPEGParser(mjpegParserInChanLen) } + r.mjpegOutputChan = make(chan []byte, 10000) switch r.config.Packetization { case None: r.parser.SetOutputChan(r.mjpegOutputChan) @@ -231,6 +233,16 @@ func (r *revidInst) ChangeState(config Config) error { return errors.New("Bad output type defined in config!") } + switch config.Packetization { + case None: + case Mpegts: + case NothingDefined: + r.Log(Warning, "No packetization option defined, defaulting to none!") + config.Packetization = None + default: + return errors.New("Bad packetization option defined in config!") + } + if config.Width == "" { r.Log(Warning, "No width defined, defaulting to 1280!") config.Width = defaultWidth @@ -427,6 +439,10 @@ func (r *revidInst) packClips() { case None: frame := <-r.mjpegOutputChan upperBound := clipSize + len(frame) + fmt.Printf("len(clip): %v\n", len(clip)) + fmt.Printf("clipsize: %v\n", clipSize) + fmt.Printf("upperBound: %v\n", upperBound) + fmt.Printf("len(frame): %v\n", len(frame)) copy(clip[clipSize:upperBound], frame) packetCount++ clipSize += len(frame)