diff --git a/generator/MPEGTSGenerator.go b/generator/MPEGTSGenerator.go index 477e0c43..002ddea5 100644 --- a/generator/MPEGTSGenerator.go +++ b/generator/MPEGTSGenerator.go @@ -86,6 +86,7 @@ type tsGenerator struct { fps uint pesPktChan chan []byte ccMap map[int]int + isGenerating bool } // getInputChan returns a handle to the nalInputChan (inputChan) so that nal units @@ -117,6 +118,7 @@ func NewTsGenerator(fps uint) (g *tsGenerator) { g.ccMap[pmtPid] = 0 g.ccMap[videoPid] = 0 genPatAndPmt() + g.isGenerating = false return } @@ -137,9 +139,14 @@ func (g *tsGenerator) genPcr() (pcr uint64) { // Start is called when we would like generation to begin, i.e. we would like // the generator to start taking input data and creating mpegts packets func (g *tsGenerator) Start() { + g.isGenerating = true go g.generate() } +func (g *tsGenerator) Stop() { + g.isGenerating = false +} + // getCC returns the next continuity counter for a particular pid func (g *tsGenerator) getCC(pid int) int { temp := g.ccMap[pid]