mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-03 00:06:06 +00:00
Added command line option to control omx rotation
This commit is contained in:
parent
a205edc1c7
commit
4bfeee690a
@ -67,6 +67,7 @@ static struct option long_options[] = {
|
|||||||
{"unsupported", no_argument, NULL, 'y'},
|
{"unsupported", no_argument, NULL, 'y'},
|
||||||
{"quitappafter", no_argument, NULL, '1'},
|
{"quitappafter", no_argument, NULL, '1'},
|
||||||
{"viewonly", no_argument, NULL, '2'},
|
{"viewonly", no_argument, NULL, '2'},
|
||||||
|
{"rotate", required_argument, NULL, '3'},
|
||||||
{"verbose", no_argument, NULL, 'z'},
|
{"verbose", no_argument, NULL, 'z'},
|
||||||
{"debug", no_argument, NULL, 'Z'},
|
{"debug", no_argument, NULL, 'Z'},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
@ -220,6 +221,9 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
|||||||
case '2':
|
case '2':
|
||||||
config->viewonly = true;
|
config->viewonly = true;
|
||||||
break;
|
break;
|
||||||
|
case '3':
|
||||||
|
config->rotate = atoi(value);
|
||||||
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
config->debug_level = 1;
|
config->debug_level = 1;
|
||||||
break;
|
break;
|
||||||
@ -295,6 +299,8 @@ void config_save(char* filename, PCONFIGURATION config) {
|
|||||||
write_config_bool(fd, "quitappafter", config->quitappafter);
|
write_config_bool(fd, "quitappafter", config->quitappafter);
|
||||||
if (config->viewonly)
|
if (config->viewonly)
|
||||||
write_config_bool(fd, "viewonly", 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)
|
if (strcmp(config->app, "Steam") != 0)
|
||||||
write_config_string(fd, "app", config->app);
|
write_config_string(fd, "app", config->app);
|
||||||
@ -327,6 +333,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
|||||||
config->unsupported = false;
|
config->unsupported = false;
|
||||||
config->quitappafter = false;
|
config->quitappafter = false;
|
||||||
config->viewonly = false;
|
config->viewonly = false;
|
||||||
|
config->rotate = 0;
|
||||||
config->codec = CODEC_UNSPECIFIED;
|
config->codec = CODEC_UNSPECIFIED;
|
||||||
|
|
||||||
config->inputsCount = 0;
|
config->inputsCount = 0;
|
||||||
|
@ -39,6 +39,7 @@ typedef struct _CONFIGURATION {
|
|||||||
bool sops;
|
bool sops;
|
||||||
bool localaudio;
|
bool localaudio;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
|
int rotate;
|
||||||
bool unsupported;
|
bool unsupported;
|
||||||
bool quitappafter;
|
bool quitappafter;
|
||||||
bool viewonly;
|
bool viewonly;
|
||||||
|
15
src/main.c
15
src/main.c
@ -118,6 +118,18 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
|
|||||||
if (config->fullscreen)
|
if (config->fullscreen)
|
||||||
drFlags |= DISPLAY_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) {
|
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);
|
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;
|
connection_debug = true;
|
||||||
@ -179,6 +191,9 @@ static void help() {
|
|||||||
printf("\t-4k\t\t\tUse 3840x2160 resolution\n");
|
printf("\t-4k\t\t\tUse 3840x2160 resolution\n");
|
||||||
printf("\t-width <width>\t\tHorizontal resolution (default 1280)\n");
|
printf("\t-width <width>\t\tHorizontal resolution (default 1280)\n");
|
||||||
printf("\t-height <height>\tVertical resolution (default 720)\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-fps <fps>\t\tSpecify the fps to use (default -1)\n");
|
||||||
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
|
printf("\t-bitrate <bitrate>\tSpecify the bitrate in Kbps\n");
|
||||||
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
|
printf("\t-packetsize <size>\tSpecify the maximum packetsize in bytes\n");
|
||||||
|
@ -143,10 +143,22 @@ static int decoder_renderer_setup(int videoFormat, int width, int height, int re
|
|||||||
}
|
}
|
||||||
|
|
||||||
OMX_CONFIG_ROTATIONTYPE rotationType;
|
OMX_CONFIG_ROTATIONTYPE rotationType;
|
||||||
|
memset(&rotationType, 0, sizeof(OMX_CONFIG_ROTATIONTYPE));
|
||||||
rotationType.nSize = sizeof(OMX_CONFIG_ROTATIONTYPE);
|
rotationType.nSize = sizeof(OMX_CONFIG_ROTATIONTYPE);
|
||||||
rotationType.nVersion.nVersion = OMX_VERSION;
|
rotationType.nVersion.nVersion = OMX_VERSION;
|
||||||
rotationType.nPortIndex = 90;
|
rotationType.nPortIndex = 90;
|
||||||
|
int displayRotation = drFlags & DISPLAY_ROTATE_MASK;
|
||||||
|
switch (displayRotation) {
|
||||||
|
case DISPLAY_ROTATE_90:
|
||||||
rotationType.nRotation = 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) {
|
if(OMX_SetParameter(ILC_GET_HANDLE(video_render), OMX_IndexConfigCommonRotate, &rotationType) != OMX_ErrorNone) {
|
||||||
fprintf(stderr, "Failed to set video rotation\n");
|
fprintf(stderr, "Failed to set video rotation\n");
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
#define DISPLAY_FULLSCREEN 1
|
#define DISPLAY_FULLSCREEN 1
|
||||||
#define ENABLE_HARDWARE_ACCELERATION_1 2
|
#define ENABLE_HARDWARE_ACCELERATION_1 2
|
||||||
#define ENABLE_HARDWARE_ACCELERATION_2 4
|
#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_EGL 1
|
||||||
#define INIT_VDPAU 2
|
#define INIT_VDPAU 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user