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