Add support for custom ports with Sunshine

This commit is contained in:
Cameron Gutman
2022-09-23 22:48:43 -05:00
parent 3f00f25a39
commit 0325a3b88c
7 changed files with 147 additions and 110 deletions

View File

@@ -73,6 +73,7 @@ static struct option long_options[] = {
{"debug", no_argument, NULL, 'Z'},
{"nomouseemulation", no_argument, NULL, '4'},
{"pin", required_argument, NULL, '5'},
{"port", required_argument, NULL, '6'},
{0, 0, 0, 0},
};
@@ -248,6 +249,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
case '5':
config->pin = atoi(value);
break;
case '6':
config->port = atoi(value);
break;
case 1:
if (config->action == NULL)
config->action = value;
@@ -369,6 +373,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
config->rotate = 0;
config->codec = CODEC_UNSPECIFIED;
config->pin = 0;
config->port = 47989;
config->inputsCount = 0;
config->mapping = get_path("gamecontrollerdb.txt", getenv("XDG_DATA_DIRS"));
@@ -386,7 +391,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
} else {
int option_index = 0;
int c;
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s:tu:v:w:xy45:", long_options, &option_index)) != -1) {
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s:tu:v:w:xy45:6:", long_options, &option_index)) != -1) {
parse_argument(c, optarg, config);
}
}

View File

@@ -47,7 +47,8 @@ typedef struct _CONFIGURATION {
char* inputs[MAX_INPUTS];
int inputsCount;
enum codecs codec;
int pin;
int pin;
unsigned short port;
} CONFIGURATION, *PCONFIGURATION;
extern bool inputAdded;

View File

@@ -263,7 +263,7 @@ int main(int argc, char* argv[]) {
}
config.address[0] = 0;
printf("Searching for server...\n");
gs_discover_server(config.address);
gs_discover_server(config.address, &config.port);
if (config.address[0] == 0) {
fprintf(stderr, "Autodiscovery failed. Specify an IP address next time.\n");
exit(-1);
@@ -279,7 +279,7 @@ int main(int argc, char* argv[]) {
printf("Connecting to %s...\n", config.address);
int ret;
if ((ret = gs_init(&server, config.address, config.key_dir, config.debug_level, config.unsupported)) == GS_OUT_OF_MEMORY) {
if ((ret = gs_init(&server, config.address, config.port, config.key_dir, config.debug_level, config.unsupported)) == GS_OUT_OF_MEMORY) {
fprintf(stderr, "Not enough memory\n");
exit(-1);
} else if (ret == GS_ERROR) {