mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-06-30 23:05:43 +00:00
Update moonlight-common-c with Sunshine extensions
This commit is contained in:
parent
606e6d1181
commit
ab53f149f2
@ -99,9 +99,9 @@ By default, 1392 is used on LAN and 1024 on WAN.
|
|||||||
=item B<-codec> [I<CODEC>]
|
=item B<-codec> [I<CODEC>]
|
||||||
|
|
||||||
Select codec to use.
|
Select codec to use.
|
||||||
Can be 'auto', 'h264', 'h265' or 'hevc'.
|
Can be 'auto', 'h264', 'h265', 'hevc', or 'av1'.
|
||||||
Not all video decoders do support H.265/HEVC.
|
Not all video decoders support H.265/HEVC or AV1.
|
||||||
Will still use H.264 if server doesn't support HEVC.
|
Will still use H.264 if server doesn't support HEVC or AV1.
|
||||||
|
|
||||||
=item B<-remote> [I<yes/no/auto>]
|
=item B<-remote> [I<yes/no/auto>]
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ static int load_serverinfo(PSERVER_DATA server, bool https) {
|
|||||||
|
|
||||||
server->paired = pairedText != NULL && strcmp(pairedText, "1") == 0;
|
server->paired = pairedText != NULL && strcmp(pairedText, "1") == 0;
|
||||||
server->currentGame = currentGameText == NULL ? 0 : atoi(currentGameText);
|
server->currentGame = currentGameText == NULL ? 0 : atoi(currentGameText);
|
||||||
server->supports4K = serverCodecModeSupportText != NULL;
|
server->serverInfo.serverCodecModeSupport = serverCodecModeSupportText == NULL ? SCM_H264 : atoi(serverCodecModeSupportText);
|
||||||
server->serverMajorVersion = atoi(server->serverInfo.serverInfoAppVersion);
|
server->serverMajorVersion = atoi(server->serverInfo.serverInfoAppVersion);
|
||||||
server->isNvidiaSoftware = strstr(stateText, "MJOLNIR") != NULL;
|
server->isNvidiaSoftware = strstr(stateText, "MJOLNIR") != NULL;
|
||||||
|
|
||||||
@ -714,9 +714,6 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b
|
|||||||
if (!correct_mode && !server->unsupported)
|
if (!correct_mode && !server->unsupported)
|
||||||
return GS_NOT_SUPPORTED_MODE;
|
return GS_NOT_SUPPORTED_MODE;
|
||||||
|
|
||||||
if (config->height >= 2160 && !server->supports4K)
|
|
||||||
return GS_NOT_SUPPORTED_4K;
|
|
||||||
|
|
||||||
RAND_bytes(config->remoteInputAesKey, sizeof(config->remoteInputAesKey));
|
RAND_bytes(config->remoteInputAesKey, sizeof(config->remoteInputAesKey));
|
||||||
memset(config->remoteInputAesIv, 0, sizeof(config->remoteInputAesIv));
|
memset(config->remoteInputAesIv, 0, sizeof(config->remoteInputAesIv));
|
||||||
|
|
||||||
@ -743,7 +740,7 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b
|
|||||||
int surround_info = SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(config->audioConfiguration);
|
int surround_info = SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(config->audioConfiguration);
|
||||||
snprintf(url, sizeof(url), "https://%s:%u/%s?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d%s",
|
snprintf(url, sizeof(url), "https://%s:%u/%s?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d%s",
|
||||||
server->serverInfo.address, server->httpsPort, server->currentGame ? "resume" : "launch", unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask,
|
server->serverInfo.address, server->httpsPort, server->currentGame ? "resume" : "launch", unique_id, uuid_str, appId, config->width, config->height, fps, sops, rikey_hex, rikeyid, localaudio, surround_info, gamepad_mask, gamepad_mask,
|
||||||
config->enableHdr ? "&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" : "");
|
(config->supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT) ? "&hdrMode=1&clientHdrCapVersion=0&clientHdrCapSupportedFlagsInUint32=0&clientHdrCapMetaDataId=NV_STATIC_METADATA_TYPE_1&clientHdrCapDisplayData=0x0x0x0x0x0x0x0x0x0x0" : "");
|
||||||
if ((ret = http_request(url, data)) == GS_OK)
|
if ((ret = http_request(url, data)) == GS_OK)
|
||||||
server->currentGame = appId;
|
server->currentGame = appId;
|
||||||
else
|
else
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
typedef struct _SERVER_DATA {
|
typedef struct _SERVER_DATA {
|
||||||
char* gpuType;
|
char* gpuType;
|
||||||
bool paired;
|
bool paired;
|
||||||
bool supports4K;
|
|
||||||
bool unsupported;
|
bool unsupported;
|
||||||
bool isNvidiaSoftware;
|
bool isNvidiaSoftware;
|
||||||
int currentGame;
|
int currentGame;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -225,6 +226,8 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
|||||||
config->codec = CODEC_H264;
|
config->codec = CODEC_H264;
|
||||||
else if (strcasecmp(value, "h265") == 0 || strcasecmp(value, "hevc") == 0)
|
else if (strcasecmp(value, "h265") == 0 || strcasecmp(value, "hevc") == 0)
|
||||||
config->codec = CODEC_HEVC;
|
config->codec = CODEC_HEVC;
|
||||||
|
else if (strcasecmp(value, "av1") == 0)
|
||||||
|
config->codec = CODEC_AV1;
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
config->unsupported = false;
|
config->unsupported = false;
|
||||||
@ -254,7 +257,7 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
|||||||
config->port = atoi(value);
|
config->port = atoi(value);
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
config->stream.enableHdr = true;
|
config->hdr = true;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (config->action == NULL)
|
if (config->action == NULL)
|
||||||
@ -344,8 +347,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
|||||||
config->stream.packetSize = 1392;
|
config->stream.packetSize = 1392;
|
||||||
config->stream.streamingRemotely = STREAM_CFG_AUTO;
|
config->stream.streamingRemotely = STREAM_CFG_AUTO;
|
||||||
config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
|
||||||
config->stream.supportsHevc = false;
|
config->stream.supportedVideoFormats = SCM_H264;
|
||||||
config->stream.enableHdr = false;
|
|
||||||
config->stream.encryptionFlags = ENCFLG_AUDIO;
|
config->stream.encryptionFlags = ENCFLG_AUDIO;
|
||||||
|
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
@ -377,6 +379,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
|||||||
config->mouse_emulation = true;
|
config->mouse_emulation = true;
|
||||||
config->rotate = 0;
|
config->rotate = 0;
|
||||||
config->codec = CODEC_UNSPECIFIED;
|
config->codec = CODEC_UNSPECIFIED;
|
||||||
|
config->hdr = false;
|
||||||
config->pin = 0;
|
config->pin = 0;
|
||||||
config->port = 47989;
|
config->port = 47989;
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#define MAX_INPUTS 6
|
#define MAX_INPUTS 6
|
||||||
|
|
||||||
enum codecs { CODEC_UNSPECIFIED, CODEC_H264, CODEC_HEVC };
|
|
||||||
|
|
||||||
typedef struct _CONFIGURATION {
|
typedef struct _CONFIGURATION {
|
||||||
STREAM_CONFIGURATION stream;
|
STREAM_CONFIGURATION stream;
|
||||||
int debug_level;
|
int debug_level;
|
||||||
@ -47,6 +45,7 @@ typedef struct _CONFIGURATION {
|
|||||||
char* inputs[MAX_INPUTS];
|
char* inputs[MAX_INPUTS];
|
||||||
int inputsCount;
|
int inputsCount;
|
||||||
enum codecs codec;
|
enum codecs codec;
|
||||||
|
bool hdr;
|
||||||
int pin;
|
int pin;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
} CONFIGURATION, *PCONFIGURATION;
|
} CONFIGURATION, *PCONFIGURATION;
|
||||||
|
24
src/main.c
24
src/main.c
@ -20,8 +20,8 @@
|
|||||||
#include "loop.h"
|
#include "loop.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "config.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "config.h"
|
||||||
#include "sdl.h"
|
#include "sdl.h"
|
||||||
|
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
@ -96,7 +96,7 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
|
|||||||
gamepads += sdl_gamepads;
|
gamepads += sdl_gamepads;
|
||||||
#endif
|
#endif
|
||||||
int gamepad_mask = 0;
|
int gamepad_mask = 0;
|
||||||
for (int i = 0; i < gamepads && i < 4; i++)
|
for (int i = 0; i < gamepads; i++)
|
||||||
gamepad_mask = (gamepad_mask << 1) + 1;
|
gamepad_mask = (gamepad_mask << 1) + 1;
|
||||||
|
|
||||||
int ret = gs_start_app(server, &config->stream, appId, config->sops, config->localaudio, gamepad_mask);
|
int ret = gs_start_app(server, &config->stream, appId, config->sops, config->localaudio, gamepad_mask);
|
||||||
@ -201,7 +201,7 @@ static void help() {
|
|||||||
printf("\t-fps <fps>\t\tSpecify the fps to use (default 60)\n");
|
printf("\t-fps <fps>\t\tSpecify the fps to use (default 60)\n");
|
||||||
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
|
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
|
||||||
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
|
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
|
||||||
printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265 (default auto)\n");
|
printf("\t-codec <codec>\t\tSelect used codec: auto/h264/h265/av1 (default auto)\n");
|
||||||
printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
|
printf("\t-hdr\t\tEnable HDR streaming (experimental, requires host and device support)\n");
|
||||||
printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
|
printf("\t-remote <yes/no/auto>\t\t\tEnable optimizations for WAN streaming (default auto)\n");
|
||||||
printf("\t-app <app>\t\tName of app to stream\n");
|
printf("\t-app <app>\t\tName of app to stream\n");
|
||||||
@ -316,9 +316,21 @@ int main(int argc, char* argv[]) {
|
|||||||
fprintf(stderr, "You can't select a audio device for SDL\n");
|
fprintf(stderr, "You can't select a audio device for SDL\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
config.stream.supportsHevc = config.codec != CODEC_H264 && (config.codec == CODEC_HEVC || platform_supports_hevc(system));
|
|
||||||
if (config.stream.enableHdr && !config.stream.supportsHevc) {
|
config.stream.supportedVideoFormats = SCM_H264;
|
||||||
fprintf(stderr, "HDR streaming requires HEVC codec\n");
|
if (config.codec == CODEC_HEVC || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, config.codec))) {
|
||||||
|
config.stream.supportedVideoFormats |= SCM_HEVC;
|
||||||
|
if (config.hdr)
|
||||||
|
config.stream.supportedVideoFormats |= SCM_HEVC_MAIN10;
|
||||||
|
}
|
||||||
|
if (config.codec == CODEC_AV1 || (config.codec == CODEC_UNSPECIFIED && platform_prefers_codec(system, config.codec))) {
|
||||||
|
config.stream.supportedVideoFormats |= SCM_AV1_MAIN8;
|
||||||
|
if (config.hdr)
|
||||||
|
config.stream.supportedVideoFormats |= SCM_AV1_MAIN10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.hdr && !(config.stream.supportedVideoFormats & VIDEO_FORMAT_MASK_10BIT)) {
|
||||||
|
fprintf(stderr, "HDR streaming requires HEVC or AV1 codec\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,13 +206,22 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system, char* audio_d
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool platform_supports_hevc(enum platform system) {
|
bool platform_prefers_codec(enum platform system, enum codecs codec) {
|
||||||
switch (system) {
|
switch (codec) {
|
||||||
case AML:
|
case CODEC_H264:
|
||||||
case RK:
|
// H.264 is always supported
|
||||||
case X11_VAAPI:
|
|
||||||
case X11_VDPAU:
|
|
||||||
return true;
|
return true;
|
||||||
|
case CODEC_HEVC:
|
||||||
|
switch (system) {
|
||||||
|
case AML:
|
||||||
|
case RK:
|
||||||
|
case X11_VAAPI:
|
||||||
|
case X11_VDPAU:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case CODEC_AV1:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,12 @@
|
|||||||
#define IS_EMBEDDED(SYSTEM) SYSTEM != SDL
|
#define IS_EMBEDDED(SYSTEM) SYSTEM != SDL
|
||||||
|
|
||||||
enum platform { NONE, SDL, X11, X11_VDPAU, X11_VAAPI, PI, MMAL, IMX, AML, RK, FAKE };
|
enum platform { NONE, SDL, X11, X11_VDPAU, X11_VAAPI, PI, MMAL, IMX, AML, RK, FAKE };
|
||||||
|
enum codecs { CODEC_UNSPECIFIED, CODEC_H264, CODEC_HEVC, CODEC_AV1 };
|
||||||
|
|
||||||
enum platform platform_check(char*);
|
enum platform platform_check(char*);
|
||||||
PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
|
PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
|
||||||
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system, char* audio_device);
|
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system, char* audio_device);
|
||||||
bool platform_supports_hevc(enum platform system);
|
bool platform_prefers_codec(enum platform system, enum codecs codec);
|
||||||
char* platform_name(enum platform system);
|
char* platform_name(enum platform system);
|
||||||
|
|
||||||
void platform_start(enum platform system);
|
void platform_start(enum platform system);
|
||||||
|
2
third_party/moonlight-common-c
vendored
2
third_party/moonlight-common-c
vendored
@ -1 +1 @@
|
|||||||
Subproject commit c9426a6a71c4162e65dde8c0c71a25f1dbca46ba
|
Subproject commit 2bb026c763fc18807d7e4a93f918054c488f84e1
|
Loading…
x
Reference in New Issue
Block a user