Parsec SDK Overview
The Parsec SDK allows your application to make interactive, low–latency peer–to–peer connections for the purpose of game streaming. The SDK handles the low level internals of peer–to–peer connectivity, networking, and hardware accelerated video/audio processing. It is lightweight, consisting of a single header file and a shared object < 5MB.
Visit our GitHub repo for binaries and examples. Visit our Discord server for discussion and support.
Instance Functions
Instance functions operate either globally or on the top–level Parsec instance.
- Call
ParsecInitto create a newParsecinstance used for either making a client connection or hosting. - Call
ParsecSetLogCallbackto receive log messages globally. - Call
ParsecDestroywhen finished.
| Name | Description |
|---|---|
ParsecInit | Initialize Parsec instance. |
ParsecDestroy | Destroy Parsec instance. |
ParsecGetConfig | Get Parsec runtime configuration. |
ParsecGetBuffer | Get an internal dynamically allocated buffer by 32-bit lookup key. |
ParsecFree | Free a dynamically allocated buffer returned by ParsecGetBuffer. |
ParsecSetLogCallback | Receive log messages accross all Parsec instances. |
ParsecVersion | Retrieve the Parsec SDK internal PARSEC_VER. |
ParsecGetOutputs | Get a list of currently available outputs. Windows only. |
ParsecGetDecoders | Get a list of currently available video decoders. |
Client Functions
Client functions deal with making a connection to a host, sending input, rendering frames, and playing audio.
- Call
ParsecClientConnectto make a connection to a host. This function requires asessionIDandpeerIDobtained via the Parsec API. - Call
ParsecClientGetStatusperiodically to check if the connection remains active. - Call
ParsecClientSetDimensionsat least once and whenever the client window resizes. - Call either
ParsecClientPollFrameorParsecClientGLRenderFrameto process and display incoming video frames. If usingParscClientGLRenderFrame, callParsecClientGLDestroywhen finished on the thread that was doing the rendering. - Call
ParsecClientPollAudioto process then play audio from the host. - Call
ParsecClientPollEventsto respond to host events such as cursor changes and user defined messages. - Call
ParsecClientSendMessageto send input to the host. - Call
ParsecClientDisconnectwhen finished.
| Name | Description |
|---|---|
ParsecClientConnect | Begin connecting to a remote Parsec host. |
ParsecClientDisconnect | Disconnect client. |
ParsecClientGetStatus | Get client connection health and status information. |
ParsecClientGetGuests | Get a list of all guests currently connected to the host. |
ParsecClientSetConfig | Set client configuration. |
ParsecClientSetDimensions | Set client window dimensions and screen scale. |
ParsecClientPollFrame | Poll for a new video frame from the host and make it available in system memory. |
ParsecClientPollAudio | Poll for new audio from the host. |
ParsecClientPollEvents | Poll client events. |
ParsecClientGLRenderFrame | Renders a remote video frame with OpenGL/GLES. |
ParsecClientMetalRenderFrame | Renders a remote video frame with Metal. |
ParsecClientD3D9RenderFrame | Renders a remote video frame with D3D9. |
ParsecClientD3D11RenderFrame | Renders a remote video frame with D3D11. |
ParsecClientGLDestroy | Cleanup internal OpenGL/GLES state. |
ParsecClientSendMessage | Send an input message to the host. |
ParsecClientPause | Pause video and/or audio output from the host. |
ParsecClientEnableStream | Enable or disable video streams. |
ParsecClientSendUserData | Send a user-defined string to the host. |
Host Functions
Host functions deal with accepting guest connections, polling host/guest events, and in HOST_GAME submitting video/audio.
- Call
ParsecHostStartto begin a hosting session. This function requires asessionIDobtained via the Parsec API. - Call
ParsecHostGetGueststo retrieve a list of currently connected guests. - Call
ParsecHostPollEventsto respond to guest events such as connect, disconnect, user and user defined messages. - In
HOST_GAME, callParsecHostPollInputto receieve input messages from all guests. - In
HOST_GAME, callParsecHostSubmitAudioto send game audio to all guests. - In
HOST_GAME, callParsecHostD3D11SubmitFrame(or similar) to send rendered frames to all guests. - Call
ParsecHostStopwhen finished.
| Name | Description |
|---|---|
ParsecHostStart | Start accepting guests. |
ParsecHostStop | Disconnect all guests and stop hosting. |
ParsecHostGetStatus | Get current hosting status. |
ParsecHostSetConfig | Set host configuration. |
ParsecHostGetGuests | Get a list of all connected and/or waiting guests. |
ParsecHostKickGuest | Kick guest. |
ParsecHostSendUserData | Send a user-defined message to a guest. |
ParsecHostPollEvents | Poll host events. |
ParsecHostAllowGuest | Allow or reject a pending guest. HOST_DESKTOP only. |
ParsecHostSetPermissions | Change guest input permissions. HOST_DESKTOP only. |
ParsecHostPollInput | Poll input messages from connected guests. HOST_GAME only. |
ParsecHostSubmitAudio | Submit PCM audio to connected guests. HOST_GAME only. |
ParsecHostSubmitCursor | Submit a cursor mode and/or image update to connected guests. HOST_GAME only. |
ParsecHostSubmitRumble | Submit gamepad rumble data to a connected guests. HOST_GAME only. |
ParsecHostGLSubmitFrame | Submit rendered OpenGL frame to connected guests. HOST_GAME only. |
ParsecHostD3D9SubmitFrame | Submit rendered D3D9 frame to connected guests. HOST_GAME only. Windows only. |
ParsecHostD3D11SubmitFrame | Submit rendered D3D11 frame to connected guests. HOST_GAME only. Windows only. |
Structures
| Name | Description |
|---|---|
ParsecConfig | Parsec instance configuration. |
ParsecFrame | Video frame properties. |
ParsecRect | Rectangle defined by the coordinates of its upper-left and lower-right corners. |
ParsecOutput | Output (monitor) properties. |
ParsecCursor | Cursor properties. |
ParsecPermissions | Guest input permissions. |
ParsecMetrics | Latency performance metrics. |
ParsecGuest | Guest properties. |
ParsecKeyboardMessage | Keyboard message. |
ParsecMouseButtonMessage | Mouse button message. |
ParsecMouseWheelMessage | Mouse wheel message. |
ParsecMouseMotionMessage | Mouse motion message. |
ParsecGamepadButtonMessage | Gamepad button message. |
ParsecGamepadAxisMessage | Gamepad axis message. |
ParsecGamepadUnplugMessage | Gamepad unplug message. |
ParsecGamepadStateMessage | Gamepad state message. |
ParsecMessage | Generic input message that can represent any message type. |
ParsecClientVideoConfig | Client video configuration. |
ParsecClientConfig | Client configuration. |
ParsecDecoder | Decoder description. |
ParsecClientStatus | Client connection health and status information. |
ParsecClientCursorEvent | Cursor mode/image update event. |
ParsecClientRumbleEvent | Gamepad rumble data event. |
ParsecClientStreamEvent | Video stream status change event. |
ParsecClientUserDataEvent | User-defined host message event. |
ParsecClientEvent | Generic client event that can represent any event type. |
ParsecHostVideoConfig | Host video configuration. |
ParsecHostConfig | Host configuration. |
ParsecHostStatus | Host runtime status. |
ParsecGuestStateChangeEvent | Guest connection state change event. |
ParsecUserDataEvent | User-defined guest message event. |
ParsecHostEvent | Generic host event that can represent any event type. |
Enumerations
| Name | Description |
|---|---|
ParsecStatus | Status codes indicating success, warning, or error. |
ParsecLogLevel | Log level. |
ParsecKeycode | Keyboard input. |
ParsecKeymod | Modifier keys applied to keyboard input. |
ParsecMouseButton | Mouse button. |
ParsecGamepadButton | Gamepad button. |
ParsecGamepadState | Gamepad state button. |
ParsecGamepadAxis | Gamepad axes related to thumbsticks and triggers. |
ParsecMessageType | Input message type. |
ParsecColorFormat | Color formats for raw image data. |
ParsecRotation | Degrees of rotation for raw image data. |
ParsecProtocol | Network protocol used for peer-to-peer connections. |
ParsecContainer | Video stream container. |
ParsecPCMFormat | PCM audio format. |
ParsecGuestState | Guest connection lifecycle states. |
ParsecHostMode | Host mode of operation. |
ParsecGamepadType | Virtual gamepad type. |
ParsecHostEventType | Host event type. |
ParsecClientEventType | Client event type. |
Typedefs
| Type | Name (Params) |
|---|---|
Parsec | Parsec instance. |
ParsecGLuint | OpenGL/GLES 32-bit unsigned integer. |
ParsecMetalCommandQueue | Metal id<MTLCommandQueue>. |
ParsecMetalTexture | Metal id<MTLTexture>. |
ParsecD3D9Device | D3D9 IDirect3DDevice9. |
ParsecD3D9Surface | D3D9 IDirect3DSurface9. |
ParsecD3D11Device | D3D11 ID3D11Device. |
ParsecD3D11DeviceContext | D3D11 ID3D11DeviceContext. |
ParsecD3D11Texture2D | D3D11 ID3D11Texture2D. |
ParsecLogCallback | Fired when a new log message is available from the Parsec SDK. |
ParsecFrameCallback | Fired synchronously if a new host video frame is available. |
ParsecPreRenderCallback | Fired synchronously just before a new host video frame is rendered. |
ParsecAudioCallback | Fired synchronously if new audio is available from the host. |
Defines
| Name | Description |
|---|---|
GUEST_NAME_LEN | (32) Maximum length of a guest's name. Used in ParsecGuest. |
EXTERNAL_ID_LEN | (64) Maximum length of a guest's external ID. Used in ParsecGuest. |
HOST_NAME_LEN | (256) Maximum length of a host's name. Used in ParsecHostConfig. |
HOST_DESC_LEN | (512) Maximum length of a game's description. Used in ParsecHostConfig. |
HOST_SECRET_LEN | (32) Maximum length of a host's secret code to grant temporary access. Used in ParsecHostConfig and ParsecClientConfig. |
OUTPUT_ID_LEN | (64) Maximum length of a host output identifier. |
OUTPUT_NAME_LEN | (256) Maximum length of an output's name in ParsecOutput. |
ADAPTER_NAME_LEN | (256) Maximum length of an adapter's name in ParsecOutput. |
GAME_ID_LEN | (72) Maximum length of a Game ID. Used in ParsecHostConfig. |
NUM_VSTREAMS | (2) Maximum number of video streams per client connection. |
DEFAULT_STREAM | (0) The default video stream, enabled automatically on client connection to the host. |
DECODER_NAME_LEN | (16) Maximum length of a decoder name. Used in ParsecDecoder. |
PARSEC_VER_MAJOR | (6) Parsec SDK breaking API/ABI change. |
PARSEC_VER_MINOR | (0) Parsec SDK internal implementation detail or additional functionality. |
PARSEC_VER | 32-bit concatenated major/minor version. |
PARSEC_DEFAULTS | Default Parsec instance configuration passed to ParsecInit. |
PARSEC_HOST_VIDEO_DEFAULTS | Default host video configuration, one per stream, member of ParsecHostConfig. |
PARSEC_HOST_DEFAULTS | Default host configuration passed to ParsecHostStart and ParsecHostSetConfig. |
PARSEC_CLIENT_VIDEO_DEFAULTS | Default client video configuration, one per stream, member of ParsecClientConfig. |
PARSEC_CLIENT_DEFAULTS | Default client configuration passed to ParsecClientConnect and ParsecClientSetConfig. |