Exemple #1
0
func source(t *testing.T, q *ts.PktWriteQueue) {
	s := psi.MakeEmptySection(psi.ISOSectionMaxLen, true)
	s.SetTableId(79)
	s.SetTableIdExt(333)
	s.SetVersion(3)
	s.SetCurrent(true)
	s.SetNumber(1)
	s.SetLastNumber(1)
	e := psi.NewSectionEncoder(q, 0x321)
	for n := 4000; n > 0; n-- {
		buf := s.Alloc(n, n)
		for i := range buf {
			buf[i] = byte(n + i)
		}
		s.MakeCRC()
		if err := e.WriteSection(s); err != nil {
			t.Fatal(err)
		}
		s.SetEmpty()
	}
	if err := e.Flush(); err != nil {
		t.Fatal(err)
	}
	q.Close()
}
Exemple #2
0
func main() {
	log.SetFlags(0)
	if len(os.Args) != 2 {
		log.Fatal(usage)
	}

	pid, err := strconv.ParseUint(os.Args[1], 0, 64)
	checkErr(err)
	if uint64(pid) > 8191 {
		log.Fatal(pid, "isn't valid PID")
	}

	s := make(psi.Section, psi.SectionMaxLen)
	r := psi.NewSectionStreamReader(os.Stdin, pid != 20)
	w := psi.NewSectionEncoder(ts.PktStreamWriter{os.Stdout}, int16(pid))
	for {
		err := r.ReadSection(s)
		if err != nil {
			if err == io.EOF {
				break
			}
			checkErr(err)
		}
		/*log.Println(
			"TableId:", s.TableId(),
			"TableIdExt:", s.TableIdExt(),
			"GenericSyntax:", s.GenericSyntax(),
			"PrivateSyntax:", s.PrivateSyntax(),
			"Len:", s.Len(),
			"Version:", s.Version(),
			"Current:", s.Current(),
			"Number:", s.Number(),
			"LastNumber:", s.LastNumber(),
		)*/
		checkErr(w.WriteSection(s))
	}
	checkErr(w.Flush())
}