@@ -73,6 +73,9 @@ static inline void usage(__attribute__((__unused__)) int argc, char *argv[]) {
7373 " -v Enable Video\n"
7474 " (only -v by default)\n"
7575 "\n"
76+ " -vflip Apply vertical flip\n"
77+ " -hflip Apply horizontal flip\n"
78+ "\n"
7679 " -nocontrols Disable controls and avoid reading from stdin.\n"
7780 " Otherwise, enter '?' for list of commands while streaming.\n"
7881 "\n"
@@ -91,16 +94,18 @@ static inline void usage(__attribute__((__unused__)) int argc, char *argv[]) {
9194}
9295
9396static void parse_args (int argc , char * argv []) {
94- if (argc == 3 && argv [1 ][0 ] == '-' && argv [1 ][1 ] == 'l' ) {
95- g_settings .port = strtoul (argv [2 ], NULL , 10 );
96- g_settings .connection = CB_WIFI_SRVR ;
97- v_running = 1 ;
98- return ;
99- }
100-
10197 if (argc >= 3 ) {
10298 int i = 1 ;
10399 for (; i < argc ; i ++ ) {
100+ if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'v' && argv [i ][2 ] == 'f' && argv [i ][3 ] == 'l' && argv [i ][5 ] == 'p' ) {
101+ g_settings .vertical_flip = 1 ;
102+ continue ;
103+ }
104+ if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'h' && argv [i ][2 ] == 'f' && argv [i ][3 ] == 'l' && argv [i ][5 ] == 'p' ) {
105+ g_settings .horizontal_flip = 1 ;
106+ continue ;
107+ }
108+
104109 if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'a' ) {
105110 a_running = 1 ;
106111 continue ;
@@ -109,6 +114,7 @@ static void parse_args(int argc, char *argv[]) {
109114 v_running = 1 ;
110115 continue ;
111116 }
117+
112118 if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'd' && argv [i ][3 ] == 'v' ) {
113119 if (argv [i ][4 ] != '=' || argv [i ][5 ] == 0 )
114120 goto ERROR ;
@@ -121,6 +127,7 @@ static void parse_args(int argc, char *argv[]) {
121127 goto ERROR ;
122128 continue ;
123129 }
130+
124131 if (argv [i ][0 ] == '-' && strstr (& argv [i ][1 ], "nocontrols" ) != NULL ) {
125132 no_controls = 1 ;
126133 continue ;
@@ -130,6 +137,14 @@ static void parse_args(int argc, char *argv[]) {
130137 if (i > (argc - 2 ))
131138 goto ERROR ;
132139
140+ if (argv [i ][0 ] == '-' && argv [i ][1 ] == 'l' ) {
141+ g_settings .port = strtoul (argv [i + 1 ], NULL , 10 );
142+ g_settings .connection = CB_WIFI_SRVR ;
143+ a_running = 0 ;
144+ v_running = 1 ;
145+ return ;
146+ }
147+
133148 strncpy (g_settings .ip , argv [i ], sizeof (g_settings .ip ) - 1 );
134149 g_settings .ip [sizeof (g_settings .ip ) - 1 ] = '\0' ;
135150 g_settings .port = strtoul (argv [i + 1 ], NULL , 10 );
@@ -146,8 +161,6 @@ static void parse_args(int argc, char *argv[]) {
146161 g_settings .connection = CB_RADIO_WIFI ;
147162 }
148163
149- if (!v_running && !a_running ) v_running = 1 ;
150-
151164 return ;
152165 }
153166
@@ -219,6 +232,9 @@ void wait_command() {
219232int main (int argc , char * argv []) {
220233 parse_args (argc , argv );
221234
235+ if (!v_running && !a_running )
236+ v_running = 1 ;
237+
222238 if (!decoder_init (v4l2_dev , v4l2_width , v4l2_height )) {
223239 return 2 ;
224240 }
@@ -261,9 +277,14 @@ int main(int argc, char *argv[]) {
261277 signal (SIGINT , sig_handler );
262278 signal (SIGHUP , sig_handler );
263279
264- if (!no_controls ){
280+ if (g_settings .vertical_flip )
281+ decoder_vertical_flip ();
282+
283+ if (g_settings .horizontal_flip )
284+ decoder_horizontal_flip ();
285+
286+ if (!no_controls )
265287 wait_command ();
266- }
267288
268289 while (v_running || a_running )
269290 usleep (2000 );
0 commit comments