diff --git a/src/config.c b/src/config.c index 7cf42ed..4742dcd 100644 --- a/src/config.c +++ b/src/config.c @@ -67,6 +67,7 @@ static struct option long_options[] = { {"unsupported", no_argument, NULL, 'y'}, {"quitappafter", no_argument, NULL, '1'}, {"viewonly", no_argument, NULL, '2'}, + {"rotate", required_argument, NULL, '3'}, {"verbose", no_argument, NULL, 'z'}, {"debug", no_argument, NULL, 'Z'}, {0, 0, 0, 0}, @@ -220,6 +221,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { case '2': config->viewonly = true; break; + case '3': + config->rotate = atoi(value); + break; case 'z': config->debug_level = 1; break; @@ -295,6 +299,8 @@ void config_save(char* filename, PCONFIGURATION config) { write_config_bool(fd, "quitappafter", config->quitappafter); if (config->viewonly) write_config_bool(fd, "viewonly", config->viewonly); + if (config->rotate != 0) + write_config_int(fd, "rotate", config->rotate); if (strcmp(config->app, "Steam") != 0) write_config_string(fd, "app", config->app); @@ -327,6 +333,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->unsupported = false; config->quitappafter = false; config->viewonly = false; + config->rotate = 0; config->codec = CODEC_UNSPECIFIED; config->inputsCount = 0; diff --git a/src/config.h b/src/config.h index ecd3961..72c22f3 100644 --- a/src/config.h +++ b/src/config.h @@ -39,6 +39,7 @@ typedef struct _CONFIGURATION { bool sops; bool localaudio; bool fullscreen; + int rotate; bool unsupported; bool quitappafter; bool viewonly; diff --git a/src/main.c b/src/main.c index 31e581e..0471cab 100644 --- a/src/main.c +++ b/src/main.c @@ -118,6 +118,18 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys if (config->fullscreen) drFlags |= DISPLAY_FULLSCREEN; + switch (config->rotate) { + case 90: + drFlags |= DISPLAY_ROTATE_90; + break; + case 180: + drFlags |= DISPLAY_ROTATE_180; + break; + case 270: + drFlags |= DISPLAY_ROTATE_270; + break; + } + 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; @@ -179,6 +191,9 @@ static void help() { printf("\t-4k\t\t\tUse 3840x2160 resolution\n"); printf("\t-width \t\tHorizontal resolution (default 1280)\n"); printf("\t-height \tVertical resolution (default 720)\n"); + #if defined(HAVE_PI) + printf("\t-rotate \tRotate display: 0/90/180/270 (default 0)\n"); + #endif printf("\t-fps \t\tSpecify the fps to use (default -1)\n"); printf("\t-bitrate \tSpecify the bitrate in Kbps\n"); printf("\t-packetsize \tSpecify the maximum packetsize in bytes\n"); diff --git a/src/video/pi.c b/src/video/pi.c index 6af786a..227a120 100644 --- a/src/video/pi.c +++ b/src/video/pi.c @@ -143,10 +143,22 @@ static int decoder_renderer_setup(int videoFormat, int width, int height, int re } OMX_CONFIG_ROTATIONTYPE rotationType; + memset(&rotationType, 0, sizeof(OMX_CONFIG_ROTATIONTYPE)); rotationType.nSize = sizeof(OMX_CONFIG_ROTATIONTYPE); rotationType.nVersion.nVersion = OMX_VERSION; rotationType.nPortIndex = 90; - rotationType.nRotation = 90; + int displayRotation = drFlags & DISPLAY_ROTATE_MASK; + switch (displayRotation) { + case DISPLAY_ROTATE_90: + rotationType.nRotation = 90; + break; + case DISPLAY_ROTATE_180: + rotationType.nRotation = 180; + break; + case DISPLAY_ROTATE_270: + rotationType.nRotation = 270; + break; + } if(OMX_SetParameter(ILC_GET_HANDLE(video_render), OMX_IndexConfigCommonRotate, &rotationType) != OMX_ErrorNone) { fprintf(stderr, "Failed to set video rotation\n"); diff --git a/src/video/video.h b/src/video/video.h index 306215c..a5564fb 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -24,6 +24,10 @@ #define DISPLAY_FULLSCREEN 1 #define ENABLE_HARDWARE_ACCELERATION_1 2 #define ENABLE_HARDWARE_ACCELERATION_2 4 +#define DISPLAY_ROTATE_MASK 24 +#define DISPLAY_ROTATE_90 8 +#define DISPLAY_ROTATE_180 16 +#define DISPLAY_ROTATE_270 24 #define INIT_EGL 1 #define INIT_VDPAU 2