add debug options for example/test

This commit is contained in:
nareix 2015-12-09 14:30:30 +08:00
parent 86e41350b3
commit bc93d48788

View File

@ -45,14 +45,16 @@ type Sample struct {
RandomAccessIndicator bool RandomAccessIndicator bool
} }
var (
debugData = true
debugStream = true
)
func readSamples(filename string, ch chan Sample) { func readSamples(filename string, ch chan Sample) {
defer func() { defer func() {
close(ch) close(ch)
}() }()
debugData := true
debugStream := true
var file *os.File var file *os.File
var err error var err error
if file, err = os.Open(filename); err != nil { if file, err = os.Open(filename); err != nil {
@ -191,7 +193,9 @@ func testInputGob(pathGob string, pathOut string) {
} }
outfile.Close() outfile.Close()
fmt.Println("written to", pathOut) if debugStream {
fmt.Println("written to", pathOut)
}
} }
func main() { func main() {
@ -199,6 +203,10 @@ func main() {
output := flag.String("o", "", "output file") output := flag.String("o", "", "output file")
inputGob := flag.String("g", "", "input gob file") inputGob := flag.String("g", "", "input gob file")
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to 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() flag.Parse()
if *cpuprofile != "" { if *cpuprofile != "" {
@ -210,10 +218,6 @@ func main() {
defer pprof.StopCPUProfile() defer pprof.StopCPUProfile()
} }
ts.DebugReader = true
ts.DebugWriter = true
if *inputGob != "" && *output != "" { if *inputGob != "" && *output != "" {
testInputGob(*inputGob, *output) testInputGob(*inputGob, *output)
return return
@ -287,7 +291,7 @@ func main() {
break break
} }
if sample.Type == ts.ElementaryStreamTypeH264 { if sample.Type == ts.ElementaryStreamTypeH264 {
if true { if debugStream {
fmt.Println("sample: ", len(sample.Data), fmt.Println("sample: ", len(sample.Data),
"PCR", sample.PCR, "PTS", sample.PTS, "PCR", sample.PCR, "PTS", sample.PTS,
"DTS", sample.DTS, "sync", sample.RandomAccessIndicator, "DTS", sample.DTS, "sync", sample.RandomAccessIndicator,