Add verbose option and hide most logging

This commit is contained in:
Iwan Timmer 2017-06-11 18:06:50 +02:00
parent d759cfdf37
commit e06a78130a
7 changed files with 41 additions and 6 deletions

View File

@ -137,6 +137,14 @@ By default the gamecontrollerdb.txt provided by Moonlight Embedded is used.
Select platform for audio and video output and input. Select platform for audio and video output and input.
<PLATFORM> can be pi, imx, aml, x11, x11_vdpau, sdl or fake. <PLATFORM> can be pi, imx, aml, x11, x11_vdpau, sdl or fake.
=item B<-unsupported>
Try streaming if GFE version is unsupported
=item B<-verbose>
Enable verbose output
=item B<-input> [I<INPUT>] =item B<-input> [I<INPUT>]
Enable the I<INPUT> device. Enable the I<INPUT> device.

View File

@ -63,6 +63,7 @@ static struct option long_options[] = {
{"fps", required_argument, NULL, 'v'}, {"fps", required_argument, NULL, 'v'},
{"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'},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
@ -203,6 +204,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
case 'y': case 'y':
config->unsupported_version = true; config->unsupported_version = true;
break; break;
case 'z':
config->debug_level = 1;
break;
case 1: case 1:
if (config->action == NULL) if (config->action == NULL)
config->action = value; config->action = value;
@ -289,6 +293,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO; config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO;
config->stream.supportsHevc = false; config->stream.supportsHevc = false;
config->debug_level = 0;
config->platform = "auto"; config->platform = "auto";
config->app = "Steam"; config->app = "Steam";
config->action = NULL; config->action = NULL;

View File

@ -27,6 +27,7 @@ enum codecs { CODEC_UNSPECIFIED, CODEC_H264, CODEC_HEVC };
typedef struct _CONFIGURATION { typedef struct _CONFIGURATION {
STREAM_CONFIGURATION stream; STREAM_CONFIGURATION stream;
int debug_level;
char* app; char* app;
char* action; char* action;
char* address; char* address;

View File

@ -20,9 +20,11 @@
#include "connection.h" #include "connection.h"
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <signal.h> #include <signal.h>
pthread_t main_thread_id = 0; pthread_t main_thread_id = 0;
bool connection_debug;
static void connection_terminated() { static void connection_terminated() {
if (main_thread_id != 0) if (main_thread_id != 0)
@ -37,6 +39,13 @@ static void connection_display_transient_message(const char *msg) {
printf("%s\n", msg); printf("%s\n", msg);
} }
static void connection_log_message(const char* format, ...) {
va_list arglist;
va_start(arglist, format);
vprintf(format, arglist);
va_end(arglist);
}
CONNECTION_LISTENER_CALLBACKS connection_callbacks = { CONNECTION_LISTENER_CALLBACKS connection_callbacks = {
.stageStarting = NULL, .stageStarting = NULL,
.stageComplete = NULL, .stageComplete = NULL,
@ -45,4 +54,5 @@ CONNECTION_LISTENER_CALLBACKS connection_callbacks = {
.connectionTerminated = connection_terminated, .connectionTerminated = connection_terminated,
.displayMessage = connection_display_message, .displayMessage = connection_display_message,
.displayTransientMessage = connection_display_transient_message, .displayTransientMessage = connection_display_transient_message,
.logMessage = connection_log_message,
}; };

View File

@ -20,6 +20,8 @@
#include <Limelight.h> #include <Limelight.h>
#include <pthread.h> #include <pthread.h>
#include <stdbool.h>
extern CONNECTION_LISTENER_CALLBACKS connection_callbacks; extern CONNECTION_LISTENER_CALLBACKS connection_callbacks;
extern pthread_t main_thread_id; extern pthread_t main_thread_id;
extern bool connection_debug;

View File

@ -105,7 +105,10 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
if (config->fullscreen) if (config->fullscreen)
drFlags |= DISPLAY_FULLSCREEN; drFlags |= DISPLAY_FULLSCREEN;
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate); if (config->debug_level > 0) {
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate);
connection_debug = true;
}
platform_start(system); platform_start(system);
LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0); LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);
@ -125,6 +128,7 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
} }
static void help() { static void help() {
printf("Moonlight Embedded %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
printf("Usage: moonlight [action] (options) [host]\n"); printf("Usage: moonlight [action] (options) [host]\n");
printf(" moonlight [configfile]\n"); printf(" moonlight [configfile]\n");
printf("\n Actions\n\n"); printf("\n Actions\n\n");
@ -137,6 +141,7 @@ static void help() {
printf("\n Global Options\n\n"); printf("\n Global Options\n\n");
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("\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");
@ -177,14 +182,15 @@ static void pair_check(PSERVER_DATA server) {
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
printf("Moonlight Embedded %d.%d.%d (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, COMPILE_OPTIONS);
CONFIGURATION config; CONFIGURATION config;
config_parse(argc, argv, &config); config_parse(argc, argv, &config);
if (config.action == NULL || strcmp("help", config.action) == 0) if (config.action == NULL || strcmp("help", config.action) == 0)
help(); help();
if (config.debug_level > 0)
printf("Moonlight Embedded %d.%d.%d (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, COMPILE_OPTIONS);
if (config.address == NULL) { if (config.address == NULL) {
config.address = malloc(MAX_ADDRESS_SIZE); config.address = malloc(MAX_ADDRESS_SIZE);
if (config.address == NULL) { if (config.address == NULL) {
@ -225,7 +231,8 @@ int main(int argc, char* argv[]) {
exit(-1); exit(-1);
} }
printf("NVIDIA %s, GFE %s (%s, %s)\n", server.gpuType, server.serverInfo.serverInfoGfeVersion, server.gsVersion, server.serverInfo.serverInfoAppVersion); if (config.debug_level > 0)
printf("NVIDIA %s, GFE %s (%s, %s)\n", server.gpuType, server.serverInfo.serverInfoGfeVersion, server.gsVersion, server.serverInfo.serverInfoAppVersion);
if (strcmp("list", config.action) == 0) { if (strcmp("list", config.action) == 0) {
pair_check(&server); pair_check(&server);
@ -251,7 +258,9 @@ int main(int argc, char* argv[]) {
struct mapping* mappings = mapping_load(config.mapping); struct mapping* mappings = mapping_load(config.mapping);
for (int i=0;i<config.inputsCount;i++) { for (int i=0;i<config.inputsCount;i++) {
printf("Add input %s...\n", config.inputs[i]); if (config.debug_level > 0)
printf("Add input %s...\n", config.inputs[i]);
evdev_create(config.inputs[i], mappings); evdev_create(config.inputs[i], mappings);
} }

@ -1 +1 @@
Subproject commit a38af3e80ad6da52422a9deb2cfb657719d8a982 Subproject commit a1bdb36766f8db5dc9cc0694c9a376f0dca3ab59