Documentation ¶
Index ¶
- Constants
- func Signal(webrtcSignal *WebrtcSignal, targetPeerId string) (interface{}, error)
- type Router
- type SimplePeer
- func (this *SimplePeer) AddTrack(track webrtc.TrackLocal) (*webrtc.RTPSender, error)
- func (this *SimplePeer) BufferedAmount() uint64
- func (this *SimplePeer) Connected() bool
- func (this *SimplePeer) Create(opts *webrtc2.WebrtcOption) error
- func (this *SimplePeer) CreateTrack(c *webrtc.RTPCodecCapability, trackId string, streamId string) (webrtc.TrackLocal, error)
- func (this *SimplePeer) Destroy(err error)
- func (this *SimplePeer) EmitEvent(name string, event *webrtc2.PeerEvent) (interface{}, error)
- func (this *SimplePeer) GetReceiver(trackId string) (*webrtc.TrackRemote, *webrtc.RTPReceiver)
- func (this *SimplePeer) GetSender(trackId string) *webrtc.RTPSender
- func (this *SimplePeer) GetSenders(streamId string) []*webrtc.RTPSender
- func (this *SimplePeer) GetSendersByKind(kind webrtc.RTPCodecType) []*webrtc.RTPSender
- func (this *SimplePeer) GetTrackRemotes(streamId string) []*webrtc.TrackRemote
- func (this *SimplePeer) GetTrackRemotesByKind(kind webrtc.RTPCodecType) []*webrtc.TrackRemote
- func (this *SimplePeer) ReadRTP(track *webrtc.TrackRemote) (*rtp.Packet, error)
- func (this *SimplePeer) RegistEvent(name string, fn func(event *webrtc2.PeerEvent) (interface{}, error))
- func (this *SimplePeer) RemoveStream(streamId string) error
- func (this *SimplePeer) RemoveTrack(trackId string) error
- func (this *SimplePeer) ReplaceTrack(oldTrack webrtc.TrackLocal, newTrack webrtc.TrackLocal) error
- func (this *SimplePeer) Send(data []byte) error
- func (this *SimplePeer) SendText(message string) error
- func (this *SimplePeer) Signal(webrtcSignal *WebrtcSignal) error
- func (this *SimplePeer) StopReceiver(trackId string) error
- func (this *SimplePeer) StopStream(streamId string) error
- func (this *SimplePeer) UnregistEvent(name string) bool
- func (this *SimplePeer) Write(sender *webrtc.RTPSender, buf []byte) error
- func (this *SimplePeer) WriteRTP(sender *webrtc.RTPSender, packet *rtp.Packet) error
- type WebrtcSignal
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 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) 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) 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
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
Click to show internal directories.
Click to hide internal directories.