2015-05-11 09:16:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, Igalia S.L
|
|
|
|
* Author: Philippe Normand <philn@igalia.com>
|
|
|
|
* Licence: LGPL. (See COPYING.LGPL)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/video/videoorientation.h>
|
|
|
|
|
|
|
|
#define PIPELINE "rpicamsrc name=src preview=0 fullscreen=0 ! h264parse ! omxh264dec ! glimagesink sync=0"
|
|
|
|
|
2020-07-10 13:08:55 +00:00
|
|
|
static void
|
2020-07-09 23:42:13 +00:00
|
|
|
configure_orientation (GstVideoOrientation * orientation)
|
2015-05-11 09:16:52 +00:00
|
|
|
{
|
2020-07-09 23:42:13 +00:00
|
|
|
gboolean flip;
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
if (gst_video_orientation_get_hflip (orientation, &flip)) {
|
|
|
|
g_print ("current hflip: %s\n", flip ? "enabled" : "disabled");
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
if (g_getenv ("HFLIP"))
|
|
|
|
gst_video_orientation_set_hflip (orientation, TRUE);
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
gst_video_orientation_get_hflip (orientation, &flip);
|
|
|
|
g_print ("new hflip: %s\n", flip ? "enabled" : "disabled");
|
|
|
|
}
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
if (gst_video_orientation_get_vflip (orientation, &flip)) {
|
|
|
|
g_print ("current vflip: %s\n", flip ? "enabled" : "disabled");
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
if (g_getenv ("VFLIP"))
|
|
|
|
gst_video_orientation_set_vflip (orientation, TRUE);
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
gst_video_orientation_get_vflip (orientation, &flip);
|
|
|
|
g_print ("new vflip: %s\n", flip ? "enabled" : "disabled");
|
|
|
|
}
|
2015-05-11 09:16:52 +00:00
|
|
|
}
|
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
2015-05-11 09:16:52 +00:00
|
|
|
{
|
2020-07-09 23:42:13 +00:00
|
|
|
GMainLoop *loop;
|
|
|
|
GstElement *pipeline;
|
|
|
|
GError *error = NULL;
|
|
|
|
GstElement *src;
|
|
|
|
GstVideoOrientation *orientation;
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
gst_init (&argc, &argv);
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
pipeline = gst_parse_launch (PIPELINE, &error);
|
|
|
|
if (error != NULL) {
|
|
|
|
g_printerr ("Error parsing '%s': %s", PIPELINE, error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return -1;
|
|
|
|
}
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
|
|
|
|
if (!src) {
|
|
|
|
g_printerr ("Source element not found\n");
|
|
|
|
return -2;
|
|
|
|
}
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
orientation = GST_VIDEO_ORIENTATION (src);
|
|
|
|
configure_orientation (orientation);
|
|
|
|
g_main_loop_run (loop);
|
2015-05-11 09:16:52 +00:00
|
|
|
|
2020-07-09 23:42:13 +00:00
|
|
|
gst_object_unref (src);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
return 0;
|
2015-05-11 09:16:52 +00:00
|
|
|
}
|