6 #define QUOTE(x) QUOTE_(x)
8 static gboolean option_fake
= FALSE
;
9 static gboolean option_fullscreen
= FALSE
;
10 static gint option_debug
= -1;
11 static gint option_timer
= -1;
12 static gint option_screens
= 1;
13 static gint option_fps
= 20;
14 static guint option_first_screen
= 0;
15 static guint option_serial
= 0;
16 static char **option_reload
= NULL
;
17 static char **option_save
= NULL
;
18 static char *option_avi
= NULL
;
23 static GOptionEntry entries
[] =
25 { "fake-source", 0, 0, G_OPTION_ARG_NONE
, &option_fake
,
26 "use videotestsrc, not v4l2src (mostly won't work)", NULL
},
27 { "full-screen", 'f', 0, G_OPTION_ARG_NONE
, &option_fullscreen
, "run full screen", NULL
},
28 { "fps", 'p', 0, G_OPTION_ARG_INT
, &option_fps
,
29 "speed (Frames per second, multiple of 5 <= 30)", "FPS" },
30 { "screens", 's', 0, G_OPTION_ARG_INT
, &option_screens
, "Use this many screens, (max "
31 QUOTE(MAX_SCREENS
) ")", "S" },
32 { "first-screen", 0, 0, G_OPTION_ARG_INT
, &option_first_screen
, "Start with this screen", "S" },
33 { "debug", 'd', 0, G_OPTION_ARG_INT
, &option_debug
, "Save screen's debug images in /tmp", "SCREEN" },
34 { "timer", 't', 0, G_OPTION_ARG_INT
, &option_timer
, "Log frame times in /tmp/timer.log", "SCREEN" },
35 { "serial-calibration", 'c', 0, G_OPTION_ARG_NONE
, &option_serial
,
36 "calibrate projections one at a time, not together", NULL
},
37 { "reload", 'r', 0, G_OPTION_ARG_FILENAME_ARRAY
, &option_reload
,
38 "load calibration data from FILE (one per screen)", "FILE" },
39 { "save", 'S', 0, G_OPTION_ARG_FILENAME_ARRAY
, &option_save
,
40 "save calibration data to FILE (one per screen)", "FILE" },
41 { "avi", 'a', 0, G_OPTION_ARG_FILENAME
, &option_avi
,
42 "save mjpeg video to FILE", "FILE" },
43 { NULL
, 0, 0, 0, NULL
, NULL
, NULL
}
47 typedef struct windows_s
{
50 GstElement
*sinks
[MAX_SCREENS
];
51 XID xwindows
[MAX_SCREENS
];
52 GtkWidget
*gtk_windows
[MAX_SCREENS
];
57 "framerate", GST_TYPE_FRACTION, option_fps, 1, \
58 "width", G_TYPE_INT, WIDTH, \
59 "height", G_TYPE_INT, HEIGHT, \
65 mjpeg_branch(GstPipeline
*pipeline
, GstElement
*tee
)
67 /* ! jpegenc ! avimux ! filesink location=mjpeg.avi */
68 GstElement
*queue
= gst_element_factory_make("queue", NULL
);
69 GstElement
*jpegenc
= gst_element_factory_make("jpegenc", NULL
);
70 GstElement
*avimux
= gst_element_factory_make("avimux", NULL
);
71 GstElement
*filesink
= gst_element_factory_make("filesink", NULL
);
72 GstElement
*cs
= gst_element_factory_make("ffmpegcolorspace", NULL
);
73 g_object_set(G_OBJECT(filesink
),
74 "location", option_avi
,
76 gst_bin_add_many(GST_BIN(pipeline
),
83 gst_element_link_many(tee
,
93 post_tee_pipeline(GstPipeline
*pipeline
, GstElement
*tee
, GstElement
*sink
,
94 int rngseed
, int colour
, int timer
, int debug
, char *save
, char *reload
){
95 GstElement
*queue
= gst_element_factory_make("queue", NULL
);
96 GstElement
*sparrow
= gst_element_factory_make("sparrow", NULL
);
97 GstElement
*caps_posteriori
= gst_element_factory_make("capsfilter", NULL
);
98 GstElement
*cs_posteriori
= gst_element_factory_make("ffmpegcolorspace", NULL
);
100 g_object_set(G_OBJECT(caps_posteriori
), "caps",
101 gst_caps_new_simple ("video/x-raw-rgb",
104 g_object_set(G_OBJECT(sparrow
),
109 "serial", option_serial
,
112 g_object_set(G_OBJECT(sparrow
),
117 g_object_set(G_OBJECT(sparrow
),
122 gst_bin_add_many (GST_BIN(pipeline
),
130 gst_element_link_many(tee
,
140 pre_tee_pipeline(GstPipeline
*pipeline
){
141 if (pipeline
== NULL
){
142 pipeline
= GST_PIPELINE(gst_pipeline_new("sparrow_pipeline"));
144 char * src_name
= (option_fake
) ? "videotestsrc" : "v4l2src";
145 GstElement
*src
= gst_element_factory_make(src_name
, NULL
);
146 GstElement
*caps_priori
= gst_element_factory_make("capsfilter", NULL
);
147 GstElement
*cs_priori
= gst_element_factory_make("ffmpegcolorspace", NULL
);
148 GstElement
*caps_interiori
= gst_element_factory_make("capsfilter", NULL
);
149 GstElement
*tee
= gst_element_factory_make ("tee", NULL
);
151 g_object_set(G_OBJECT(caps_priori
), "caps",
152 gst_caps_new_simple ("video/x-raw-yuv",
153 "format", GST_TYPE_FOURCC
, GST_MAKE_FOURCC('Y', 'U', 'Y', '2'),
156 g_object_set(G_OBJECT(caps_interiori
), "caps",
157 gst_caps_new_simple ("video/x-raw-rgb",
160 gst_bin_add_many(GST_BIN(pipeline
),
168 gst_element_link_many(src
,
178 static void hide_mouse(GtkWidget
*widget
){
179 GdkWindow
*w
= GDK_WINDOW(widget
->window
);
180 GdkDisplay
*display
= gdk_display_get_default();
181 GdkCursor
*cursor
= gdk_cursor_new_for_display(display
, GDK_BLANK_CURSOR
);
182 gdk_window_set_cursor(w
, cursor
);
183 gdk_cursor_unref (cursor
);