pcremote

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 31 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 pcremote plays a gaming PC on the home network through Matinee: the PC runs Sunshine (https://github.com/LizardByte/Sunshine), the free game streaming host for Windows, Linux and macOS, and Matinee is its client, as the Moonlight apps are. This package pairs with the PC and starts Steam's Big Picture there over Sunshine's HTTPS API, and matinee-pcremote (games/pcremote, built on moonlight-common-c) receives the picture and sound, which go on to players through the game stream (see gamestream.Remote). Everything stays on the home network.

It's for a PC someone already plays Steam on. A server can instead have a game host of its own (internal/gamehost), such as a Steam container.

Index

Constants

View Source
const (
	KindVideo = mediabridge.KindVideo
	KindAudio = mediabridge.KindAudio
)

Packet kinds, as the game stream's (gamehost.KindVideo and KindAudio).

View Source
const DefaultPort = 47989

DefaultPort is Sunshine's HTTP port; its HTTPS port is 5 below it, and its own web page 1 above.

Variables

View Source
var DefaultSettings = Settings{Width: 1920, Height: 1080, FPS: 60, Bitrate: 20000}

DefaultSettings is 1080p at 60 frames a second, 20 megabits: what the game host sends too.

View Source
var ErrNoAnswer = errors.New("Sunshine didn't answer at that address: check that it's running on the PC and that its firewall allows it")

ErrNoAnswer means nothing answered as Sunshine at that address.

View Source
var ErrNotPaired = errors.New("the PC doesn't know Matinee: pair it again")

ErrNotPaired means the PC doesn't know Matinee (any more).

Functions

func CheckHost

func CheckHost(host string) error

CheckHost says whether host is an address on the home network, so the server only ever talks to a PC there.

func NewPIN

func NewPIN() string

NewPIN makes the 4-digit code the person types into Sunshine's page.

func SplitAddress

func SplitAddress(addr string) (string, int, error)

SplitAddress takes "host" or "host:port" as people type it.

Types

type App

type App struct {
	ID    int    `xml:"ID" json:"id"`
	Title string `xml:"AppTitle" json:"title"`
}

App is something Sunshine can start.

func SteamApp

func SteamApp(apps []App) (App, bool)

SteamApp picks the app that starts Steam's Big Picture, which Sunshine sets up on its own: by its title. Without one, it's the desktop, where Steam can be opened by hand.

type Bridge

type Bridge struct {
	// Path is matinee-pcremote's.
	Path string
}

Bridge runs matinee-pcremote.

func (*Bridge) Available

func (b *Bridge) Available() bool

Available says whether this server has the bridge.

func (*Bridge) LaunchQuery

func (b *Bridge) LaunchQuery(ctx context.Context) (string, error)

LaunchQuery is what the bridge needs added to a launch request.

func (*Bridge) Play

func (b *Bridge) Play(ctx context.Context, c *Client, pc PC, app int, set Settings, log *slog.Logger) (*Stream, error)

Play starts app on the PC and streams it.

type Client

type Client struct {
	Identity Identity
	// Timeout is for one request, apart from pairing's wait for the PIN.
	Timeout time.Duration
}

Client talks to Sunshine as Matinee.

func (*Client) Apps

func (c *Client) Apps(ctx context.Context, pc PC) ([]App, error)

Apps lists what the PC can start.

func (*Client) Find

func (c *Client) Find(ctx context.Context, host string, port int) (Info, error)

Find asks whatever is at host and port whether it's Sunshine, without pairing: for checking the address before pairing.

func (*Client) Info

func (c *Client) Info(ctx context.Context, pc PC) (Info, error)

Info asks a paired PC how it is.

func (*Client) Launch

func (c *Client) Launch(ctx context.Context, pc PC, app int, width, height, fps int, key []byte, keyID uint32, launchQuery string) (string, Info, error)

Launch has the PC start app (or go back to it, if it's already running), to stream at width × height and fps, and returns the stream's address. key and keyID encrypt the player's input; launchQuery is what matinee-pcremote asks for (Bridge.LaunchQuery).

func (*Client) Pair

func (c *Client) Pair(ctx context.Context, host string, port int, pin string, wait time.Duration) (PC, error)

Pair pairs with the PC at host and port. Sunshine waits until someone types pin into its web page (PIN, on https://<pc>:47990), so this takes as long as that does, up to wait.

func (*Client) Quit

func (c *Client) Quit(ctx context.Context, pc PC) error

Quit ends what the PC is streaming.

func (*Client) Unpair

func (c *Client) Unpair(ctx context.Context, pc PC) error

Unpair has the PC forget Matinee.

type Identity

type Identity struct {
	Cert string `json:"cert"` // PEM
	Key  string `json:"key"`  // PEM
	// UniqueID is sent with each request, as Moonlight does.
	UniqueID string `json:"uniqueId"`
}

Identity is Matinee's own certificate, which Sunshine knows it by once paired.

func NewIdentity

func NewIdentity() (Identity, error)

NewIdentity makes a new certificate.

type Info

type Info struct {
	Name       string `xml:"hostname" json:"name"`
	AppVersion string `xml:"appversion" json:"version"`
	GfeVersion string `xml:"GfeVersion" json:"-"`
	HTTPSPort  int    `xml:"HttpsPort" json:"-"`
	MAC        string `xml:"mac" json:"-"`
	// Codecs is the codecs it can send (ServerCodecModeSupport).
	Codecs int `xml:"ServerCodecModeSupport" json:"-"`
	// Paired says whether it knows Matinee: only asked over HTTPS.
	Paired bool `xml:"-" json:"paired"`
	// CurrentGame is the app it's streaming, by its id, or 0.
	CurrentGame int    `xml:"currentgame" json:"-"`
	State       string `xml:"state" json:"-"`
	PairStatus  int    `xml:"PairStatus" json:"-"`
}

Info is what a PC says about itself (Sunshine's serverinfo).

func (Info) Busy

func (i Info) Busy() bool

Busy says whether it's streaming to someone.

type PC

type PC struct {
	Name string `json:"name"`
	// Host is its address on the home network, and Port Sunshine's HTTP
	// port there.
	Host string `json:"host"`
	Port int    `json:"port"`
	// HTTPSPort is Sunshine's HTTPS port, which it said when paired.
	HTTPSPort int `json:"httpsPort,omitempty"`
	// Cert is the PC's own certificate (PEM), which pairing gave.
	Cert string `json:"cert"`
	MAC  string `json:"mac,omitempty"`
}

PC is a paired gaming PC.

type Settings

type Settings struct {
	Width, Height, FPS int
	// Bitrate is in kilobits a second.
	Bitrate int
}

Settings is the picture asked of the PC.

type Stream

type Stream struct {
	*mediabridge.Stream
	// contains filtered or unexported fields
}

Stream is the PC being played: its picture and sound as RTP packets (see mediabridge.Stream), and the player's input back to it.

func (*Stream) Close

func (s *Stream) Close()

Close ends the stream, and the game on the PC with it, so Big Picture doesn't stay up on the PC's own screen.

func (*Stream) Input

func (s *Stream) Input(b []byte)

Input takes the player's input messages (see gamestream.Session.input): controllers, keyboard and mouse.

Jump to

Keyboard shortcuts

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