psi: writing new data strcutres to make things neater and more usable

This commit is contained in:
saxon 2018-12-04 16:03:04 +10:30
parent 86949813fd
commit 5f0bef9365
2 changed files with 51 additions and 1 deletions

View File

@ -27,6 +27,18 @@ LICENSE
package psi
// Bitmasks
const (
// bitmasks used for second byte
SYNTAX_INDICATOR = 0x80
PRIVATE_BIT = 0x40
RESERVED_BITS = 0x30
SECTION_LENGTH_1 = 0x03 // first two bits of the section length
// bitmasks used for third byte
SECTION_LENGTH_2 = 0xff
)
type PMT struct {
PF byte // Point field
PFB []byte // pointer filler bytes
@ -39,9 +51,11 @@ type PMT struct {
CNI bool // Current/next indicator
Section byte // Section number
LSN byte // Last section number
}
func ReadPMT(pmtData []byte) (PMT, error) {
return PMT{}, nil
}
func (p *PMT) ToByteSlice() (output []byte) {
return
}

36
stream/mts/psi/psi.go Normal file
View File

@ -0,0 +1,36 @@
package psi
// Program specific information
type PSI struct {
PF byte // Point field
PFB []byte // pointer filler bytes
TableID byte // Table ID
SSI bool // Sectiopn syntax indicator (1 for PAT, PMT, CAT)
PB bool // Private bit (0 for PAT, PMT, CAT)
SL uint16 // Section length
tss *TSS // Table syntax section (length defined by SL) if length 0 then nil
}
// Table syntax section
type TSS struct {
TIE uint16 // Table ID extension
Version byte // Version number
CNI bool // Current/next indicator
Section byte // Section number
LSN byte // Last section number
table SD // specific data PAT/PMT
}
// Specific Data, which could be PAT or PMT
type SD interface {
Read(psiData []byte) (PSI, error)
ToByte() []byte
}
func (p *PSI) Read(psiData []byte) (PSI, error) {
return PSI{}, nil
}
func (p *PSI) ToByte() []byte {
return nil
}