Documentation
¶
Index ¶
- Variables
- type Direction
- type HangUp
- type JSON
- type Message
- func NewHangUp(roomID identifiers.RoomID, payload HangUp) Message
- func NewPing(roomID identifiers.RoomID) Message
- func NewPubTrack(roomID identifiers.RoomID, payload PubTrack) Message
- func NewReady(roomID identifiers.RoomID, payload Ready) Message
- func NewRoomJoin(roomID identifiers.RoomID, payload RoomJoin) Message
- func NewRoomLeave(roomID identifiers.RoomID, clientID identifiers.ClientID) Message
- func NewSignal(roomID identifiers.RoomID, payload UserSignal) Message
- func NewSubTrack(roomID identifiers.RoomID, payload SubTrack) Message
- func NewUsers(roomID identifiers.RoomID, payload Users) Message
- type Payload
- type Ping
- type Pong
- type PubTrack
- type Ready
- type RoomJoin
- type Signal
- type SignalType
- type SubTrack
- type TransceiverInit
- type TransceiverRequest
- type Type
- type UserSignal
- type Users
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownMessageType = errors.New("unknown message type")
Functions ¶
This section is empty.
Types ¶
type Direction ¶
type Direction string
func (Direction) RTPTransceiverDirection ¶
func (d Direction) RTPTransceiverDirection() (webrtc.RTPTransceiverDirection, bool)
type HangUp ¶
type HangUp struct {
PeerID identifiers.ClientID `json:"peerId"`
}
type JSON ¶
type JSON struct {
Type Type `json:"type"`
// Room this message is related to
Room identifiers.RoomID `json:"room"`
// Payload content
Payload json.RawMessage `json:"payload"`
}
type Message ¶
type Message struct {
// Types 0-10 are reserved for base functionality, others can be used for
// custom implementations.
Type Type
// Room this message is related to
Room identifiers.RoomID
// Payload content
Payload Payload
}
func NewPing ¶
func NewPing(roomID identifiers.RoomID) Message
func NewPubTrack ¶
func NewPubTrack(roomID identifiers.RoomID, payload PubTrack) Message
func NewRoomJoin ¶
func NewRoomJoin(roomID identifiers.RoomID, payload RoomJoin) Message
func NewRoomLeave ¶
func NewRoomLeave(roomID identifiers.RoomID, clientID identifiers.ClientID) Message
func NewSignal ¶
func NewSignal(roomID identifiers.RoomID, payload UserSignal) Message
func NewSubTrack ¶
func NewSubTrack(roomID identifiers.RoomID, payload SubTrack) Message
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type Payload ¶
type Payload struct {
HangUp *HangUp
// Ready is sent from the client to the server.
Ready *Ready
Signal *UserSignal
Ping *Ping
Pong *Pong
PubTrack *PubTrack
SubTrack *SubTrack
// RoomJoin is only sent to other server-side clients in the same room.
RoomJoin *RoomJoin
// RoomLeave is only sent to other server-side clients in the same room.
RoomLeave identifiers.ClientID
// Users is sent as a response to Ready.
// TODO use PubTrack instead.
Users *Users
}
Payload should only have a single field set, depending on the type of the message.
type PubTrack ¶
type PubTrack struct {
// TrackID is the unique track identifier.
TrackID identifiers.TrackID `json:"trackId"`
// PubClientID is the ID of the remote client that published the track.
PubClientID identifiers.ClientID `json:"pubClientId"`
// PeerID is the original track source.
PeerID identifiers.PeerID `json:"peerId"`
// Kind defines whether this is an audio or video track.
Kind transport.TrackKind `json:"kind"`
// Type can contain only Add or Remove.
Type transport.TrackEventType `json:"type"`
}
PubTrack will be sent to the clients whenever a track is published or unpublished.
Note about PubClientID, PeerID and SourceID: these values will be the same for Mesh, but different for SFU.
In the case of a single-node SFU:
- PubClientID and PeerID will be the same and define the original track source.
In the case of multi-node SFU:
- PubClientID will be ID of the transport (WebRTC or Server) that published the track to current node.
- PeerID will be the ID of the original track source (most likely a WebRTC transport)
type RoomJoin ¶
type RoomJoin struct {
ClientID identifiers.ClientID `json:"peerId"`
Metadata string `json:"metadata"`
}
type Signal ¶
type Signal struct {
Candidate *webrtc.ICECandidateInit `json:"candidate,omitempty"`
Renegotiate bool `json:"renegotiate,omitempty"`
Type SignalType `json:"type"`
SDP string `json:"sdp,omitempty"`
TransceiverRequest *TransceiverRequest `json:"transceiverRequest,omitempty"`
}
type SignalType ¶
type SignalType string
const ( SignalTypeCandidate SignalType = "candidate" SignalTypeTransceiverRequest SignalType = "transceiverRequest" SignalTypeRenegotiate SignalType = "renegotiate" SignalTypeOffer SignalType = "offer" SignalTypePranswer SignalType = "pranswer" SignalTypeAnswer SignalType = "answer" SignalTypeRollback SignalType = "rollback" )
func NewSignalTypeFromSDPType ¶
func NewSignalTypeFromSDPType(sdpType webrtc.SDPType) (SignalType, bool)
type SubTrack ¶
type SubTrack struct {
TrackID identifiers.TrackID `json:"trackId"`
PubClientID identifiers.ClientID `json:"pubClientId"`
// Type can contain only Sub or Unsub.
Type transport.TrackEventType `json:"type"`
}
type TransceiverInit ¶
type TransceiverInit struct {
Direction Direction `json:"direction,omitempty"`
}
type TransceiverRequest ¶
type TransceiverRequest struct {
Kind transport.TrackKind `json:"kind"`
Init TransceiverInit `json:"init"`
}
type UserSignal ¶
type UserSignal struct {
PeerID identifiers.ClientID `json:"peerId"`
Signal Signal `json:"signal"`
}
type Users ¶
type Users struct {
Initiator identifiers.ClientID `json:"initiator"`
PeerIDs []identifiers.ClientID `json:"peerIds"`
Nicknames map[identifiers.ClientID]string `json:"nicknames"`
}
The only thing that's not easy to handle this way are nicknames.
Click to show internal directories.
Click to hide internal directories.