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
- Variables
- func CheckHost(host string) error
- func NewPIN() string
- func SplitAddress(addr string) (string, int, error)
- type App
- type Bridge
- type Client
- func (c *Client) Apps(ctx context.Context, pc PC) ([]App, error)
- func (c *Client) Find(ctx context.Context, host string, port int) (Info, error)
- func (c *Client) Info(ctx context.Context, pc PC) (Info, error)
- func (c *Client) Launch(ctx context.Context, pc PC, app int, width, height, fps int, key []byte, ...) (string, Info, error)
- func (c *Client) Pair(ctx context.Context, host string, port int, pin string, wait time.Duration) (PC, error)
- func (c *Client) Quit(ctx context.Context, pc PC) error
- func (c *Client) Unpair(ctx context.Context, pc PC) error
- type Identity
- type Info
- type PC
- type Settings
- type Stream
Constants ¶
const ( KindVideo = mediabridge.KindVideo KindAudio = mediabridge.KindAudio )
Packet kinds, as the game stream's (gamehost.KindVideo and KindAudio).
const DefaultPort = 47989
DefaultPort is Sunshine's HTTP port; its HTTPS port is 5 below it, and its own web page 1 above.
Variables ¶
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.
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.
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 ¶
CheckHost says whether host is an address on the home network, so the server only ever talks to a PC there.
Types ¶
type Bridge ¶
type Bridge struct {
// Path is matinee-pcremote's.
Path string
}
Bridge runs matinee-pcremote.
func (*Bridge) LaunchQuery ¶
LaunchQuery is what the bridge needs added to a launch request.
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) Find ¶
Find asks whatever is at host and port whether it's Sunshine, without pairing: for checking the address before pairing.
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.
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.
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).
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 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.