HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
capability.h zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.h \
colortone.h exposure.h aperture.h iso.h noisereduction.h \
- flickerreduction.h
+ flickerreduction.h mute.h
SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
capability.cpp zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
- flickerreduction.cpp
+ flickerreduction.cpp mute.cpp
--- /dev/null
+#include "mute.h"
+#include "qtcammute.h"
+#include "camera.h"
+#include "qtcamdevice.h"
+
+Mute::Mute(QObject *parent) :
+ QObject(parent), m_cam(0), m_mute(0) {
+
+}
+
+Mute::~Mute() {
+ m_cam = 0;
+}
+
+Camera *Mute::camera() {
+ return m_cam;
+}
+
+void Mute::setCamera(Camera *camera) {
+ if (camera == m_cam) {
+ return;
+ }
+
+ if (m_cam) {
+ QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ m_cam = camera;
+
+ if (m_cam) {
+ QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ emit cameraChanged();
+
+ deviceChanged();
+}
+
+bool Mute::isEnabled() const {
+ return m_mute ? m_mute->isEnabled() : false;
+}
+
+void Mute::setEnabled(bool enabled) {
+ if (m_mute) {
+ m_mute->setEnabled(enabled);
+ }
+}
+
+void Mute::deviceChanged() {
+ if (m_mute) {
+ delete m_mute; m_mute = 0;
+ }
+
+ if (m_cam->device()) {
+ m_mute = new QtCamMute(m_cam->device(), this);
+ QObject::connect(m_mute, SIGNAL(stateChanged()), this, SIGNAL(stateChanged()));
+
+ emit stateChanged();
+ }
+}
--- /dev/null
+// -*- c++ -*-
+#ifndef MUTE_H
+#define MUTE_H
+
+#include <QObject>
+
+class Camera;
+class QtCamMute;
+
+class Mute : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY stateChanged);
+
+public:
+ Mute(QObject *parent = 0);
+ ~Mute();
+
+ Camera *camera();
+ void setCamera(Camera *camera);
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled);
+
+signals:
+ void stateChanged();
+ void cameraChanged();
+
+private slots:
+ void deviceChanged();
+
+private:
+ Camera *m_cam;
+ QtCamMute *m_mute;
+};
+
+#endif /* MUTE_H */
#include "iso.h"
#include "noisereduction.h"
#include "flickerreduction.h"
+#include "mute.h"
#include <QtDeclarative>
qmlRegisterType<Iso>(URI, MAJOR, MINOR, "Iso");
qmlRegisterType<NoiseReduction>(URI, MAJOR, MINOR, "NoiseReduction");
qmlRegisterType<FlickerReduction>(URI, MAJOR, MINOR, "FlickerReduction");
+ qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
qmlRegisterType<Mode>();
qmlRegisterType<Capability>();
+// -*- c++ -*-
#ifndef VIDEO_TORCH_H
#define VIDEO_TORCH_H
qtcamimagemode.h qtcamvideomode.h qtcammetadata.h qtcamcapability.h \
qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
- qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h
+ qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
+ qtcammute.h
SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
qtcamimagemode.cpp qtcamvideomode.cpp qtcammetadata.cpp qtcamcapability.cpp \
qtcamzoom.cpp qtcamflash.cpp qtcamscene.cpp qtcamevcomp.cpp qtcamvideotorch.cpp \
qtcamwhitebalance.cpp qtcamcolortone.cpp qtcamflickerreduction.cpp \
- qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp
+ qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
+ qtcammute.cpp
HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h
friend class QtCamMetaData;
friend class QtCamCapability;
friend class QtCamVideoTorch;
+ friend class QtCamMute;
QtCamDevicePrivate *d_ptr;
};
--- /dev/null
+#include "qtcammute.h"
+#include "qtcamdevice.h"
+#include "qtcamdevice_p.h"
+#include <QPointer>
+
+class QtCamMutePrivate {
+public:
+ static void mute_notify(GObject *gobject, GParamSpec *pspec, QtCamMute *q) {
+ Q_UNUSED(gobject);
+ Q_UNUSED(pspec);
+
+ QMetaObject::invokeMethod(q, "stateChanged", Qt::QueuedConnection);
+ }
+
+ QPointer<QtCamDevice> dev;
+ gulong handler;
+};
+
+QtCamMute::QtCamMute(QtCamDevice *dev, QObject *parent) :
+ QObject(parent), d_ptr(new QtCamMutePrivate) {
+
+ d_ptr->dev = dev;
+ d_ptr->handler = 0;
+
+ if (d_ptr->dev->d_ptr->cameraBin) {
+ d_ptr->handler = g_signal_connect(d_ptr->dev->d_ptr->cameraBin,
+ "notify::mute",
+ G_CALLBACK(QtCamMutePrivate::mute_notify), this);
+ }
+}
+
+QtCamMute::~QtCamMute() {
+ if (d_ptr->dev && d_ptr->handler) {
+ g_signal_handler_disconnect(d_ptr->dev->d_ptr->cameraBin, d_ptr->handler);
+ }
+
+ delete d_ptr; d_ptr = 0;
+}
+
+void QtCamMute::setEnabled(bool enabled) {
+ gboolean val = enabled ? TRUE : FALSE;
+
+ if (d_ptr->dev->d_ptr->cameraBin) {
+ g_object_set(d_ptr->dev->d_ptr->cameraBin, "mute", val, NULL);
+ }
+}
+
+bool QtCamMute::isEnabled() const {
+ gboolean val = FALSE;
+
+ if (d_ptr->dev->d_ptr->cameraBin) {
+ g_object_get(d_ptr->dev->d_ptr->cameraBin, "mute", &val, NULL);
+ }
+
+ return (val == TRUE);
+}
--- /dev/null
+// -*- c++ -*-
+
+#ifndef QT_CAM_MUTE_H
+#define QT_CAM_MUTE_H
+
+#include <QObject>
+
+class QtCamDevice;
+class QtCamMutePrivate;
+
+class QtCamMute : public QObject {
+ Q_OBJECT
+
+public:
+ QtCamMute(QtCamDevice *dev, QObject *parent = 0);
+ ~QtCamMute();
+
+ void setEnabled(bool enabled);
+ bool isEnabled() const;
+
+signals:
+ void stateChanged();
+
+private:
+ QtCamMutePrivate *d_ptr;
+};
+
+#endif /* QT_CAM_MUTE_H */