Documentation ¶
Overview ¶
Package bridge provides utilities to create, keep track of and delete WebRTC calls
Index ¶
- Constants
- Variables
- type Bridge
- func (b *Bridge) AddRoom(roomHash string) (*Room, error)
- func (b *Bridge) Connect(username, roomHash string, w http.ResponseWriter, r *http.Request) error
- func (b *Bridge) GetOrCreateRoom(roomHash string) (*Room, error)
- func (b *Bridge) GetRoom(roomHash string) (*Room, error)
- func (b *Bridge) RemoveRoom(roomHash string) error
- type Event
- type Message
- type PublicUser
- type Room
- func (r *Room) Broadcast(data []byte, user *User)
- func (r *Room) BroadcastEvent(event Event, user *User) error
- func (r *Room) BroadcastEventJoin(user *User) error
- func (r *Room) BroadcastEventLeave(user *User) error
- func (r *Room) BroadcastEventMute(user *User) error
- func (r *Room) BroadcastEventUnmute(user *User) error
- func (r *Room) GetParticipants(u *User) []*User
- func (r *Room) GetUsersList() []*User
- func (r *Room) Join(user *User)
- func (r *Room) Leave(user *User)
- func (r *Room) Run()
- type User
- func (u *User) AddListeners() error
- func (u *User) AddTrack(ssrc uint32) error
- func (u *User) GetOutTracks() map[uint32]*webrtc.Track
- func (u *User) Offer() (webrtc.SessionDescription, error)
- func (u *User) ReadRTP() (*rtp.Packet, error)
- func (u *User) SendEventUser() error
- func (u *User) SendOffer() error
- func (u *User) ToPublic() *PublicUser
- func (u *User) Watch()
- func (u *User) WriteRTP(pkt *rtp.Packet) error
- type UserInfo
Constants ¶
const ( // TypeOffer describes the event type 'offer' TypeOffer string = "offer" // TypeAnswer describes the event type 'answer' TypeAnswer string = "answer" // TypeCandidate describes the event type 'candidate' TypeCandidate string = "candidate" // TypeMute describes the event type 'mute' TypeMute string = "mute" // TypeUnmute describes the event type 'unmute' TypeUnmute string = "unmute" // TypeUser describes the event type 'user' TypeUser string = "user" // TypeUserJoin describes the event type 'user-join' TypeUserJoin string = "user-join" // TypeUserLeave describes the event type 'user-leave' TypeUserLeave string = "user-leave" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge keeps track of active rooms
func (*Bridge) AddRoom ¶
AddRoom adds a room to the pool of active rooms with the key 'roomHash'. If the room already exists ErrDuplicateRoom is returned
func (*Bridge) Connect ¶
Connect connects a user with 'username' to room and sets up the sognaling websocket
func (*Bridge) GetOrCreateRoom ¶
GetOrCreateRoom returns an existing room, or if no such room exists, creates a new one and returns it
func (*Bridge) GetRoom ¶
GetRoom returns room with 'roomHash' from the pool of active rooms. If the room doesn't exists ErrNoSuchRoom is returned
type Event ¶
type Event struct { Type string `json:"type"` Offer *webrtc.SessionDescription `json:"offer,omitempty"` Answer *webrtc.SessionDescription `json:"answer,omitempty"` Candidate *webrtc.ICECandidateInit `json:"candidate,omitempty"` User *PublicUser `json:"user,omitempty"` }
Event represents a WebRTC signaling message / event
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message carries a message with the additional info of the sender. A message will be delivered to everyone except the sender
type PublicUser ¶
PublicUser is the public representation of a user. It only includes necessary data
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room maintains a number of active connections and handles messages from and to clients
func (*Room) Broadcast ¶
Broadcast sends a message to everyone except sender
func (*Room) BroadcastEvent ¶
BroadcastEvent sends an event message to everyone except sender
func (*Room) BroadcastEventJoin ¶
BroadcastEventJoin creates a join event and broadcasts it
func (*Room) BroadcastEventLeave ¶
BroadcastEventLeave creates a leave event and broadcasts it
func (*Room) BroadcastEventMute ¶
BroadcastEventMute creates microphone mute event and broadcasts it
func (*Room) BroadcastEventUnmute ¶
BroadcastEventUnmute creates microphone unmute event and broadcasts it
func (*Room) GetParticipants ¶
GetParticipants returns all users except the provided user as a slice
func (*Room) GetUsersList ¶
GetUsersList returns the user map as a slice of users
type User ¶
type User struct { ID string // A unique ID of the user // contains filtered or unexported fields }
User keeps track of a websocket connection for signaling, a WebRTC peer connection and connects hub, room and user
func NewUser ¶
NewUser creates and returns a new user
func (*User) AddListeners ¶
AddListeners adds all neccesary WebRTC PC event handlers
func (*User) AddTrack ¶
AddTrack adds track to peer connection
func (*User) GetOutTracks ¶
GetOutTracks return outgoing tracks
func (*User) SendEventUser ¶
SendEventUser sends user to client to identify himself
func (*User) ToPublic ¶
func (u *User) ToPublic() *PublicUser
ToPublic returns the public representation of a user