5d51fe58f43b4e39348ebb63dc29594cd8ff6e58
[harmattan/cameraplus] / lib / qtcamviewfinderrenderergeneric.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef QT_CAM_VIEWFINDER_RENDERER_GENERIC_H
24 #define QT_CAM_VIEWFINDER_RENDERER_GENERIC_H
25
26 #include "qtcamviewfinderrenderer.h"
27 #include <QImage>
28 #include <QMutex>
29
30 class QtCamViewfinderRendererGeneric : public QtCamViewfinderRenderer {
31   Q_OBJECT
32
33 public:
34   Q_INVOKABLE QtCamViewfinderRendererGeneric(QtCamConfig *config, QObject *parent = 0);
35
36   ~QtCamViewfinderRendererGeneric();
37
38   virtual void paint(QPainter *painter);
39   virtual void resize(const QSizeF& size);
40   virtual void reset();
41   virtual GstElement *sinkElement();
42   QRectF renderArea();
43   QSizeF videoResolution();
44
45 private:
46   static void on_gst_buffer(GstElement *element, GstBuffer *buf, GstPad *pad,
47                             QtCamViewfinderRendererGeneric *q);
48
49   static void sink_notify(QtCamViewfinderRendererGeneric *q, GObject *object,
50                           gboolean is_last_ref);
51
52   GstElement *m_elem;
53   GstElement *m_sink;
54   QImage m_image;
55   QMutex m_mutex;
56   QSizeF m_size;
57   unsigned long m_id;
58 };
59
60 #endif /* QT_CAM_VIEWFINDER_RENDERER_GENERIC_H */