Documentation
¶
Overview ¶
Package call is the media server of calls in chats: everybody on a call sends their microphone, and their camera when it is on, to the server once, and the server forwards each of those to everybody else on the call without mixing it (a selective forwarding unit). A phone sends its microphone once and its camera in two sizes however many people are on the call; each person is sent the whole picture of whoever they feature and the small one of the rest (video.go), and is told who is speaking (speaker.go).
One port of each kind carries every call: UDP, and TCP for networks that let no UDP through. The server's public address is what it tells the devices to send to. The server is an ICE-lite agent: it is reachable at that address, so a device needs to tell it nothing about its own; the server answers whatever reaches it.
Signaling is the caller's: Join answers a device's offer, and every later change (somebody's stream to add or take away) is an offer from the server, handed to the signal function given at Join, which the device answers with Answer. Only the server offers after the first exchange, so the two sides never offer at once.
Index ¶
- Variables
- type AudioRecorder
- type RecordedVoice
- type Recorder
- type Server
- func (self *Server) Answer(callId, userId, answerSDP string) error
- func (self *Server) Close() error
- func (self *Server) End(callId string)
- func (self *Server) Feature(callId, userId, featuredUserId string) error
- func (self *Server) IsOn(callId, userId string) bool
- func (self *Server) Join(callId, userId, offerSDP string, shouldTellSpeaker bool, signal func(Signal)) (string, error)
- func (self *Server) Leave(callId, userId string)
- func (self *Server) SetAudioRecorder(recorder AudioRecorder)
- func (self *Server) SetDeviceLost(deviceLost func(callId, userId string))
- func (self *Server) SpeakingUserID(callId string) string
- type Settings
- type Signal
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotOnCall is a device answering for a call it has not joined. ErrNotOnCall = errors.New("call: not on the call") // ErrClosed is the media server stopped. ErrClosed = errors.New("call: the media server is stopped") )
Functions ¶
This section is empty.
Types ¶
type AudioRecorder ¶
type AudioRecorder func(callId, userId string, packet []byte, codec webrtc.RTPCodecParameters)
AudioRecorder is told each packet of each person's microphone; it keeps those it has been asked to. The packet is the server's to reuse once the call returns.
type RecordedVoice ¶
RecordedVoice is one stretch of one person's microphone on a call.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder keeps the microphone of everybody on a call being transcribed, each in files of their own: the server hears each person apart, so whose words are whose is known without guessing. A file holds one stretch of one person's microphone; a person who leaves and joins again has a file for each time.
A stretch is cut into files of at most recordingPieceDuration, each short enough to be transcribed at once.
The files are kept under the directory given, on this server's disk, until the call's recording is made from them: a server that stops before then finds them again when it starts (Finish reads the directory, not what this process remembers).
func NewRecorder ¶
func (*Recorder) Finish ¶
func (self *Recorder) Finish(callId string) []RecordedVoice
Finish ends a call's recordings and returns what is kept of it on disk, oldest first, also what a process that stopped kept; the files are the caller's to remove with Discard once read.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the media server.
func (*Server) Feature ¶ added in v0.217.0
Feature sets whose camera the person's device is sent whole: the person chosen, or whoever is speaking when featuredUserId is empty. It is the device's own, and goes when it leaves.
func (*Server) Join ¶
func (self *Server) Join(callId, userId, offerSDP string, shouldTellSpeaker bool, signal func(Signal)) (string, error)
Join puts a device on a call with its offer, and returns the server's answer. A device already on it for the person is replaced: the person moved to another device, or this one connected again. shouldTellSpeaker says the device is to be told who is speaking; a device that does not read such signals is not sent them.
func (*Server) SetAudioRecorder ¶
func (self *Server) SetAudioRecorder(recorder AudioRecorder)
SetAudioRecorder sets what is told each microphone packet.
func (*Server) SetDeviceLost ¶
SetDeviceLost sets what is told when a device's connection fails, after it has been taken off the call: the person is no longer on it, though nothing said so. A device the server takes off itself (it joined again, it left) is not lost.
func (*Server) SpeakingUserID ¶ added in v0.217.0
SpeakingUserID is who is speaking on a call, as far as the server can tell; empty when nobody has yet.
type Settings ¶
type Settings struct {
// PublicAddress is the address devices send to: the server's own, or the
// address of the gateway that forwards the ports to it.
PublicAddress string
UDPPort int
TCPPort int
}
Settings say where the media server listens and what address it gives.
type Signal ¶
Signal is something the server tells one device on a call: an offer to answer, or who is speaking now (for a device that asked to be told). An offer can arrive before the device has read the server's answer to its join, so a device takes its join and then each offer one at a time, in that order.