Documentation
¶
Overview ¶
Package mpegts reads the parts of an MPEG transport stream a TV tuner needs: the scrambling bits, what the stream says it carries (PAT, PMT, SDT, ATSC VCT) and the programme guide inside it (DVB EIT, ATSC PSIP).
It never decrypts anything. Scrambled packets are only counted, so that a stream can be refused.
Index ¶
Constants ¶
const ( PIDPAT = 0x0000 PIDSDT = 0x0011 PIDEIT = 0x0012 PIDPSIP = 0x1FFB )
Well-known PIDs.
const PacketSize = 188
PacketSize is the size of one transport stream packet.
Variables ¶
var ErrScrambled = errors.New("the stream is scrambled")
ErrScrambled: the stream is encrypted, and the packets say so.
Functions ¶
func DVBText ¶
DVBText decodes a DVB text field (EN 300 468 annex A). UTF-8 and the Latin-1 family are read; the default table is close enough to Latin-1 for names and titles. Other character tables come through with the unknown characters dropped.
func MultipleString ¶
MultipleString reads ATSC's multiple_string_structure: the first string, in the modes that are plain text. Huffman-compressed strings need tables this reader does not carry, and give an empty result.
Types ¶
type Event ¶
type Event struct {
ServiceID int // DVB service, or the ATSC source id when ATSC is set
ATSC bool
Start time.Time
Duration time.Duration
Title string
Desc string
Rating string
}
Event is a programme from the broadcast's own guide.
func ParseATSCEIT ¶
ParseATSCEIT reads an ATSC Event Information Table section.
type Guard ¶
type Guard struct {
OnEvent func(Event)
// contains filtered or unexported fields
}
Guard passes a transport stream through unchanged, while watching it. When the stream turns out to be encrypted it stops with ErrScrambled. It also collects the guide data going by, which costs almost nothing.
func (*Guard) Underneath ¶ added in v0.2.0
func (g *Guard) Underneath() io.ReadCloser
Underneath is the stream being watched, for a helper handing it to a server that watches it for itself: looking twice would cost twice, and only the server's look counts.
type Header ¶
Header is what a packet's first four bytes say.
func ParsePacket ¶
ParsePacket reads one packet. ok is false for anything out of sync.
type PMT ¶
type PMT struct {
Program int
PCR int
Streams []ES
CA bool // a conditional access descriptor: the programme may be encrypted
}
PMT says what a programme is made of.
type ProgramFilter ¶
type ProgramFilter struct {
// contains filtered or unexported fields
}
ProgramFilter passes one programme from a stream that carries many: its PAT (rewritten to list only it), PMT, audio and video, and the guide tables.
func NewProgramFilter ¶
func NewProgramFilter(r io.ReadCloser, program int) *ProgramFilter
NewProgramFilter keeps only this programme of r.
func (*ProgramFilter) Close ¶
func (f *ProgramFilter) Close() error
Close closes the stream underneath.
func (*ProgramFilter) Fatal ¶
func (f *ProgramFilter) Fatal() error
Fatal passes on a guard's reason from underneath.
type Service ¶
type Service struct {
ID int
Name string
Provider string
Type int
FreeCA bool // conditional access: encrypted
}
Service is an entry of DVB's SDT.
type VirtualChannel ¶
type VirtualChannel struct {
Name string
Major int
Minor int
Program int
SourceID int
Encrypted bool // access_controlled
Hidden bool
Type int
}
VirtualChannel is an entry of ATSC's channel table.
func ParseVCT ¶
func ParseVCT(s []byte) []VirtualChannel
ParseVCT reads a terrestrial or cable Virtual Channel Table section.