From 724042baeb8f863048711a86b402ff37531d0b62 Mon Sep 17 00:00:00 2001 From: saxon Date: Mon, 24 Sep 2018 19:56:05 +0930 Subject: [PATCH 1/6] revid: change no of frames per clip to 25 for http --- revid/config.go | 2 +- revid/revid.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/revid/config.go b/revid/config.go index ea00f392..0b73194d 100644 --- a/revid/config.go +++ b/revid/config.go @@ -99,7 +99,7 @@ const ( defaultFramesPerClip = 1 defaultVerticalFlip = No defaultHorizontalFlip = No - httpFramesPerClip = 7 + httpFramesPerClip = 25 defaultInputCodec = H264 defaultVerbosity = No ) diff --git a/revid/revid.go b/revid/revid.go index 6cc26c7f..8fc24dc9 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -472,11 +472,10 @@ func (r *Revid) startRaspivid() error { return err } r.inputReader = stdout - go func() { - r.config.Logger.Log(smartlogger.Info, pkg+"reading camera data") - r.lexTo(r.encoder, r.inputReader, delay) - r.config.Logger.Log(smartlogger.Info, pkg+"not trying to read from camera anymore") - }() + + r.config.Logger.Log(smartlogger.Info, pkg+"reading camera data") + r.lexTo(r.encoder, r.inputReader, delay) + r.config.Logger.Log(smartlogger.Info, pkg+"not trying to read from camera anymore") return nil } From 195f52ae16a4c6d5a348926f4dc02d20aa9b9d72 Mon Sep 17 00:00:00 2001 From: saxon Date: Mon, 24 Sep 2018 20:21:49 +0930 Subject: [PATCH 2/6] revid: adding debug prints --- revid/senders.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/revid/senders.go b/revid/senders.go index 38f7856a..c3d8b04d 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -29,6 +29,7 @@ LICENSE package revid import ( + "fmt" "io" "os" "os/exec" @@ -122,6 +123,7 @@ func (s *httpSender) load(c *ring.Chunk) error { func (s *httpSender) send() error { if s.chunk == nil { + fmt.Println("chunk is nil") // Do not retry with httpSender, // so just return without error // if the chunk has been cleared. @@ -133,6 +135,7 @@ func (s *httpSender) send() error { pins := netsender.MakePins(ip, "V") for i, pin := range pins { if pin.Name == "V0" { + fmt.Println("pin is V0") send = true pins[i].Value = s.chunk.Len() pins[i].Data = s.chunk.Bytes() @@ -142,6 +145,7 @@ func (s *httpSender) send() error { } var err error if send { + fmt.Println("sending") _, _, err = s.client.Send(netsender.RequestPoll, pins) } // We will not retry, so release From 9b7b88be98f0abd251be33fad2cff9204b3d83a5 Mon Sep 17 00:00:00 2001 From: saxon Date: Mon, 24 Sep 2018 20:24:15 +0930 Subject: [PATCH 3/6] revid: adding another debug print to make sure we're flushing ring buffer --- revid/revid.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/revid/revid.go b/revid/revid.go index 8fc24dc9..cf8d8001 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -31,7 +31,7 @@ package revid import ( "errors" - _ "fmt" + "fmt" "io" "os" "os/exec" @@ -315,6 +315,7 @@ func (r *Revid) packClips() { packetCount++ clipSize += lenOfFrame if packetCount >= r.config.FramesPerClip { + fmt.Println("flushing buffer") r.ringBuffer.Flush() clipSize = 0 packetCount = 0 From e6d0ee035eabddffa162062571a543017aff2659 Mon Sep 17 00:00:00 2001 From: saxon Date: Mon, 24 Sep 2018 20:27:43 +0930 Subject: [PATCH 4/6] revid: added yet another message --- revid/revid.go | 1 + 1 file changed, 1 insertion(+) diff --git a/revid/revid.go b/revid/revid.go index cf8d8001..a951555c 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -297,6 +297,7 @@ func (r *Revid) packClips() { // TODO: This is temporary, need to work out how to make this work // for cases when there is not packetisation. case frame := <-r.encoder.Stream(): + fmt.Println("got frame") lenOfFrame := len(frame) if lenOfFrame > ringBufferElementSize { r.config.Logger.Log(smartlogger.Warning, pkg+"frame was too big", "frame size", lenOfFrame) From 0c2ccf55fae0ad499d27517149d0087525b1269a Mon Sep 17 00:00:00 2001 From: saxon Date: Tue, 25 Sep 2018 17:10:35 +0930 Subject: [PATCH 5/6] revid: move initialisation of revids netsender up higher in New so that we don't get nil pointer deference --- revid/config.go | 2 +- revid/revid.go | 5 +---- revid/senders.go | 4 ---- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/revid/config.go b/revid/config.go index 0b73194d..ea00f392 100644 --- a/revid/config.go +++ b/revid/config.go @@ -99,7 +99,7 @@ const ( defaultFramesPerClip = 1 defaultVerticalFlip = No defaultHorizontalFlip = No - httpFramesPerClip = 25 + httpFramesPerClip = 7 defaultInputCodec = H264 defaultVerbosity = No ) diff --git a/revid/revid.go b/revid/revid.go index a951555c..968d01ff 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -31,7 +31,6 @@ package revid import ( "errors" - "fmt" "io" "os" "os/exec" @@ -116,13 +115,13 @@ type Revid struct { // an error if construction of the new instance was not successful. func New(c Config, ns *netsender.Sender) (*Revid, error) { var r Revid + r.ns = ns err := r.reset(c) if err != nil { return nil, err } r.ringBuffer = ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout) r.outputChan = make(chan []byte, outputChanSize) - r.ns = ns return &r, nil } @@ -297,7 +296,6 @@ func (r *Revid) packClips() { // TODO: This is temporary, need to work out how to make this work // for cases when there is not packetisation. case frame := <-r.encoder.Stream(): - fmt.Println("got frame") lenOfFrame := len(frame) if lenOfFrame > ringBufferElementSize { r.config.Logger.Log(smartlogger.Warning, pkg+"frame was too big", "frame size", lenOfFrame) @@ -316,7 +314,6 @@ func (r *Revid) packClips() { packetCount++ clipSize += lenOfFrame if packetCount >= r.config.FramesPerClip { - fmt.Println("flushing buffer") r.ringBuffer.Flush() clipSize = 0 packetCount = 0 diff --git a/revid/senders.go b/revid/senders.go index c3d8b04d..38f7856a 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -29,7 +29,6 @@ LICENSE package revid import ( - "fmt" "io" "os" "os/exec" @@ -123,7 +122,6 @@ func (s *httpSender) load(c *ring.Chunk) error { func (s *httpSender) send() error { if s.chunk == nil { - fmt.Println("chunk is nil") // Do not retry with httpSender, // so just return without error // if the chunk has been cleared. @@ -135,7 +133,6 @@ func (s *httpSender) send() error { pins := netsender.MakePins(ip, "V") for i, pin := range pins { if pin.Name == "V0" { - fmt.Println("pin is V0") send = true pins[i].Value = s.chunk.Len() pins[i].Data = s.chunk.Bytes() @@ -145,7 +142,6 @@ func (s *httpSender) send() error { } var err error if send { - fmt.Println("sending") _, _, err = s.client.Send(netsender.RequestPoll, pins) } // We will not retry, so release From 6a0c9941ea3bae800e9c90fac1fde116cd43c430 Mon Sep 17 00:00:00 2001 From: Saxon Milton Date: Fri, 28 Sep 2018 04:23:43 +0000 Subject: [PATCH 6/6] revid: capturing any errors from r.lexTo --- revid/revid.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/revid/revid.go b/revid/revid.go index 968d01ff..bac1262a 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -473,7 +473,10 @@ func (r *Revid) startRaspivid() error { r.inputReader = stdout r.config.Logger.Log(smartlogger.Info, pkg+"reading camera data") - r.lexTo(r.encoder, r.inputReader, delay) + err = r.lexTo(r.encoder, r.inputReader, delay) + if err != nil { + return err + } r.config.Logger.Log(smartlogger.Info, pkg+"not trying to read from camera anymore") return nil }