Improving pes packet data struct

This commit is contained in:
Saxon Milton 2018-01-07 14:16:10 +10:30
parent fae1fdd4ee
commit 2a3f058e77
1 changed files with 50 additions and 16 deletions

View File

@ -25,26 +25,60 @@ LICENSE
*/
package packets
/*
============================================================================
| octet no | bit 0 | bit 1 | bit 2 | bit 3 | bit 4 | bit 5 | bit 6 | bit 7 |
============================================================================
| octet 0 | 0x00 |
----------------------------------------------------------------------------
| octet 1 | 0x00 |
----------------------------------------------------------------------------
| octet 2 | 0x01 |
----------------------------------------------------------------------------
| octet 3 | Stream ID (0xE0 for video) |
----------------------------------------------------------------------------
| octet 4 | PES Packet Length (no bytes in packet after this field) |
----------------------------------------------------------------------------
| octet 5 | PES Length cont. |
----------------------------------------------------------------------------
| octet 6 | 0x2 | SC | Prior | DAI | Copyr | Copy |
----------------------------------------------------------------------------
| octet 7 | PDI | ESCRF | ESRF | DSMTMF| ACIF | CRCF | EF |
----------------------------------------------------------------------------
| octet 8 | PES Header Length |
----------------------------------------------------------------------------
| optional | optional fields (determined by flags above) (variable Length) |
----------------------------------------------------------------------------
| - | ... |
----------------------------------------------------------------------------
| optional | stuffing bytes (varible length) |
----------------------------------------------------------------------------
| - | ... |
----------------------------------------------------------------------------
| Optional | Data (variable length) |
----------------------------------------------------------------------------
| - | ... |
----------------------------------------------------------------------------
*/
type PESPacket struct {
StreamID byte
Length uint16
ScramblingControl byte
Priority bool
DAI bool // data alginment indicator
Copyright bool
Original bool
SC byte // Scrambling control
Priority bool // Priority Indicator
DAI bool // Data alginment indicator
Copyright bool // Copyright indicator
Original bool // Original data indicator
PDI byte // PTS DTS indicator
ESCR bool
ESRate bool
DSMTrickMode bool
ACI bool // additional copy info flag
CRC bool
Ext bool
HeaderLength byte
OptFields []byte
Stuffing []byte
Data []byte
ESCRF bool // Elementary stream clock reference flag
ESRF bool // Elementary stream rate reference flag
DSMTMF bool // Dsm trick mode flag
ACI bool // Additional copy info flag
CRC bool //
EF bool // Extension flag
HeaderLength byte // Pes header length
OptFields []byte // Optional fields
Stuffing []byte // Stuffing bytes
Data []byte // Pes packet data
}
func (p *PESPacket) ToByteSlice() (output []byte) {