Added command line option to control omx rotation

This commit is contained in:
Tom 2020-04-17 10:44:16 -06:00
parent a205edc1c7
commit 4bfeee690a
5 changed files with 40 additions and 1 deletions

View File

@ -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;

View File

@ -39,6 +39,7 @@ typedef struct _CONFIGURATION {
bool sops;
bool localaudio;
bool fullscreen;
int rotate;
bool unsupported;
bool quitappafter;
bool viewonly;

View File

@ -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 <width>\t\tHorizontal resolution (default 1280)\n");
printf("\t-height <height>\tVertical resolution (default 720)\n");
#if defined(HAVE_PI)
printf("\t-rotate <height>\tRotate display: 0/90/180/270 (default 0)\n");
#endif
printf("\t-fps <fps>\t\tSpecify the fps to use (default -1)\n");
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");

View File

@ -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");

View File

@ -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