From 94e174b6412b641852f9b24b0e92db3efa55dbdb Mon Sep 17 00:00:00 2001 From: Saxon1 Date: Sun, 6 May 2018 17:02:51 +0930 Subject: [PATCH] made tsGenerator implement Generator --- generator/MPEGTSGenerator.go | 7 +++++++ 1 file changed, 7 insertions(+) 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]