mirror of https://bitbucket.org/ausocean/av.git
Fixed h264 Parser - now to test on pi again
This commit is contained in:
parent
dd05c13110
commit
86dc14fa7a
|
@ -29,9 +29,11 @@ LICENSE
|
|||
package h264
|
||||
|
||||
import (
|
||||
"bitbucket.org/ausocean/av/itut"
|
||||
"../itut"
|
||||
"log"
|
||||
"sync"
|
||||
_"fmt"
|
||||
_"time"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -60,17 +62,16 @@ func (p* H264Parser)Parse() {
|
|||
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
|
||||
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{}
|
||||
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
|
||||
|
@ -81,33 +82,4 @@ func (p* H264Parser)Parse() {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
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{}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ import (
|
|||
"time"
|
||||
"io"
|
||||
|
||||
"bitbucket.org/ausocean/av/h264"
|
||||
"bitbucket.org/ausocean/av/tsgenerator"
|
||||
"../h264"
|
||||
"../tsgenerator"
|
||||
|
||||
"bitbucket.org/ausocean/av/ringbuffer"
|
||||
)
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue