Documentation
¶
Overview ¶
Package psi provides mechanisms for collecting and querying program specific information in an MPEG transport stream.
Index ¶
- Constants
- func CanBuildPMT(payload []byte, sectionLength uint16) bool
- func ExtractCRC(payload []byte) (uint32, error)
- func FilterPMTPacketsToPids(packets []*packet.Packet, pids []int) ([]*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) AVC_VIDEO uint8 = 40 // 0010 1000 (0x28) STREAM_IDENTIFIER uint8 = 82 // 0101 0010 (0x52) EXTENSION 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_CLEAN_EFFECTS int = 1 // 0000 0001 (0x01) AUDIO_HEARING_IMPAIRED int = 2 // 0000 0010 (0x02) AUDIO_DESCRIPTION int = 3 // 0000 0011 (0x03) AUDIO_PRIMARY int = 128 // 1000 0000 (0x80) AUDIO_NATIVE int = 129 // 1000 0001 (0x81) )
ISO_639 Audio service type
const ( TTML_PURPOSE_SAME_LANG_DIALOGUE uint8 = 0 // 0000 0000 (0x00) TTML_PURPOSE_OTHER_LANG_DIALOGUE uint8 = 1 // 0000 0001 (0x01) TTML_PURPOSE_ALL_DIALOGUE uint8 = 2 // 0000 0010 (0x02) TTML_PURPOSE_HARD_OF_HEARING uint8 = 16 // 0001 0000 (0x10) TTML_PURPOSE_OTHER_LANG_DIALOGUE_WITH_HARD_OF_HEARING uint8 = 17 // 0001 0001 (0x11) TTML_PURPOSE_ALL_DIALOGUE_WITH_HARD_OF_HEARING uint8 = 18 // 0001 0010 (0x12) TTML_PURPOSE_AUDIO_DESCRIPTION uint8 = 48 // 0011 0000 (0x30) TTML_PURPOSE_CONTENT_RELATED_COMMENTARY uint8 = 49 // 0011 0001 (0x31) )
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 )
Stream type constants
const (
// PatPid is the PID of a PAT. By definition this value is zero.
PatPid = 0
)
const PidNotFound int = 1<<16 - 1
const (
TTML_DESC_TAG_EXTENSION uint8 = 32 // 0010 0000 (0x20)
)
Descriptor tag extension
Variables ¶
This section is empty.
Functions ¶
func CanBuildPMT ¶
func ExtractCRC ¶
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 ¶
PAT interface represents operations on a Program Association Table. Currently only single program transport streams (SPTS)are supported
type PMT ¶
type PMT interface { Pids() []int VersionNumber() uint8 CurrentNextIndicator() bool ElementaryStreams() []PmtElementaryStream RemoveElementaryStreams(pids []int) IsPidForStreamWherePresentationLagsEbp(pid int) bool String() string PIDExists(pid int) bool }
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() uint8 IsTTMLDescTagExtension() bool }
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() int Descriptors() []PmtDescriptor MaxBitRate() uint64 IsTTMLSubtitling() bool }
PmtElementaryStream represents an elementary stream inside a PMT
func NewPmtElementaryStream ¶
func NewPmtElementaryStream(streamType uint8, elementaryPid int, descriptors []PmtDescriptor) PmtElementaryStream
NewPmtElementaryStream creates a new PmtElementaryStream.
type PmtStreamType ¶
type PmtStreamType interface { StreamType() uint8 StreamTypeDescription() string IsStreamWherePresentationLagsEbp() bool IsAudioContent() bool IsVideoContent() bool IsSCTE35Content() bool IsID3Content() bool IsPrivateContent() 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, error)
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.