Documentation ¶
Overview ¶
Package psi provides mechanisms for collecting and querying program specific information in an MPEG transport stream.
Index ¶
- Constants
- func FilterPMTPacketsToPids(packets []*packet.Packet, pids []uint16) ([]*packet.Packet, error)
- func IsPMT(pkt *packet.Packet, pat PAT) (bool, error)
- func NewPointerField(size int) []byte
- func PmtAccumulatorDoneFunc(b []byte) (bool, error)
- func PointerField(psi []byte) uint8
- func PrivateIndicator(psi []byte) bool
- func SectionLength(psi []byte) uint16
- func SectionSyntaxIndicator(psi []byte) bool
- func TableID(psi []byte) uint8
- type PAT
- type PMT
- type PmtDescriptor
- type PmtElementaryStream
- type PmtStreamType
- type TableHeader
Constants ¶
const ( // Pointerfield(1) + table id(1) + flags(.5) + section length (2.5) PSIHeaderLen uint16 = 4 CrcLen uint16 = 4 )
Unaccounted bytes before the end of the SectionLength field
const ( VIDEO_STREAM uint8 = 2 // 0000 0010 (0x02) AUDIO_STREAM uint8 = 3 // 0000 0011 (0x03) REGISTRATION uint8 = 5 // 0000 1000 (0x05) CONDITIONAL_ACCESS uint8 = 9 // 0000 1001 (0x09) LANGUAGE uint8 = 10 // 0000 1010 (0x0A) SYSTEM_CLOCK uint8 = 11 // 0000 1011 (0x0B) DOLBY_DIGITAL uint8 = 12 // 0000 1100 (0x0C) COPYRIGHT uint8 = 13 // 0000 1101 (0x0D) MAXIMUM_BITRATE uint8 = 14 // 0000 1110 (0x0E) METADATA uint8 = 38 // 0010 0110 (0x26) AVC_VIDEO uint8 = 40 // 0010 1000 (0x28) STREAM_IDENTIFIER uint8 = 82 // 0101 0010 (0x52) TTML_SUBTITLING uint8 = 127 // 0111 1111 (0x7F) SCTE_ADAPTATION uint8 = 151 // 1001 0111 (0x97) DOLBY_VISION uint8 = 176 // 1011 0000 (0xB0) EBP uint8 = 233 // 1110 1001 (0xE9) EC3 uint8 = 204 // 1100 1100 (0xCC) )
Program Element Stream Descriptor Type.
const ( AUDIO_UNDEFINED int = 0 // 0000 0000 (0x00) AUDIO_DESCRIPTION int = 3 // 0000 0011 (0x03) AUDIO_PRIMARY int = 128 // 1000 0000 (0x80) )
ISO_639 Audio service type
const ( // BitsPerByte is the number of bits in a byte BitsPerByte = 8 // MaxBitRateBytesPerSecond is the maximum bit rate per second in a profile MaxBitRateBytesPerSecond = 50 )
const ( PmtStreamTypeMpeg2VideoH262 uint8 = 2 // H262 PmtStreamTypeMpeg4Video uint8 = 27 // H264 PmtStreamTypeMpeg4VideoH264 uint8 = 27 // H264 PmtStreamTypeMpeg4VideoH265 uint8 = 36 // H265 PmtStreamTypeAac uint8 = 15 // AAC PmtStreamTypeAc3 uint8 = 129 // DD PmtStreamTypeEc3 uint8 = 135 // DD+ PmtStreamTypeScte35 uint8 = 134 // SCTE-35 PmtStreamTypeID3 uint8 = 21 // Nielsen ID3 PmtStreamTypePrivateContent uint8 = 6 // Private Content PmtStreamTypeMetadata uint8 = 21 // Metadata in PES packets )
Stream type constants
const ( // PatPid is the PID of a PAT. By definition this value is zero. PatPid = uint16(0) )
Variables ¶
This section is empty.
Functions ¶
func FilterPMTPacketsToPids ¶
FilterPMTPacketsToPids filters the PMT contents of the provided packet to the PIDs provided and returns a new packet(s). For example: if the provided PMT has PIDs 101, 102, and 103 and the provided PIDs are 101 and 102,
the new PMT will have only descriptors for PID 101 and 102. The descriptor for PID 103 will be stripped from the new PMT packet.
Returns packets and nil error if all pids are present in the PMT. Returns packets and non-nil error if some pids are present in the PMT. Returns nil packets and non-nil error if none of the pids are present in the PMT.
func IsPMT ¶
IsPMT returns true if the provided packet is a PMT defined by the PAT provided. Returns ErrNilPAT if pat is nil, or any error encountered in parsing the PID of pkt.
func NewPointerField ¶
NewPointerField will return a new pointer field with stuffing as raw bytes. The pointer field specifies where the TableHeader should start. Everything in between the pointer field and table header should be bytes with the value 0xFF.
func PmtAccumulatorDoneFunc ¶
PmtAccumulatorDoneFunc is a doneFunc that can be used for packet accumulation to create a PMT
func PointerField ¶
func PrivateIndicator ¶
PrivateIndicator returns true if the psi contains private data
func SectionLength ¶
SectionLength returns the psi section length
func SectionSyntaxIndicator ¶
SectionSyntaxIndicator returns true if the psi contains section syntax
Types ¶
type PAT ¶
type PAT interface { NumPrograms() int ProgramMap() map[uint16]uint16 SPTSpmtPID() (uint16, error) }
PAT interface represents operations on a Program Association Table. Currently only single program transport streams (SPTS)are supported
type PMT ¶
type PMT interface { Pids() []uint16 IsPidForStreamWherePresentationLagsEbp(pid uint16) bool ElementaryStreams() []PmtElementaryStream RemoveElementaryStreams(pids []uint16) String() string PIDExists(pid uint16) bool VideoPid() uint16 KlvPid() uint16 }
PMT is a Program Map Table.
type PmtDescriptor ¶
type PmtDescriptor interface { Tag() uint8 Format() string IsIso639LanguageDescriptor() bool IsMaximumBitrateDescriptor() bool IsIFrameProfile() bool IsEBPDescriptor() bool DecodeMaximumBitRate() uint32 DecodeIso639LanguageCode() string DecodeIso639AudioType() byte IsDolbyATMOS() bool IsDolbyVision() bool DecodeDolbyVisionCodec(string) string IsTTMLSubtitlingDescriptor() bool DecodeTTMLIso639LanguageCode() string DecodeTTMLSubtitlePurpose() uint }
PmtDescriptor represents operations currently necessary on descriptors found in the PMT
func NewPmtDescriptor ¶
func NewPmtDescriptor(tag uint8, data []byte) PmtDescriptor
NewPmtDescriptor creates a new PMTDescriptor with the provided tag and byte contents.
type PmtElementaryStream ¶
type PmtElementaryStream interface { PmtStreamType ElementaryPid() uint16 Descriptors() []PmtDescriptor MaxBitRate() uint64 }
PmtElementaryStream represents an elementary stream inside a PMT
func NewPmtElementaryStream ¶
func NewPmtElementaryStream(streamType uint8, elementaryPid uint16, descriptors []PmtDescriptor) PmtElementaryStream
NewPmtElementaryStream creates a new PmtElementaryStream.
type PmtStreamType ¶
type PmtStreamType interface { StreamType() uint8 StreamTypeDescription() string IsStreamWherePresentationLagsEbp() bool IsAudioContent() bool IsVideoContent() bool // IsKlvContent() bool IsSCTE35Content() bool IsID3Content() bool IsPrivateContent() bool IsSyncKlvContent() bool IsAsyncKlvContent() bool }
PmtStreamType is used to represent elementary steam type inside a PMT
func LookupPmtStreamType ¶
func LookupPmtStreamType(code uint8) PmtStreamType
LookupPmtStreamType returns the associated PmtStreamType of the provided code. If the code is not recognized, a PmtSteamType of "unknown" is returned.
type TableHeader ¶
type TableHeader struct { TableID uint8 SectionSyntaxIndicator bool PrivateIndicator bool SectionLength uint16 }
TableHeader struct represents operations available on all PSI
func NewTableHeader ¶
func NewTableHeader() TableHeader
NewPSI will create a PSI with default values of zero and false for everything
func TableHeaderFromBytes ¶
func TableHeaderFromBytes(data []byte) TableHeader
PSIFromBytes returns the PSI struct from a byte slice
func (TableHeader) Data ¶
func (th TableHeader) Data() []byte
Data returns the byte representation of the PSI struct.