imageCaptureEnded =
videoRecordingStarted = /usr/share/sounds/ui-tones//snd_camera_video_record_start.wav
videoRecordingEnded = /usr/share/sounds/ui-tones//snd_camera_video_record_stop.wav
+autoFocusAcquired = /usr/share/sounds/ui-tones//snd_camera_af.wav
virtual void imageCaptureEnded() = 0;
virtual void videoRecordingStarted() = 0;
virtual void videoRecordingEnded() = 0;
+ virtual void autoFocusAcquired() = 0;
};
Q_DECLARE_INTERFACE(Notifications, "org.foolab.qml.CameraPlus/1.0");
QObject::disconnect(n, SIGNAL(imageCaptureEnded()), this, SLOT(imageCaptureEnded()));
QObject::disconnect(n, SIGNAL(videoRecordingStarted()), this, SLOT(videoRecordingStarted()));
QObject::disconnect(n, SIGNAL(videoRecordingEnded()), this, SLOT(videoRecordingEnded()));
+ QObject::disconnect(n, SIGNAL(autoFocusAcquired()), this, SLOT(autoFocusAcquired()));
}
m_dev = dev;
this, SLOT(videoRecordingStarted()), Qt::DirectConnection);
QObject::connect(n, SIGNAL(videoRecordingEnded()),
this, SLOT(videoRecordingEnded()), Qt::DirectConnection);
+ QObject::connect(n, SIGNAL(autoFocusAcquired()),
+ this, SLOT(autoFocusAcquired()), Qt::DirectConnection);
}
}
m_notifications->videoRecordingEnded();
}
}
+
+void NotificationsContainer::autoFocusAcquired() {
+ QMutexLocker l(&m_mutex);
+
+ if (m_notifications) {
+ m_notifications->autoFocusAcquired();
+ }
+}
void imageCaptureEnded();
void videoRecordingStarted();
void videoRecordingEnded();
+ void autoFocusAcquired();
private:
QPointer<QtCamDevice> m_dev;
#include <QMutex>
#include <QWaitCondition>
-#define CAMERA_IMAGE_START_SOUND_ID "camera-image-start"
-#define CAMERA_IMAGE_END_SOUND_ID "camera-image-end"
-#define CAMERA_VIDEO_START_SOUND_ID "camera-video-start"
-#define CAMERA_VIDEO_STOP_SOUND_ID "camera-video-stop"
+#define CAMERA_IMAGE_START_SOUND_ID "camera-image-start"
+#define CAMERA_IMAGE_END_SOUND_ID "camera-image-end"
+#define CAMERA_VIDEO_START_SOUND_ID "camera-video-start"
+#define CAMERA_VIDEO_STOP_SOUND_ID "camera-video-stop"
+#define CAMERA_FOCUS_SOUND_ID "camera-focus"
// Odd, volume has to be a char *
#define CANBERRA_FULL_VOLUME "0.0"
play(CAMERA_VIDEO_STOP_SOUND_ID);
}
+void Sounds::autoFocusAcquired() {
+ if (isMuted() || !m_ctx) {
+ return;
+ }
+
+ play(CAMERA_FOCUS_SOUND_ID);
+}
+
bool Sounds::isMuted() const {
return m_muted;
}
cache(m_conf->imageCaptureEndedSound(), CAMERA_IMAGE_END_SOUND_ID);
cache(m_conf->videoRecordingStartedSound(), CAMERA_VIDEO_START_SOUND_ID);
cache(m_conf->videoRecordingEndedSound(), CAMERA_VIDEO_STOP_SOUND_ID);
+ cache(m_conf->autoFocusAcquiredSound(), CAMERA_FOCUS_SOUND_ID);
}
void Sounds::cache(const QString& path, const char *id) {
void imageCaptureEnded();
void videoRecordingStarted();
void videoRecordingEnded();
+ void autoFocusAcquired();
bool isMuted() const;
void setMuted(bool mute);
qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
qtcamvideomute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp
-HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h
+HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h qtcamnotifications_p.h
LIBS += -lgstphotography-0.10
bool setStatus(QtCamAutoFocus::Status *status, GstMessage *message) {
const GstStructure *s = gst_message_get_structure(message);
int st = GST_PHOTOGRAPHY_FOCUS_STATUS_NONE;
-
if (gst_structure_get_int(s, "status", &st)) {
if (*status != st) {
*status = (QtCamAutoFocus::Status) st;
QString QtCamConfig::videoRecordingEndedSound() const {
return d_ptr->conf->value("sounds/videoRecordingEnded").toString();
}
+
+QString QtCamConfig::autoFocusAcquiredSound() const {
+ return d_ptr->conf->value("sounds/autoFocusAcquired").toString();
+}
QString imageCaptureEndedSound() const;
QString videoRecordingStartedSound() const;
QString videoRecordingEndedSound() const;
+ QString autoFocusAcquiredSound() const;
private:
QtCamConfigPrivate *d_ptr;
*/
#include "qtcamnotifications.h"
-#include "qtcamgstreamermessagehandler.h"
-#include "qtcamgstreamermessagelistener.h"
+#include "qtcamnotifications_p.h"
#include "qtcamdevice.h"
-#include <QPointer>
-
-class QtCamNotificationsPrivate {
-public:
- QtCamDevice *dev;
- QPointer<QtCamGStreamerMessageHandler> imageStart;
- QPointer<QtCamGStreamerMessageHandler> imageEnd;
-
- QPointer<QtCamGStreamerMessageHandler> videoDone;
- QPointer<QtCamGStreamerMessageListener> listener;
-};
QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
QObject(parent), d_ptr(new QtCamNotificationsPrivate) {
+
+ d_ptr->q_ptr = this;
d_ptr->dev = dev;
d_ptr->listener = dev->listener();
d_ptr->imageEnd = new QtCamGStreamerMessageHandler("photo-capture-end", this);
d_ptr->videoDone = new QtCamGStreamerMessageHandler("video-done", this);
+ d_ptr->af = new QtCamAutoFocus(dev, this);
+
if (d_ptr->listener) {
d_ptr->listener->addSyncHandler(d_ptr->imageStart);
d_ptr->listener->addHandler(d_ptr->imageEnd);
QObject::connect(d_ptr->videoDone, SIGNAL(messageSent(GstMessage *)),
this, SIGNAL(videoRecordingEnded()), Qt::DirectConnection);
+
+ QObject::connect(d_ptr->af, SIGNAL(statusChanged()), this, SLOT(autoFocusStatusChanged()));
}
QtCamNotifications::~QtCamNotifications() {
delete d_ptr->imageStart.data();
delete d_ptr->imageEnd.data();
+ delete d_ptr->af;
+
delete d_ptr; d_ptr = 0;
}
+
+#include "moc_qtcamnotifications.cpp"
class QtCamNotifications : public QObject {
Q_OBJECT
+ friend class QtCamNotificationsPrivate;
+
public:
QtCamNotifications(QtCamDevice *dev, QObject *parent = 0);
~QtCamNotifications();
void videoRecordingStarted();
void videoRecordingEnded();
+ void autoFocusAcquired();
+
private:
+ Q_PRIVATE_SLOT(d_ptr, void autoFocusStatusChanged());
+
QtCamNotificationsPrivate *d_ptr;
};
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QT_CAM_NOTIFICATIONS_P_H
+#define QT_CAM_NOTIFICATIONS_P_H
+
+#include <QPointer>
+#include "qtcamautofocus.h"
+#include "qtcamgstreamermessagehandler.h"
+#include "qtcamgstreamermessagelistener.h"
+#include "qtcamnotifications.h"
+
+class QtCamNotificationsPrivate : public QObject {
+ Q_OBJECT
+
+public:
+ QtCamDevice *dev;
+ QPointer<QtCamGStreamerMessageHandler> imageStart;
+ QPointer<QtCamGStreamerMessageHandler> imageEnd;
+
+ QPointer<QtCamGStreamerMessageHandler> videoDone;
+ QPointer<QtCamGStreamerMessageListener> listener;
+ QPointer<QtCamAutoFocus> af;
+
+ QtCamNotifications *q_ptr;
+
+public slots:
+ void autoFocusStatusChanged() {
+ if (af->status() == QtCamAutoFocus::Success) {
+ emit q_ptr->autoFocusAcquired();
+ }
+ }
+};
+
+#endif /* QT_CAM_NOTIFICATIONS_P_H */