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.
Instance Functions
Instance functions operate either globally or on the top–level Parsec
instance.
- Call
ParsecInit
to create a newParsec
instance used for either making a client connection or hosting. - Call
ParsecSetLogCallback
to receive log messages globally. - Call
ParsecDestroy
when 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 and Mac only. |
ParsecGetAudioOutputs | Get a list of currently available audio outputs. |
ParsecGetDecoders | Get a list of currently available video decoders. |
ParsecJSONCommand | Execute a Parsec command from a JSON string. |
ParsecCanHost | Checks if Parsec can host. |
ParsecGetVUSBState | Gets the current VUSB status. |
ParsecGetVDDState | Gets the current VDD status. |
ParsecSetConfig | Updates the current configuration in use. |
Client Functions
Client functions deal with making a connection to a host, sending input, rendering frames, and playing audio.
- Call
ParsecClientConnect
to make a connection to a host. This function requires asessionID
andpeerID
obtained via the Parsec API. - Call
ParsecClientGetStatus
periodically to check if the connection remains active. - Call
ParsecClientSetDimensions
at least once and whenever the client window resizes. - Call either
ParsecClientPollFrame
orParsecClientGLRenderFrame
to process and display incoming video frames. If usingParscClientGLRenderFrame
, callParsecClientGLDestroy
when finished on the thread that was doing the rendering. - Call
ParsecClientPollAudio
to process then play audio from the host. - Call
ParsecClientPollEvents
to respond to host events such as cursor changes and user defined messages. - Call
ParsecClientSendMessage
to send input to the host. - Call
ParsecClientDisconnect
when finished.
Name | Description |
---|---|
ParsecClientNewAttempt | 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. |
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. |
ParsecClientSendExtraData | Send extra binary data to the host. |
ParsecClientScalePenMessage | Scale a pen message to the client viewport. |
ParsecClientSendVirtualUSB | Send virtual USB binary data to the host. |
ParsecClientAddCandidate | Give a possible candidate to connect to. |
ParsecClientBeginP2P | After approving of the guest, start the peer 2 peer frame. |
ParsecClientEndConnection | Use to disconnect the client connection. Should use ParsecClientDisconnect for normal disconnects. |
Host Functions
Host functions deal with accepting guest connections, polling host/guest events, and in HOST_GAME
submitting video/audio.
- Call
ParsecHostStart
to begin a hosting session. This function requires asessionID
obtained via the Parsec API. - Call
ParsecHostGetGuests
to retrieve a list of currently connected guests. - Call
ParsecHostPollEvents
to respond to guest events such as connect, disconnect, user and user defined messages. - In
HOST_GAME
, callParsecHostPollInput
to receieve input messages from all guests. - In
HOST_GAME
, callParsecHostSubmitAudio
to send game audio to all guests. - In
HOST_GAME
, callParsecHostD3D11SubmitFrame
(or similar) to send rendered frames to all guests. - Call
ParsecHostStop
when 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. |
ParsecHostBeginP2P | 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. |
ParsecHostD3D12SubmitFrame | Submit rendered D3D12 frame to connected guests. HOST_GAME only. Windows only. |
ParsecHostVulkanSubmitFrame | Submit rendered Vulkan frame to connected guests. HOST_GAME only. Windows only. |
ParsecHostHookStart | Hook video, audio, or both in the current process. Windows only. |
ParsecHostHookStop | Detach Parsec from the current process. This function takes longer than 2 seconds to complete, since we need to make sure nothing is left behind. Windows only. |
ParsecHostResetGamepads | Reset all ViGem controllers in case of issues. |
ParsecHostSetWhitelist | Set the whitelist of approved applications. |
ParsecHostAddCandidate | Give a possible candidate to connect to. |
ParsecHostNewAttempt | Start a new NAT attempt. |
ParsecHostEndConnection | End a connection. |
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. |
ParsecAudioOutput | AudioOutput properties. |
ParsecCursor | Cursor properties. |
ParsecPermissions | Guest input permissions. |
ParsecMetrics | Latency performance metrics. |
ParsecGuest | Guest properties. |
ParsecCandidate | The NAT candidates. |
ParsecCredentials | Credentials for the STUN phase. |
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. |
ParsecPenMessage | Pen 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. |
ParsecClientConnectionEvent | Connection event from Client. |
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. |
ParsecVkArgs | Vulkan submission info. |
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. |
ParsecChroma | Layout of the chrominance values given a YUV format image. |
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. |
ParsecGuestConnectionEvent | Events on the clients side. |
ParsecHostMode | Host mode of operation. |
ParsecGamepadMode | Virtual gamepad type. |
ParsecGamepadType | Virtual gamepad type. |
ParsecHostEventType | Host event type. |
ParsecClientConnectionState | Client connection lifecycle states. |
ParsecClientEventType | Client event type. |
ParsecRenderer | Graphics renderer. |
ParsecVDDState | VDD State. |
ParsecHookMode | Hook Mode Flags. |
ParsecAudioCancelMode | Audio Echo Cancel Type. |
ParsecCGLevel | Congestion Control level. |
ParsecPenFlags | Different pen flags. |
ParsecForceRelay | Force the use of the relay server. |
ParsecQualityFlags | The encoding quality. |
ParsecVirtualDeviceType | The virtual device type to be used. |
ParsecVirtualDeviceStatus | The virtual device state. |
Typedefs
Type | Name (Params) |
---|---|
Parsec | Parsec instance. |
ParsecGLuint | OpenGL/GLES 32-bit unsigned integer. |
ParsecD3D9Device | D3D9 IDirect3DDevice9 . |
ParsecD3D9Surface | D3D9 IDirect3DSurface9 . |
ParsecD3D11Device | D3D11 ID3D11Device . |
ParsecD3D11DeviceContext | D3D11 ID3D11DeviceContext . |
ParsecD3D11Texture2D | D3D11 ID3D11Texture2D . |
ParsecOpaqueWindow | Windows HWND . |
ParsecOpaqueDevice | Renderer device. |
ParsecOpaqueContext | Renderer device context. |
ParsecOpaqueTexture | Renderer frame texture. |
ParsecD3D12Device | D3D12 ID3D12Device . |
ParsecD3D12CommandQueue | D3D12 ID3D12CommandQueue . |
ParsecD3D12Resource | D3D12 ID3D12Resource . |
ParsecVkImage | Vulkan VkImage . |
ParsecWAVEFORMATEX | The WAVEFORMATEX structure defines the format of waveform-audio data. |
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. |
ParsecHookStatusCallback | The return status of the hook that happened on the graphios layer ParsecHostHookStart . |
ParsecHookVideoCallback | Fired on each frame from a hooked renderer. |
ParsecHookAudioCallback | Fired on new hooked audio data. |
ParsecAudioInjectFunc | Fired when a new process needs to be injected for audio cancellation. |
Defines
Name | Description |
---|---|
GUEST_NAME_LEN | (32) Maximum length of a guest's name. Used in ParsecGuest . |
ATTEMPT_ID_LEN | (56) Maximum length of an attempt id. Used in ParsecGuest and ParsecClientConnectionEvent . |
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 . |
DECODER_NAME_LEN | (16) Maximum length of a decoder name. Used in ParsecDecoder . |
ICE_SAFE_LEN | (256) Maximum length regarding a Interactive Connectivity Establishment. |
ADDR_LEN | (72) Maximum length of an addresses. |
STUN_ADDR_LEN | (256) Maximum length of the possible stun addresses. |
ECHO_EXEC_LEN | (256) Maximum length of an application name to have audio cancelation |
FINGERPRINT_LEN | (112) Maximum length of the DTLS Fingerprint. |
NUM_VSTREAMS | (3) Maximum number of video streams per client connection. |
DEFAULT_STREAM | (0) The default video stream, enabled automatically on client connection to the host. |
MAX_OUTPUTS | (30) Maximum number of Audio or Video outputs to try / return. |
MAX_RES_W | (3840) Maximum width resolution increasing this, will increase memory size. |
MAX_RES_H | (2160) Maximum height resolution increasing this, will increase maximum size. |
MAX_DECODERS | (5) Maxmimum number of decoders a system can have. |
MAX_CLIENTS | (64) Maximum number of connected clients a host can have. |
KEEP_HOST_RES | (65535) Magic number to indicate we want to keep using the host resolution. |
STUN_ADDRESS | stun.parsec.app Currently the IP is statically coded for team/enterprise environments. |
STUN_PORT | (3478) The default stun port to communicate on. |
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_HV_DEFAULTS | Default host video configuration, one per stream, member of ParsecHostConfig . |
PARSEC_HOST_DEFAULTS | Default host configuration passed to ParsecHostStart and ParsecHostSetConfig . |
PARSEC_CV_DEFAULTS | Default client video configuration, one per stream, member of ParsecClientConfig . |
PARSEC_CLIENT_DEFAULTS | Default client configuration passed to ParsecClientNewAttempt and ParsecClientSetConfig . |