ts

package module
v0.0.0-...-ce18db6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 8 Imported by: 2

README

orange-ts

MPEG Transport Stream library for my Orange Project

Documentation

Index

Constants

View Source
const (
	// Program Clock Reference (PCR) is based on a 27 Mhz clock
	PCRFrequency = uint64(27000000)

	// Presentation Time Stamp (PTS) is based on a 90khz clock
	PTSFrequency = uint64(90000)
)
View Source
const (
	PacketSize = 188
)

Variables

View Source
var (
	ErrNoPCR                  = fmt.Errorf("AdaptationField has no Program Clock Reference")
	ErrNoOPCR                 = fmt.Errorf("AdaptationField has no Original Program Clock Reference")
	ErrNoAdaptationField      = fmt.Errorf("Packet has no Adaptation Field")
	ErrNoPayload              = fmt.Errorf("Packet has no payload")
	ErrNoPESHeader            = fmt.Errorf("Packet does not contain a PES Header")
	ErrNoSplicingPoint        = fmt.Errorf("Adaptation Field has no splicing point")
	ErrNoTransportPrivateData = fmt.Errorf("Adaptation Field has no transport private data")
	ErrNoAdaptationExtension  = fmt.Errorf("Adaptation Field does not have an extension field")
	ErrNoLTW                  = fmt.Errorf("Adaptation Extension Field has no Legal Time Window")
	ErrNoPiecewiseRate        = fmt.Errorf("Adaptation Extension Field has no Piecewise Rate")
	ErrNoSeamlessSplice       = fmt.Errorf("Adaptation Extension Field has no Seamless Splice")
)
View Source
var (
	ErrNoPESPTS                          = fmt.Errorf("PES Header has no Presentation Time Stamp")
	ErrNoPESDTS                          = fmt.Errorf("PES Header has no Decoding Time Stamp")
	ErrNoPESESCR                         = fmt.Errorf("PES Header has no Elementary Stream Clock Reference")
	ErrNoPESESRate                       = fmt.Errorf("PES Header has no Elementary Stream Rate")
	ErrNoPESAdditionalCopyInfo           = fmt.Errorf("PES Header has no additional copy information")
	ErrNoPESCRC                          = fmt.Errorf("PES Header has no CRC")
	ErrNoPESExtension                    = fmt.Errorf("PES Header has no header extension")
	ErrNoPESPrivateData                  = fmt.Errorf("PES Header has no private data")
	ErrNoPESPackHeaderField              = fmt.Errorf("PES Header has no pack header field")
	ErrNoPESProgramPacketSequenceCounter = fmt.Errorf("PES Header has no Program Packet Sequence Counter")
	ErrNoPStdBufferInfo                  = fmt.Errorf("PES Header has no P-STD Buffer information")
	ErrNoPESSecondExtension              = fmt.Errorf("PES Header has no additional PES extension")
)
View Source
var CalculateDTS = CalculatePTS
View Source
var CalculateESCR = CalculatePTS
View Source
var (
	ErrSyncByteNotFound = fmt.Errorf("Sync Byte (0x47) not found in bit stream")
)

Functions

func Bool

func Bool(b byte, bit int) bool

func DumpPTS

func DumpPTS(timestamp TimeStamp) []byte

func SegmentStream

func SegmentStream(inCh <-chan Packet) <-chan Segment

func SetBool

func SetBool(b *byte, bit int, value bool)

func SetUimsbf16

func SetUimsbf16(b []byte, width int, value uint16)

func SetUimsbf8

func SetUimsbf8(b *byte, value uint8)

func StringToUtf16

func StringToUtf16(str string) []byte

func Uimsbf16

func Uimsbf16(b []byte, width int) uint16

func Uimsbf32

func Uimsbf32(b []byte, width int) uint32

func Uimsbf64

func Uimsbf64(b []byte, width int) uint64

func Uimsbf8

func Uimsbf8(b byte) uint8

func Utf16ToString

func Utf16ToString(b []byte, offset int, length int) string

Types

type AdaptationExtension

type AdaptationExtension []byte

func (AdaptationExtension) DTSNextAccessUnit

func (ae AdaptationExtension) DTSNextAccessUnit() (uint64, error)

func (AdaptationExtension) HasLTW

func (ae AdaptationExtension) HasLTW() bool

func (AdaptationExtension) HasPiecewiseRate

func (ae AdaptationExtension) HasPiecewiseRate() bool

func (AdaptationExtension) HasSeamlessSplice

func (ae AdaptationExtension) HasSeamlessSplice() bool

func (AdaptationExtension) LTWIsValid

