From e9811d8505b9a9b5c945ee5595c7262a19ec6c63 Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Fri, 8 Apr 2016 13:23:05 +0200 Subject: [PATCH] Allow specifying which codec to use --- docs/README.pod | 6 +++++- src/config.c | 9 +++++++-- src/config.h | 3 +++ src/main.c | 5 +++-- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/README.pod b/docs/README.pod index 51d2c4a..5da4f0a 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -99,11 +99,15 @@ Change the network packetsize to I. The packetsize should the smaller than the MTU of the network. By default a safe value of 1024 is used. -=item B<-forcehevc> +=item B<-hevc> Request a h265/HEVC from the server. Will still use h264 if server doesn't support HEVC. +=item B<-h264> + +Request a h264 from the server even if server and video decoder supports HEVC. + =item B<-remote> Enable the optimizations for remote connections in GFE. diff --git a/src/config.c b/src/config.c index 64bb73b..1381905 100644 --- a/src/config.c +++ b/src/config.c @@ -64,7 +64,8 @@ static struct option long_options[] = { {"surround", no_argument, NULL, 'u'}, {"fps", required_argument, NULL, 'v'}, {"forcehw", no_argument, NULL, 'w'}, - {"forcehevc", no_argument, NULL, 'x'}, + {"hevc", no_argument, NULL, 'x'}, + {"h264", no_argument, NULL, 'z'}, {"unsupported", no_argument, NULL, 'y'}, {0, 0, 0, 0}, }; @@ -204,7 +205,10 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { config->forcehw = true; break; case 'x': - config->stream.supportsHevc = true; + config->codec = CODEC_HEVC; + break; + case 'z': + config->codec = CODEC_H264; break; case 'y': config->unsupported_version = true; @@ -302,6 +306,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->fullscreen = true; config->unsupported_version = false; config->forcehw = false; + config->codec = CODEC_UNSPECIFIED; config->inputsCount = 0; config->mapping = get_path("mappings/default.conf", getenv("XDG_DATA_DIRS")); diff --git a/src/config.h b/src/config.h index cb448da..de7d3a8 100644 --- a/src/config.h +++ b/src/config.h @@ -23,6 +23,8 @@ #define MAX_INPUTS 6 +enum codecs { CODEC_UNSPECIFIED, CODEC_H264, CODEC_HEVC }; + struct input_config { char* path; char* mapping; @@ -44,6 +46,7 @@ typedef struct _CONFIGURATION { bool unsupported_version; struct input_config inputs[MAX_INPUTS]; int inputsCount; + enum codecs codec; } CONFIGURATION, *PCONFIGURATION; bool inputAdded; diff --git a/src/main.c b/src/main.c index b568db7..619cd3e 100644 --- a/src/main.c +++ b/src/main.c @@ -138,7 +138,8 @@ static void help() { printf("\t-60fps\t\t\tUse 60fps [default]\n"); printf("\t-bitrate \tSpecify the bitrate in Kbps\n"); printf("\t-packetsize \tSpecify the maximum packetsize in bytes\n"); - printf("\t-forcehevc\t\tUse high efficiency video decoding (HEVC)\n"); + printf("\t-hevc\t\t\tUse the high efficiency video coding (HEVC)\n"); + printf("\t-h264\t\t\tUse the advanced video coding (H264)\n"); printf("\t-remote\t\t\tEnable remote optimizations\n"); printf("\t-app \t\tName of app to stream\n"); printf("\t-nosops\t\t\tDon't allow GFE to modify game settings\n"); @@ -181,7 +182,7 @@ int main(int argc, char* argv[]) { fprintf(stderr, "Platform '%s' not found\n", config.platform); exit(-1); } - config.stream.supportsHevc = config.stream.supportsHevc || platform_supports_hevc(system); + config.stream.supportsHevc = config.codec != CODEC_H264 && (config.codec == CODEC_HEVC || platform_supports_hevc(system)); if (strcmp("map", config.action) == 0) { if (config.address == NULL) {