From c772b9926773222b2a0f95c81996a71a46048a51 Mon Sep 17 00:00:00 2001 From: Jack Richardson Date: Thu, 11 Jan 2018 17:19:33 +1030 Subject: [PATCH] Things seem to be working --- h264/h264Parser.go | 2 +- revid/RevidInstance.go | 56 +++++++++++++++++++------------------- revid/revid_test.go | 5 ++-- tsgenerator/TsGenerator.go | 8 +++--- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/h264/h264Parser.go b/h264/h264Parser.go index 836238ee..77d69a04 100644 --- a/h264/h264Parser.go +++ b/h264/h264Parser.go @@ -29,7 +29,7 @@ LICENSE package h264 import ( - "../itut" + "bitbucket.org/ausocean/av/itut" "log" "sync" _"fmt" diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index d6feb04b..059753a0 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -45,8 +45,8 @@ import ( "time" "io" - "../h264" - "../tsgenerator" + "bitbucket.org/ausocean/av/h264" + "bitbucket.org/ausocean/av/tsgenerator" "bitbucket.org/ausocean/av/ringbuffer" ) @@ -160,7 +160,7 @@ func (r *revidInst) input() { var inputReader *bufio.Reader switch r.config.Input { case raspivid: - cmd := exec.Command("raspivid", "-o", "-", "-n", "-t", "0") + cmd := exec.Command("raspivid", "-o", "-", "-n", "-t", "0", "-b", "5000000") stdout, _ := cmd.StdoutPipe() err := cmd.Start() inputReader = bufio.NewReader(stdout) @@ -169,8 +169,6 @@ func (r *revidInst) input() { return } case file: - - default: r.Error.Println("Input not valid!") } @@ -189,33 +187,35 @@ func (r *revidInst) input() { donePSI := false ii := 0 - for r.isRunning { - fmt.Println("reading") - var h264Data []byte - switch(r.config.Input){ - case raspivid: - go func(){ - for { - h264Data = make([]byte, 1) - io.ReadFull(inputReader, h264Data) + fmt.Println("reading") + var h264Data []byte + switch(r.config.Input){ + case raspivid: + go func(){ + for { + h264Data = make([]byte, 2) + _,err := io.ReadFull(inputReader, h264Data) + if err == nil { h264Parser.InputByteChan<-h264Data[0] + h264Parser.InputByteChan<-h264Data[1] } - }() - case file: - stats, err := r.inputFile.Stat() - if err != nil { - panic("Could not get file stats!") - } - h264Data = make([]byte, stats.Size()) - _, err = r.inputFile.Read(h264Data) - if err != nil { - r.Error.Println(err.Error()) - } - for i := range h264Data { - h264Parser.InputByteChan<-h264Data[i] } + }() + case file: + stats, err := r.inputFile.Stat() + if err != nil { + panic("Could not get file stats!") } - + h264Data = make([]byte, stats.Size()) + _, err = r.inputFile.Read(h264Data) + if err != nil { + r.Error.Println(err.Error()) + } + for i := range h264Data { + h264Parser.InputByteChan<-h264Data[i] + } + } + for r.isRunning { if clip, err := r.ringBuffer.Get(); err != nil { r.Error.Println(err.Error()) return diff --git a/revid/revid_test.go b/revid/revid_test.go index aa54dadf..f5001006 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -37,6 +37,7 @@ import ( * Testing with file input * */ + /* func TestFileInput(t *testing.T){ config := Config{ Input: file, @@ -52,12 +53,12 @@ func TestFileInput(t *testing.T){ time.Sleep(100*time.Second) revidInst.Stop() } +* */ /* Testing use with raspivid */ -/* func TestRaspividInput(t *testing.T){ config := Config{ Input: raspivid, @@ -72,7 +73,7 @@ func TestRaspividInput(t *testing.T){ time.Sleep(100*time.Second) revidInst.Stop() } -* */ + diff --git a/tsgenerator/TsGenerator.go b/tsgenerator/TsGenerator.go index 07be9b45..c7250ab3 100644 --- a/tsgenerator/TsGenerator.go +++ b/tsgenerator/TsGenerator.go @@ -31,10 +31,10 @@ package tsgenerator import ( _ "fmt" _"os" - "../mpegts" - "../pes" - "../tools" - "../rtp" + "bitbucket.org/ausocean/av/mpegts" + "bitbucket.org/ausocean/av/pes" + "bitbucket.org/ausocean/av/tools" + "bitbucket.org/ausocean/av/rtp" ) type TsGenerator interface {