mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Code within extern "C" should not be indented
This commit is contained in:
parent
5ba0f82b35
commit
cbbe251f50
@ -8,62 +8,62 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enable this definition during debugging to enable assertions
|
// Enable this definition during debugging to enable assertions
|
||||||
//#define LC_DEBUG
|
//#define LC_DEBUG
|
||||||
|
|
||||||
typedef struct _STREAM_CONFIGURATION {
|
typedef struct _STREAM_CONFIGURATION {
|
||||||
// Dimensions in pixels of the desired video stream
|
// Dimensions in pixels of the desired video stream
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
// FPS of the desired video stream
|
// FPS of the desired video stream
|
||||||
int fps;
|
int fps;
|
||||||
|
|
||||||
// Bitrate of the desired video stream (audio adds another ~1 Mbps)
|
// Bitrate of the desired video stream (audio adds another ~1 Mbps)
|
||||||
int bitrate;
|
int bitrate;
|
||||||
|
|
||||||
// Max video packet size in bytes (use 1024 if unsure)
|
// Max video packet size in bytes (use 1024 if unsure)
|
||||||
int packetSize;
|
int packetSize;
|
||||||
|
|
||||||
// Set to non-zero value to enable remote (over the Internet)
|
// Set to non-zero value to enable remote (over the Internet)
|
||||||
// streaming optimizations. If unsure, set to 0.
|
// streaming optimizations. If unsure, set to 0.
|
||||||
int streamingRemotely;
|
int streamingRemotely;
|
||||||
|
|
||||||
// Specifies the channel configuration of the audio stream.
|
// Specifies the channel configuration of the audio stream.
|
||||||
// See AUDIO_CONFIGURATION_XXX constants below.
|
// See AUDIO_CONFIGURATION_XXX constants below.
|
||||||
int audioConfiguration;
|
int audioConfiguration;
|
||||||
|
|
||||||
// AES encryption data for the remote input stream. This must be
|
// AES encryption data for the remote input stream. This must be
|
||||||
// the same as what was passed as rikey and rikeyid
|
// the same as what was passed as rikey and rikeyid
|
||||||
// in /launch and /resume requests.
|
// in /launch and /resume requests.
|
||||||
char remoteInputAesKey[16];
|
char remoteInputAesKey[16];
|
||||||
char remoteInputAesIv[16];
|
char remoteInputAesIv[16];
|
||||||
} STREAM_CONFIGURATION, *PSTREAM_CONFIGURATION;
|
} STREAM_CONFIGURATION, *PSTREAM_CONFIGURATION;
|
||||||
|
|
||||||
// Use this function to zero the stream configuration when allocated on the stack or heap
|
// Use this function to zero the stream configuration when allocated on the stack or heap
|
||||||
void LiInitializeStreamConfiguration(PSTREAM_CONFIGURATION streamConfig);
|
void LiInitializeStreamConfiguration(PSTREAM_CONFIGURATION streamConfig);
|
||||||
|
|
||||||
typedef struct _LENTRY {
|
typedef struct _LENTRY {
|
||||||
// Pointer to the next entry or NULL if this is the last entry
|
// Pointer to the next entry or NULL if this is the last entry
|
||||||
struct _LENTRY* next;
|
struct _LENTRY* next;
|
||||||
|
|
||||||
// Pointer to data (never NULL)
|
// Pointer to data (never NULL)
|
||||||
char* data;
|
char* data;
|
||||||
|
|
||||||
// Size of data in bytes (never <= 0)
|
// Size of data in bytes (never <= 0)
|
||||||
int length;
|
int length;
|
||||||
} LENTRY, *PLENTRY;
|
} LENTRY, *PLENTRY;
|
||||||
|
|
||||||
// A decode unit describes a buffer chain of H264 data from multiple packets
|
// A decode unit describes a buffer chain of H264 data from multiple packets
|
||||||
typedef struct _DECODE_UNIT {
|
typedef struct _DECODE_UNIT {
|
||||||
// Length of the entire buffer chain in bytes
|
// Length of the entire buffer chain in bytes
|
||||||
int fullLength;
|
int fullLength;
|
||||||
|
|
||||||
// Head of the buffer chain (never NULL)
|
// Head of the buffer chain (never NULL)
|
||||||
PLENTRY bufferList;
|
PLENTRY bufferList;
|
||||||
} DECODE_UNIT, *PDECODE_UNIT;
|
} DECODE_UNIT, *PDECODE_UNIT;
|
||||||
|
|
||||||
// Specifies that the audio stream should be encoded in stereo (default)
|
// Specifies that the audio stream should be encoded in stereo (default)
|
||||||
#define AUDIO_CONFIGURATION_STEREO 0
|
#define AUDIO_CONFIGURATION_STEREO 0
|
||||||
|
|
||||||
// Specifies that the audio stream should be in 5.1 surround sound if the PC is able
|
// Specifies that the audio stream should be in 5.1 surround sound if the PC is able
|
||||||
@ -85,73 +85,73 @@ extern "C" {
|
|||||||
#define CAPABILITY_SLICES_PER_FRAME(x) (((unsigned char)(x)) << 24)
|
#define CAPABILITY_SLICES_PER_FRAME(x) (((unsigned char)(x)) << 24)
|
||||||
|
|
||||||
// This callback is invoked to provide details about the video stream and allow configuration of the decoder
|
// This callback is invoked to provide details about the video stream and allow configuration of the decoder
|
||||||
typedef void(*DecoderRendererSetup)(int width, int height, int redrawRate, void* context, int drFlags);
|
typedef void(*DecoderRendererSetup)(int width, int height, int redrawRate, void* context, int drFlags);
|
||||||
|
|
||||||
// This callback performs the teardown of the video decoder
|
// This callback performs the teardown of the video decoder
|
||||||
typedef void(*DecoderRendererCleanup)(void);
|
typedef void(*DecoderRendererCleanup)(void);
|
||||||
|
|
||||||
// This callback provides Annex B formatted H264 elementary stream data to the
|
// This callback provides Annex B formatted H264 elementary stream data to the
|
||||||
// decoder. If the decoder is unable to process the submitted data for some reason,
|
// decoder. If the decoder is unable to process the submitted data for some reason,
|
||||||
// it must return DR_NEED_IDR to generate a keyframe.
|
// it must return DR_NEED_IDR to generate a keyframe.
|
||||||
#define DR_OK 0
|
#define DR_OK 0
|
||||||
#define DR_NEED_IDR -1
|
#define DR_NEED_IDR -1
|
||||||
typedef int(*DecoderRendererSubmitDecodeUnit)(PDECODE_UNIT decodeUnit);
|
typedef int(*DecoderRendererSubmitDecodeUnit)(PDECODE_UNIT decodeUnit);
|
||||||
|
|
||||||
typedef struct _DECODER_RENDERER_CALLBACKS {
|
typedef struct _DECODER_RENDERER_CALLBACKS {
|
||||||
DecoderRendererSetup setup;
|
DecoderRendererSetup setup;
|
||||||
DecoderRendererCleanup cleanup;
|
DecoderRendererCleanup cleanup;
|
||||||
DecoderRendererSubmitDecodeUnit submitDecodeUnit;
|
DecoderRendererSubmitDecodeUnit submitDecodeUnit;
|
||||||
int capabilities;
|
int capabilities;
|
||||||
} DECODER_RENDERER_CALLBACKS, *PDECODER_RENDERER_CALLBACKS;
|
} DECODER_RENDERER_CALLBACKS, *PDECODER_RENDERER_CALLBACKS;
|
||||||
|
|
||||||
// Use this function to zero the video callbacks when allocated on the stack or heap
|
// Use this function to zero the video callbacks when allocated on the stack or heap
|
||||||
void LiInitializeVideoCallbacks(PDECODER_RENDERER_CALLBACKS drCallbacks);
|
void LiInitializeVideoCallbacks(PDECODER_RENDERER_CALLBACKS drCallbacks);
|
||||||
|
|
||||||
// This structure provides the Opus multistream decoder parameters required to successfully
|
// This structure provides the Opus multistream decoder parameters required to successfully
|
||||||
// decode the audio stream being sent from the computer. See opus_multistream_decoder_init docs
|
// decode the audio stream being sent from the computer. See opus_multistream_decoder_init docs
|
||||||
// for details about these fields.
|
// for details about these fields.
|
||||||
//
|
//
|
||||||
// The supplied mapping array is indexed according to the following output channel order:
|
// The supplied mapping array is indexed according to the following output channel order:
|
||||||
// 0 - Front Left
|
// 0 - Front Left
|
||||||
// 1 - Front Right
|
// 1 - Front Right
|
||||||
// 2 - Center
|
// 2 - Center
|
||||||
// 3 - LFE
|
// 3 - LFE
|
||||||
// 4 - Surround Left
|
// 4 - Surround Left
|
||||||
// 5 - Surround Right
|
// 5 - Surround Right
|
||||||
//
|
//
|
||||||
// If the mapping order does not match the channel order of the audio renderer, you may swap
|
// If the mapping order does not match the channel order of the audio renderer, you may swap
|
||||||
// the values in the mismatched indices until the mapping array matches the desired channel order.
|
// the values in the mismatched indices until the mapping array matches the desired channel order.
|
||||||
typedef struct _OPUS_MULTISTREAM_CONFIGURATION {
|
typedef struct _OPUS_MULTISTREAM_CONFIGURATION {
|
||||||
int sampleRate;
|
int sampleRate;
|
||||||
int channelCount;
|
int channelCount;
|
||||||
int streams;
|
int streams;
|
||||||
int coupledStreams;
|
int coupledStreams;
|
||||||
const unsigned char mapping[6];
|
const unsigned char mapping[6];
|
||||||
} OPUS_MULTISTREAM_CONFIGURATION, *POPUS_MULTISTREAM_CONFIGURATION;
|
} OPUS_MULTISTREAM_CONFIGURATION, *POPUS_MULTISTREAM_CONFIGURATION;
|
||||||
|
|
||||||
// This callback initializes the audio renderer. The audio configuration parameter
|
// This callback initializes the audio renderer. The audio configuration parameter
|
||||||
// provides the negotiated audio configuration. This may differ from the one
|
// provides the negotiated audio configuration. This may differ from the one
|
||||||
// specified in the stream configuration.
|
// specified in the stream configuration.
|
||||||
typedef void(*AudioRendererInit)(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig);
|
typedef void(*AudioRendererInit)(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig);
|
||||||
|
|
||||||
// This callback performs the final teardown of the audio decoder
|
// This callback performs the final teardown of the audio decoder
|
||||||
typedef void(*AudioRendererCleanup)(void);
|
typedef void(*AudioRendererCleanup)(void);
|
||||||
|
|
||||||
// This callback provides Opus audio data to be decoded and played. sampleLength is in bytes.
|
// This callback provides Opus audio data to be decoded and played. sampleLength is in bytes.
|
||||||
typedef void(*AudioRendererDecodeAndPlaySample)(char* sampleData, int sampleLength);
|
typedef void(*AudioRendererDecodeAndPlaySample)(char* sampleData, int sampleLength);
|
||||||
|
|
||||||
typedef struct _AUDIO_RENDERER_CALLBACKS {
|
typedef struct _AUDIO_RENDERER_CALLBACKS {
|
||||||
AudioRendererInit init;
|
AudioRendererInit init;
|
||||||
AudioRendererCleanup cleanup;
|
AudioRendererCleanup cleanup;
|
||||||
AudioRendererDecodeAndPlaySample decodeAndPlaySample;
|
AudioRendererDecodeAndPlaySample decodeAndPlaySample;
|
||||||
int capabilities;
|
int capabilities;
|
||||||
} AUDIO_RENDERER_CALLBACKS, *PAUDIO_RENDERER_CALLBACKS;
|
} AUDIO_RENDERER_CALLBACKS, *PAUDIO_RENDERER_CALLBACKS;
|
||||||
|
|
||||||
// Use this function to zero the audio callbacks when allocated on the stack or heap
|
// Use this function to zero the audio callbacks when allocated on the stack or heap
|
||||||
void LiInitializeAudioCallbacks(PAUDIO_RENDERER_CALLBACKS arCallbacks);
|
void LiInitializeAudioCallbacks(PAUDIO_RENDERER_CALLBACKS arCallbacks);
|
||||||
|
|
||||||
// Subject to change in future releases
|
// Subject to change in future releases
|
||||||
// Use LiGetStageName() for stable stage names
|
// Use LiGetStageName() for stable stage names
|
||||||
#define STAGE_NONE 0
|
#define STAGE_NONE 0
|
||||||
#define STAGE_PLATFORM_INIT 1
|
#define STAGE_PLATFORM_INIT 1
|
||||||
#define STAGE_NAME_RESOLUTION 2
|
#define STAGE_NAME_RESOLUTION 2
|
||||||
@ -167,78 +167,78 @@ extern "C" {
|
|||||||
#define STAGE_MAX 12
|
#define STAGE_MAX 12
|
||||||
|
|
||||||
// This callback is invoked to indicate that a stage of initialization is about to begin
|
// This callback is invoked to indicate that a stage of initialization is about to begin
|
||||||
typedef void(*ConnListenerStageStarting)(int stage);
|
typedef void(*ConnListenerStageStarting)(int stage);
|
||||||
|
|
||||||
// This callback is invoked to indicate that a stage of initialization has completed
|
// This callback is invoked to indicate that a stage of initialization has completed
|
||||||
typedef void(*ConnListenerStageComplete)(int stage);
|
typedef void(*ConnListenerStageComplete)(int stage);
|
||||||
|
|
||||||
// This callback is invoked to indicate that a stage of initialization has failed
|
// This callback is invoked to indicate that a stage of initialization has failed
|
||||||
typedef void(*ConnListenerStageFailed)(int stage, long errorCode);
|
typedef void(*ConnListenerStageFailed)(int stage, long errorCode);
|
||||||
|
|
||||||
// This callback is invoked after initialization has finished
|
// This callback is invoked after initialization has finished
|
||||||
typedef void(*ConnListenerConnectionStarted)(void);
|
typedef void(*ConnListenerConnectionStarted)(void);
|
||||||
|
|
||||||
// This callback is invoked when a connection failure occurs. It will not
|
// This callback is invoked when a connection failure occurs. It will not
|
||||||
// occur as a result of a call to LiStopConnection()
|
// occur as a result of a call to LiStopConnection()
|
||||||
typedef void(*ConnListenerConnectionTerminated)(long errorCode);
|
typedef void(*ConnListenerConnectionTerminated)(long errorCode);
|
||||||
|
|
||||||
// This callback is invoked to display a dialog-type message to the user
|
// This callback is invoked to display a dialog-type message to the user
|
||||||
typedef void(*ConnListenerDisplayMessage)(char* message);
|
typedef void(*ConnListenerDisplayMessage)(char* message);
|
||||||
|
|
||||||
// This callback is invoked to display a transient message for the user
|
// This callback is invoked to display a transient message for the user
|
||||||
// while streaming
|
// while streaming
|
||||||
typedef void(*ConnListenerDisplayTransientMessage)(char* message);
|
typedef void(*ConnListenerDisplayTransientMessage)(char* message);
|
||||||
|
|
||||||
typedef struct _CONNECTION_LISTENER_CALLBACKS {
|
typedef struct _CONNECTION_LISTENER_CALLBACKS {
|
||||||
ConnListenerStageStarting stageStarting;
|
ConnListenerStageStarting stageStarting;
|
||||||
ConnListenerStageComplete stageComplete;
|
ConnListenerStageComplete stageComplete;
|
||||||
ConnListenerStageFailed stageFailed;
|
ConnListenerStageFailed stageFailed;
|
||||||
ConnListenerConnectionStarted connectionStarted;
|
ConnListenerConnectionStarted connectionStarted;
|
||||||
ConnListenerConnectionTerminated connectionTerminated;
|
ConnListenerConnectionTerminated connectionTerminated;
|
||||||
ConnListenerDisplayMessage displayMessage;
|
ConnListenerDisplayMessage displayMessage;
|
||||||
ConnListenerDisplayTransientMessage displayTransientMessage;
|
ConnListenerDisplayTransientMessage displayTransientMessage;
|
||||||
} CONNECTION_LISTENER_CALLBACKS, *PCONNECTION_LISTENER_CALLBACKS;
|
} CONNECTION_LISTENER_CALLBACKS, *PCONNECTION_LISTENER_CALLBACKS;
|
||||||
|
|
||||||
// Use this function to zero the connection callbacks when allocated on the stack or heap
|
// Use this function to zero the connection callbacks when allocated on the stack or heap
|
||||||
void LiInitializeConnectionCallbacks(PCONNECTION_LISTENER_CALLBACKS clCallbacks);
|
void LiInitializeConnectionCallbacks(PCONNECTION_LISTENER_CALLBACKS clCallbacks);
|
||||||
|
|
||||||
// This function begins streaming.
|
// This function begins streaming.
|
||||||
//
|
//
|
||||||
// Callbacks are all optional. Pass NULL for individual callbacks within each struct or pass NULL for the entire struct
|
// Callbacks are all optional. Pass NULL for individual callbacks within each struct or pass NULL for the entire struct
|
||||||
// to use the defaults for all callbacks.
|
// to use the defaults for all callbacks.
|
||||||
//
|
//
|
||||||
// _serverMajorVersion is the major version number of the 'appversion' tag in the /serverinfo request
|
// _serverMajorVersion is the major version number of the 'appversion' tag in the /serverinfo request
|
||||||
//
|
//
|
||||||
int LiStartConnection(const char* host, PSTREAM_CONFIGURATION streamConfig, PCONNECTION_LISTENER_CALLBACKS clCallbacks,
|
int LiStartConnection(const char* host, PSTREAM_CONFIGURATION streamConfig, PCONNECTION_LISTENER_CALLBACKS clCallbacks,
|
||||||
PDECODER_RENDERER_CALLBACKS drCallbacks, PAUDIO_RENDERER_CALLBACKS arCallbacks, void* renderContext, int drFlags, int _serverMajorVersion);
|
PDECODER_RENDERER_CALLBACKS drCallbacks, PAUDIO_RENDERER_CALLBACKS arCallbacks, void* renderContext, int drFlags, int _serverMajorVersion);
|
||||||
|
|
||||||
// This function stops streaming.
|
// This function stops streaming.
|
||||||
void LiStopConnection(void);
|
void LiStopConnection(void);
|
||||||
|
|
||||||
// Use to get a user-visible string to display initialization progress
|
// Use to get a user-visible string to display initialization progress
|
||||||
// from the integer passed to the ConnListenerStageXXX callbacks
|
// from the integer passed to the ConnListenerStageXXX callbacks
|
||||||
const char* LiGetStageName(int stage);
|
const char* LiGetStageName(int stage);
|
||||||
|
|
||||||
// This function queues a mouse move event to be sent to the remote server.
|
// This function queues a mouse move event to be sent to the remote server.
|
||||||
int LiSendMouseMoveEvent(short deltaX, short deltaY);
|
int LiSendMouseMoveEvent(short deltaX, short deltaY);
|
||||||
|
|
||||||
// This function queues a mouse button event to be sent to the remote server.
|
// This function queues a mouse button event to be sent to the remote server.
|
||||||
#define BUTTON_ACTION_PRESS 0x07
|
#define BUTTON_ACTION_PRESS 0x07
|
||||||
#define BUTTON_ACTION_RELEASE 0x08
|
#define BUTTON_ACTION_RELEASE 0x08
|
||||||
#define BUTTON_LEFT 0x01
|
#define BUTTON_LEFT 0x01
|
||||||
#define BUTTON_MIDDLE 0x02
|
#define BUTTON_MIDDLE 0x02
|
||||||
#define BUTTON_RIGHT 0x03
|
#define BUTTON_RIGHT 0x03
|
||||||
int LiSendMouseButtonEvent(char action, int button);
|
int LiSendMouseButtonEvent(char action, int button);
|
||||||
|
|
||||||
// This function queues a keyboard event to be sent to the remote server.
|
// This function queues a keyboard event to be sent to the remote server.
|
||||||
#define KEY_ACTION_DOWN 0x03
|
#define KEY_ACTION_DOWN 0x03
|
||||||
#define KEY_ACTION_UP 0x04
|
#define KEY_ACTION_UP 0x04
|
||||||
#define MODIFIER_SHIFT 0x01
|
#define MODIFIER_SHIFT 0x01
|
||||||
#define MODIFIER_CTRL 0x02
|
#define MODIFIER_CTRL 0x02
|
||||||
#define MODIFIER_ALT 0x04
|
#define MODIFIER_ALT 0x04
|
||||||
int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers);
|
int LiSendKeyboardEvent(short keyCode, char keyAction, char modifiers);
|
||||||
|
|
||||||
// Button flags
|
// Button flags
|
||||||
#define A_FLAG 0x1000
|
#define A_FLAG 0x1000
|
||||||
#define B_FLAG 0x2000
|
#define B_FLAG 0x2000
|
||||||
#define X_FLAG 0x4000
|
#define X_FLAG 0x4000
|
||||||
@ -257,18 +257,18 @@ extern "C" {
|
|||||||
|
|
||||||
// This function queues a controller event to be sent to the remote server. It will
|
// This function queues a controller event to be sent to the remote server. It will
|
||||||
// be seen by the computer as the first controller.
|
// be seen by the computer as the first controller.
|
||||||
int LiSendControllerEvent(short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
|
int LiSendControllerEvent(short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
|
||||||
short leftStickX, short leftStickY, short rightStickX, short rightStickY);
|
short leftStickX, short leftStickY, short rightStickX, short rightStickY);
|
||||||
|
|
||||||
// This function queues a controller event to be sent to the remote server. The controllerNumber
|
// This function queues a controller event to be sent to the remote server. The controllerNumber
|
||||||
// parameter is a zero-based index of which controller this event corresponds to. The largest legal
|
// parameter is a zero-based index of which controller this event corresponds to. The largest legal
|
||||||
// controller number is 3 (for a total of 4 controllers, the Xinput maximum). On generation 3 servers (GFE 2.1.x),
|
// controller number is 3 (for a total of 4 controllers, the Xinput maximum). On generation 3 servers (GFE 2.1.x),
|
||||||
// these will be sent as controller 0 regardless of the controllerNumber parameter.
|
// these will be sent as controller 0 regardless of the controllerNumber parameter.
|
||||||
int LiSendMultiControllerEvent(short controllerNumber, short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
|
int LiSendMultiControllerEvent(short controllerNumber, short buttonFlags, unsigned char leftTrigger, unsigned char rightTrigger,
|
||||||
short leftStickX, short leftStickY, short rightStickX, short rightStickY);
|
short leftStickX, short leftStickY, short rightStickX, short rightStickY);
|
||||||
|
|
||||||
// This function queues a vertical scroll event to the remote server.
|
// This function queues a vertical scroll event to the remote server.
|
||||||
int LiSendScrollEvent(signed char scrollClicks);
|
int LiSendScrollEvent(signed char scrollClicks);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user