gamehost

package
v0.2.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gamehost plays PC games on a computer with Steam and streams them to Matinee: the game host (cmd/matinee-gamehost) runs beside Steam, in a container or on a gaming PC, lists the games installed there, launches one, captures its picture and sound, encodes them on that computer's GPU and sends them to Matinee in the direct stream's messages (internal/gamestream/direct.go), taking the player's buttons back as virtual gamepads. Matinee passes the stream on to the player as it does an emulated game's.

Index

Constants

View Source
const (
	KindVideo = 0x10
	KindAudio = 0x11
)
View Source
const BigPicture = 0

BigPicture, as an app id, plays Steam itself: its Big Picture mode full screen, where the player picks and quits games with the controller.

View Source
const DesktopPath = "/v1/desktop/"

DesktopPath is where the host serves the desktop.

Variables

View Source
var ErrBusy = errors.New("the game host is already playing a game")

ErrBusy means the host is already playing a game.

Functions

func SteamRoot

func SteamRoot(home string) (string, error)

SteamRoot finds Steam's own folder under home: where its steamapps/libraryfolders.vdf is.

Types

type Client

type Client struct {
	// URL is the host's address, such as http://steam:7174.
	URL   string
	Token string
	HTTP  *http.Client
}

Client is Matinee's side of a game host.

func (*Client) Desktop

func (c *Client) Desktop(path string) http.Handler

Desktop passes requests on to the host's desktop: path is the part after the desktop's own address. It adds the token, and drops the player's cookies and credentials so they never reach the host.

func (*Client) Games

func (c *Client) Games(ctx context.Context) ([]Game, error)

Games lists the games installed on the host.

func (*Client) Play

func (c *Client) Play(ctx context.Context, appID, width, height int, fps float64) (*websocket.Conn, Hello, error)

Play starts a game on the host and returns its socket and the picture it sends. The caller closes the socket to end the game.

type Game

type Game struct {
	AppID int    `json:"appId"`
	Name  string `json:"name"`
	// Size is how much room it takes on disk, in bytes.
	Size int64 `json:"size,omitempty"`
}

Game is a game installed in Steam.

func Installed

func Installed(steamRoot string) ([]Game, error)

Installed lists the games installed in every Steam library folder, by name. Steam's own tools (Proton, its runtimes) are left out.

type Hello

type Hello struct {
	Width  int     `json:"width"`
	Height int     `json:"height"`
	FPS    float64 `json:"fps"`
	// Encoder is what encodes the picture, such as h264_vaapi, for the
	// server's logs.
	Encoder string `json:"encoder,omitempty"`
}

Hello is the host's first message on the play socket: the picture it sends.

type Host

type Host struct {
	// SteamRoot is Steam's folder (see SteamRoot), or empty to look for it
	// in SteamHome each time: on a first start Steam hasn't made it yet.
	SteamRoot string
	SteamHome string
	// Token is what Matinee must send; empty lets anyone on the network in.
	Token string
	// Display is the X display the games show on, such as :55.
	Display string
	// FFmpeg encodes; VAAPI is the GPU's render node to encode on, such as
	// /dev/dri/renderD128, or empty to encode on the CPU.
	FFmpeg string
	VAAPI  string
	// AudioSource is the PulseAudio source the games' sound is captured
	// from: the default output's monitor unless set.
	AudioSource string
	// Bitrate is the picture's bitrate in megabits a second.
	Bitrate int
	// Steam is the command that launches a game: Steam's own, run with
	// -applaunch <app id>.
	Steam string
	// Desktop is the address of a web page showing this computer's screen
	// (see desktop.go), or empty for none.
	Desktop string
	Log     *slog.Logger
	// VideoInput and AudioInput replace FFmpeg's input arguments, for tests.
	VideoInput, AudioInput []string
	// contains filtered or unexported fields
}

Host is the game host's side: it serves the protocol in protocol.go.

func (*Host) Handler

func (h *Host) Handler() http.Handler

Handler serves the protocol.

type KV

type KV struct {
	Pairs []Pair
}

KV is one level of Valve's KeyValues text format (.vdf, .acf): keys, each with a string or a nested KV. Keys are matched without regard to case, as Steam does.

func ParseVDF

func ParseVDF(r io.Reader) (*KV, error)

ParseVDF reads Valve's KeyValues text.

func (*KV) Child

func (kv *KV) Child(key string) *KV

Child is a key's block, or nil.

func (*KV) Children

func (kv *KV) Children() []Pair

Children are the nested blocks, in order.

func (*KV) Get

func (kv *KV) Get(key string) string

Get is a key's string, or "".

type Pair

type Pair struct {
	Key   string
	Str   string
	Value *KV
}

Pair is one key and its value: Value for a nested block, Str otherwise.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL