mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-01 23:35:47 +00:00
Add debug option to show http traffic
This commit is contained in:
parent
b0660e9dd3
commit
cbf31be73b
@ -145,6 +145,10 @@ Try streaming if GFE version is unsupported
|
|||||||
|
|
||||||
Enable verbose output
|
Enable verbose output
|
||||||
|
|
||||||
|
=item B<-debug>
|
||||||
|
|
||||||
|
Enable verbose and debug output
|
||||||
|
|
||||||
=item B<-input> [I<INPUT>]
|
=item B<-input> [I<INPUT>]
|
||||||
|
|
||||||
Enable the I<INPUT> device.
|
Enable the I<INPUT> device.
|
||||||
|
@ -727,7 +727,7 @@ int gs_quit_app(PSERVER_DATA server) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory) {
|
int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory, int log_level) {
|
||||||
mkdirtree(keyDirectory);
|
mkdirtree(keyDirectory);
|
||||||
if (load_unique_id(keyDirectory) != GS_OK)
|
if (load_unique_id(keyDirectory) != GS_OK)
|
||||||
return GS_FAILED;
|
return GS_FAILED;
|
||||||
@ -735,7 +735,7 @@ int gs_init(PSERVER_DATA server, char *address, const char *keyDirectory) {
|
|||||||
if (load_cert(keyDirectory))
|
if (load_cert(keyDirectory))
|
||||||
return GS_FAILED;
|
return GS_FAILED;
|
||||||
|
|
||||||
http_init(keyDirectory);
|
http_init(keyDirectory, log_level);
|
||||||
|
|
||||||
LiInitializeServerInformation(&server->serverInfo);
|
LiInitializeServerInformation(&server->serverInfo);
|
||||||
server->serverInfo.address = address;
|
server->serverInfo.address = address;
|
||||||
|
@ -40,7 +40,7 @@ typedef struct _SERVER_DATA {
|
|||||||
SERVER_INFORMATION serverInfo;
|
SERVER_INFORMATION serverInfo;
|
||||||
} SERVER_DATA, *PSERVER_DATA;
|
} SERVER_DATA, *PSERVER_DATA;
|
||||||
|
|
||||||
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory);
|
int gs_init(PSERVER_DATA server, char* address, const char *keyDirectory, int logLevel);
|
||||||
int gs_start_app(PSERVER_DATA server, PSTREAM_CONFIGURATION config, int appId, bool sops, bool localaudio);
|
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_applist(PSERVER_DATA server, PAPP_LIST *app_list);
|
||||||
int gs_unpair(PSERVER_DATA server);
|
int gs_unpair(PSERVER_DATA server);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ static CURL *curl;
|
|||||||
static const char *pCertFile = "./client.pem";
|
static const char *pCertFile = "./client.pem";
|
||||||
static const char *pKeyFile = "./key.pem";
|
static const char *pKeyFile = "./key.pem";
|
||||||
|
|
||||||
|
static bool debug;
|
||||||
|
|
||||||
static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp)
|
static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp)
|
||||||
{
|
{
|
||||||
size_t realsize = size * nmemb;
|
size_t realsize = size * nmemb;
|
||||||
@ -44,8 +47,9 @@ static size_t _write_curl(void *contents, size_t size, size_t nmemb, void *userp
|
|||||||
return realsize;
|
return realsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int http_init(const char* keyDirectory) {
|
int http_init(const char* keyDirectory, int logLevel) {
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
|
debug = logLevel >= 2;
|
||||||
if (!curl)
|
if (!curl)
|
||||||
return GS_FAILED;
|
return GS_FAILED;
|
||||||
|
|
||||||
@ -73,6 +77,9 @@ int http_request(char* url, PHTTP_DATA data) {
|
|||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, data);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
printf("Request %s\n", url);
|
||||||
|
|
||||||
if (data->size > 0) {
|
if (data->size > 0) {
|
||||||
free(data->memory);
|
free(data->memory);
|
||||||
data->memory = malloc(1);
|
data->memory = malloc(1);
|
||||||
@ -90,6 +97,9 @@ int http_request(char* url, PHTTP_DATA data) {
|
|||||||
return GS_OUT_OF_MEMORY;
|
return GS_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
printf("Response:\n%s\n\n", data->memory);
|
||||||
|
|
||||||
return GS_OK;
|
return GS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ typedef struct _HTTP_DATA {
|
|||||||
size_t size;
|
size_t size;
|
||||||
} HTTP_DATA, *PHTTP_DATA;
|
} HTTP_DATA, *PHTTP_DATA;
|
||||||
|
|
||||||
int http_init(const char* keyDirectory);
|
int http_init(const char* keyDirectory, int logLevel);
|
||||||
PHTTP_DATA http_create_data();
|
PHTTP_DATA http_create_data();
|
||||||
int http_request(char* url, PHTTP_DATA data);
|
int http_request(char* url, PHTTP_DATA data);
|
||||||
void http_free_data(PHTTP_DATA data);
|
void http_free_data(PHTTP_DATA data);
|
||||||
|
@ -64,6 +64,7 @@ static struct option long_options[] = {
|
|||||||
{"codec", required_argument, NULL, 'x'},
|
{"codec", required_argument, NULL, 'x'},
|
||||||
{"unsupported", no_argument, NULL, 'y'},
|
{"unsupported", no_argument, NULL, 'y'},
|
||||||
{"verbose", no_argument, NULL, 'z'},
|
{"verbose", no_argument, NULL, 'z'},
|
||||||
|
{"debug", no_argument, NULL, 'Z'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -207,6 +208,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
|||||||
case 'z':
|
case 'z':
|
||||||
config->debug_level = 1;
|
config->debug_level = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'Z':
|
||||||
|
config->debug_level = 2;
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (config->action == NULL)
|
if (config->action == NULL)
|
||||||
config->action = value;
|
config->action = value;
|
||||||
|
@ -142,6 +142,7 @@ static void help() {
|
|||||||
printf("\t-config <config>\tLoad configuration file\n");
|
printf("\t-config <config>\tLoad configuration file\n");
|
||||||
printf("\t-save <config>\t\tSave configuration file\n");
|
printf("\t-save <config>\t\tSave configuration file\n");
|
||||||
printf("\t-verbose\t\tEnable verbose output\n");
|
printf("\t-verbose\t\tEnable verbose output\n");
|
||||||
|
printf("\t-debug\t\t\tEnable verbose and debug output\n");
|
||||||
printf("\n Streaming options\n\n");
|
printf("\n Streaming options\n\n");
|
||||||
printf("\t-720\t\t\tUse 1280x720 resolution [default]\n");
|
printf("\t-720\t\t\tUse 1280x720 resolution [default]\n");
|
||||||
printf("\t-1080\t\t\tUse 1920x1080 resolution\n");
|
printf("\t-1080\t\t\tUse 1920x1080 resolution\n");
|
||||||
@ -215,7 +216,7 @@ int main(int argc, char* argv[]) {
|
|||||||
printf("Connect to %s...\n", config.address);
|
printf("Connect to %s...\n", config.address);
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
if ((ret = gs_init(&server, config.address, config.key_dir)) == GS_OUT_OF_MEMORY) {
|
if ((ret = gs_init(&server, config.address, config.key_dir, config.debug_level)) == GS_OUT_OF_MEMORY) {
|
||||||
fprintf(stderr, "Not enough memory\n");
|
fprintf(stderr, "Not enough memory\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else if (ret == GS_INVALID) {
|
} else if (ret == GS_INVALID) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user