sfu

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SfuSignalType_Join    = "join"
	SfuSignalType_Offer   = "offer"
	SfuSignalType_Answer  = "answer"
	SfuSignalType_Trickle = "trickle"
)

Variables

This section is empty.

Functions

func GetICEServerConfigs

func GetICEServerConfigs() []sfu.ICEServerConfig

func Signal

func Signal(sfuSignal *SfuSignal, targetPeerId string) (interface{}, error)

* 调用注册发送信号函数发送信号

Types

type PoolEvent

type PoolEvent struct {
	Name   string
	Source *SfuPeer
	Data   interface{}
}

type SfuPeer

type SfuPeer struct {
	*sfu.Peer
	*p2p.NetPeer
	// contains filtered or unexported fields
}

* 代表两个peer之间的webrtc连接

func NewSfuPeer

func NewSfuPeer(netPeer *p2p.NetPeer, iceServer []webrtc.ICEServer) *SfuPeer

func (*SfuPeer) Connected

func (this *SfuPeer) Connected() bool

func (*SfuPeer) EmitEvent

func (this *SfuPeer) EmitEvent(name string, event *PoolEvent) (interface{}, error)

func (*SfuPeer) GetPeer

func (this *SfuPeer) GetPeer() *p2p.NetPeer

func (*SfuPeer) Id

func (this *SfuPeer) Id() string

func (*SfuPeer) RegistEvent

func (this *SfuPeer) RegistEvent(name string, fn func(event *PoolEvent) (interface{}, error)) bool

func (*SfuPeer) SetPeer

func (this *SfuPeer) SetPeer(connectPeerId string, connectSessionId string, peerType string)

func (*SfuPeer) UnregistEvent

func (this *SfuPeer) UnregistEvent(name string) bool

type SfuPeerPool

type SfuPeerPool struct {
	*sfu.SFU
	// contains filtered or unexported fields
}

* 代表SFU服务器,包含多个peer与peer之间的webrtc连接 每个SFU服务器有多个session,每个session表示一个房间,内含多个peer,在一个session内的peer互相订阅

func GetSfuPeerPool

func GetSfuPeerPool() *SfuPeerPool

func NewSfuPeerPool

func NewSfuPeerPool() *SfuPeerPool

func (*SfuPeerPool) EmitEvent

func (this *SfuPeerPool) EmitEvent(name string, event *PoolEvent) (interface{}, error)

* 触发sfu的全局事件

func (*SfuPeerPool) GetPeer

func (this *SfuPeerPool) GetPeer(netPeer *p2p.NetPeer) *SfuPeer

func (*SfuPeerPool) Receive

func (this *SfuPeerPool) Receive(netPeer *p2p.NetPeer, payload map[string]interface{}) (interface{}, error)

* 收到客户端发来的消息进行分派处理

func (*SfuPeerPool) RegistEvent

func (this *SfuPeerPool) RegistEvent(name string, fn func(event *PoolEvent) (interface{}, error))

* 注册sfu的全局事件

func (*SfuPeerPool) Remove

func (this *SfuPeerPool) Remove(netPeer *p2p.NetPeer) error

func (*SfuPeerPool) UnregistEvent

func (this *SfuPeerPool) UnregistEvent(name string) bool

type SfuSignal

type SfuSignal struct {
	//四种类型
	SignalType string `json:"type,omitempty"`
	// 房间号
	Sid string `json:"sid,omitempty"`
	// 房间的原始节点
	PrimaryPeerId string `json:"sid,omitempty"`
	// join,offer,answer
	Sdp *webrtc.SessionDescription `json:"sdp,omitempty"`
	// candidate(trickle) publisher:0 or subscriber:1
	Target int `json:"target,omitempty"`
	// candidate(trickle)
	Candidate *webrtc.ICECandidateInit `json:"candidate,omitempty"`
}

func Transform

func Transform(payload map[string]interface{}) *SfuSignal

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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