diff --git a/stream/mts/psi/psi.go b/stream/mts/psi/psi.go index 7366ee3b..7f9569e6 100644 --- a/stream/mts/psi/psi.go +++ b/stream/mts/psi/psi.go @@ -1,6 +1,7 @@ package psi import ( + "errors" "hash/crc32" "math/bits" ) @@ -63,7 +64,7 @@ type PMT struct { Pcrpid uint16 // Program clock reference pid Pil uint16 // Program info length Pd []Desc // Program descriptors - Essd ESSD // Elementary stream specific data + Essd *ESSD // Elementary stream specific data } // Elementary stream specific data @@ -177,6 +178,13 @@ func readEssd(data []byte) *ESSD { essd := ESSD{} pos := 0 essd.St = data[pos] + pos++ + essd.Epid = uint16(data[pos]&0x1f)<<8 | uint16(data[pos+1]) + pos += 2 + essd.Esil = uint16(data[pos]&0x03)<<8 | uint16(data[pos+1]) + pos += 2 + essd.Esd = readDescs(data[pos:], int(essd.Esil)) + return &essd } // Bytes outputs a byte slice representation of the PSI @@ -295,3 +303,12 @@ func crc32_Update(crc uint32, tab *crc32.Table, p []byte) uint32 { } return crc } + +// UpdateTimestamp +func UpdateTimestamp(data []byte, t int) error { + psi := ReadPSI(data) + if psi.Tid != PATTableID { + return errors.New("Timestamp update failed because psi is not a PMT") + } + return nil +} diff --git a/stream/mts/psi/psi_test.go b/stream/mts/psi/psi_test.go new file mode 100644 index 00000000..7ec1a3b2 --- /dev/null +++ b/stream/mts/psi/psi_test.go @@ -0,0 +1,9 @@ +package psi + +import ( + "testing" +) + +func TestReadPSI1(t *testing.T) { + +}