From bc93d48788d25ff4ac9883331741dd04a8e75da5 Mon Sep 17 00:00:00 2001 From: nareix Date: Wed, 9 Dec 2015 14:30:30 +0800 Subject: [PATCH] add debug options for example/test --- example/test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/example/test.go b/example/test.go index 24be502..a508053 100644 --- a/example/test.go +++ b/example/test.go @@ -45,14 +45,16 @@ type Sample struct { RandomAccessIndicator bool } +var ( + debugData = true + debugStream = true +) + func readSamples(filename string, ch chan Sample) { defer func() { close(ch) }() - debugData := true - debugStream := true - var file *os.File var err error if file, err = os.Open(filename); err != nil { @@ -191,7 +193,9 @@ func testInputGob(pathGob string, pathOut string) { } outfile.Close() - fmt.Println("written to", pathOut) + if debugStream { + fmt.Println("written to", pathOut) + } } func main() { @@ -199,6 +203,10 @@ func main() { output := flag.String("o", "", "output file") inputGob := flag.String("g", "", "input gob file") cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file") + flag.BoolVar(&debugData, "vd", false, "debug data") + flag.BoolVar(&debugStream, "vs", false, "debug stream") + flag.BoolVar(&ts.DebugReader, "vr", false, "debug reader") + flag.BoolVar(&ts.DebugWriter, "vw", false, "debug writer") flag.Parse() if *cpuprofile != "" { @@ -210,10 +218,6 @@ func main() { defer pprof.StopCPUProfile() } - - ts.DebugReader = true - ts.DebugWriter = true - if *inputGob != "" && *output != "" { testInputGob(*inputGob, *output) return @@ -287,7 +291,7 @@ func main() { break } if sample.Type == ts.ElementaryStreamTypeH264 { - if true { + if debugStream { fmt.Println("sample: ", len(sample.Data), "PCR", sample.PCR, "PTS", sample.PTS, "DTS", sample.DTS, "sync", sample.RandomAccessIndicator,