need to update remote

This commit is contained in:
Saxon Milton 2018-07-04 00:12:44 +09:30
parent 79710f27f6
commit fd730a5235
1 changed files with 56 additions and 1 deletions

View File

@ -8,9 +8,63 @@ import (
)
const (
testInputFileName = "testInput/testInput.avi"
mjpegInputFileName = "testInput/testInput.avi"
h264InputFileName = "bitbucket.org/ausocean/test/test-data/av/input/betterInput.h264"
)
func TestH264Parser(t *testing.T) {
fmt.Println("Opening input file!")
// Open the input file
inputFile, err := os.Open(h264InputFileName)
if err != nil {
t.Errorf("Should not have got error opening file!")
}
fmt.Println("Getting file stats!")
stats, err := inputFile.Stat()
if err != nil {
t.Errorf("Could not get input file stats!")
return
}
fmt.Println("Creating space for file data!")
data := make([]byte, stats.Size())
_, err = inputFile.Read(data)
if err != nil {
t.Errorf("Should not have got read error!")
return
}
fmt.Println("Creating parser!")
parser := NewH264Parser(len(data) + 1)
parser.SetOutputChan(make(chan []byte, 10000))
parser.Start()
fmt.Printf("len(data): %v\n", len(data))
count := 0
for i := range data {
parser.GetInputChan() <- data[i]
select {
case frame:=<-parser.GetOutputChan()
outputFile, err := os.Create("")
count++
if count > 4 {
return
}
default:
}
}
for i := 0; len(parser.GetOutputChan()) > 0; i++ {
// Open a new output file
outputFile, err := os.Create("testOutput/image" + strconv.Itoa(i) + ".jpeg")
if err != nil {
t.Errorf("Should not have got error creating output file!")
return
}
outputFile.Write(<-parser.GetOutputChan())
outputFile.Close()
}
}
/*
func TestMJPEGParser(t *testing.T) {
fmt.Println("Opening input file!")
// Open the input file
@ -51,3 +105,4 @@ func TestMJPEGParser(t *testing.T) {
outputFile.Close()
}
}
*/