Documentation
¶
Overview ¶
Package tstream implements encoding and decoding of MPEG transport streams as specified in ISO/IEC 13818-1.
Index ¶
Constants ¶
const ( ScrambleNone = 0 + iota ScrambeReserved ScrambleEvenKey ScrambleOddKey )
const PacketSize int = 188
PacketSize is the number of bytes in a single MPEG-TS packet.
Variables ¶
var ErrBadPacket error = errors.New("malformed packet")
var ErrNoData error = errors.New("no data in packet")
Functions ¶
Types ¶
type AdaptationField ¶
type AdaptationField struct { Header AdaptationHeader PCR *ClockRef OPCR *ClockRef // contains filtered or unexported fields }
type AdaptationHeader ¶
type ClockRef ¶
type ClockRef [6]byte
A ClockRef holds a duration as the number of ticks of a 27MHz clock, most commonly used as the value of a Program Clock Reference (PCR).
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes MPEG-TS packets from an input stream using its own internal buffering.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
type Header ¶
type Header struct { // Indicates whether the packet's payload is erroneous. // If true, the payload is likely to be discarded by players. Error bool // Indicates if a PES packet is present in the payload. PayloadStart bool Priority bool PacketID uint16 Scramble uint8 // Also known as the payload unit start indicator (PUSI). HasPayload bool HasAdaptationField bool ContinuityCounter uint8 // contains filtered or unexported fields }
A Header contains metadata of a Packet.
type PESFlags ¶
type PESFlags struct { // Scrambling holds a 2-bit field representing... Scrambling uint8 Priority bool Aligned bool Copyright bool Original bool HasPTS bool HasDTS bool // Indicates presence of Element stream clock reference HasClockRef bool // Indicates presence of Element stream rate HasStreamRate bool HasTrickMode bool HasCopyInfo bool HasCRC bool HasExtensions bool HeaderLength uint8 // contains filtered or unexported fields }
PESFlags indicates what data is present in PES header fields.
type PESHeader ¶
type PESHeader struct { StreamID uint8 // Holds the number of bytes in the PES packet. // TODO(otl): does this include or exclude bytes in Fields? PacketLength uint16 // Optional fields; may be nil. Flags *PESFlags Fields *PESHeaderFields // contains filtered or unexported fields }
PESHeader contains metadata on the contents of a PES packet.
type PESHeaderFields ¶
type PESHeaderFields struct { // Holds the presentation timestamp; the number of ticks of a 90KHz clock. PTS Timestamp // Holds the decoder timestamp. This is usually not required. // Even if it is set, it usually holds the same value as PTS. DTS Timestamp // Holds the Digital Storage Media trick mode configuration. TrickMode uint8 // CopyInfo *CopyInfo Extensions uint8 Stuffing []byte // contains filtered or unexported fields }
PESHeaderFields represents the parsed values of header fields set in a PES header.
type PESPacket ¶
PESPacket represents a packetized elementary stream (PES) packet. PES packets are encapsulated in the payloads of MPEG-TS packets.
type Packet ¶
type Packet struct { // Header contains this Packet's metadata. Header Header // Holds the optional adaptation field in its native binary-encoded format. // If nil, the packet has no adapation field. AdaptationField *AdaptationField // Contains the raw payload, excluding the adapation field if present. Payload []byte // PES holds a decoded packet elementary stream (PES) packet if one is // encapsulated in Payload. PES *PESPacket }
A Packet represents a fixed-length MPEG Transport Stream packet.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
A Scanner provides a way to incrementally read through a stream of Packets. A Scanner must be created with NewScanner.
func NewScanner ¶
func (*Scanner) Err ¶
Err returns the most recent error the scanner encountered while reading from its input.
type Timestamp ¶
type Timestamp [5]byte
Timestamp holds a presentation or decode timestamp (PTS/DTS) in wire format. It is a binary encoding of 32-bit unsigned integers using 5 bytes, with some padding. Using "." as the bits of a PTS/DTS, a timestamp is encoded like so:
0b0010...1...............1...............1