• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015, Igalia S.L
3  *     Author: Philippe Normand <philn@igalia.com>
4  * Licence: LGPL. (See COPYING.LGPL)
5  */
6 
7 #include <glib.h>
8 #include <gst/gst.h>
9 #include <gst/video/videoorientation.h>
10 
11 #define PIPELINE "rpicamsrc name=src preview=0 fullscreen=0 ! h264parse ! omxh264dec ! glimagesink sync=0"
12 
13 static void
configure_orientation(GstVideoOrientation * orientation)14 configure_orientation (GstVideoOrientation * orientation)
15 {
16   gboolean flip;
17 
18   if (gst_video_orientation_get_hflip (orientation, &flip)) {
19     g_print ("current hflip: %s\n", flip ? "enabled" : "disabled");
20 
21     if (g_getenv ("HFLIP"))
22       gst_video_orientation_set_hflip (orientation, TRUE);
23 
24     gst_video_orientation_get_hflip (orientation, &flip);
25     g_print ("new hflip: %s\n", flip ? "enabled" : "disabled");
26   }
27 
28   if (gst_video_orientation_get_vflip (orientation, &flip)) {
29     g_print ("current vflip: %s\n", flip ? "enabled" : "disabled");
30 
31     if (g_getenv ("VFLIP"))
32       gst_video_orientation_set_vflip (orientation, TRUE);
33 
34     gst_video_orientation_get_vflip (orientation, &flip);
35     g_print ("new vflip: %s\n", flip ? "enabled" : "disabled");
36   }
37 }
38 
39 int
main(int argc,char ** argv)40 main (int argc, char **argv)
41 {
42   GMainLoop *loop;
43   GstElement *pipeline;
44   GError *error = NULL;
45   GstElement *src;
46   GstVideoOrientation *orientation;
47 
48   gst_init (&argc, &argv);
49   loop = g_main_loop_new (NULL, FALSE);
50 
51   pipeline = gst_parse_launch (PIPELINE, &error);
52   if (error != NULL) {
53     g_printerr ("Error parsing '%s': %s", PIPELINE, error->message);
54     g_error_free (error);
55     return -1;
56   }
57 
58   gst_element_set_state (pipeline, GST_STATE_PLAYING);
59   src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
60   if (!src) {
61     g_printerr ("Source element not found\n");
62     return -2;
63   }
64 
65   orientation = GST_VIDEO_ORIENTATION (src);
66   configure_orientation (orientation);
67   g_main_loop_run (loop);
68 
69   gst_object_unref (src);
70   gst_element_set_state (pipeline, GST_STATE_NULL);
71   return 0;
72 }
73