psi: restructuring data structures and files

This commit is contained in:
saxon 2018-12-05 19:31:29 +10:30
parent 5f0bef9365
commit 731285d665
3 changed files with 46 additions and 131 deletions

View File

@ -1,51 +0,0 @@
/*
NAME
revid - a testbed for re-muxing and re-directing video streams as MPEG-TS over various protocols.
DESCRIPTION
See Readme.md
AUTHOR
Alan Noble <anoble@gmail.com>
LICENSE
revid is Copyright (C) 2017 Alan Noble.
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
*/
package psi
type PAT 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
TIE uint16 // Table ID extension
Version byte // Version number
CNI bool // Current/next indicator
Section byte // Section number
LSN byte // Last section number
DT byte // Descriptor tag
DL byte // Descriptor length
Program uint16 // Program number
PMPID uint16 // Program map PID
CRC32 uint32 // Checksum of table
}
func (p *PAT) ToByteSlice() (output []byte) {
return
}

View File

@ -1,61 +0,0 @@
/*
NAME
revid - a testbed for re-muxing and re-directing video streams as MPEG-TS over various protocols.
DESCRIPTION
See Readme.md
AUTHOR
Alan Noble <anoble@gmail.com>
LICENSE
revid is Copyright (C) 2017 Alan Noble.
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
*/
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
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
TIE uint16 // Table ID extension
Version byte // Version number
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
}

View File

@ -2,35 +2,62 @@ package psi
// Program specific information // Program specific information
type PSI struct { type PSI struct {
PF byte // Point field pf byte // Point field
PFB []byte // pointer filler bytes pfb []byte // pointer filler bytes
TableID byte // Table ID tid byte // Table ID
SSI bool // Sectiopn syntax indicator (1 for PAT, PMT, CAT) ssi bool // Sectiopn syntax indicator (1 for PAT, PMT, CAT)
PB bool // Private bit (0 for PAT, PMT, CAT) pb bool // Private bit (0 for PAT, PMT, CAT)
SL uint16 // Section length sl uint16 // Section length
tss *TSS // Table syntax section (length defined by SL) if length 0 then nil tss *TSS // Table syntax section (length defined by SL) if length 0 then nil
} }
// Table syntax section // Table syntax section
type TSS struct { type TSS struct {
TIE uint16 // Table ID extension tie uint16 // Table ID extension
Version byte // Version number v byte // Version number
CNI bool // Current/next indicator cni bool // Current/next indicator
Section byte // Section number sn byte // Section number
LSN byte // Last section number lsn byte // Last section number
table SD // specific data PAT/PMT sd SD // specific data PAT/PMT
crc []byte // crc32 of entire table excluding pointer field, pointer filler bytes and the trailing CRC32
} }
// Specific Data, which could be PAT or PMT // Specific Data, (could be PAT or PMT)
type SD interface { type SD interface {
Read(psiData []byte) (PSI, error) Bytes() []byte
ToByte() []byte
} }
func (p *PSI) Read(psiData []byte) (PSI, error) { // Program association table, implements SD
return PSI{}, nil type PAT struct {
pn uint16 // Program Number
pmpid uint16 // program map PID
} }
func (p *PSI) ToByte() []byte { type Descriptor struct {
dt byte // Descriptor tag
dl byte // Descriptor length
dd []byte // Descriptor data
}
// Program mapping table, implements SD
type PMT struct {
pcrpid uint16 // program clock reference pid
PIL uint16 // program info length
PD []Descriptor // program descriptors
}
func ReadPSI(data []byte) *PAT {
return nil
}
func (p *PSI) Bytes() (output []byte) {
return nil
}
func (p *PAT) Bytes() (output []byte) {
return nil
}
func (p *PMT) Bytes() (output []byte) {
return nil return nil
} }