diff --git a/libgamestream/client.c b/libgamestream/client.c index 4e7410f..2160199 100644 --- a/libgamestream/client.c +++ b/libgamestream/client.c @@ -170,6 +170,8 @@ static int load_server_status(PSERVER_DATA server) { char *currentGameText = NULL; char *versionText = NULL; char *stateText = NULL; + char *heightText = NULL; + char *serverCodecModeSupportText = NULL; uuid_t uuid; char uuid_str[37]; @@ -203,8 +205,15 @@ static int load_server_status(PSERVER_DATA server) { if (xml_search(data->memory, data->size, "state", &stateText) != GS_OK) goto cleanup; + if (xml_search(data->memory, data->size, "Height", &heightText) != GS_OK) + goto cleanup; + + if (xml_search(data->memory, data->size, "ServerCodecModeSupport", &serverCodecModeSupportText) != GS_OK) + goto cleanup; + server->paired = pairedText != NULL && strcmp(pairedText, "1") == 0; server->currentGame = currentGameText == NULL ? 0 : atoi(currentGameText); + server->supports4K = heightText != NULL && serverCodecModeSupportText != NULL && atoi(heightText) >= 2160; char *versionSep = strstr(versionText, "."); if (versionSep != NULL) { *versionSep = 0; @@ -231,6 +240,12 @@ static int load_server_status(PSERVER_DATA server) { if (versionText != NULL) free(versionText); + if (heightText != NULL) + free(heightText); + + if (serverCodecModeSupportText != NULL) + free(serverCodecModeSupportText); + return ret; } @@ -445,6 +460,9 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b uuid_t uuid; char uuid_str[37]; + if (config->height >= 2160 && !server->supports4K) + return GS_NOT_SUPPORTED_4K; + RAND_bytes(config->remoteInputAesKey, 16); memset(config->remoteInputAesIv, 0, 16); diff --git a/libgamestream/client.h b/libgamestream/client.h index 2d5706d..826a6c9 100644 --- a/libgamestream/client.h +++ b/libgamestream/client.h @@ -28,6 +28,7 @@ typedef struct _SERVER_DATA { const char* address; bool paired; + bool supports4K; int currentGame; int serverMajorVersion; } SERVER_DATA, *PSERVER_DATA; diff --git a/libgamestream/errors.h b/libgamestream/errors.h index a68510c..441aea3 100644 --- a/libgamestream/errors.h +++ b/libgamestream/errors.h @@ -25,5 +25,6 @@ #define GS_INVALID -3 #define GS_WRONG_STATE -4 #define GS_IO_ERROR -5 +#define GS_NOT_SUPPORTED_4K -6 const char* gs_error; diff --git a/src/main.c b/src/main.c index 7ad9ac5..7459cf0 100644 --- a/src/main.c +++ b/src/main.c @@ -83,7 +83,14 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys exit(-1); } - gs_start_app(server, &config->stream, appId, config->sops, config->localaudio); + int ret = gs_start_app(server, &config->stream, appId, config->sops, config->localaudio); + if (ret < 0) { + if (ret == GS_NOT_SUPPORTED_4K) + fprintf(stderr, "Server doesn't support 4K\n"); + else + fprintf(stderr, "Errorcode starting app: %d\n", ret); + exit(-1); + } int drFlags = 0; if (config->fullscreen)