tsio

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamIdH264 = 0xe0
	StreamIdAAC  = 0xc0
)
View Source
const (
	PAT_PID = 0
	PMT_PID = 0x1000
)
View Source
const (
	ElementaryStreamTypeH264                = 0x1B
	ElementaryStreamTypeAdtsAAC             = 0x0F
	ElementaryStreamTypeAlignmentDescriptor = 0x06
	ElementaryStreamTypeH265                = 0x24
)
View Source
const (
	PTS_HZ = 90000
	PCR_HZ = 27000000
)
View Source
const MaxPESHeaderLength = 19
View Source
const MaxTSHeaderLength = 12
View Source
const PSIHeaderLength = 9
View Source
const TableExtPAT = 1
View Source
const TableExtPMT = 1
View Source
const TableIdPAT = 0
View Source
const TableIdPMT = 2

Variables

View Source
var ErrPESHeader = fmt.Errorf("invalid PES header")
View Source
var ErrPSIHeader = fmt.Errorf("invalid PSI header")
View Source
var ErrParsePAT = fmt.Errorf("invalid PAT")
View Source
var ErrParsePMT = fmt.Errorf("invalid PMT")

Functions

func FillPESHeader

func FillPESHeader(h []byte, streamid uint8, datalen int, pts, dts time.Duration) (n int)

func FillPSI

func FillPSI(h []byte, tableid uint8, tableext uint16, datalen int) (n int)

func PCRToTime

func PCRToTime(pcr uint64) (tm time.Duration)

func PCRToUInt

func PCRToUInt(pcr uint64) uint64

PCRToUInt func

func ParsePESHeader

func ParsePESHeader(h []byte) (hdrlen int, streamid uint8, datalen int, pts, dts time.Duration, err error)

func ParsePSI

func ParsePSI(h []byte) (tableid uint8, tableext uint16, hdrlen int, datalen int, err error)

func ParseTSHeader

func ParseTSHeader(tshdr []byte) (pid uint16, start bool, iskeyframe bool, hdrlen int, err error)

func TimeToPCR

func TimeToPCR(tm time.Duration) (pcr uint64)

func TimeToTs

func TimeToTs(tm time.Duration) (v uint64)

func TsToTime

func TsToTime(v uint64) (tm time.Duration)

func WriteRepeatVal

func WriteRepeatVal(w io.Writer, val byte, n int) (err error)

WriteRepeatVal func

func WriteTSHeader

func WriteTSHeader(w io.Writer, element TSHeader, dataLength int) (written int, err error)

WriteTSHeader func

func WriteUInt

func WriteUInt(w io.Writer, val uint, n int) (err error)

WriteUInt func

func WriteUInt64

func WriteUInt64(w io.Writer, val uint64, n int) (err error)

WriteUInt64 func

Types

type Descriptor

type Descriptor struct {
	Tag  uint8
	Data []byte
}

type ElementaryStreamInfo

type ElementaryStreamInfo struct {
	StreamType    uint8
	ElementaryPID uint16
	Descriptors   []Descriptor
}

type PAT

type PAT struct {
	Entries []PATEntry
}

func (PAT) Len

func (self PAT) Len() (n int)

func (PAT) Marshal

func (self PAT) Marshal(b []byte) (n int)

func (*PAT) Unmarshal

func (self *PAT) Unmarshal(b []byte) (n int, err error)

type PATEntry

type PATEntry struct {
	ProgramNumber uint16
	NetworkPID    uint16
	ProgramMapPID uint16
}

type PMT

type PMT struct {
	PCRPID                uint16
	ProgramDescriptors    []Descriptor
	ElementaryStreamInfos []ElementaryStreamInfo
}

func (PMT) Len

func (self PMT) Len() (n int)

func (PMT) Marshal

func (self PMT) Marshal(b []byte) (n int)

func (*PMT) Unmarshal

func (self *PMT) Unmarshal(b []byte) (n int, err error)

type TSHeader

type TSHeader struct {
	PID                    uint
	PCR                    uint64
	OPCR                   uint64
	ContinuityCounter      uint
	PayloadUnitStart       bool
	DiscontinuityIndicator bool
	RandomAccessIndicator  bool
	HeaderLength           uint
}

TSHeader func

type TSWriter

type TSWriter struct {
	ContinuityCounter uint
	// contains filtered or unexported fields
}

func NewTSWriter

func NewTSWriter(pid uint16) *TSWriter

func (*TSWriter) WritePackets

func (self *TSWriter) WritePackets(w io.Writer, datav [][]byte, pcr time.Duration, sync bool, paddata bool) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL