mpegts

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 12 Imported by: 0

README

PTS/DTS/CTS

if DTS == 0 {
    // for I and P frames
	packet.Timestamp = PTS (presentation time)
} else {
    // for B frames
    packet.Timestamp = DTS (decode time)
    CTS = PTS-DTS (composition time)
}
  • MPEG-TS container uses PTS and optional DTS.
  • MP4 container uses DTS and CTS
  • RTP container uses PTS

MPEG-TS

FFmpeg:

  • PMTID=4096
  • H264: PESID=256, StreamType=27, StreamID=224
  • H265: PESID=256, StreamType=36, StreamID=224
  • AAC: PESID=257, StreamType=15, StreamID=192

Tapo:

  • PMTID=18
  • H264: PESID=68, StreamType=27, StreamID=224
  • AAC: PESID=69, StreamType=144, StreamID=192

Documentation

Index

Constants

View Source
const (
	PacketSize = 188
	SyncByte   = 0x47  // Uppercase G
	ClockRate  = 90000 // fixed clock rate for PTS/DTS of any type
)
View Source
const (
	StreamTypeMetadata    = 0    // Reserved
	StreamTypePrivate     = 0x06 // PCMU or PCMA or FLAC from FFmpeg
	StreamTypeAAC         = 0x0F
	StreamTypeH264        = 0x1B
	StreamTypeH265        = 0x24
	StreamTypePCMATapo    = 0x90
	StreamTypePrivateOPUS = 0xEB
)

https://en.wikipedia.org/wiki/Program-specific_information#Elementary_stream_types

Variables

This section is empty.

Functions

func CutOPUSPacket added in v1.8.5

func CutOPUSPacket(b []byte) (packet []byte, left []byte)

func StreamType added in v1.7.0

func StreamType(codec *core.Codec) uint8

func TimestampFromRTP added in v1.7.0

func TimestampFromRTP(rtp *rtp.Packet, codec *core.Codec)

func TimestampToRTP added in v1.7.0

func TimestampToRTP(rtp *rtp.Packet, codec *core.Codec)

func WriteTime added in v1.7.0

func WriteTime(b []byte, t uint32)

Types

type Consumer

type Consumer struct {
	core.SuperConsumer
	// contains filtered or unexported fields
}

func NewConsumer added in v1.7.0

func NewConsumer() *Consumer

func (*Consumer) AddTrack

func (c *Consumer) AddTrack(media *core.Media, codec *core.Codec, track *core.Receiver) error

func (*Consumer) Stop added in v1.3.0

func (c *Consumer) Stop() error

func (*Consumer) WriteTo added in v1.7.0

func (c *Consumer) WriteTo(wr io.Writer) (int64, error)

type Demuxer added in v1.7.0

type Demuxer struct {
	// contains filtered or unexported fields
}

func NewDemuxer added in v1.7.0

func NewDemuxer() *Demuxer

func (*Demuxer) ReadPacket added in v1.7.0

func (d *Demuxer) ReadPacket(rd io.Reader) (*rtp.Packet, error)

type Muxer added in v1.7.0

type Muxer struct {
	// contains filtered or unexported fields
}

func NewMuxer added in v1.7.0

func NewMuxer() *Muxer

func (*Muxer) AddTrack added in v1.7.0

func (m *Muxer) AddTrack(streamType byte) (pid uint16)

func (*Muxer) GetHeader added in v1.7.0

func (m *Muxer) GetHeader() []byte

func (*Muxer) GetPayload added in v1.7.0

func (m *Muxer) GetPayload(pid uint16, timestamp uint32, payload []byte) []byte

GetPayload - safe to run concurently with different pid

func (*Muxer) WriteTail added in v1.7.0

func (m *Muxer) WriteTail(wr *bits.Writer)

type PES

type PES struct {
	StreamID   byte   // from each PES header
	StreamType byte   // from PMT table
	Sequence   uint16 // manual
	Timestamp  uint32 // manual
	PTS        uint32 // from extra header, always 90000Hz
	DTS        uint32
	Payload    []byte // from PES body
	Size       int    // from PES header, can be 0
	// contains filtered or unexported fields
}

PES - Packetized Elementary Stream

func (*PES) AppendBuffer

func (p *PES) AppendBuffer(b []byte)

func (*PES) GetPacket

func (p *PES) GetPacket() (pkt *rtp.Packet)

func (*PES) SetBuffer

func (p *PES) SetBuffer(size uint16, b []byte)

type Producer added in v1.7.0

type Producer struct {
	core.SuperProducer
	// contains filtered or unexported fields
}

func Open added in v1.7.0

func Open(rd io.Reader) (*Producer, error)

func (*Producer) GetTrack added in v1.7.0

func (c *Producer) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver, error)

func (*Producer) Start added in v1.7.0

func (c *Producer) Start() error

func (*Producer) Stop added in v1.7.0

func (c *Producer) Stop() error

Jump to

Keyboard shortcuts

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