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 package h264
import ( import (
"../itut" "bitbucket.org/ausocean/av/itut"
"log" "log"
"sync" "sync"
_"fmt" _"fmt"

View File

@ -45,8 +45,8 @@ import (
"time" "time"
"io" "io"
"../h264" "bitbucket.org/ausocean/av/h264"
"../tsgenerator" "bitbucket.org/ausocean/av/tsgenerator"
"bitbucket.org/ausocean/av/ringbuffer" "bitbucket.org/ausocean/av/ringbuffer"
) )
@ -160,7 +160,7 @@ func (r *revidInst) input() {
var inputReader *bufio.Reader var inputReader *bufio.Reader
switch r.config.Input { switch r.config.Input {
case raspivid: case raspivid:
cmd := exec.Command("raspivid", "-o", "-", "-n", "-t", "0") cmd := exec.Command("raspivid", "-o", "-", "-n", "-t", "0", "-b", "5000000")
stdout, _ := cmd.StdoutPipe() stdout, _ := cmd.StdoutPipe()
err := cmd.Start() err := cmd.Start()
inputReader = bufio.NewReader(stdout) inputReader = bufio.NewReader(stdout)
@ -169,8 +169,6 @@ func (r *revidInst) input() {
return return
} }
case file: case file:
default: default:
r.Error.Println("Input not valid!") r.Error.Println("Input not valid!")
} }
@ -189,33 +187,35 @@ func (r *revidInst) input() {
donePSI := false donePSI := false
ii := 0 ii := 0
for r.isRunning { fmt.Println("reading")
fmt.Println("reading") var h264Data []byte
var h264Data []byte switch(r.config.Input){
switch(r.config.Input){ case raspivid:
case raspivid: go func(){
go func(){ for {
for { h264Data = make([]byte, 2)
h264Data = make([]byte, 1) _,err := io.ReadFull(inputReader, h264Data)
io.ReadFull(inputReader, h264Data) if err == nil {
h264Parser.InputByteChan<-h264Data[0] 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 { if clip, err := r.ringBuffer.Get(); err != nil {
r.Error.Println(err.Error()) r.Error.Println(err.Error())
return return

View File

@ -37,6 +37,7 @@ import (
* Testing with file input * Testing with file input
* *
*/ */
/*
func TestFileInput(t *testing.T){ func TestFileInput(t *testing.T){
config := Config{ config := Config{
Input: file, Input: file,
@ -52,12 +53,12 @@ func TestFileInput(t *testing.T){
time.Sleep(100*time.Second) time.Sleep(100*time.Second)
revidInst.Stop() revidInst.Stop()
} }
* */
/* /*
Testing use with raspivid Testing use with raspivid
*/ */
/*
func TestRaspividInput(t *testing.T){ func TestRaspividInput(t *testing.T){
config := Config{ config := Config{
Input: raspivid, Input: raspivid,
@ -72,7 +73,7 @@ func TestRaspividInput(t *testing.T){
time.Sleep(100*time.Second) time.Sleep(100*time.Second)
revidInst.Stop() revidInst.Stop()
} }
* */

View File

@ -31,10 +31,10 @@ package tsgenerator
import ( import (
_ "fmt" _ "fmt"
_"os" _"os"
"../mpegts" "bitbucket.org/ausocean/av/mpegts"
"../pes" "bitbucket.org/ausocean/av/pes"
"../tools" "bitbucket.org/ausocean/av/tools"
"../rtp" "bitbucket.org/ausocean/av/rtp"
) )
type TsGenerator interface { type TsGenerator interface {