func (ae AdaptationExtension) LTWIsValid() (bool, error)

func (AdaptationExtension) LTWOffset

func (ae AdaptationExtension) LTWOffset() (uint16, error)

func (AdaptationExtension) Length

func (ae AdaptationExtension) Length() int

func (AdaptationExtension) PiecewiseRate

func (ae AdaptationExtension) PiecewiseRate() (uint32, error)

func (AdaptationExtension) SpliceType

func (ae AdaptationExtension) SpliceType() (byte, error)

type AdaptationField

type AdaptationField []byte

func (AdaptationField) AdaptationExtension

func (a AdaptationField) AdaptationExtension() (AdaptationExtension, error)

func (AdaptationField) HasAdaptationExtension

func (a AdaptationField) HasAdaptationExtension() bool

func (AdaptationField) HasElementaryStreamPriorty

func (a AdaptationField) HasElementaryStreamPriorty() bool

func (AdaptationField) HasOPCR

func (a AdaptationField) HasOPCR() bool

func (AdaptationField) HasPCR

func (a AdaptationField) HasPCR() bool

func (AdaptationField) HasSplicingPoint

func (a AdaptationField) HasSplicingPoint() bool

func (AdaptationField) HasTransportPrivateData

func (a AdaptationField) HasTransportPrivateData() bool

func (AdaptationField) IsDiscontinuous

func (a AdaptationField) IsDiscontinuous() bool

func (AdaptationField) IsRandomAccess

func (a AdaptationField) IsRandomAccess() bool

func (AdaptationField) Length

func (a AdaptationField) Length() int

func (AdaptationField) OPCR

func (a AdaptationField) OPCR() (TimeStamp, error)

func (AdaptationField) PCR

func (a AdaptationField) PCR() (TimeStamp, error)

func (AdaptationField) SetIsDiscontinuous

func (a AdaptationField) SetIsDiscontinuous()

func (AdaptationField) SetIsRandomAccess

func (a AdaptationField) SetIsRandomAccess()

func (AdaptationField) SpliceCountdown

func (a AdaptationField) SpliceCountdown() (int, error)

func (AdaptationField) TransportPrivateData

func (a AdaptationField) TransportPrivateData() ([]byte, error)

func (AdaptationField) TransportPrivateDataLength

func (a AdaptationField) TransportPrivateDataLength() (int, error)

type Demux

type Demux interface {
	Select(pid uint16, handler PacketHandler)
	Clear(pid uint16)
	Run()
}

func NewDemux

func NewDemux(reader PacketReader) Demux

type PESExtension

type PESExtension []byte

func (PESExtension) Extension

func (pe PESExtension) Extension() (PESSecondExtension, error)

func (PESExtension) HasExtension

func (pe PESExtension) HasExtension() bool

func (PESExtension) HasPStdBufferInfo

func (pe PESExtension) HasPStdBufferInfo() bool

func (PESExtension) HasPackHeaderField

func (pe PESExtension) HasPackHeaderField() bool

func (PESExtension) HasPrivateData

func (pe PESExtension) HasPrivateData() bool

func (PESExtension) HasProgramPacketSequenceCounter

func (pe PESExtension) HasProgramPacketSequenceCounter() bool

func (PESExtension) Length

func (pe PESExtension) Length() int

func (PESExtension) PStdBufferInfo

func (pe PESExtension) PStdBufferInfo() (PStdBufferInfo, error)

func (PESExtension) PackHeaderField

func (pe PESExtension) PackHeaderField() (byte, error)

func (PESExtension) PrivateData

func (pe PESExtension) PrivateData() ([]byte, error)

func (PESExtension) ProgramPacketSequenceCounter

func (pe PESExtension) ProgramPacketSequenceCounter() (ProgramPacketSequenceCounter, error)

type PESHeader

type PESHeader []byte

func FillPESHeader

func FillPESHeader(payload []byte) PESHeader

func (PESHeader) AdditionalCopyInfo

func (p PESHeader) AdditionalCopyInfo() (uint8, error)

func (PESHeader) AdditionalLength

func (p PESHeader) AdditionalLength() uint8

func (PESHeader) CRC

func (p PESHeader) CRC() ([]byte, error)

func (PESHeader) DTS

func (p PESHeader) DTS() (TimeStamp, error)

func (PESHeader) ESCR

func (p PESHeader) ESCR() (TimeStamp, error)

func (PESHeader) ESRate

func (p PESHeader) ESRate() (uint16, error)

func (PESHeader) Extension

func (p PESHeader) Extension() (PESExtension, error)

func (PESHeader) HasAdditionalCopyInfo

