Documentation
¶
Overview ¶
Package stream serves one game window to a browser over WebRTC (rtc.go): video and an Opus audio track on one connection, and input sent back as JSON (data channel, or POST when it is not open) and replayed through XTEST (xdotool when the display cannot be reached).
Index ¶
Constants ¶
const ( EncAuto = "auto" EncVAAPI = "vaapi" EncNVENC = "nvenc" EncX264 = "x264" )
H.264 encoders, in order of preference when RTCConfig.Encoder is "auto": the GPU's when it works (VAAPI on Intel / AMD, NVENC on NVIDIA), otherwise libx264 on the CPU.
Variables ¶
This section is empty.
Functions ¶
func ConfigureRTC ¶
ConfigureRTC sets the WebRTC network settings; call once before serving.
func ParseEncoder ¶
ParseEncoder checks an -encoder value.
Types ¶
type Game ¶
Game is the stream source.
type Input ¶
type Input struct {
T string `json:"t"` // "click", "move", "key", "keydown", "keyup" or "text"
X, Y int
B int `json:"b"`
NoMove int `json:"nomove"`
K string `json:"k"`
S string `json:"s"` // text for "text"
}
Input is one browser event.
type RTCConfig ¶
type RTCConfig struct {
ICEServers []webrtc.ICEServer // STUN / TURN for viewers behind NAT
PublicIPs []string // announce these instead of the local addresses (1:1 NAT, port forward)
Port int // single UDP and TCP port for all media (0 = random UDP ports, no TCP)
Bitrate int // video kbit/s ceiling (default 3000); each viewer's connection may lower it (abr.go)
Encoder string // H.264 encoder: auto (GPU when it works) / vaapi / nvenc / x264 (encoder.go)
}
RTCConfig is how peers reach this server. The zero value works on a LAN.