packets

package
v0.0.0-...-a783914 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Packege pubsub implements publisher-subscribers model used in multi-channel streaming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buf

type Buf struct {
	Head, Tail BufPos

	Size  int
	Count int
	// contains filtered or unexported fields
}

func NewBuf

func NewBuf() *Buf

func (*Buf) Get

func (self *Buf) Get(pos BufPos) Packet

func (*Buf) IsValidPos

func (self *Buf) IsValidPos(pos BufPos) bool

func (*Buf) Pop

func (self *Buf) Pop() Packet

func (*Buf) Push

func (self *Buf) Push(pkt Packet)

type BufPos

type BufPos int

func (BufPos) GE

func (self BufPos) GE(pos BufPos) bool

func (BufPos) GT

func (self BufPos) GT(pos BufPos) bool

func (BufPos) LT

func (self BufPos) LT(pos BufPos) bool

type Packet

type Packet struct {
	Packet          *rtp.Packet
	IsAudio         bool          // packet is audio
	IsVideo         bool          // packet is video
	IsKeyFrame      bool          // video packet is key frame
	Idx             int8          // stream index in container format
	Codec           string        // codec name
	CompositionTime time.Duration // packet presentation time minus decode time for H264 B-Frame
	Time            time.Duration // packet decode time
	Data            []byte        // packet data
}

Packet represents an RTP Packet

type Queue

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

One publisher and multiple subscribers thread-safe packet buffer queue.

func NewQueue

func NewQueue() *Queue

func (*Queue) Close

func (self *Queue) Close() (err error)

After Close() called, all QueueCursor's ReadPacket will return io.EOF.

func (*Queue) DelayedGopCount

func (self *Queue) DelayedGopCount(n int) *QueueCursor

Create cursor position at specific delayed GOP count in buffered packets.

func (*Queue) DelayedTime

func (self *Queue) DelayedTime(dur time.Duration) *QueueCursor

Create cursor position at specific time in buffered packets.

func (*Queue) GetSize

func (self *Queue) GetSize() int

func (*Queue) Latest

func (self *Queue) Latest() *QueueCursor

Create cursor position at latest packet.

func (*Queue) Oldest

func (self *Queue) Oldest() *QueueCursor

Create cursor position at oldest buffered packet.

func (*Queue) SetMaxGopCount

func (self *Queue) SetMaxGopCount(n int)

func (*Queue) WriteHeader

func (self *Queue) WriteHeader(streams []Stream) error

func (*Queue) WritePacket

func (self *Queue) WritePacket(pkt Packet) (err error)

Put packet into buffer, old packets will be discared.

func (*Queue) WriteTrailer

func (self *Queue) WriteTrailer() error

type QueueCursor

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

func (*QueueCursor) ReadPacket

func (self *QueueCursor) ReadPacket() (pkt Packet, err error)

ReadPacket will not consume packets in Queue, it's just a cursor.

func (*QueueCursor) Streams

func (self *QueueCursor) Streams() (streams []Stream, err error)

type Stream

type Stream struct {
	// The name of the stream.
	Name string

	// The URL of the stream.
	URL string

	// Is the stream a video stream.
	IsVideo bool

	// Is the stream a audio stream.
	IsAudio bool

	// The width of the stream.
	Width int

	// The height of the stream.
	Height int

	// Num is the numerator of the framerate.
	Num int

	// Denum is the denominator of the framerate.
	Denum int

	// FPS is the framerate of the stream.
	FPS float64

	// For H264, this is the sps.
	SPS []byte

	// For H264, this is the pps.
	PPS []byte

	// For H265, this is the vps.
	VPS []byte

	// IsBackChannel is true if this stream is a back channel.
	IsBackChannel bool
}

type Timeline

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

func (*Timeline) Pop

func (self *Timeline) Pop(dur time.Duration) (tm time.Duration)

func (*Timeline) Push

func (self *Timeline) Push(tm time.Duration, dur time.Duration)

Jump to

Keyboard shortcuts

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