diff --git a/h264/h264Parser.go b/h264/h264Parser.go index ab80a1ce..836238ee 100644 --- a/h264/h264Parser.go +++ b/h264/h264Parser.go @@ -29,9 +29,11 @@ LICENSE package h264 import ( - "bitbucket.org/ausocean/av/itut" + "../itut" "log" "sync" + _"fmt" + _"time" ) const ( @@ -55,59 +57,29 @@ func (p* H264Parser)Stop(){ } func (p* H264Parser)Parse() { - p.isParsing = true + p.isParsing = true outputBuffer := []byte{} - searchingForEnd := false + searchingForEnd := false p.InputByteChan = make(chan byte, 10000) for p.isParsing { - aByte := <-p.InputByteChan - + aByte := <-p.InputByteChan outputBuffer = append(outputBuffer, aByte) for i:=1; aByte == 0x00 && i != 4; i++ { - aByte = <-p.InputByteChan + aByte = <-p.InputByteChan outputBuffer = append(outputBuffer, aByte) if ( aByte == 0x01 && i == 2 ) || ( aByte == 0x01 && i == 3 ) { if searchingForEnd { - outputBuffer = outputBuffer[:len(outputBuffer)-(i+1)] - p.OutputChan<-append(append(itut.StartCode1(),itut.AUD()...),outputBuffer...) - outputBuffer = []byte{} - searchingForEnd = false + output := append(append(itut.StartCode1(),itut.AUD()...),outputBuffer[:len(outputBuffer)-(i+1)]...) + p.OutputChan<-output + outputBuffer = outputBuffer[len(outputBuffer)-1-i:] + searchingForEnd = false } aByte = <-p.InputByteChan outputBuffer = append(outputBuffer, aByte) if nalType := aByte & 0x1F; nalType == 1 || nalType == 5 { - searchingForEnd = true + searchingForEnd = true } } } } - /* - for p.isParsing { - aByte := <-p.InputByteChan - outputBuffer = append(outputBuffer, aByte) - for i:=1; aByte == 0x00 && i != 4; i++ { - aByte = <-p.InputByteChan - outputbuffer = append(outputBuffer, aByte) - if ( aByte == 0x01 && i == 2 ) || ( aByte == 0x01 && i == 3 ) { - aByte = <-p.InputByteChan - outputBuffer = append(outputBuffer, aByte) - if nalType := aByte & 0x1F; nalType == 1 || nalType == 5 { - for { - aByte = <-p.InputByteChan - outputBuffer = append(outputBuffer,aByte) - for i := 1; aByte == 0x00; i++ { - aByte = <-p.InputByteChan - outputbuffer = append(outputBuffer, aByte) - if ( aByte == 0x01 && i == 2 ) || ( aByte == 0x01 && i == 3 ) { - outputBuffer = outputBuffer[:len(outputBuffer)-(i+1)] - outputChan<-append(append(itut.StartCode1(),itut.AUD()...),outputBuffer...) - outputBuffer = []byte{} - } - } - } - } - } - } - } - */ } diff --git a/revid/RevidInstance.go b/revid/RevidInstance.go index 14744fbb..d6feb04b 100644 --- a/revid/RevidInstance.go +++ b/revid/RevidInstance.go @@ -45,8 +45,8 @@ import ( "time" "io" - "bitbucket.org/ausocean/av/h264" - "bitbucket.org/ausocean/av/tsgenerator" + "../h264" + "../tsgenerator" "bitbucket.org/ausocean/av/ringbuffer" ) @@ -85,7 +85,7 @@ type Config struct { InputCmd string Output uint8 OutputFileName string - InputFileName string + InputFileName string } type RevidInst interface { @@ -154,8 +154,8 @@ func (r *revidInst) input() { generator := tsgenerator.NewTsGenerator(framesPerSec) go generator.Generate() h264Parser := h264.H264Parser{OutputChan: generator.NalInputChan} - // TODO: Need to create constructor for parser otherwise I'm going to break - // something eventuallyl + // TODO: Need to create constructor for parser otherwise I'm going to break + // something eventuallyl go h264Parser.Parse() var inputReader *bufio.Reader switch r.config.Input { @@ -169,8 +169,8 @@ func (r *revidInst) input() { return } case file: - - + + default: r.Error.Println("Input not valid!") } @@ -211,15 +211,11 @@ func (r *revidInst) input() { if err != nil { r.Error.Println(err.Error()) } - fmt.Println("about to start sending data") for i := range h264Data { - fmt.Printf("i: %v\n", i) h264Parser.InputByteChan<-h264Data[i] } - fmt.Println("all data sent") } - if clip, err := r.ringBuffer.Get(); err != nil { r.Error.Println(err.Error()) return @@ -235,7 +231,6 @@ func (r *revidInst) input() { if err != nil { fmt.Println(err) } - fmt.Println("getting ts packet") tsPacket := <-generator.TsChan byteSlice, err := tsPacket.ToByteSlice() if err != nil { diff --git a/tsgenerator/TsGenerator.go b/tsgenerator/TsGenerator.go index c7250ab3..07be9b45 100644 --- a/tsgenerator/TsGenerator.go +++ b/tsgenerator/TsGenerator.go @@ -31,10 +31,10 @@ package tsgenerator import ( _ "fmt" _"os" - "bitbucket.org/ausocean/av/mpegts" - "bitbucket.org/ausocean/av/pes" - "bitbucket.org/ausocean/av/tools" - "bitbucket.org/ausocean/av/rtp" + "../mpegts" + "../pes" + "../tools" + "../rtp" ) type TsGenerator interface {