Renamed QtCamWb to QtCamWhiteBalance
[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     if (!src) {
62       return false;
63     }
64
65     g_object_set(src, prop.toAscii().data(), val, NULL);
66
67     return true;
68   }
69
70   bool floatValue(qreal *val) {
71     if (!src) {
72       return false;
73     }
74
75     g_object_get(src, prop.toAscii().data(), val, NULL);
76
77     return true;
78   }
79
80   bool setFloatValue(qreal val) {
81     if (!src) {
82       return false;
83     }
84
85     g_object_set(src, prop.toAscii().data(), val, NULL);
86
87     return true;
88   }
89
90   static void camera_src_notify(GObject *gobject, GParamSpec *pspec, QtCamCapabilityPrivate *d) {
91     Q_UNUSED(gobject);
92     Q_UNUSED(pspec);
93
94     QMetaObject::invokeMethod(d->q_ptr, "valueChanged", Qt::QueuedConnection);
95   }
96
97   QtCamDevice *dev;
98   QtCamCapability::Capability cap;
99   QString prop;
100   GstElement *bin;
101   GstElement *src;
102   gulong handler;
103   QtCamCapability *q_ptr;
104 };
105
106 #endif /* QT_CAM_CAPABILITY_P_H */