Skip to content

Commit

Permalink
Merge pull request #39 from d3m3vilurr/update-modules
Browse files Browse the repository at this point in the history
This patch will fix lots of report about GFE3.x, sockets, and etc.

close #10 
close #12 
close #15 
close #17 
close #20 
close #29 
close #32 
close #33 
close #38

now new build require to update openssl, curl, newlib for vita and to update all submoduels (enet, moonlight-common-c repos changed to upstream tree)
  • Loading branch information
d3m3vilurr authored Oct 9, 2016
2 parents 3994286 + f903ce6 commit bd019a8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "common"]
path = third_party/moonlight-common-c
url = https://github.com/xyzz/moonlight-common-c.git
url = https://github.com/moonlight-stream/moonlight-common-c.git
[submodule "third_party/enet"]
path = third_party/enet
url = https://github.com/xyzz/vita-enet.git
url = https://github.com/cgutman/enet.git
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a vita port.

## OpenSSL

https://github.com/xyzz/vita-openssl branch `vita-1_0_2`
https://github.com/d3m3vilurr/vita-openssl branch `vita-1_0_2`

```
./Configure no-threads --prefix=$VITASDK/arm-vita-eabi/ vita-cross
Expand All @@ -17,12 +17,12 @@ make install

## curl

https://github.com/xyzz/vita-curl branch `vita`
https://github.com/d3m3vilurr/vita-curl branch `vita`


```
./buildconf
./configure --host=arm-vita-eabi --with-ssl=$VITASDK/arm-vita-eabi/ --disable-shared --disable-ftp --disable-ldap --disable-imap --disable-ipv6 --disable-rtsp --disable-dict --disable-file --disable-gopher --disable-pop3 --disable-smtp --disable-telnet --disable-tftp --enable-https --disable-smb --disable-smbs --prefix=$VITASDK/arm-vita-eabi/
cp lib/config-vita.h lib/curl_config.h
make -j8
make install
```
Expand Down
40 changes: 20 additions & 20 deletions libgamestream/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ static int load_server_status(PSERVER_DATA server) {
do {
char *pairedText = NULL;
char *currentGameText = NULL;
char *versionText = NULL;
char *stateText = NULL;
char *heightText = NULL;
char *serverCodecModeSupportText = NULL;
Expand All @@ -199,7 +198,7 @@ static int load_server_status(PSERVER_DATA server) {
// make another request over HTTP if the HTTPS request fails. We can't just use HTTP
// for everything because it doesn't accurately tell us if we're paired.
sprintf(url, "%s://%s:%d/serverinfo?uniqueid=%s&uuid=%s",
i == 0 ? "https" : "http", server->address, i == 0 ? 47984 : 47989, unique_id, uuid_str);
i == 0 ? "https" : "http", server->serverInfo.address, i == 0 ? 47984 : 47989, unique_id, uuid_str);

PHTTP_DATA data = http_create_data();
if (data == NULL) {
Expand All @@ -218,7 +217,7 @@ static int load_server_status(PSERVER_DATA server) {
if (xml_search(data->memory, data->size, "PairStatus", &pairedText) != GS_OK)
goto cleanup;

if (xml_search(data->memory, data->size, "appversion", &versionText) != GS_OK)
if (xml_search(data->memory, data->size, "appversion", (char**) &server->serverInfo.serverInfoAppVersion) != GS_OK)
goto cleanup;

if (xml_search(data->memory, data->size, "state", &stateText) != GS_OK)
Expand All @@ -233,17 +232,18 @@ static int load_server_status(PSERVER_DATA server) {
if (xml_search(data->memory, data->size, "gputype", &server->gpuType) != GS_OK)
goto cleanup;

if (xml_search(data->memory, data->size, "GfeVersion", &server->gfeVersion) != GS_OK)
if (xml_search(data->memory, data->size, "GfeVersion", (char**) &server->serverInfo.serverInfoGfeVersion) != GS_OK)
goto cleanup;

// These fields are present on all version of GFE that this client supports
if (!strlen(currentGameText) || !strlen(pairedText) || !strlen(versionText) || !strlen(stateText))
if (!strlen(currentGameText) || !strlen(pairedText) || !strlen(server->serverInfo.serverInfoAppVersion) || !strlen(stateText))
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;
server->serverMajorVersion = atoi(versionText);
server->serverMajorVersion = atoi(server->serverInfo.serverInfoAppVersion);

if (strstr(stateText, "_SERVER_AVAILABLE")) {
// After GFE 2.8, current game remains set even after streaming
// has ended. We emulate the old behavior by forcing it to zero
Expand All @@ -262,9 +262,6 @@ static int load_server_status(PSERVER_DATA server) {
if (currentGameText != NULL)
free(currentGameText);

if (versionText != NULL)
free(versionText);

if (heightText != NULL)
free(heightText);

Expand Down Expand Up @@ -384,7 +381,7 @@ int gs_unpair(PSERVER_DATA server) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "http://%s:47989/unpair?uniqueid=%s&uuid=%s", server->address, unique_id, uuid_str);
sprintf(url, "http://%s:47989/unpair?uniqueid=%s&uuid=%s", server->serverInfo.address, unique_id, uuid_str);
ret = http_request(url, data);

http_free_data(data);
Expand Down Expand Up @@ -415,7 +412,7 @@ int gs_pair(PSERVER_DATA server, char* pin) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&phrase=getservercert&salt=%s&clientcert=%s", server->address, unique_id, uuid_str, salt_hex, cert_hex);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&phrase=getservercert&salt=%s&clientcert=%s", server->serverInfo.address, unique_id, uuid_str, salt_hex, cert_hex);
PHTTP_DATA data = http_create_data();
if (data == NULL)
return GS_OUT_OF_MEMORY;
Expand Down Expand Up @@ -473,7 +470,7 @@ int gs_pair(PSERVER_DATA server, char* pin) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&clientchallenge=%s", server->address, unique_id, uuid_str, challenge_hex);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&clientchallenge=%s", server->serverInfo.address, unique_id, uuid_str, challenge_hex);
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;

Expand Down Expand Up @@ -527,7 +524,7 @@ int gs_pair(PSERVER_DATA server, char* pin) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&serverchallengeresp=%s", server->address, unique_id, uuid_str, challenge_response_hex);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&serverchallengeresp=%s", server->serverInfo.address, unique_id, uuid_str, challenge_response_hex);
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;

Expand Down Expand Up @@ -576,7 +573,7 @@ int gs_pair(PSERVER_DATA server, char* pin) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&clientpairingsecret=%s", server->address, unique_id, uuid_str, client_pairing_secret_hex);
sprintf(url, "http://%s:47989/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&clientpairingsecret=%s", server->serverInfo.address, unique_id, uuid_str, client_pairing_secret_hex);
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;

Expand All @@ -593,7 +590,7 @@ int gs_pair(PSERVER_DATA server, char* pin) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "https://%s:47984/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&phrase=pairchallenge", server->address, unique_id, uuid_str);
sprintf(url, "https://%s:47984/pair?uniqueid=%s&uuid=%s&devicename=roth&updateState=1&phrase=pairchallenge", server->serverInfo.address, unique_id, uuid_str);
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;

Expand Down Expand Up @@ -633,7 +630,7 @@ int gs_applist(PSERVER_DATA server, PAPP_LIST *list) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "https://%s:47984/applist?uniqueid=%s&uuid=%s", server->address, unique_id, uuid_str);
sprintf(url, "https://%s:47984/applist?uniqueid=%s&uuid=%s", server->serverInfo.address, unique_id, uuid_str);
if (http_request(url, data) != GS_OK)
ret = GS_IO_ERROR;
else if (xml_applist(data->memory, data->size, list) != GS_OK)
Expand Down Expand Up @@ -672,9 +669,9 @@ int gs_start_app(PSERVER_DATA server, STREAM_CONFIGURATION *config, int appId, b
if (server->currentGame == 0) {
int channelCounnt = config->audioConfiguration == AUDIO_CONFIGURATION_STEREO ? CHANNEL_COUNT_STEREO : CHANNEL_COUNT_51_SURROUND;
int mask = config->audioConfiguration == AUDIO_CONFIGURATION_STEREO ? CHANNEL_MASK_STEREO : CHANNEL_MASK_51_SURROUND;
sprintf(url, "https://%s:47984/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d", server->address, unique_id, uuid_str, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid, localaudio, (mask << 16) + channelCounnt);
sprintf(url, "https://%s:47984/launch?uniqueid=%s&uuid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d&surroundAudioInfo=%d", server->serverInfo.address, unique_id, uuid_str, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid, localaudio, (mask << 16) + channelCounnt);
} else
sprintf(url, "https://%s:47984/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d", server->address, unique_id, uuid_str, rikey_hex, rikeyid);
sprintf(url, "https://%s:47984/resume?uniqueid=%s&uuid=%s&rikey=%s&rikeyid=%d", server->serverInfo.address, unique_id, uuid_str, rikey_hex, rikeyid);

if ((ret = http_request(url, data)) == GS_OK)
server->currentGame = appId;
Expand Down Expand Up @@ -710,7 +707,7 @@ int gs_quit_app(PSERVER_DATA server) {

uuid_generate_random(uuid);
uuid_unparse(uuid, uuid_str);
sprintf(url, "https://%s:47984/cancel?uniqueid=%s&uuid=%s", server->address, unique_id, uuid_str);
sprintf(url, "https://%s:47984/cancel?uniqueid=%s&uuid=%s", server->serverInfo.address, unique_id, uuid_str);
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;

Expand All @@ -730,7 +727,7 @@ int gs_quit_app(PSERVER_DATA server) {
return ret;
}

int gs_init(PSERVER_DATA server, const char *keyDirectory) {
int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory) {
mkdirtree(keyDirectory);
if (load_unique_id(keyDirectory) != GS_OK)
return GS_FAILED;
Expand All @@ -739,5 +736,8 @@ int gs_init(PSERVER_DATA server, const char *keyDirectory) {
return GS_FAILED;

http_init(keyDirectory);

LiInitializeServerInformation(&server->serverInfo);
server->serverInfo.address = address;
return load_server_status(server);
}
4 changes: 2 additions & 2 deletions libgamestream/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
typedef struct _SERVER_DATA {
const char* address;
char* gpuType;
char* gfeVersion;
bool paired;
bool supports4K;
int currentGame;
int serverMajorVersion;
SERVER_INFORMATION serverInfo;
} SERVER_DATA, *PSERVER_DATA;

int gs_init(PSERVER_DATA server, const char *keyDirectory);
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory);
int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio);
int gs_applist(PSERVER_DATA server, PAPP_LIST *app_list);
int gs_unpair(PSERVER_DATA server);
Expand Down
16 changes: 6 additions & 10 deletions src/gui/ui_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ void ui_connect_stream(PSERVER_DATA server, int appId) {
drFlags |= FORCE_HARDWARE_ACCELERATION;

ret = LiStartConnection(
server->address,
&server->serverInfo,
&config.stream,
&connection_callbacks,
platform_get_video(system),
platform_get_audio(system),
NULL,
drFlags,
server->serverMajorVersion
drFlags
);

if (ret == 0) {
Expand Down Expand Up @@ -185,24 +184,21 @@ int ui_connect_loop(int id, void *context) {

int ui_connect(char *address) {
if (!server_connected) {
server.address = malloc(sizeof(char)*256);
strcpy(server.address, address);

flash_message("Connecting to:\n %s...", server.address);
int ret = gs_init(&server, config.key_dir);
flash_message("Connecting to:\n %s...", address);
int ret = gs_init(&server, address, config.key_dir);
if (ret == GS_OUT_OF_MEMORY) {
display_error("Not enough memory");
return 0;
} else if (ret == GS_INVALID) {
display_error("Invalid data received from server: %s\n", config.address, gs_error);
display_error("Invalid data received from server: %s\n", address, gs_error);
return 0;
} else if (ret == GS_UNSUPPORTED_VERSION) {
if (!config.unsupported_version) {
display_error("Unsupported version: %s\n", gs_error);
return 0;
}
} else if (ret != GS_OK) {
display_error("Can't connect to server\n%s", config.address);
display_error("Can't connect to server\n%s", address);
return 0;
}

Expand Down
6 changes: 1 addition & 5 deletions src/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ bool platform_supports_hevc(enum platform system) {
}

#ifdef __vita__
int shutdown(int s, int how) {
return sceNetShutdown(s, how);
}

int chmod(const char *path, mode_t mode) {
return 0;
}
Expand All @@ -154,4 +150,4 @@ uid_t getgid(void) {
uid_t getegid(void) {
return 1;
}
#endif
#endif
2 changes: 1 addition & 1 deletion third_party/enet
Submodule enet updated 8 files
+4 −29 host.c
+18 −49 include/enet/enet.h
+22 −5 include/enet/vita.h
+1 −0 include/enet/win32.h
+7 −15 protocol.c
+148 −180 unix.c
+112 −214 vita.c
+93 −113 win32.c

0 comments on commit bd019a8

Please sign in to comment.