Working out how to convert to byte slice

This commit is contained in:
Unknown 2017-12-11 17:08:09 +10:30
parent 4118d27769
commit b1771483ce
1 changed files with 43 additions and 12 deletions

View File

@ -28,19 +28,50 @@ LICENSE
package packet
import (
"strconv"
)
// Length of some fields in bits
const (
SyncByteLength = 8
TEILength = 1
PUSILength = 1
PriorityLength = 1
PIDLength = 13
TSCLength = 2
AFCLength = 2
CCLength = 4
)
// Index of the fields
const (
SyncByteIndex = 0
TEIIndex = SyncByteIndex + SyncByteLength
PUSIIndex = TEIIndex + TEILength
PriorityIndex = PUSIIndex + PUSILength
PIDIndex = PriorityIndex + PriorityLength
TSCIndex = PIDIndex + PIDLength
AFCIndex = TSCIndex + TSCLength
CCIndex = AFCIndex + AFCLength
AFIndex = CCIndex + CCLength
)
type MpegTsPacket struct {
SyncByte byte
TEI bool
PUSI bool
Priority bool
PID uint
TSC byte
AFC byte
CC byte
AdaptionField []byte
Payload []byte
SyncByte byte
TEI bool // Transport Error Indicator
PUSI bool // Payload Unit Start Indicator
Priority bool
PID int
TSC byte // Transport Scrambling Control
AFC byte // Adaption Field Control
CC int // Continuity Counter
AF []byte // Adaption Field
Payload []byte
}
type (p *MpegTsPacket) toByteSlice() []byte {
func getHex()
func (p *MpegTsPacket) toByteSlice() (output []byte) {
output[0] = p.SyncByte
output[1] =
}