func (p PESHeader) HasAdditionalCopyInfo() bool

func (PESHeader) HasCRC

func (p PESHeader) HasCRC() bool

func (PESHeader) HasCopyright

func (p PESHeader) HasCopyright() bool

func (PESHeader) HasDSMTrickMode

func (p PESHeader) HasDSMTrickMode() bool

func (PESHeader) HasDTS

func (p PESHeader) HasDTS() bool

func (PESHeader) HasESCR

func (p PESHeader) HasESCR() bool

func (PESHeader) HasESRate

func (p PESHeader) HasESRate() bool

func (PESHeader) HasExtension

func (p PESHeader) HasExtension() bool

func (PESHeader) HasPTS

func (p PESHeader) HasPTS() bool

func (PESHeader) HasPriority

func (p PESHeader) HasPriority() bool

func (PESHeader) IsAligned

func (p PESHeader) IsAligned() bool

func (PESHeader) IsOriginal

func (p PESHeader) IsOriginal() bool

func (PESHeader) Length

func (p PESHeader) Length() uint16

func (PESHeader) PTS

func (p PESHeader) PTS() (TimeStamp, error)

func (PESHeader) ScramblingControl

func (p PESHeader) ScramblingControl() byte

func (PESHeader) SetHasDTS

func (p PESHeader) SetHasDTS(hasDts bool)

func (PESHeader) SetHasPTS

func (p PESHeader) SetHasPTS()

func (PESHeader) SetPTS

func (p PESHeader) SetPTS(timestamp TimeStamp)

func (PESHeader) StreamID

func (p PESHeader) StreamID() uint8

type PESSecondExtension

type PESSecondExtension uint16

type PStdBufferInfo

type PStdBufferInfo uint16

type Packet

type Packet []byte

func NewPacket

func NewPacket() Packet

func (Packet) AdaptationField

func (p Packet) AdaptationField() (AdaptationField, error)

func (Packet) ContinuityCounter

func (p Packet) ContinuityCounter() uint8

func (Packet) HasAdaptationField

func (p Packet) HasAdaptationField() bool

func (Packet) HasPESHeader

func (p Packet) HasPESHeader() bool

func (Packet) HasPayload

func (p Packet) HasPayload() bool

func (Packet) IsNull

func (p Packet) IsNull() bool

func (Packet) PESHeader

func (p Packet) PESHeader() (PESHeader, error)

func (Packet) PID

func (p Packet) PID() uint16

func (Packet) PUSI

func (p Packet) PUSI() bool

func (Packet) Payload

func (p Packet) Payload() ([]byte, error)

func (Packet) Scrambled

func (p Packet) Scrambled() bool

func (Packet) ScrambledEven

func (p Packet) ScrambledEven() bool

func (Packet) ScrambledOdd

func (p Packet) ScrambledOdd() bool

func (Packet) SetContinuityCounter

func (p Packet) SetContinuityCounter(cc uint8)

func (Packet) SetHasAdaptationField

func (p Packet) SetHasAdaptationField()

func (Packet) SetHasPayload

func (p Packet) SetHasPayload()

func (Packet) SetPID

func (p Packet) SetPID(pid uint16)

func (Packet) SetPUSI

func (p Packet) SetPUSI(pusi bool)

func (Packet) SetPayload

func (p Packet) SetPayload(payload []byte) int

func (Packet) SyncByte

func (p Packet) SyncByte() byte

func (Packet) TEI

func (p Packet) TEI() bool

func (Packet) TSC

func (p Packet) TSC() byte

func (Packet) TransportPriority

func (p Packet) TransportPriority() bool

type PacketHandler

type PacketHandler interface {
	Handle(pkt Packet)
}

type PacketHandlerFunc

type PacketHandlerFunc func(pkt Packet)

func (PacketHandlerFunc) Handle

func (phf PacketHandlerFunc) Handle(pkt Packet)

type PacketReader

type PacketReader interface {
	Read() (Packet, error)
}

func NewReader

func NewReader(r io.Reader) PacketReader

type ProgramPacketSequenceCounter

type ProgramPacketSequenceCounter uint16

type Segment

type Segment struct {
	Duration time.Duration
	Buffer   []byte
}

type TimeStamp

type TimeStamp interface {
	Ticks() uint64
	Increment(ticks uint64)
	Duration() time.Duration
	Delta(endTs TimeStamp) TimeStamp
}

func CalculatePCR

func CalculatePCR(b []byte) TimeStamp

func CalculatePTS

func CalculatePTS(b []byte) TimeStamp

func NewPCR

func NewPCR() TimeStamp

func NewPTS

func NewPTS() TimeStamp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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