Documentation ¶
Overview ¶
Package psi provides functionality for read program specific information from MPEG transport stream.
Index ¶
- Constants
- Variables
- func DecodeText(s []byte) string
- func EncodeText(s string) []byte
- func ParsePrivateDataSpecifier(d Descriptor) (pds uint32, ok bool)
- func ParseTDT(s Section) (time.Time, error)
- type AudioType
- type CADescriptor
- type CAS
- type Descriptor
- type DescriptorList
- type DescriptorTag
- type ESInfo
- type ESInfoList
- type ISO639LangCode
- type ISO639LangDescriptor
- type LocalTimeOffset
- type LocalTimeOffsetDescriptor
- type LogicalChannelDescriptor
- type LogicalChannelInfo
- type MuxInfo
- type MuxInfoList
- type NIT
- func (nit *NIT) AppendMuxInfo(mis ...MuxInfo)
- func (nit *NIT) AppendNetDescriptor(ds ...Descriptor)
- func (nit NIT) Close(netid uint16, actualMux, current bool, version int8)
- func (nit NIT) Current() bool
- func (nit NIT) Descriptors() TableDescriptors
- func (nit NIT) MuxInfo() MuxInfoList
- func (nit NIT) NetId() uint16
- func (nit *NIT) Update(r SectionReader, actualMux bool, current bool) error
- func (nit NIT) Version() int8
- type NetworkNameDescriptor
- type PAT
- func (pat *PAT) Append(progId uint16, pmtpid int16)
- func (pat PAT) Close(tsid uint16, current bool, version int8)
- func (pat PAT) Current() bool
- func (pat PAT) FindPMT(progid uint16) (pmtpid int16)
- func (pat PAT) FindProgId(pmtpid int16) (progid uint16, ok bool)
- func (pat PAT) MuxId() uint16
- func (pat PAT) ProgramList() ProgramList
- func (pat *PAT) SetEmpty()
- func (pat *PAT) Update(r SectionReader, current bool) error
- func (pat PAT) Version() int8
- type PMT
- func (p PMT) Current() bool
- func (p PMT) ESInfo() ESInfoList
- func (p PMT) Len() int
- func (p PMT) MakeCRC()
- func (p PMT) PidPCR() int16
- func (p PMT) ProgId() uint16
- func (p PMT) ProgramDescriptors() DescriptorList
- func (p PMT) Section() Section
- func (p PMT) SetPidPCR(pid int16)
- func (p PMT) SetProgId(sid uint16)
- func (p PMT) SetVersion(v int8)
- func (p PMT) Update(r SectionReader) error
- func (p PMT) Version() int8
- type ProgramList
- type SDT
- func (sdt *SDT) Append(onid uint16, si ServiceInfo)
- func (sdt SDT) Close(tsid uint16, actualMux, current bool, version int8)
- func (sdt SDT) Current() bool
- func (sdt SDT) MuxId() uint16
- func (sdt SDT) OrgNetId() uint16
- func (sdt SDT) ServiceInfo() ServiceInfoList
- func (sdt *SDT) SetEmpty()
- func (sdt *SDT) Update(r SectionReader, actualMux bool, current bool) error
- func (sdt SDT) Version() int8
- type Section
- func (s Section) Alloc(n, m int) []byte
- func (s Section) CRC() uint32
- func (s Section) Cap() int
- func (s Section) CheckCRC() bool
- func (s Section) Copy(sec Section)
- func (s Section) Current() bool
- func (s Section) Data() []byte
- func (s Section) GenericSyntax() bool
- func (s Section) LastNumber() byte
- func (s Section) Len() int
- func (s Section) MakeCRC()
- func (s Section) Number() byte
- func (s Section) PrivateSyntax() bool
- func (s Section) Reserved() int
- func (s Section) Reset()
- func (s Section) SetCurrent(c bool)
- func (s Section) SetEmpty()
- func (s Section) SetGenericSyntax(si bool)
- func (s Section) SetLastNumber(n byte)
- func (s Section) SetNumber(n byte)
- func (s Section) SetPrivateSyntax(pi bool)
- func (s Section) SetTableId(id byte)
- func (s Section) SetTableIdExt(id uint16)
- func (s Section) SetVersion(v int8)
- func (s Section) String() string
- func (s Section) TableId() byte
- func (s Section) TableIdExt() uint16
- func (s Section) Version() int8
- type SectionDecoder
- type SectionEncoder
- type SectionQueue
- type SectionReadQueue
- type SectionReader
- type SectionReplacer
- type SectionStreamReader
- type SectionWriteQueue
- type SectionWriter
- type ServiceDescriptor
- type ServiceInfo
- func (si *ServiceInfo) AppendDescriptors(ds ...Descriptor)
- func (si ServiceInfo) ClearDescriptors()
- func (si ServiceInfo) Descriptors() DescriptorList
- func (si ServiceInfo) EITPresentFollowing() bool
- func (si ServiceInfo) EITSchedule() bool
- func (si ServiceInfo) Scrambled() bool
- func (si ServiceInfo) ServiceId() uint16
- func (si ServiceInfo) SetEITPresentFollowing(b bool)
- func (si ServiceInfo) SetEITSchedule(b bool)
- func (si ServiceInfo) SetServiceId(sid uint16)
- func (si ServiceInfo) SetStatus(s ServiceStatus)
- func (si ServiceInfo) Status() ServiceStatus
- type ServiceInfoList
- type ServiceListDescriptor
- type ServiceStatus
- type ServiceType
- type StreamIdentifierDescriptor
- type StreamType
- type TDT
- type TOT
- type Table
- func (t *Table) Alloc(n int, cfg *TableConfig, uself int, sectionHeader []byte) []byte
- func (t Table) Close(cfg *TableConfig, tableIdExt uint16, current bool, version int8)
- func (t Table) Current() bool
- func (t Table) Cursor() TableCursor
- func (t Table) Descriptors(offset int) TableDescriptors
- func (t *Table) Reset()
- func (t *Table) SetEmpty()
- func (t Table) SetTableId(id byte)
- func (t Table) TableId() byte
- func (t Table) TableIdExt() uint16
- func (t *Table) Update(r SectionReader, tableId byte, private, current bool, sectionMaxLen int) error
- func (t Table) Version() int8
- type TableConfig
- type TableCursor
- type TableDescriptors
- type TerrestrialDeliverySystemDescriptor
Constants ¶
const ( ZeroServiceType = ServiceType(0x00) DigitalTelevisionService = ServiceType(0x01) DigitalRadioSoundService = ServiceType(0x02) TeletextService = ServiceType(0x03) NVODReferenceService = ServiceType(0x04) NVODTimeShiftedService = ServiceType(0x05) MosaicService = ServiceType(0x06) FMRadioService = ServiceType(0x07) DVBSRMService = ServiceType(0x08) AdvancedCodecDigitalRadioSoundService = ServiceType(0x0a) AdvancedCodecMosaicService = ServiceType(0x0b) DataBroadcastService = ServiceType(0x0c) RCSMapService = ServiceType(0x0e) RCSFLSService = ServiceType(0x0f) DVBMHPService = ServiceType(0x10) MPEG2HDDigitalTelevisionService = ServiceType(0x11) H264SDDigitalTelevisionService = ServiceType(0x16) H264SDNVODTimeShiftedService = ServiceType(0x17) H264SDNVODReferenceService = ServiceType(0x18) H264HDDigitalTelevisionService = ServiceType(0x19) H264HDNVODTimeShiftedService = ServiceType(0x1a) H264HDNVODReferenceService = ServiceType(0x1b) H264StereoscopicHDDigitalTelevisionService = ServiceType(0x1c) H264StereoscopicHDNVODTimeShiftedService = ServiceType(0x1d) H264StereoscopicHDNVODReferenceService = ServiceType(0x1e) H265DigitalTelevisionService = ServiceType(0x1f) )
const ( SectionMaxLen = 4096 ISOSectionMaxLen = 1024 )
const TDTSectionLen = 3 + 5
Variables ¶
var ( ErrPMTSectionSyntax = dvb.TemporaryError("incorrect PMT section syntax") ErrPMTProgInfoLen = dvb.TemporaryError("incorrect PMT program info length") )
var ( ErrSectionLength = dvb.TemporaryError("incorrect value of section_length field") ErrSectionPointer = dvb.TemporaryError("incorrect pointer_field") ErrSectionSpace = dvb.TemporaryError("no free space for section decoding") ErrSectionSyntax = dvb.TemporaryError("section syntax indicator not set") ErrSectionCRC = dvb.TemporaryError("section has incorrect CRC") ErrSectionReserved = dvb.TemporaryError("section has wrong value of header reserved bits") ErrSectionData = dvb.TemporaryError("too few data to decode section") )
var ( ErrTableSectionNumber = dvb.TemporaryError("Table: incorrect section number") ErrTableSyntax = dvb.TemporaryError("Table: incorrect section syntax") )
var ErrBadMJDUTC = errors.New("bad MJD UTC time")
var ErrNITSectionLen = dvb.TemporaryError("incorrect NIT section length")
var ErrSDTSectionLen = dvb.TemporaryError("incorrect SDT section length")
var ErrTDTSectionSyntax = dvb.TemporaryError("incorrect TDT section syntax")
var ErrTOTSectionSyntax = dvb.TemporaryError("incorrect TOT section syntax")
Functions ¶
func DecodeText ¶
Decode treats s as text encoded according to EN 300 468 Annex A. It uses appropriate conversion according to selection byte
func EncodeText ¶
func ParsePrivateDataSpecifier ¶
func ParsePrivateDataSpecifier(d Descriptor) (pds uint32, ok bool)
Types ¶
type CADescriptor ¶
func ParseCADescriptor ¶
func ParseCADescriptor(d Descriptor) (cad CADescriptor, ok bool)
type Descriptor ¶
type Descriptor []byte
func MakeDescriptor ¶
func MakeDescriptor(tag DescriptorTag, datalen int) Descriptor
func MakeNetworkNameDescriptor ¶
func MakeNetworkNameDescriptor(netname string) Descriptor
func MakePrivateDataSpecifierDescriptor ¶
func MakePrivateDataSpecifierDescriptor(pds uint32) Descriptor
func MakeServiceDescriptor ¶
func MakeServiceDescriptor(typ ServiceType, provider, service string) Descriptor
func (Descriptor) Data ¶
func (d Descriptor) Data() []byte
func (Descriptor) SetTag ¶
func (d Descriptor) SetTag(tag DescriptorTag)
func (Descriptor) Tag ¶
func (d Descriptor) Tag() DescriptorTag
type DescriptorList ¶
type DescriptorList []byte
func (*DescriptorList) Alloc ¶
func (dl *DescriptorList) Alloc(datalen int) Descriptor
Alloc allocates descriptor for datalen bytes of data + 2 bytes for tag and data length.
func (DescriptorList) Pop ¶
func (dl DescriptorList) Pop() (d Descriptor, rdl DescriptorList)
Pop returns first descriptor in d and remaining descriptors in rdl. If there is no more descriptors len(rdl) == 0. If an error occurs d == nil.
type DescriptorTag ¶
type DescriptorTag byte
const ( VideoStreamTag DescriptorTag = 0x02 AudioStreamTag DescriptorTag = 0x03 //PMT HierarchyTag DescriptorTag = 0x04 RegistrationTag DescriptorTag = 0x05 //PMT DataStreamAlignmentTag DescriptorTag = 0x06 TargetBackgroundGridTag DescriptorTag = 0x07 VideoWindowTag DescriptorTag = 0x08 CATag DescriptorTag = 0x09 ISO639LangTag DescriptorTag = 0x0A //PMT SystemClockTag DescriptorTag = 0x0B MultiplexBufferUtilizationTag DescriptorTag = 0x0C CopyrightTag DescriptorTag = 0x0D MaximumBitrateTag DescriptorTag = 0x0E //PMT PrivateDataIndicatorTag DescriptorTag = 0x0F SmoothingBufferTag DescriptorTag = 0x10 STDTag DescriptorTag = 0x11 IBPTag DescriptorTag = 0x12 MPEG4VideoTag DescriptorTag = 0x1b MPEG4AudioTag DescriptorTag = 0x1c IODTag DescriptorTag = 0x1d SLTag DescriptorTag = 0x1f FMCTag DescriptorTag = 0x20 ExternalESIDTag DescriptorTag = 0x21 MuxCodeTag DescriptorTag = 0x22 FmxBufferSizeTag DescriptorTag = 0x23 MultiplexBufferTag DescriptorTag = 0x24 NetworkNameTag DescriptorTag = 0x40 //NIT ServiceListTag DescriptorTag = 0x41 //NIT StuffingTag DescriptorTag = 0x42 SatelliteDeliverySystemTag DescriptorTag = 0x43 CableDeliverySystemTag DescriptorTag = 0x44 BouquetNameTag DescriptorTag = 0x47 ServiceTag DescriptorTag = 0x48 CountryAvailabilityTag DescriptorTag = 0x49 LinkageTag DescriptorTag = 0x4A NVODReferenceTag DescriptorTag = 0x4B TimeShiftedServiceTag DescriptorTag = 0x4C ShortEventTag DescriptorTag = 0x4D ExtendedEventTag DescriptorTag = 0x4E TimeShiftedEventTag DescriptorTag = 0x4F ComponentTag DescriptorTag = 0x50 MosaicTag DescriptorTag = 0x51 StreamIdentifierTag DescriptorTag = 0x52 //PMT CAIdentifierTag DescriptorTag = 0x53 ContentTag DescriptorTag = 0x54 ParentalRatingTag DescriptorTag = 0x55 TeletextTag DescriptorTag = 0x56 TelephoneTag DescriptorTag = 0x57 LocalTimeOffsetTag DescriptorTag = 0x58 SubtitlingTag DescriptorTag = 0x59 //PMT TerrestrialDeliverySystemTag DescriptorTag = 0x5A //NIT MultilingualNetworkNameTag DescriptorTag = 0x5B MultilingualBouquetNameTag DescriptorTag = 0x5C MultilingualServiceNameTag DescriptorTag = 0x5D MultilingualComponentTag DescriptorTag = 0x5E PrivateDataSpecifierTag DescriptorTag = 0x5F //NIT ServiceMoveTag DescriptorTag = 0x60 ShortSmoothingBufferTag DescriptorTag = 0x61 FrequencyListTag DescriptorTag = 0x62 //NIT PartialTransportStreamTag DescriptorTag = 0x63 DataBroadcastTag DescriptorTag = 0x64 CASystemTag DescriptorTag = 0x65 DataBroadcastIdTag DescriptorTag = 0x66 TransportStreamTag DescriptorTag = 0x67 DSNGTag DescriptorTag = 0x68 PDCTag DescriptorTag = 0x69 AC3Tag DescriptorTag = 0x6a //PMT AncillaryDataTag DescriptorTag = 0x6b CellListTag DescriptorTag = 0x6c CellFrequencyLinkTag DescriptorTag = 0x6d AnnouncementSupportTag DescriptorTag = 0x6e ApplicationSignallingTag DescriptorTag = 0x6f //PMT EnhancedAC3Tag DescriptorTag = 0x7a //PMT DTSTag DescriptorTag = 0x7b AACTag DescriptorTag = 0x7c LogicalChannelTag DescriptorTag = 0x83 //NIT )
func (DescriptorTag) String ¶
func (tag DescriptorTag) String() string
type ESInfo ¶
type ESInfo []byte
func (ESInfo) Descriptors ¶
func (i ESInfo) Descriptors() DescriptorList
func (ESInfo) SetType ¶ added in v0.1.4
func (i ESInfo) SetType(typ StreamType)
func (ESInfo) Type ¶
func (i ESInfo) Type() StreamType
type ESInfoList ¶
type ESInfoList []byte
func (ESInfoList) Append ¶
func (il ESInfoList) Append(i ESInfo) ESInfoList
Append adds i to the end of the il. It works like Go append function so need to be used in this way:
il = il.Append(i)
func (ESInfoList) Pop ¶
func (il ESInfoList) Pop() (i ESInfo, ril ESInfoList)
Pop returns first elementary stream information element in i and remaining elements in ril. If there is no more elements then len(ril) == 0. If an error occurs i == nil.
type ISO639LangCode ¶
type ISO639LangCode uint32
type ISO639LangDescriptor ¶
type ISO639LangDescriptor []byte
func ParseISO639LangDescriptor ¶
func ParseISO639LangDescriptor(d Descriptor) (ld ISO639LangDescriptor, ok bool)
func (ISO639LangDescriptor) Pop ¶
func (d ISO639LangDescriptor) Pop() (lc ISO639LangCode, at AudioType, rd ISO639LangDescriptor)
Pop returns first (lc, at) pair from d. Remaining pairs are returned in rd. If there is no more pairs to read len(rd) == 0. If an error occurs rd = nil
type LocalTimeOffset ¶
type LocalTimeOffsetDescriptor ¶
type LocalTimeOffsetDescriptor []byte
func MakeLocalTimeOffsetDescriptor ¶
func MakeLocalTimeOffsetDescriptor(n int) LocalTimeOffsetDescriptor
MakeLocalTimeOffsetDescriptor makes descriptor suitable for n time offsets.
func ParseLocalTimeOffsetDescriptor ¶
func ParseLocalTimeOffsetDescriptor(d Descriptor) (tod LocalTimeOffsetDescriptor, ok bool)
func (LocalTimeOffsetDescriptor) MakeDescriptor ¶
func (lto LocalTimeOffsetDescriptor) MakeDescriptor() Descriptor
func (LocalTimeOffsetDescriptor) Pop ¶
func (d LocalTimeOffsetDescriptor) Pop() (lto LocalTimeOffset, rd LocalTimeOffsetDescriptor)
Pop returns first LocalTimeOffset from d. Remaining offsets are returned in rd. If there is no more data to read len(rd) == 0. If an error occurs rd = nil.
func (LocalTimeOffsetDescriptor) Set ¶
func (d LocalTimeOffsetDescriptor) Set(n int, lto LocalTimeOffset)
Update updates n-th time ofset in d.
type LogicalChannelDescriptor ¶
type LogicalChannelDescriptor []byte
func ParseLogicalChannelDescriptor ¶
func ParseLogicalChannelDescriptor(d Descriptor) (lcd LogicalChannelDescriptor, ok bool)
func (*LogicalChannelDescriptor) Append ¶
func (lcd *LogicalChannelDescriptor) Append(lci LogicalChannelInfo)
func (LogicalChannelDescriptor) MakeDescriptor ¶
func (lcd LogicalChannelDescriptor) MakeDescriptor() Descriptor
func (LogicalChannelDescriptor) Pop ¶
func (d LogicalChannelDescriptor) Pop() (lci LogicalChannelInfo, rd LogicalChannelDescriptor)
Pop returns first LogicalChannelInfo from d. Remaining infos are returned in rd. If there is no more infos to read len(rd) == 0. If an error occurs rd = nil.
type LogicalChannelInfo ¶
type MuxInfo ¶
type MuxInfo []byte
func MakeMuxInfo ¶
func MakeMuxInfo() MuxInfo
func (*MuxInfo) AppendDescriptor ¶
func (mi *MuxInfo) AppendDescriptor(ds ...Descriptor)
func (MuxInfo) ClearDescriptors ¶
func (mi MuxInfo) ClearDescriptors()
func (MuxInfo) Descriptors ¶
func (mi MuxInfo) Descriptors() DescriptorList
func (MuxInfo) SetOrgNetId ¶
type MuxInfoList ¶
type MuxInfoList struct {
TableCursor
}
func (MuxInfoList) Pop ¶
func (il MuxInfoList) Pop() (MuxInfo, MuxInfoList)
Pop returns first MuxInfo element from il. If there is no more data to read Pop returns empty ServiceInfoList. If an error occurs it returns nil MuxInfo and non-empty MuxInfoList.
type NIT ¶
type NIT Table
func (*NIT) AppendMuxInfo ¶
AppendMuxInfos appends information about transport stream to nit.
func (*NIT) AppendNetDescriptor ¶
func (nit *NIT) AppendNetDescriptor(ds ...Descriptor)
AppendNetDescriptors appends network descriptors ds to nit. It can be called only before first AppendMuxInfo call.
func (NIT) Descriptors ¶
func (nit NIT) Descriptors() TableDescriptors
Descriptors returns network descriptors list
func (NIT) MuxInfo ¶
func (nit NIT) MuxInfo() MuxInfoList
type NetworkNameDescriptor ¶
type NetworkNameDescriptor []byte
func ParseNetworkNameDescriptor ¶
func ParseNetworkNameDescriptor(d Descriptor) (nnd NetworkNameDescriptor, ok bool)
type PAT ¶
type PAT Table
func (*PAT) Append ¶
Append appends next program to PAT. After Append pat is in invalid state. Use Close to recalculate all section numbers and CRCs.
func (PAT) FindPMT ¶
FindPMT returns PMT PID for given progid. If there is no such progId it returns pid == ts.NullPid. If an error occurs FindPMT retuns -1
func (PAT) FindProgId ¶
FindProgId returns first found program number that corresponds to pmtpid. Returns ok == false if not found or error.
func (PAT) ProgramList ¶
func (pat PAT) ProgramList() ProgramList
ProgramList returns list of programs
type PMT ¶
type PMT Section
func AsPMT ¶
AsPMT returns s as PMT or error if s isn't PMT section. This works because PMT should fit in one section (other tables occupy multiple sections.
func (PMT) ESInfo ¶
func (p PMT) ESInfo() ESInfoList
func (PMT) ProgramDescriptors ¶
func (p PMT) ProgramDescriptors() DescriptorList
func (PMT) SetVersion ¶
func (PMT) Update ¶
func (p PMT) Update(r SectionReader) error
Update reads one section into p and runs AsPMT to check its syntax.
type ProgramList ¶
type ProgramList struct {
TableCursor
}
func (ProgramList) Pop ¶
func (pl ProgramList) Pop() (progId uint16, pmtpid int16, rpl ProgramList)
Pop returns first (progId, pid) pair from pl. Remaining pairs are returned in rpl. If there is no more programs to read rpl is empty. If an error occurs pmtpid == -1
type SDT ¶
type SDT Table
func (*SDT) Append ¶
func (sdt *SDT) Append(onid uint16, si ServiceInfo)
func (SDT) ServiceInfo ¶
func (sdt SDT) ServiceInfo() ServiceInfoList
Info returns list of ifnormation about services (programs)
type Section ¶
type Section []byte
func MakeEmptySection ¶
MakeEmptySection creates new empty, reseted section.
func (Section) Alloc ¶
Alloc allocates n bytes in section. It returns nil if there is no room for n+m bytes. Alloc invalidates CRC sum if used. Use MakeCRC to recalculate it.
func (Section) CheckCRC ¶
CheckCRC returns true if s.Len() is valid and CRC32 of whole section is correct
func (Section) Copy ¶
Copy copies content of sec to s (sec.Len() bytes are copied from sec to s). It panics if len(s) < sec.Len().
func (Section) GenericSyntax ¶
GenericSyntax returns the value of section_syntax_indicator field
func (Section) LastNumber ¶
LastNumber returns the value of last_section_number field
func (Section) Len ¶
Len returns length of the whole section (section_length + 3) or -1 if section_length filed contains incorrect value
func (Section) MakeCRC ¶
func (s Section) MakeCRC()
MakeCRC calculates CRC32 for whole section and uses it to set CRC_32 field
func (Section) PrivateSyntax ¶
PrivateIndicator returns the value of private_syntax_indicator field
func (Section) Reset ¶
func (s Section) Reset()
Reset resets section s to contain all bits set to 1.
func (Section) SetCurrent ¶
SetCurrent sets the value of current_next_indicator field
func (Section) SetEmpty ¶
func (s Section) SetEmpty()
SetEmpty initializes section lenght, so s becomes empty. SetEmpty invalidates CRC sum. Use MakeCRC to recalculate it.
func (Section) SetGenericSyntax ¶
SetGenericSyntax sets the value of section_syntax_indicator field
func (Section) SetLastNumber ¶
SetLastNumber sets the value of last_section_number field
func (Section) SetPrivateSyntax ¶
SetPrivateSyntax sets the value of private_syntax_indicator field
func (Section) SetTableId ¶
SetTableId sets the value of table_id field
func (Section) SetTableIdExt ¶
Set TableIdExt sets the value of table_id_extension
func (Section) SetVersion ¶
SetVersion sets the value of version_number field. It panic if v > 31
func (Section) TableIdExt ¶
TableIdExt returns the value of table_id_extension
type SectionDecoder ¶
type SectionDecoder struct {
// contains filtered or unexported fields
}
SectionDecoder can decode section from stream of packets
func NewSectionDecoder ¶
func NewSectionDecoder(r ts.PktReplacer, check bool) *SectionDecoder
NewSectionDecoder creates section decoder. You can use r == nil and set source of packets lather using SetPktReplacer or SetPktReader method. If check is true decoder checks value of reserved header bits and CRC.
func (*SectionDecoder) ReadSection ¶
func (d *SectionDecoder) ReadSection(s Section) error
ReadSection decodes one section.
func (*SectionDecoder) Reset ¶
func (d *SectionDecoder) Reset()
Reset resets internal state of decoder (discards possible buffered data for next section decoding)
func (*SectionDecoder) SetPktReader ¶
func (d *SectionDecoder) SetPktReader(r ts.PktReader)
SetPktReader sets ts.PktReader that will be usea as data source
func (*SectionDecoder) SetPktReplacer ¶
func (d *SectionDecoder) SetPktReplacer(r ts.PktReplacer)
SetPktReplacer sets ts.PktReplacer that will be used as data source
type SectionEncoder ¶
type SectionEncoder struct {
// contains filtered or unexported fields
}
SectionEncoder can encode sections into stream of MPEG-TS packets. It has one TS packet internal buffer and writes it down only when it need more space or Flush method is called.
func NewSectionEncoder ¶
func NewSectionEncoder(r ts.PktReplacer, pid int16) *SectionEncoder
NewSectionEncoder creates section encoder. You can use r == nil and set it lather using SetPktReplacer or SetPktWriter method.
func (*SectionEncoder) Flush ¶
func (e *SectionEncoder) Flush() error
Flush writes internally buffered packet adding stuffing bytes at end if need.
func (*SectionEncoder) SetPktReplacer ¶
func (e *SectionEncoder) SetPktReplacer(r ts.PktReplacer)
SetPktReplacer sets ts.PktReplacer that will be used to write packets.
func (*SectionEncoder) SetPktWriter ¶
func (e *SectionEncoder) SetPktWriter(r ts.PktWriter)
SetPktWriter sets ts.PktWriter that will be used to write packets.
func (*SectionEncoder) WriteSection ¶
func (e *SectionEncoder) WriteSection(s Section) error
WriteSection encodes one section into one or more MPEG-TS packets.
type SectionQueue ¶
type SectionQueue struct {
// contains filtered or unexported fields
}
SectionQueue represents queue of Sections.
func NewSectionQueue ¶
func NewSectionQueue(n, seclen int) *SectionQueue
NewSectionQueue creates new queue with internall buffer of size n sections. Every section in buffer has secap capacity. Sections in buffer are not inintialized.
func (*SectionQueue) Len ¶
func (q *SectionQueue) Len() int
Len returns number of sections queued in q.
func (*SectionQueue) ReadPart ¶
func (q *SectionQueue) ReadPart() *SectionReadQueue
ReadPart returns read part of q that can be used only to read sections from q.
func (*SectionQueue) WritePart ¶
func (q *SectionQueue) WritePart() *SectionWriteQueue
WritePart returns write part of q that can be used to write sections to q and to close q.
type SectionReadQueue ¶
type SectionReadQueue SectionQueue
SectionReadQueue represenst read part of SectionQueue and implements SectionReplacer interface. If reader uses raw channels insteed of ReplaceSection method it should first read filled sections from the Filled channel and next write empty sections to the Empty channel.
func (*SectionReadQueue) Empty ¶
func (q *SectionReadQueue) Empty() chan<- Section
Empty returns a channel that can be used to pass empty sections to q.
func (*SectionReadQueue) Filled ¶
func (q *SectionReadQueue) Filled() <-chan Section
Filled returns a channel that can be used to obtain filled sections from q.
func (*SectionReadQueue) Len ¶
func (q *SectionReadQueue) Len() int
Len returns number of sections queued in q.
func (*SectionReadQueue) ReplaceSection ¶
func (q *SectionReadQueue) ReplaceSection(s Section) (Section, error)
ReplaceSection obtains filled section from q and next pass empty section to q. It returns io.EOF error when queue was closed and there is no more sections to read.
type SectionReader ¶
type SectionReader interface { // ReadSection reads one section into s. len(s) should be equal to // MaxSectionLen or MaxISOSectionLen if you read standard PSI tables. You // can use shorter s (but not shorter that 8 bytes) if you are sure that // read section should fit in it. If ReadSection returned error of // dvb.TemporaryError type you can try read next section. ReadSection(Section) error }
SectionReader is an interface that wraps the ReadSection method.
type SectionReplacer ¶
type SectionReplacer interface { // ReplaceSection consumes secion reffered by s an returns other section // reffered by r. ReplaceSection(s Section) (r Section, e error) }
SectionReplacer is an interface that wraps the ReplaceSection method. After ReplaceSection call caller should not reffer to s content any more. If ReplaceSection returns an error it is guaranteed that r == s (but content reffered by s can be modified). Generally ReplaceSection should be used in this way:
s, err = q.ReplaceSection(s) if err != nil { ... }
type SectionStreamReader ¶
type SectionStreamReader struct {
// contains filtered or unexported fields
}
SectionStreamReader wraps any io.Reader interface and returns SectionReader implementation for read MPEG-TS sections from stream of bytes.
func NewSectionStreamReader ¶
func NewSectionStreamReader(r io.Reader, checkCRC bool) *SectionStreamReader
func (*SectionStreamReader) ReadSection ¶
func (sr *SectionStreamReader) ReadSection(s Section) error
type SectionWriteQueue ¶
type SectionWriteQueue SectionQueue
SectionWriteQueue represenst write part of SectionQueue and implements SectionReplacer interface. If writer uses raw channels insteed of ReplaceSection method it should read empty section from Empty channel and next write filled section to Filled channel.
func (*SectionWriteQueue) Close ¶
func (q *SectionWriteQueue) Close()
Close closes write part of queue. After close on write part, ReplaceSection method on read part returns io.EOF error if there is no more sections to read from q.
func (*SectionWriteQueue) Empty ¶
func (q *SectionWriteQueue) Empty() <-chan Section
Empty returns a channel that can be used to obtain empty sections from q.
func (*SectionWriteQueue) Filled ¶
func (q *SectionWriteQueue) Filled() chan<- Section
Filled returns a channel that can be used to pass filled sections to q.
func (*SectionWriteQueue) Len ¶
func (q *SectionWriteQueue) Len() int
Len returns number of sections queued in q.
func (*SectionWriteQueue) ReplaceSection ¶
func (q *SectionWriteQueue) ReplaceSection(s Section) (Section, error)
ReplaceSection obtains empty section from q and next pass pkt to q. It always returns nil error.
type SectionWriter ¶
SectionWriter is an interface wraps the WriteSection method.
type ServiceDescriptor ¶
type ServiceDescriptor struct { Type ServiceType ProviderName []byte ServiceName []byte }
func ParseServiceDescriptor ¶
func ParseServiceDescriptor(d Descriptor) (sd ServiceDescriptor, ok bool)
type ServiceInfo ¶
type ServiceInfo []byte
func MakeServiceInfo ¶
func MakeServiceInfo() ServiceInfo
func (*ServiceInfo) AppendDescriptors ¶
func (si *ServiceInfo) AppendDescriptors(ds ...Descriptor)
func (ServiceInfo) ClearDescriptors ¶
func (si ServiceInfo) ClearDescriptors()
ClearDescriptors clears descriptors_loop_length field.
func (ServiceInfo) Descriptors ¶
func (si ServiceInfo) Descriptors() DescriptorList
func (ServiceInfo) EITPresentFollowing ¶
func (si ServiceInfo) EITPresentFollowing() bool
EITPresentFollowing returns the value of EIT_present_following_flag field.
func (ServiceInfo) EITSchedule ¶
func (si ServiceInfo) EITSchedule() bool
EITSchedule returns the value of EIT_schedule_flag field.
func (ServiceInfo) Scrambled ¶
func (si ServiceInfo) Scrambled() bool
Scrambled returns the value of free_CA_mode field.
func (ServiceInfo) ServiceId ¶
func (si ServiceInfo) ServiceId() uint16
ServiceId return id of service (program) that this information applies to.
func (ServiceInfo) SetEITPresentFollowing ¶
func (si ServiceInfo) SetEITPresentFollowing(b bool)
func (ServiceInfo) SetEITSchedule ¶
func (si ServiceInfo) SetEITSchedule(b bool)
func (ServiceInfo) SetServiceId ¶
func (si ServiceInfo) SetServiceId(sid uint16)
func (ServiceInfo) SetStatus ¶
func (si ServiceInfo) SetStatus(s ServiceStatus)
SetStatus sets running_status field.
func (ServiceInfo) Status ¶
func (si ServiceInfo) Status() ServiceStatus
Status returns the value of running_status field.
type ServiceInfoList ¶
type ServiceInfoList struct {
TableCursor
}
func (ServiceInfoList) Pop ¶
func (sl ServiceInfoList) Pop() (ServiceInfo, ServiceInfoList)
Pop returns first ServiceInfo element from sl. If there is no more data to read Pop returns empty ServiceInfoList. If an error occurs it returns nil ServiceInfo.
type ServiceListDescriptor ¶
type ServiceListDescriptor []byte
func ParseServiceListDescriptor ¶
func ParseServiceListDescriptor(d Descriptor) (sld ServiceListDescriptor, ok bool)
func (*ServiceListDescriptor) Append ¶
func (sld *ServiceListDescriptor) Append(sid uint16, typ ServiceType)
func (ServiceListDescriptor) MakeDescriptor ¶
func (sld ServiceListDescriptor) MakeDescriptor() Descriptor
func (ServiceListDescriptor) Pop ¶
func (d ServiceListDescriptor) Pop() (sid uint16, typ ServiceType, rd ServiceListDescriptor)
Pop returns first (sid, typ) pair from d. Remaining pairs are returned in rd. If there is no more pairs to read len(rd) == 0. If an error occurs rd = nil
type ServiceStatus ¶
type ServiceStatus byte
const ( StatusUndefined ServiceStatus = iota NotRunnind StartsInFewSeconds Pausing Running )
func (ServiceStatus) String ¶
func (ss ServiceStatus) String() string
type ServiceType ¶
type ServiceType byte
func (ServiceType) String ¶
func (t ServiceType) String() string
type StreamIdentifierDescriptor ¶
type StreamIdentifierDescriptor byte
func ParseStreamIdentifierDescriptor ¶
func ParseStreamIdentifierDescriptor(d Descriptor) (sid StreamIdentifierDescriptor, ok bool)
type StreamType ¶
type StreamType byte
const ( ZeroStreamType StreamType = 0x00 MPEG1Video StreamType = 0x01 MPEG2Video StreamType = 0x02 MPEG1Audio StreamType = 0x03 MPEG2Audio StreamType = 0x04 PrivSect StreamType = 0x05 PrivPES StreamType = 0x06 MHEG StreamType = 0x07 DSMCC StreamType = 0x08 H222_1 StreamType = 0x09 DSMCC_A StreamType = 0x0A DSMCC_B StreamType = 0x0B DSMCC_C StreamType = 0x0C DSMCC_D StreamType = 0x0D MPEG2Aux StreamType = 0x0E AAC StreamType = 0x0F MPEG4Video StreamType = 0x10 MPEG4Audio StreamType = 0x11 DSMCC_SDP StreamType = 0x12 SPSPES StreamType = 0x13 SPSSect StreamType = 0x14 MetaDataPES StreamType = 0x15 MetaDataSect StreamType = 0x16 MetaDataDC StreamType = 0x17 MetaDataOC StreamType = 0x18 MetaDataDL StreamType = 0x19 MPEG2IPMP StreamType = 0x1A H264Video StreamType = 0x1B MPEG4RawAudio StreamType = 0x1C MPEG4Text StreamType = 0x1D MPEG4Aux StreamType = 0x1E MPEG4SVC StreamType = 0x1E MPEG4MVC StreamType = 0x20 JPEG2000Video StreamType = 0x21 H265Video StreamType = 0x24 )
func ParseStreamType ¶
func ParseStreamType(s string) StreamType
func (StreamType) String ¶
func (t StreamType) String() string
type Table ¶
type Table []Section
func (Table) Close ¶
func (t Table) Close(cfg *TableConfig, tableIdExt uint16, current bool, version int8)
Close recalculates section numbers and makes CRC sums for all sections.
func (Table) Cursor ¶
func (t Table) Cursor() TableCursor
Cursor returns TableCursor that can be used to obtain data from table.
func (Table) Descriptors ¶
func (t Table) Descriptors(offset int) TableDescriptors
Descriptors handles table global descriptors (if exists). offset is an offest from begining of section data part to descriptor length word.
func (Table) SetTableId ¶
func (Table) TableIdExt ¶
type TableConfig ¶
type TableCursor ¶
func (TableCursor) IsEmpty ¶
func (tc TableCursor) IsEmpty() bool
func (TableCursor) NextSection ¶
func (tc TableCursor) NextSection() TableCursor
type TableDescriptors ¶
type TableDescriptors struct {
// contains filtered or unexported fields
}
func (TableDescriptors) IsEmpty ¶
func (td TableDescriptors) IsEmpty() bool
func (TableDescriptors) Pop ¶
func (td TableDescriptors) Pop() (d Descriptor, rtd TableDescriptors)
type TerrestrialDeliverySystemDescriptor ¶
type TerrestrialDeliverySystemDescriptor struct { Freq int64 // center frequency [Hz] Bandwidth int // bandwidth [Hz] HighPrio bool TimeSlicing bool MPEFEC bool Constellation dvb.Modulation Hierarchy dvb.Hierarchy CodeRateHP dvb.CodeRate CodeRateLP dvb.CodeRate Guard dvb.Guard TxMode dvb.TxMode OtherFreq bool }
func ParseTerrestrialDeliverySystemDescriptor ¶
func ParseTerrestrialDeliverySystemDescriptor(d Descriptor) (tds TerrestrialDeliverySystemDescriptor, ok bool)
func (TerrestrialDeliverySystemDescriptor) Bitrate ¶
func (tds TerrestrialDeliverySystemDescriptor) Bitrate() int64
func (TerrestrialDeliverySystemDescriptor) MakeDescriptor ¶
func (tds TerrestrialDeliverySystemDescriptor) MakeDescriptor() Descriptor