diff --git a/packet/MpegTs.go b/packet/MpegTs.go index f22a9746..71024e0a 100644 --- a/packet/MpegTs.go +++ b/packet/MpegTs.go @@ -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] = }