3
namespace Presentator.Widgets {
5
public enum RecordMode {
10
public class CameraViewer : InlineWindowActor {
12
public signal void finished (string file);
14
public CameraViewer (string title, int width, int height, RecordMode mode, PresentatorApp app){
15
base (title, width, height);
17
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
18
var rec = new Gtk.Button ();
20
var draw = new Gtk.DrawingArea ();
21
draw.halign = draw.valign = Gtk.Align.CENTER;
22
draw.set_size_request (350, 270);
24
app.overlay.add_overlay (draw);
26
dynamic Gst.Element pipe = Gst.ElementFactory.make ("camerabin", "pipe");
27
pipe.get_bus ().set_sync_handler ( (bus, message) => {
28
if (message.get_structure () != null &&
29
message.get_structure().has_name ("prepare-xwindow-id")) {
30
var xoverlay = message.src as Gst.XOverlay;
31
xoverlay.set_xwindow_id (Gdk.X11Window.get_xid (draw.get_window ()));
32
return Gst.BusSyncReply.DROP;
34
return Gst.BusSyncReply.PASS;
37
draw.map.connect ( () => {
38
pipe.set_state (Gst.State.PLAYING);
41
rec.get_style_context ().add_class ("noundo");
42
rec.halign = Gtk.Align.CENTER;
43
if (mode == RecordMode.IMAGE)
44
rec.image = new Gtk.Image.from_icon_name ("view-list-images-symbolic", Gtk.IconSize.BUTTON);
46
rec.image = new Gtk.Image.from_icon_name ("view-list-video-symbolic", Gtk.IconSize.BUTTON);
48
box.pack_start (rec, false, false);
54
rec.clicked.connect ( () => {
55
if (mode == RecordMode.IMAGE){
56
pipe.set_property ("mode", 0);
57
pipe.set_property ("filename",
58
Presentation.data_dir.get_path ()+"/image"+
59
new DateTime.now_local ().to_unix ().to_string ()+".jpg");
61
GLib.Signal.emit_by_name (pipe, "capture-start");
63
pipe.set_property ("mode", 1);
64
pipe.set_property ("filename",
65
Presentation.data_dir.get_path ()+"/video"+
66
new DateTime.now_local ().to_unix ().to_string ()+".webm");
67
GLib.Signal.emit_by_name (pipe, "capture-start");
71
this.window.closed.connect ( () => {
72
pipe.set_state (Gst.State.NULL);
73
app.overlay.remove (draw);