#include "qtcamvideomode.h"
#include "qtcamgraphicsviewfinder.h"
#include "qtcamconfig.h"
+#include "notifications.h"
+#include "notificationscontainer.h"
// TODO: a viewfinder class that inherits QDeclarativeItem
m_cam(new QtCamera(this)),
m_dev(0),
m_vf(new QtCamGraphicsViewfinder(m_cam->config(), this)),
- m_mode(Camera::ImageMode) {
+ m_mode(Camera::ImageMode),
+ m_notifications(new NotificationsContainer(this)) {
// TODO:
}
QObject::connect(m_dev, SIGNAL(error(const QString&, int, const QString&)),
this, SIGNAL(error(const QString&, int, const QString&)));
+ m_notifications->setDevice(m_dev);
+
emit deviceIdChanged();
emit deviceChanged();
}
QString Camera::videoSuffix() const {
return m_cam->config()->videoSuffix();
}
+
+Notifications *Camera::notifications() const {
+ return m_notifications->notifications();
+}
+
+void Camera::setNotifications(Notifications *notifications) {
+ if (m_notifications->setNotifications(notifications)) {
+ emit notificationsChanged();
+ }
+}
#include <QDeclarativeItem>
#include <QVariant>
+#include <QPointer>
class QtCamera;
class QtCamDevice;
class QtCamGraphicsViewfinder;
+class Notifications;
+class NotificationsContainer;
class Camera : public QDeclarativeItem {
Q_OBJECT
Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
+ Q_PROPERTY(Notifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
+
Q_ENUMS(CameraMode);
public:
QString imageSuffix() const;
QString videoSuffix() const;
+ Notifications *notifications() const;
+ void setNotifications(Notifications *notifications);
+
signals:
void deviceCountChanged();
void deviceIdChanged();
void idleStateChanged();
void runningStateChanged();
void error(const QString& message, int code, const QString& debug);
+ void notificationsChanged();
protected:
void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
QVariant m_id;
QtCamGraphicsViewfinder *m_vf;
CameraMode m_mode;
+ NotificationsContainer *m_notifications;
};
#endif /* CAMERA_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 mute.h metadata.h imagesettings.h imageresolutionmodel.h \
- videosettings.h videoresolutionmodel.h
+ videosettings.h videoresolutionmodel.h notifications.h notificationscontainer.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 mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp \
- videosettings.cpp videoresolutionmodel.cpp
+ videosettings.cpp videoresolutionmodel.cpp notifications.cpp notificationscontainer.cpp
--- /dev/null
+/*!
+ * 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
+ */
+
+#include "notifications.h"
+
+Notifications::Notifications() {
+
+}
+
+Notifications::~Notifications() {
+
+}
--- /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 NOTIFICATIONS_H
+#define NOTIFICATIONS_H
+
+#include <QObject>
+
+class Notifications {
+public:
+ Notifications();
+ virtual ~Notifications();
+
+ virtual void imageCaptureStarted() = 0;
+ virtual void imageCaptureEnded() = 0;
+ virtual void videoRecordingStarted() = 0;
+ virtual void videoRecordingEnded() = 0;
+};
+Q_DECLARE_INTERFACE(Notifications, "org.foolab.qml.CameraPlus/1.0");
+
+#endif /* NOTIFICATIONS_H */
--- /dev/null
+/*!
+ * 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
+ */
+
+#include "notificationscontainer.h"
+#include "qtcamdevice.h"
+#include "qtcamnotifications.h"
+#include "notifications.h"
+
+NotificationsContainer::NotificationsContainer(QObject *parent) :
+ QObject(parent), m_dev(0), m_notifications(0) {
+
+}
+
+NotificationsContainer::~NotificationsContainer() {
+ setDevice(0);
+
+ QMutexLocker locker(&m_mutex);
+ m_notifications = 0;
+}
+
+void NotificationsContainer::setDevice(QtCamDevice *dev) {
+ if (m_dev) {
+ QtCamNotifications *n = m_dev->notifications();
+ QObject::disconnect(n, SIGNAL(imageCaptureStarted()), this, SLOT(imageCaptureStarted()));
+ QObject::disconnect(n, SIGNAL(imageCaptureEnded()), this, SLOT(imageCaptureEnded()));
+ QObject::disconnect(n, SIGNAL(videoRecordingStarted()), this, SLOT(videoRecordingStarted()));
+ QObject::disconnect(n, SIGNAL(videoRecordingEnded()), this, SLOT(videoRecordingEnded()));
+ }
+
+ m_dev = dev;
+
+ if (m_dev) {
+ QtCamNotifications *n = m_dev->notifications();
+ QObject::connect(n, SIGNAL(imageCaptureStarted()),
+ this, SLOT(imageCaptureStarted()), Qt::DirectConnection);
+ QObject::connect(n, SIGNAL(imageCaptureEnded()),
+ this, SLOT(imageCaptureEnded()), Qt::DirectConnection);
+ QObject::connect(n, SIGNAL(videoRecordingStarted()),
+ this, SLOT(videoRecordingStarted()), Qt::DirectConnection);
+ QObject::connect(n, SIGNAL(videoRecordingEnded()),
+ this, SLOT(videoRecordingEnded()), Qt::DirectConnection);
+ }
+}
+
+Notifications *NotificationsContainer::notifications() const {
+ return m_notifications;
+}
+
+bool NotificationsContainer::setNotifications(Notifications *notifications) {
+ QMutexLocker lock(&m_mutex);
+
+ if (m_notifications != notifications) {
+ m_notifications = notifications;
+ return true;
+ }
+
+ return false;
+}
+
+void NotificationsContainer::imageCaptureStarted() {
+ QMutexLocker l(&m_mutex);
+
+ if (m_notifications) {
+ m_notifications->imageCaptureStarted();
+ }
+}
+
+void NotificationsContainer::imageCaptureEnded() {
+ QMutexLocker l(&m_mutex);
+
+ if (m_notifications) {
+ m_notifications->imageCaptureEnded();
+ }
+}
+
+void NotificationsContainer::videoRecordingStarted() {
+ QMutexLocker l(&m_mutex);
+
+ if (m_notifications) {
+ m_notifications->videoRecordingStarted();
+ }
+}
+
+void NotificationsContainer::videoRecordingEnded() {
+ QMutexLocker l(&m_mutex);
+
+ if (m_notifications) {
+ m_notifications->videoRecordingEnded();
+ }
+}
--- /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 NOTIFICATIONS_CNTAINER_H
+#define NOTIFICATIONS_CNTAINER_H
+
+#include <QObject>
+#include <QPointer>
+#include <QMutex>
+
+class QtCamDevice;
+class Notifications;
+
+class NotificationsContainer : public QObject {
+ Q_OBJECT
+
+public:
+ NotificationsContainer(QObject *parent = 0);
+ ~NotificationsContainer();
+
+ void setDevice(QtCamDevice *dev);
+ Notifications *notifications() const;
+ bool setNotifications(Notifications *notifications);
+
+private slots:
+ void imageCaptureStarted();
+ void imageCaptureEnded();
+ void videoRecordingStarted();
+ void videoRecordingEnded();
+
+private:
+ QPointer<QtCamDevice> m_dev;
+ Notifications *m_notifications;
+ QMutex m_mutex;
+};
+
+#endif /* NOTIFICATIONS_CNTAINER_H */
#include "imageresolutionmodel.h"
#include "videosettings.h"
#include "videoresolutionmodel.h"
+#include "notifications.h"
#include <QtDeclarative>
qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
qmlRegisterType<VideoSettings>(URI, MAJOR, MINOR, "VideoSettings");
+ qmlRegisterInterface<Notifications>("Notifications");
qmlRegisterUncreatableType<ImageResolutionModel>(URI, MAJOR, MINOR, "ImageResolutionModel",
"ImageResolutionModel can be obtained from ImageSettings");
qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
- qtcammute.h
+ qtcammute.h qtcamnotifications.h
SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.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 \
- qtcammute.cpp
+ qtcammute.cpp qtcamnotifications.cpp
HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h
#include "qtcammode.h"
#include "qtcamimagemode.h"
#include "qtcamvideomode.h"
+#include "qtcamnotifications.h"
// TODO: we want the ability to change the image and video gep from the app.
d_ptr->image = new QtCamImageMode(d_ptr, this);
d_ptr->video = new QtCamVideoMode(d_ptr, this);
+
+ d_ptr->notifications = new QtCamNotifications(this, this);
}
QtCamDevice::~QtCamDevice() {
return d_ptr->listener;
}
+QtCamNotifications *QtCamDevice::notifications() const {
+ return d_ptr->notifications;
+}
+
#include "moc_qtcamdevice.cpp"
class QtCamGStreamerMessageListener;
class QtCamMetaData;
class QtCamCapability;
+class QtCamNotifications;
class QtCamDevice : public QObject {
Q_OBJECT
QtCamConfig *config() const;
QtCamGStreamerMessageListener *listener() const;
+ QtCamNotifications *notifications() const;
+
signals:
void error(const QString& message, int code, const QString& debug);
void started();
active(0),
viewfinder(0),
conf(0),
- error(false) {
+ error(false),
+ notifications(0) {
}
QtCamConfig *conf;
QtCamGStreamerMessageListener *listener;
bool error;
+ QtCamNotifications *notifications;
};
#endif /* QT_CAM_DEVICE_P_H */
return 0;
}
+#if 0
+ qDebug() << "Message" << gst_structure_get_name(s);
+#endif
+
QList<QtCamGStreamerMessageHandler *> list =
map.values(gst_structure_get_name(s));
--- /dev/null
+/*!
+ * 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
+ */
+
+#include "qtcamnotifications.h"
+#include "qtcamgstreamermessagehandler.h"
+#include "qtcamgstreamermessagelistener.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->dev = dev;
+
+ d_ptr->listener = dev->listener();
+ d_ptr->imageStart = new QtCamGStreamerMessageHandler("photo-capture-start", this);
+ d_ptr->imageEnd = new QtCamGStreamerMessageHandler("photo-capture-end", this);
+ d_ptr->videoDone = new QtCamGStreamerMessageHandler("video-done", this);
+
+ if (d_ptr->listener) {
+ d_ptr->listener->addSyncHandler(d_ptr->imageStart);
+ d_ptr->listener->addHandler(d_ptr->imageEnd);
+ d_ptr->listener->addHandler(d_ptr->videoDone);
+ }
+
+ QObject::connect(d_ptr->imageStart, SIGNAL(messageSent(GstMessage *)),
+ this, SIGNAL(imageCaptureStarted()), Qt::DirectConnection);
+
+ QObject::connect(d_ptr->imageEnd, SIGNAL(messageSent(GstMessage *)),
+ this, SIGNAL(imageCaptureEnded()), Qt::DirectConnection);
+
+ QObject::connect(d_ptr->videoDone, SIGNAL(messageSent(GstMessage *)),
+ this, SIGNAL(videoRecordingEnded()), Qt::DirectConnection);
+}
+
+QtCamNotifications::~QtCamNotifications() {
+ if (d_ptr->listener) {
+ d_ptr->listener->removeSyncHandler(d_ptr->imageStart);
+ d_ptr->listener->removeHandler(d_ptr->imageEnd);
+ d_ptr->listener->removeHandler(d_ptr->videoDone);
+ }
+
+ delete d_ptr->imageStart.data();
+ delete d_ptr->imageEnd.data();
+
+ delete d_ptr; d_ptr = 0;
+}
--- /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_H
+#define QT_CAM_NOTIFICATIONS_H
+
+#include <QObject>
+
+class QtCamNotificationsPrivate;
+class QtCamDevice;
+
+class QtCamNotifications : public QObject {
+ Q_OBJECT
+
+public:
+ QtCamNotifications(QtCamDevice *dev, QObject *parent = 0);
+ ~QtCamNotifications();
+
+signals:
+ // This will be emitted from another signal.
+ void imageCaptureStarted();
+
+ void imageCaptureEnded();
+
+ void videoRecordingStarted();
+ void videoRecordingEnded();
+
+private:
+ QtCamNotificationsPrivate *d_ptr;
+};
+
+#endif /* QT_CAM_NOTIFICATIONS_H */
#include "qtcamdevice_p.h"
#include "qtcamdevice.h"
#include "qtcamvideosettings.h"
+#include "qtcamnotifications.h"
class QtCamVideoModePrivate : public QtCamModePrivate {
public:
}
}
+ // TODO: Use signals from QtCamNotifications instead ?
QObject::connect(d_ptr->dev->q_ptr, SIGNAL(idleStateChanged(bool)),
this, SLOT(_d_idleStateChanged(bool)));
}
setFileName(fileName);
+ QMetaObject::invokeMethod(d_ptr->dev->notifications, "videoRecordingStarted");
+
g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);