2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "qtcamnotifications.h"
22 #include "qtcamgstreamermessagehandler.h"
23 #include "qtcamgstreamermessagelistener.h"
24 #include "qtcamdevice.h"
27 class QtCamNotificationsPrivate {
30 QPointer<QtCamGStreamerMessageHandler> imageStart;
31 QPointer<QtCamGStreamerMessageHandler> imageEnd;
33 QPointer<QtCamGStreamerMessageHandler> videoDone;
34 QPointer<QtCamGStreamerMessageListener> listener;
37 QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
38 QObject(parent), d_ptr(new QtCamNotificationsPrivate) {
41 d_ptr->listener = dev->listener();
42 d_ptr->imageStart = new QtCamGStreamerMessageHandler("photo-capture-start", this);
43 d_ptr->imageEnd = new QtCamGStreamerMessageHandler("photo-capture-end", this);
44 d_ptr->videoDone = new QtCamGStreamerMessageHandler("video-done", this);
46 if (d_ptr->listener) {
47 d_ptr->listener->addSyncHandler(d_ptr->imageStart);
48 d_ptr->listener->addHandler(d_ptr->imageEnd);
49 d_ptr->listener->addHandler(d_ptr->videoDone);
52 QObject::connect(d_ptr->imageStart, SIGNAL(messageSent(GstMessage *)),
53 this, SIGNAL(imageCaptureStarted()), Qt::DirectConnection);
55 QObject::connect(d_ptr->imageEnd, SIGNAL(messageSent(GstMessage *)),
56 this, SIGNAL(imageCaptureEnded()), Qt::DirectConnection);
58 QObject::connect(d_ptr->videoDone, SIGNAL(messageSent(GstMessage *)),
59 this, SIGNAL(videoRecordingEnded()), Qt::DirectConnection);
62 QtCamNotifications::~QtCamNotifications() {
63 if (d_ptr->listener) {
64 d_ptr->listener->removeSyncHandler(d_ptr->imageStart);
65 d_ptr->listener->removeHandler(d_ptr->imageEnd);
66 d_ptr->listener->removeHandler(d_ptr->videoDone);
69 delete d_ptr->imageStart.data();
70 delete d_ptr->imageEnd.data();
72 delete d_ptr; d_ptr = 0;