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 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 { type PESPacket struct {
StreamID byte StreamID byte
Length uint16 Length uint16
ScramblingControl byte SC byte // Scrambling control
Priority bool Priority bool // Priority Indicator
DAI bool // data alginment indicator DAI bool // Data alginment indicator
Copyright bool Copyright bool // Copyright indicator
Original bool Original bool // Original data indicator
PDI byte // PTS DTS indicator PDI byte // PTS DTS indicator
ESCR bool ESCRF bool // Elementary stream clock reference flag
ESRate bool ESRF bool // Elementary stream rate reference flag
DSMTrickMode bool DSMTMF bool // Dsm trick mode flag
ACI bool // additional copy info flag ACI bool // Additional copy info flag
CRC bool CRC bool //
Ext bool EF bool // Extension flag
HeaderLength byte HeaderLength byte // Pes header length
OptFields []byte OptFields []byte // Optional fields
Stuffing []byte Stuffing []byte // Stuffing bytes
Data []byte Data []byte // Pes packet data
} }
func (p *PESPacket) ToByteSlice() (output []byte) { func (p *PESPacket) ToByteSlice() (output []byte) {