Things seem to be working

This commit is contained in:
Jack Richardson 2018-01-11 17:19:33 +10:30
parent 86dc14fa7a
commit c772b99267
4 changed files with 36 additions and 35 deletions

View File

@ -29,7 +29,7 @@ LICENSE
package h264
import (
"../itut"
"bitbucket.org/ausocean/av/itut"
"log"
"sync"
_"fmt"

View File

@ -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

View File

@ -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()
}
* */

View File

@ -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 {