qtcamcapability_p.h seems to have been forgotten. Adding it
[harmattan/cameraplus] / lib / qtcamcapability_p.h
1 // -*- c++ -*-
2
3 #ifndef QT_CAM_CAPABILITY_P_H
4 #define QT_CAM_CAPABILITY_P_H
5
6 #include <gst/gst.h>
7 #include "qtcamdevice.h"
8 #include "qtcamdevice_p.h"
9
10 class QtCamCapabilityPrivate {
11 public:
12   QtCamCapabilityPrivate(QtCamDevice *d, const QtCamCapability::Capability& c, const QString& p) :
13     dev(d),
14     cap(c),
15     prop(p),
16     bin(0),
17     src(0),
18     handler(0),
19     q_ptr(0) {
20
21   }
22
23   QtCamCapabilityPrivate(QtCamDevice *d, const QtCamCapability::Capability& c) :
24     dev(d),
25     cap(c),
26     bin(0),
27     src(0),
28     handler(0),
29     q_ptr(0) {
30
31   }
32
33   virtual ~QtCamCapabilityPrivate() {
34
35   }
36
37   void startMonitoring() {
38     if (src) {
39       QString p = QString("notify::%1").arg(prop);
40       handler = g_signal_connect(src, p.toAscii().data(), G_CALLBACK(camera_src_notify), this);
41     }
42   }
43
44   void stopMonitoring() {
45     if (src) {
46       g_signal_handler_disconnect(src, handler);
47     }
48   }
49
50   bool intValue(int *val) {
51     if (!src) {
52       return false;
53     }
54
55     g_object_get(src, prop.toAscii().data(), val, NULL);
56
57     return true;
58   }
59
60   bool setIntValue(int val) {
61     int old = 0;
62
63     if (!src) {
64       return false;
65     }
66
67     intValue(&old);
68
69     if (old == val) {
70       return true;
71     }
72
73     g_object_set(src, prop.toAscii().data(), val, NULL);
74
75     return true;
76   }
77
78   bool floatValue(qreal *val) {
79     if (!src) {
80       return false;
81     }
82
83     g_object_get(src, prop.toAscii().data(), val, NULL);
84
85     return true;
86   }
87
88   bool setFloatValue(qreal val) {
89     qreal old = 0;
90
91     if (!src) {
92       return false;
93     }
94
95     floatValue(&old);
96
97     if (qFuzzyCompare(old, val)) {
98       return true;
99     }
100
101     g_object_set(src, prop.toAscii().data(), val, NULL);
102
103     return true;
104   }
105
106   static void camera_src_notify(GObject *gobject, GParamSpec *pspec, QtCamCapabilityPrivate *d) {
107     Q_UNUSED(gobject);
108     Q_UNUSED(pspec);
109
110     QMetaObject::invokeMethod(d->q_ptr, "valueChanged", Qt::QueuedConnection);
111   }
112
113   QtCamDevice *dev;
114   QtCamCapability::Capability cap;
115   QString prop;
116   GstElement *bin;
117   GstElement *src;
118   gulong handler;
119   QtCamCapability *q_ptr;
120 };
121
122 #endif /* QT_CAM_CAPABILITY_P_H */