From d9ff072aecef24fc017d5227dba6cc308f11450f Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Fri, 21 Dec 2018 11:47:11 -0700 Subject: [PATCH 1/6] checked through functionality of existing overlapping functions, uncommented things to be deprecated - more to go --- packet/adaptationfield.go | 2 +- packet/adaptationfield/adaptationfield.go | 54 +++++++++++------------ packet/doc.go | 4 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packet/adaptationfield.go b/packet/adaptationfield.go index 854026b..2bc2ecf 100644 --- a/packet/adaptationfield.go +++ b/packet/adaptationfield.go @@ -28,7 +28,7 @@ import ( "github.com/Comcast/gots" ) -// NewPacket creates a new packet with a Null ID, sync byte, and with the adaptation field control set to payload only. +// NewAdaptationField creates a new *AdaptationField with the flag set for AdaptationField and no payload // This function is error free. func NewAdaptationField() *AdaptationField { p := New() diff --git a/packet/adaptationfield/adaptationfield.go b/packet/adaptationfield/adaptationfield.go index 6fe23fc..6280b79 100644 --- a/packet/adaptationfield/adaptationfield.go +++ b/packet/adaptationfield/adaptationfield.go @@ -6,51 +6,51 @@ import ( ) // Length returns the length of the adaptation field in bytes -func Length(pkt *packet.Packet) uint8 { - return uint8(pkt[4]) -} +// func Length(pkt *packet.Packet) uint8 { +// return uint8(pkt[4]) +// } // IsDiscontinuous returns the discontinuity indicator for this adaptation field -func IsDiscontinuous(pkt *packet.Packet) bool { - return pkt[5]&0x80 != 0 -} +// func IsDiscontinuous(pkt *packet.Packet) bool { +// return pkt[5]&0x80 != 0 +// } // IsRandomAccess returns the random access indicator for this adaptation field -func IsRandomAccess(pkt *packet.Packet) bool { - return pkt[5]&0x40 != 0 -} +// func IsRandomAccess(pkt *packet.Packet) bool { +// return pkt[5]&0x40 != 0 +// } // IsESHigherPriority returns true if this elementary stream is // high priority. Corresponds to the elementary stream // priority indicator. -func IsESHigherPriority(pkt *packet.Packet) bool { - return pkt[5]&0x20 != 0 -} +// func IsESHigherPriority(pkt *packet.Packet) bool { +// return pkt[5]&0x20 != 0 +// } // HasPCR returns true when the PCR flag is set -func HasPCR(pkt *packet.Packet) bool { - return pkt[5]&0x10 != 0 -} +// func HasPCR(pkt *packet.Packet) bool { +// return pkt[5]&0x10 != 0 +// } // HasOPCR returns true when the OPCR flag is set -func HasOPCR(pkt *packet.Packet) bool { - return pkt[5]&0x08 != 0 -} +// func HasOPCR(pkt *packet.Packet) bool { +// return pkt[5]&0x08 != 0 +// } // HasSplicingPoint returns true when the splicing countdown field is present -func HasSplicingPoint(pkt *packet.Packet) bool { - return pkt[5]&0x04 != 0 -} +// func HasSplicingPoint(pkt *packet.Packet) bool { +// return pkt[5]&0x04 != 0 +// } // HasTransportPrivateData returns true when the private data field is present -func HasTransportPrivateData(pkt *packet.Packet) bool { - return pkt[5]&0x02 != 0 -} +// func HasTransportPrivateData(pkt *packet.Packet) bool { +// return pkt[5]&0x02 != 0 +// } // HasAdaptationFieldExtension returns true if this adaptation field contains an extension field -func HasAdaptationFieldExtension(pkt *packet.Packet) bool { - return pkt[5]&0x01 != 0 -} +// func HasAdaptationFieldExtension(pkt *packet.Packet) bool { +// return pkt[5]&0x01 != 0 +// } // EncoderBoundaryPoint returns the byte array located in the optional TransportPrivateData of the (also optional) // AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error diff --git a/packet/doc.go b/packet/doc.go index dcf80a6..db8553f 100644 --- a/packet/doc.go +++ b/packet/doc.go @@ -49,8 +49,8 @@ const ( type AdaptationFieldControlOptions byte const ( - PayloadFlag AdaptationFieldControlOptions = 1 // 10 - AdaptationFieldFlag AdaptationFieldControlOptions = 2 // 01 + PayloadFlag AdaptationFieldControlOptions = 1 // 01 + AdaptationFieldFlag AdaptationFieldControlOptions = 2 // 10 PayloadAndAdaptationFieldFlag AdaptationFieldControlOptions = 3 // 11 ) From e29abfd68a699e31cea47232036a600bba28dd9c Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Thu, 27 Dec 2018 10:24:35 -0700 Subject: [PATCH 2/6] confirmed all adaptationfield functionality exists --- .vscode/launch.json | 17 +++ cli/parsefile.go | 2 +- ebp/ebp.go | 3 +- packet/adaptationfield.go | 33 +++++- packet/adaptationfield/adaptationfield.go | 135 +++++++++++----------- packet/packet.go | 8 +- 6 files changed, 120 insertions(+), 78 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c23774c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileDirname}", + "env": {}, + "args": [] + } + ] +} \ No newline at end of file diff --git a/cli/parsefile.go b/cli/parsefile.go index d735b97..9d8ea21 100644 --- a/cli/parsefile.go +++ b/cli/parsefile.go @@ -138,7 +138,7 @@ func main() { } if *showEbp { - ebpBytes, err := adaptationfield.EncoderBoundaryPoint(&pkt) + ebpBytes, err := adaptationfield.EncoderBoundaryPointBytes(&pkt) if err != nil { // Not an EBP continue diff --git a/ebp/ebp.go b/ebp/ebp.go index bffbf2f..b8087d7 100644 --- a/ebp/ebp.go +++ b/ebp/ebp.go @@ -26,9 +26,10 @@ package ebp import ( "encoding/binary" - "github.com/Comcast/gots" "io" "time" + + "github.com/Comcast/gots" ) // EBP tags diff --git a/packet/adaptationfield.go b/packet/adaptationfield.go index 2bc2ecf..8e7644f 100644 --- a/packet/adaptationfield.go +++ b/packet/adaptationfield.go @@ -95,6 +95,34 @@ func initAdaptationField(p *Packet) { } } +// EncoderBoundaryPointBytes returns the byte array located in the optional TransportPrivateData of the (also optional) +// AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error +func EncoderBoundaryPointBytes(packet *Packet) ([]byte, error) { + hasAdapt, err := ContainsAdaptationField(packet) + if err != nil { + return nil, nil + } + + af, err := packet.AdaptationField() + if err != nil { + return nil, err + } + + hasTransPriv, err := af.HasTransportPrivateData() + if err != nil { + return nil, err + } + + if hasAdapt && af.Length() > 0 && hasTransPriv { + ebp, err := af.TransportPrivateData() + if err != nil { + return nil, err + } + return ebp, nil + } + return nil, gots.ErrNoEBP +} + // returns if the adaptation field has a PCR, this does not check for errors. func (af *AdaptationField) hasPCR() bool { return af.getBit(5, 0x10) @@ -305,8 +333,7 @@ func (af *AdaptationField) ElementaryStreamPriority() (bool, error) { return af.getBit(5, 0x20), nil } -// SetHasPCR sets HasPCR -// HasPCR determines if the packet has a PCR +// SetHasPCR sets HasPCR flag func (af *AdaptationField) SetHasPCR(value bool) error { if err := af.valid(); err != nil { return err @@ -320,7 +347,7 @@ func (af *AdaptationField) SetHasPCR(value bool) error { return nil } -// HasPCR returns if the packet has a PCR +// HasPCR returns true if the packet has a PCR func (af *AdaptationField) HasPCR() (bool, error) { if err := af.valid(); err != nil { return false, err diff --git a/packet/adaptationfield/adaptationfield.go b/packet/adaptationfield/adaptationfield.go index 6280b79..2650da7 100644 --- a/packet/adaptationfield/adaptationfield.go +++ b/packet/adaptationfield/adaptationfield.go @@ -1,9 +1,4 @@ -package adaptationfield - -import ( - "github.com/Comcast/gots" - "github.com/Comcast/gots/packet" -) +//package adaptationfield // Length returns the length of the adaptation field in bytes // func Length(pkt *packet.Packet) uint8 { @@ -52,85 +47,85 @@ import ( // return pkt[5]&0x01 != 0 // } -// EncoderBoundaryPoint returns the byte array located in the optional TransportPrivateData of the (also optional) -// AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error -func EncoderBoundaryPoint(pkt *packet.Packet) ([]byte, error) { - hasAdapt, err := packet.ContainsAdaptationField(pkt) - if err != nil { - return nil, nil - } - if hasAdapt && Length(pkt) > 0 && HasTransportPrivateData(pkt) { - ebp, err := TransportPrivateData(pkt) - if err != nil { - return nil, err - } - return ebp, nil - } - return nil, gots.ErrNoEBP -} +// // EncoderBoundaryPoint returns the byte array located in the optional TransportPrivateData of the (also optional) +// // AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error +// func EncoderBoundaryPoint(pkt *packet.Packet) ([]byte, error) { +// hasAdapt, err := packet.ContainsAdaptationField(pkt) +// if err != nil { +// return nil, nil +// } +// if hasAdapt && Length(pkt) > 0 && HasTransportPrivateData(pkt) { +// ebp, err := TransportPrivateData(pkt) +// if err != nil { +// return nil, err +// } +// return ebp, nil +// } +// return nil, gots.ErrNoEBP +// } // PCR is the Program Clock Reference. // First 33 bits are PCR base. // Next 6 bits are reserved. // Final 9 bits are PCR extension. -func PCR(pkt *packet.Packet) ([]byte, error) { - if !HasPCR(pkt) { - return nil, gots.ErrNoPCR - } - offset := 6 - return pkt[offset : offset+6], nil -} +// func PCR(pkt *packet.Packet) ([]byte, error) { +// if !HasPCR(pkt) { +// return nil, gots.ErrNoPCR +// } +// offset := 6 +// return pkt[offset : offset+6], nil +// } // OPCR is the Original Program Clock Reference. // First 33 bits are original PCR base. // Next 6 bits are reserved. // Final 9 bits are original PCR extension. -func OPCR(pkt *packet.Packet) ([]byte, error) { - if !HasOPCR(pkt) { - return nil, gots.ErrNoOPCR - } - offset := 6 - if HasPCR(pkt) { - offset += 6 - } - return pkt[offset : offset+6], nil -} +// func OPCR(pkt *packet.Packet) ([]byte, error) { +// if !HasOPCR(pkt) { +// return nil, gots.ErrNoOPCR +// } +// offset := 6 +// if HasPCR(pkt) { +// offset += 6 +// } +// return pkt[offset : offset+6], nil +// } // SpliceCountdown returns a count of how many packets after this one until // a splice point occurs or an error if none exist. This function calls // HasSplicingPoint to check for the existence of a splice countdown. -func SpliceCountdown(pkt *packet.Packet) (uint8, error) { - if !HasSplicingPoint(pkt) { - return 0, gots.ErrNoSplicePoint - } - offset := 6 - if HasPCR(pkt) { - offset += 6 - } - if HasOPCR(pkt) { - offset += 6 - } - return pkt[offset], nil -} +// func SpliceCountdown(pkt *packet.Packet) (uint8, error) { +// if !HasSplicingPoint(pkt) { +// return 0, gots.ErrNoSplicePoint +// } +// offset := 6 +// if HasPCR(pkt) { +// offset += 6 +// } +// if HasOPCR(pkt) { +// offset += 6 +// } +// return pkt[offset], nil +// } // TransportPrivateData returns the private data from this adaptation field // or an empty array and an error if there is none. This function calls // HasTransportPrivateData to check for the existence of private data. -func TransportPrivateData(pkt *packet.Packet) ([]byte, error) { - if !HasTransportPrivateData(pkt) { - return nil, gots.ErrNoPrivateTransportData - } - offset := 6 - if HasPCR(pkt) { - offset += 6 - } - if HasOPCR(pkt) { - offset += 6 - } - if HasSplicingPoint(pkt) { - offset++ - } - dataLength := uint8(pkt[offset]) - offset++ - return pkt[uint8(offset) : uint8(offset)+dataLength], nil -} +// func TransportPrivateData(pkt *packet.Packet) ([]byte, error) { +// if !HasTransportPrivateData(pkt) { +// return nil, gots.ErrNoPrivateTransportData +// } +// offset := 6 +// if HasPCR(pkt) { +// offset += 6 +// } +// if HasOPCR(pkt) { +// offset += 6 +// } +// if HasSplicingPoint(pkt) { +// offset++ +// } +// dataLength := uint8(pkt[offset]) +// offset++ +// return pkt[uint8(offset) : uint8(offset)+dataLength], nil +// } diff --git a/packet/packet.go b/packet/packet.go index 81c13c8..66bbc41 100644 --- a/packet/packet.go +++ b/packet/packet.go @@ -24,7 +24,9 @@ SOFTWARE. package packet -import "github.com/Comcast/gots" +import ( + "github.com/Comcast/gots" +) // PayloadUnitStartIndicator (PUSI) is a flag that indicates the start of PES data // or PSI (Program-Specific Information) such as AT, CAT, PMT or NIT. The PUSI @@ -36,7 +38,7 @@ func payloadUnitStartIndicator(packet *Packet) bool { return packet[1]&0x040 != 0 } -// PID is the Packet Identifier. Each table or elementary stream in the +// Pid is the Packet Identifier. Each table or elementary stream in the // transport stream is identified by a PID. The PID is contained in the 13 // bits that span the last 5 bits of second byte and all bits in the byte. func Pid(packet *Packet) (uint16, error) { @@ -148,7 +150,7 @@ func SetCC(packet *Packet, newCC uint8) (*Packet, error) { return &newPacket, nil } -// Returns a byte slice containing the PES header if the Packet contains one, +// PESHeader Returns a byte slice containing the PES header if the Packet contains one, // otherwise returns an error func PESHeader(packet *Packet) ([]byte, error) { if containsPayload(packet) && payloadUnitStartIndicator(packet) { From 3671ea68851187a06f780aae4504d1d2a0dbcaad Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Thu, 27 Dec 2018 10:25:50 -0700 Subject: [PATCH 3/6] removed adaptationfield folder and files, their functions fully exist within packet/adaptationfield.go --- packet/adaptationfield/adaptationfield.go | 131 ---------------------- packet/adaptationfield/doc.go | 26 ----- 2 files changed, 157 deletions(-) delete mode 100644 packet/adaptationfield/adaptationfield.go delete mode 100644 packet/adaptationfield/doc.go diff --git a/packet/adaptationfield/adaptationfield.go b/packet/adaptationfield/adaptationfield.go deleted file mode 100644 index 2650da7..0000000 --- a/packet/adaptationfield/adaptationfield.go +++ /dev/null @@ -1,131 +0,0 @@ -//package adaptationfield - -// Length returns the length of the adaptation field in bytes -// func Length(pkt *packet.Packet) uint8 { -// return uint8(pkt[4]) -// } - -// IsDiscontinuous returns the discontinuity indicator for this adaptation field -// func IsDiscontinuous(pkt *packet.Packet) bool { -// return pkt[5]&0x80 != 0 -// } - -// IsRandomAccess returns the random access indicator for this adaptation field -// func IsRandomAccess(pkt *packet.Packet) bool { -// return pkt[5]&0x40 != 0 -// } - -// IsESHigherPriority returns true if this elementary stream is -// high priority. Corresponds to the elementary stream -// priority indicator. -// func IsESHigherPriority(pkt *packet.Packet) bool { -// return pkt[5]&0x20 != 0 -// } - -// HasPCR returns true when the PCR flag is set -// func HasPCR(pkt *packet.Packet) bool { -// return pkt[5]&0x10 != 0 -// } - -// HasOPCR returns true when the OPCR flag is set -// func HasOPCR(pkt *packet.Packet) bool { -// return pkt[5]&0x08 != 0 -// } - -// HasSplicingPoint returns true when the splicing countdown field is present -// func HasSplicingPoint(pkt *packet.Packet) bool { -// return pkt[5]&0x04 != 0 -// } - -// HasTransportPrivateData returns true when the private data field is present -// func HasTransportPrivateData(pkt *packet.Packet) bool { -// return pkt[5]&0x02 != 0 -// } - -// HasAdaptationFieldExtension returns true if this adaptation field contains an extension field -// func HasAdaptationFieldExtension(pkt *packet.Packet) bool { -// return pkt[5]&0x01 != 0 -// } - -// // EncoderBoundaryPoint returns the byte array located in the optional TransportPrivateData of the (also optional) -// // AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error -// func EncoderBoundaryPoint(pkt *packet.Packet) ([]byte, error) { -// hasAdapt, err := packet.ContainsAdaptationField(pkt) -// if err != nil { -// return nil, nil -// } -// if hasAdapt && Length(pkt) > 0 && HasTransportPrivateData(pkt) { -// ebp, err := TransportPrivateData(pkt) -// if err != nil { -// return nil, err -// } -// return ebp, nil -// } -// return nil, gots.ErrNoEBP -// } - -// PCR is the Program Clock Reference. -// First 33 bits are PCR base. -// Next 6 bits are reserved. -// Final 9 bits are PCR extension. -// func PCR(pkt *packet.Packet) ([]byte, error) { -// if !HasPCR(pkt) { -// return nil, gots.ErrNoPCR -// } -// offset := 6 -// return pkt[offset : offset+6], nil -// } - -// OPCR is the Original Program Clock Reference. -// First 33 bits are original PCR base. -// Next 6 bits are reserved. -// Final 9 bits are original PCR extension. -// func OPCR(pkt *packet.Packet) ([]byte, error) { -// if !HasOPCR(pkt) { -// return nil, gots.ErrNoOPCR -// } -// offset := 6 -// if HasPCR(pkt) { -// offset += 6 -// } -// return pkt[offset : offset+6], nil -// } - -// SpliceCountdown returns a count of how many packets after this one until -// a splice point occurs or an error if none exist. This function calls -// HasSplicingPoint to check for the existence of a splice countdown. -// func SpliceCountdown(pkt *packet.Packet) (uint8, error) { -// if !HasSplicingPoint(pkt) { -// return 0, gots.ErrNoSplicePoint -// } -// offset := 6 -// if HasPCR(pkt) { -// offset += 6 -// } -// if HasOPCR(pkt) { -// offset += 6 -// } -// return pkt[offset], nil -// } - -// TransportPrivateData returns the private data from this adaptation field -// or an empty array and an error if there is none. This function calls -// HasTransportPrivateData to check for the existence of private data. -// func TransportPrivateData(pkt *packet.Packet) ([]byte, error) { -// if !HasTransportPrivateData(pkt) { -// return nil, gots.ErrNoPrivateTransportData -// } -// offset := 6 -// if HasPCR(pkt) { -// offset += 6 -// } -// if HasOPCR(pkt) { -// offset += 6 -// } -// if HasSplicingPoint(pkt) { -// offset++ -// } -// dataLength := uint8(pkt[offset]) -// offset++ -// return pkt[uint8(offset) : uint8(offset)+dataLength], nil -// } diff --git a/packet/adaptationfield/doc.go b/packet/adaptationfield/doc.go deleted file mode 100644 index e56e54e..0000000 --- a/packet/adaptationfield/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/* -MIT License - -Copyright 2016 Comcast Cable Communications Management, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -// AdaptationField provides functions for accessing and reading packet adaptation fields -package adaptationfield From 086880f2c5082f552f75c09705bf5d09bb3509d2 Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Thu, 3 Jan 2019 14:41:13 -0700 Subject: [PATCH 4/6] consolidate adaptationfield functionality into the packet package, remove old file, move packet tests to new functions --- cli/parsefile.go | 5 ++-- packet/adaptationfield.go | 52 ++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/cli/parsefile.go b/cli/parsefile.go index 9d8ea21..00226c7 100644 --- a/cli/parsefile.go +++ b/cli/parsefile.go @@ -35,7 +35,8 @@ import ( "github.com/Comcast/gots/ebp" "github.com/Comcast/gots/packet" - "github.com/Comcast/gots/packet/adaptationfield" + + // "github.com/Comcast/gots/packet/adaptationfield" "github.com/Comcast/gots/psi" "github.com/Comcast/gots/scte35" ) @@ -138,7 +139,7 @@ func main() { } if *showEbp { - ebpBytes, err := adaptationfield.EncoderBoundaryPointBytes(&pkt) + ebpBytes, err := packet.EncoderBoundaryPointBytes(&pkt) if err != nil { // Not an EBP continue diff --git a/packet/adaptationfield.go b/packet/adaptationfield.go index 8e7644f..e7a0a8c 100644 --- a/packet/adaptationfield.go +++ b/packet/adaptationfield.go @@ -95,34 +95,6 @@ func initAdaptationField(p *Packet) { } } -// EncoderBoundaryPointBytes returns the byte array located in the optional TransportPrivateData of the (also optional) -// AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error -func EncoderBoundaryPointBytes(packet *Packet) ([]byte, error) { - hasAdapt, err := ContainsAdaptationField(packet) - if err != nil { - return nil, nil - } - - af, err := packet.AdaptationField() - if err != nil { - return nil, err - } - - hasTransPriv, err := af.HasTransportPrivateData() - if err != nil { - return nil, err - } - - if hasAdapt && af.Length() > 0 && hasTransPriv { - ebp, err := af.TransportPrivateData() - if err != nil { - return nil, err - } - return ebp, nil - } - return nil, gots.ErrNoEBP -} - // returns if the adaptation field has a PCR, this does not check for errors. func (af *AdaptationField) hasPCR() bool { return af.getBit(5, 0x10) @@ -591,3 +563,27 @@ func (af *AdaptationField) AdaptationFieldExtension() ([]byte, error) { } return af[af.adaptationExtensionStart():af.stuffingStart()], nil } + +// EncoderBoundaryPointBytes returns the byte array located in the optional TransportPrivateData of the (also optional) +// AdaptationField of the Packet. If either of these optional fields are missing an empty byte array is returned with an error +func EncoderBoundaryPointBytes(packet *Packet) ([]byte, error) { + + af, err := packet.AdaptationField() + if err != nil { + return nil, err + } + + hasTransPriv, err := af.HasTransportPrivateData() + if err != nil { + return nil, err + } + + if af.Length() > 0 && hasTransPriv { + ebp, err := af.TransportPrivateData() + if err != nil { + return nil, err + } + return ebp, nil + } + return nil, gots.ErrNoEBP +} From bcfe69438b70b4dc93d045e658e0f2dc9ad1bbe4 Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Thu, 3 Jan 2019 14:49:58 -0700 Subject: [PATCH 5/6] Delete launch.json --- .vscode/launch.json | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c23774c..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Launch", - "type": "go", - "request": "launch", - "mode": "auto", - "program": "${fileDirname}", - "env": {}, - "args": [] - } - ] -} \ No newline at end of file From 6c5fd014c79c527aa7bbf080d5259210adafd427 Mon Sep 17 00:00:00 2001 From: Michael Hedrick Date: Thu, 3 Jan 2019 14:51:44 -0700 Subject: [PATCH 6/6] remove unused import for old adaptationfield --- cli/parsefile.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/parsefile.go b/cli/parsefile.go index 00226c7..e27fbe9 100644 --- a/cli/parsefile.go +++ b/cli/parsefile.go @@ -35,8 +35,6 @@ import ( "github.com/Comcast/gots/ebp" "github.com/Comcast/gots/packet" - - // "github.com/Comcast/gots/packet/adaptationfield" "github.com/Comcast/gots/psi" "github.com/Comcast/gots/scte35" )