simplepeer

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebrtcSignalType_TransceiverRequest = "transceiverRequest"
	WebrtcSignalType_Renegotiate        = "renegotiate"
	WebrtcSignalType_Offer              = "offer"
	WebrtcSignalType_Answer             = "answer"
	WebrtcSignalType_Candidate          = "candidate"
	WebrtcSignalType_Join               = "join"
)
View Source
const MessageSize = 15

Variables

This section is empty.

Functions

func Signal

func Signal(webrtcSignal *WebrtcSignal, targetPeerId string) (interface{}, error)

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

Types

type Router

type Router struct {
	Id       string `json:"id,omitempty"`
	Typ      string `json:"type,omitempty"`
	Action   string `json:"action,omitempty"`
	RoomId   string `json:"roomId,omitempty"`
	Identity string `json:"identity,omitempty"`
}

type SimplePeer

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

func (*SimplePeer) AddTrack

func (this *SimplePeer) AddTrack(track webrtc.TrackLocal) (*webrtc.RTPSender, error)

* 将本地轨道加入,并存放进流中

func (*SimplePeer) BufferedAmount

func (this *SimplePeer) BufferedAmount() uint64

func (*SimplePeer) Connected

func (this *SimplePeer) Connected() bool

HACK: it's possible channel.readyState is "closing" before peer.destroy() fires https://bugs.chromium.org/p/chromium/issues/detail?id=882743

func (*SimplePeer) Create

func (this *SimplePeer) Create(opts *webrtc2.WebrtcOption) error

func (*SimplePeer) CreateTrack

func (this *SimplePeer) CreateTrack(c *webrtc.RTPCodecCapability, trackId string, streamId string) (webrtc.TrackLocal, error)

*

  • 主动创建本地track能够发送和接收媒体信息

func (*SimplePeer) Destroy

func (this *SimplePeer) Destroy(err error)

* 关闭peer

func (*SimplePeer) EmitEvent

func (this *SimplePeer) EmitEvent(name string, event *webrtc2.PeerEvent) (interface{}, error)

* 事件发生,调用外部函数

func (*SimplePeer) GetReceiver

func (this *SimplePeer) GetReceiver(trackId string) (*webrtc.TrackRemote, *webrtc.RTPReceiver)

func (*SimplePeer) GetSender

func (this *SimplePeer) GetSender(trackId string) *webrtc.RTPSender

func (*SimplePeer) GetSenders

func (this *SimplePeer) GetSenders(streamId string) []*webrtc.RTPSender

func (*SimplePeer) GetSendersByKind

func (this *SimplePeer) GetSendersByKind(kind webrtc.RTPCodecType) []*webrtc.RTPSender

func (*SimplePeer) GetTrackRemotes

func (this *SimplePeer) GetTrackRemotes(streamId string) []*webrtc.TrackRemote

func (*SimplePeer) GetTrackRemotesByKind

func (this *SimplePeer) GetTrackRemotesByKind(kind webrtc.RTPCodecType) []*webrtc.TrackRemote

func (*SimplePeer) ReadRTP

func (this *SimplePeer) ReadRTP(track *webrtc.TrackRemote) (*rtp.Packet, error)

func (*SimplePeer) RegistEvent

func (this *SimplePeer) RegistEvent(name string, fn func(event *webrtc2.PeerEvent) (interface{}, error))

* 注册事件,发生时调用外部函数

func (*SimplePeer) RemoveStream

func (this *SimplePeer) RemoveStream(streamId string) error

func (*SimplePeer) RemoveTrack

func (this *SimplePeer) RemoveTrack(trackId string) error

func (*SimplePeer) ReplaceTrack

func (this *SimplePeer) ReplaceTrack(oldTrack webrtc.TrackLocal, newTrack webrtc.TrackLocal) error

func (*SimplePeer) Send

func (this *SimplePeer) Send(data []byte) error

* 把要发送的数据送入缓存

func (*SimplePeer) SendText

func (this *SimplePeer) SendText(message string) error

* 把要发送的数据送入缓存

func (*SimplePeer) Signal

func (this *SimplePeer) Signal(webrtcSignal *WebrtcSignal) error

* 把外部接收的信号设置成设置本节点的信号

func (*SimplePeer) StopReceiver

func (this *SimplePeer) StopReceiver(trackId string) error

func (*SimplePeer) StopStream

func (this *SimplePeer) StopStream(streamId string) error

func (*SimplePeer) UnregistEvent

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

func (*SimplePeer) Write

func (this *SimplePeer) Write(sender *webrtc.RTPSender, buf []byte) error

func (*SimplePeer) WriteRTP

func (this *SimplePeer) WriteRTP(sender *webrtc.RTPSender, packet *rtp.Packet) error

type WebrtcSignal

type WebrtcSignal struct {
	SignalType         string                     `json:"type,omitempty"`
	Renegotiate        bool                       `json:"renegotiate,omitempty"`
	TransceiverRequest map[string]interface{}     `json:"transceiverRequest,omitempty"`
	Candidate          *webrtc.ICECandidateInit   `json:"candidate,omitempty"`
	Sdp                *webrtc.SessionDescription `json:"sdp,omitempty"`
	Router             *Router                    `json:"router,omitempty"`
}

* 用于交换的signal消息,当type为join的时候,表示需要服务器反拨,发起offer 如果为offer,表示服务器为被叫方,如果router字段不为空,表示有sfu的要求

func Transform

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

Jump to

Keyboard shortcuts

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