mirror of https://bitbucket.org/ausocean/av.git
Fixed start/stop bug
This commit is contained in:
parent
72de1758ed
commit
16c399aabf
|
@ -31,6 +31,7 @@ package mpegts
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/ausocean/av/tools"
|
"bitbucket.org/ausocean/av/tools"
|
||||||
"errors"
|
"errors"
|
||||||
|
//"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -135,6 +136,7 @@ func (p *MpegTsPacket) FillPayload(channel chan byte){
|
||||||
currentPktLength := 6 + int(tools.BoolToByte(p.PCRF))*6+int(tools.BoolToByte(p.OPCRF))*6+
|
currentPktLength := 6 + int(tools.BoolToByte(p.PCRF))*6+int(tools.BoolToByte(p.OPCRF))*6+
|
||||||
int(tools.BoolToByte(p.SPF))*1+int(tools.BoolToByte(p.TPDF))*1+len(p.TPD)
|
int(tools.BoolToByte(p.SPF))*1+int(tools.BoolToByte(p.TPDF))*1+len(p.TPD)
|
||||||
for (currentPktLength+len(p.Payload)) < 188 {
|
for (currentPktLength+len(p.Payload)) < 188 {
|
||||||
|
//fmt.Printf("len(channel): %v\n", len(channel))
|
||||||
select {
|
select {
|
||||||
case nextByte := <-channel:
|
case nextByte := <-channel:
|
||||||
p.Payload = append(p.Payload,nextByte)
|
p.Payload = append(p.Payload,nextByte)
|
||||||
|
|
|
@ -148,6 +148,7 @@ func NewRevidInstance(config Config) (r *revidInst, err error) {
|
||||||
// something eventuallyl
|
// something eventuallyl
|
||||||
go r.h264Parser.Parse()
|
go r.h264Parser.Parse()
|
||||||
go r.input()
|
go r.input()
|
||||||
|
go r.generator.Generate()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +160,6 @@ func (r *revidInst) ChangeState(newConfig Config) error {
|
||||||
|
|
||||||
func (r *revidInst) Start() {
|
func (r *revidInst) Start() {
|
||||||
r.isRunning = true
|
r.isRunning = true
|
||||||
go r.generator.Generate()
|
|
||||||
switch r.config.Input {
|
switch r.config.Input {
|
||||||
case Raspivid:
|
case Raspivid:
|
||||||
cmd = exec.Command("raspivid", "-o", "-", "-n", "-t", "0", "-b",
|
cmd = exec.Command("raspivid", "-o", "-", "-n", "-t", "0", "-b",
|
||||||
|
@ -214,7 +214,6 @@ func (r *revidInst) Start() {
|
||||||
func (r *revidInst) Stop() {
|
func (r *revidInst) Stop() {
|
||||||
if r.isRunning {
|
if r.isRunning {
|
||||||
r.isRunning = false
|
r.isRunning = false
|
||||||
r.generator.Stop()
|
|
||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,6 +266,7 @@ func (r *revidInst) output() {
|
||||||
case HttpOut:
|
case HttpOut:
|
||||||
for err := sendClipToHTTP(clip, r.config.HttpAddress); err != nil; {
|
for err := sendClipToHTTP(clip, r.config.HttpAddress); err != nil; {
|
||||||
err = sendClipToHTTP(clip, r.config.HttpAddress)
|
err = sendClipToHTTP(clip, r.config.HttpAddress)
|
||||||
|
time.Sleep(5*time.Second)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
r.Error.Println("No output?")
|
r.Error.Println("No output?")
|
||||||
|
|
|
@ -29,7 +29,7 @@ LICENSE
|
||||||
package tsgenerator
|
package tsgenerator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
_"fmt"
|
||||||
_"os"
|
_"os"
|
||||||
"bitbucket.org/ausocean/av/mpegts"
|
"bitbucket.org/ausocean/av/mpegts"
|
||||||
"bitbucket.org/ausocean/av/pes"
|
"bitbucket.org/ausocean/av/pes"
|
||||||
|
@ -56,7 +56,6 @@ type TsGenerator interface {
|
||||||
Generate()
|
Generate()
|
||||||
GetNalInputChan() chan<- []byte
|
GetNalInputChan() chan<- []byte
|
||||||
GetTsOutputChan() <-chan *mpegts.MpegTsPacket
|
GetTsOutputChan() <-chan *mpegts.MpegTsPacket
|
||||||
Stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type tsGenerator struct {
|
type tsGenerator struct {
|
||||||
|
@ -72,7 +71,6 @@ type tsGenerator struct {
|
||||||
currentPtsTime float64
|
currentPtsTime float64
|
||||||
currentPcrTime float64
|
currentPcrTime float64
|
||||||
fps uint
|
fps uint
|
||||||
isGenerating bool
|
|
||||||
pesPktChan chan []byte
|
pesPktChan chan []byte
|
||||||
ccMap map[int]int
|
ccMap map[int]int
|
||||||
}
|
}
|
||||||
|
@ -122,14 +120,9 @@ func (g *tsGenerator) genPcr()(pcr uint64){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *tsGenerator) Stop(){
|
|
||||||
g.isGenerating = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *tsGenerator) Generate() {
|
func (g *tsGenerator) Generate() {
|
||||||
g.isGenerating = true
|
|
||||||
var rtpBuffer [](*rtp.RtpPacket)
|
var rtpBuffer [](*rtp.RtpPacket)
|
||||||
for g.isGenerating {
|
for {
|
||||||
select {
|
select {
|
||||||
case rtpPacket := <-g.inputChan:
|
case rtpPacket := <-g.inputChan:
|
||||||
rtpBuffer = append(rtpBuffer, &rtpPacket)
|
rtpBuffer = append(rtpBuffer, &rtpPacket)
|
||||||
|
@ -270,7 +263,6 @@ func (g *tsGenerator) Generate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("\n\n\nGetting out of generate!\n\n\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *tsGenerator) getCC(pid int) int {
|
func (g *tsGenerator) getCC(pid int) int {
|
||||||
|
|
Loading…
Reference in New Issue