Fixed VideoPlayerPage.qml failure to set cameraConfig
[harmattan/cameraplus] / lib / qtcamnotifications.cpp
1 /*!
2  * This file is part of CameraPlus.
3  *
4  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "qtcamnotifications.h"
22 #include "qtcamnotifications_p.h"
23 #include "qtcamdevice.h"
24 #ifndef GST_USE_UNSTABLE_API
25 #define GST_USE_UNSTABLE_API
26 #endif /* GST_USE_UNSTABLE_API */
27 #include <gst/interfaces/photography.h>
28
29 QtCamNotifications::QtCamNotifications(QtCamDevice *dev, QObject *parent) :
30   QObject(parent), d_ptr(new QtCamNotificationsPrivate) {
31
32   d_ptr->q_ptr = this;
33   d_ptr->dev = dev;
34
35   d_ptr->listener = dev->listener();
36   d_ptr->imageStart = new QtCamGStreamerMessageHandler("photo-capture-start", this);
37   d_ptr->imageEnd = new QtCamGStreamerMessageHandler("photo-capture-end", this);
38   d_ptr->videoDone = new QtCamGStreamerMessageHandler("video-done", this);
39   d_ptr->af = new QtCamGStreamerMessageHandler(GST_PHOTOGRAPHY_AUTOFOCUS_DONE, this);
40
41   if (d_ptr->listener) {
42     d_ptr->listener->addSyncHandler(d_ptr->imageStart);
43     d_ptr->listener->addHandler(d_ptr->imageEnd);
44     d_ptr->listener->addHandler(d_ptr->videoDone);
45     d_ptr->listener->addHandler(d_ptr->af);
46   }
47
48   QObject::connect(d_ptr->imageStart, SIGNAL(messageSent(GstMessage *)),
49                    this, SIGNAL(imageCaptureStarted()), Qt::DirectConnection);
50
51   QObject::connect(d_ptr->imageEnd, SIGNAL(messageSent(GstMessage *)),
52                    this, SIGNAL(imageCaptureEnded()), Qt::DirectConnection);
53
54   QObject::connect(d_ptr->videoDone, SIGNAL(messageSent(GstMessage *)),
55                    this, SIGNAL(videoRecordingEnded()), Qt::DirectConnection);
56
57   QObject::connect(d_ptr->af, SIGNAL(messageSent(GstMessage *)),
58                    this, SLOT(autoFocusStatusChanged(GstMessage *)));
59 }
60
61 QtCamNotifications::~QtCamNotifications() {
62   if (d_ptr->listener) {
63     d_ptr->listener->removeSyncHandler(d_ptr->imageStart);
64     d_ptr->listener->removeHandler(d_ptr->imageEnd);
65     d_ptr->listener->removeHandler(d_ptr->videoDone);
66     d_ptr->listener->removeHandler(d_ptr->af);
67   }
68
69   delete d_ptr->imageStart.data();
70   delete d_ptr->imageEnd.data();
71   delete d_ptr->videoDone.data();
72   delete d_ptr->af.data();
73
74   delete d_ptr; d_ptr = 0;
75 }
76
77 #include "moc_qtcamnotifications.cpp"