streammuxer

package
v0.0.0-...-e0b6167 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OnPacketFunc

type OnPacketFunc func(info *StreamInfo, data *StreamData)

type OnStreamCloseFunc

type OnStreamCloseFunc func(stream *Stream)

type PullInfo

type PullInfo struct {
	Name          string            // 拉流者的名称
	OnPacket      OnPacketFunc      // 数据包回调
	OnStreamClose OnStreamCloseFunc // 拉取的流不可用了
}

type Puller

type Puller struct {
	PullInfo
	// contains filtered or unexported fields
}

func (*Puller) GetStreamId

func (p *Puller) GetStreamId() StreamId

type Stream

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

func (*Stream) AddPull

func (st *Stream) AddPull(puller *Puller) error

func (*Stream) GetInfo

func (st *Stream) GetInfo() *StreamInfo

func (*Stream) GetPullers

func (st *Stream) GetPullers() []*Puller

func (*Stream) RemotePull

func (st *Stream) RemotePull(puller *Puller)

func (*Stream) String

func (st *Stream) String() string

type StreamData

type StreamData struct {
	StreamId StreamId
	Data     any
	Addr     net.Addr

	Ntp time.Time
	// contains filtered or unexported fields
}

type StreamId

type StreamId string

func NewStreamIdRTCP

func NewStreamIdRTCP(ssrc uint32) StreamId

func NewStreamIdRTP

func NewStreamIdRTP(ssrc uint32, pt uint8) StreamId

func NewStreamIdRTPOrder

func NewStreamIdRTPOrder(ssrc uint32, pt uint8) StreamId

NewStreamIdRTPOrder 排好序的rtp包

type StreamInfo

type StreamInfo struct {
	Id          StreamId // 必选项
	Name        string
	OnNewPuller func(*Puller) // 新拉流者
	OnDelPuller func(*Puller) // 移除拉流者
}

type StreamMux

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

StreamMux 如果一个mux处理能力不够, 使用n个mux, 均匀分片id到n个mux中 (例如: id%5=[0,1,2,3,4])

func (*StreamMux) AddPull

func (s *StreamMux) AddPull(streamId StreamId, info PullInfo) (*Puller, error)

AddPull 添加拉流

func (*StreamMux) AddStream

func (s *StreamMux) AddStream(info StreamInfo) (*Stream, error)

AddStream 添加推流stream

func (*StreamMux) Close

func (s *StreamMux) Close()

func (*StreamMux) GetStream

func (s *StreamMux) GetStream(id StreamId) (stream *Stream, ok bool)

func (*StreamMux) RangeStream

func (s *StreamMux) RangeStream(f func(stream *Stream) bool)

func (*StreamMux) RemotePull

func (s *StreamMux) RemotePull(puller *Puller) error

func (*StreamMux) RemoteStream

func (s *StreamMux) RemoteStream(stream *Stream) error

func (*StreamMux) Write

func (s *StreamMux) Write(data *StreamData) error

Write 发送数据

type StreamMuxer

type StreamMuxer interface {
	// AddStream 添加推流stream
	AddStream(info StreamInfo) (*Stream, error)
	RemoteStream(*Stream) error
	GetStream(streamId StreamId) (*Stream, bool)
	RangeStream(fnc func(*Stream) bool)

	// AddPull 添加拉流
	AddPull(streamId StreamId, info PullInfo) (*Puller, error)
	RemotePull(puller *Puller) error

	// Write 发送数据
	Write(data *StreamData) error
	Close()
}

func NewStreamMuxer

func NewStreamMuxer() StreamMuxer

NewStreamMuxer 流路由, 所有的流都汇聚到这里, 然后从拉取

Jump to

Keyboard shortcuts

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