]> git.sesse.net Git - kdenlive/blob - src/abstractmonitor.h
Merging of scopes manager by Granjow (final merge)
[kdenlive] / src / abstractmonitor.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 #ifndef ABSTRACTMONITOR_H
21 #define ABSTRACTMONITOR_H
22
23 #include <QObject>
24 #include <QVector>
25 #include <QWidget>
26 #include <QImage>
27 #include <QPainter>
28 #include <QFrame>
29 #include <QTimer>
30
31 #include <stdint.h>
32
33 class VideoPreviewContainer : public QFrame
34 {
35     Q_OBJECT
36 public:
37     VideoPreviewContainer(QWidget *parent = 0);
38     ~VideoPreviewContainer();
39     /** @brief Set the image to be displayed, will be put in the queue. */
40     void setImage(QImage img);
41     /** @brief Start the display refresh timer. */
42     void start();
43     /** @brief Stop the display refresh timer. */
44     void stop();
45     /** @brief Set the display ratio for this display. */
46     void setRatio(double ratio);
47
48 protected:
49     virtual void paintEvent(QPaintEvent */*event*/);
50     virtual void resizeEvent(QResizeEvent * event);
51
52 private:
53     /** @brief The display aspect ratio for profile. */
54     double m_dar;
55     /** @brief When true, the whole widget surface will be repainted, useful when resizing widget. */
56     bool m_refresh;
57     /** @brief The rectangle defining the area for painting our image. */
58     QRect m_displayRect;
59     /** @brief The queue of images to be displayed. */
60     QList <QImage *> m_imageQueue;
61     /** @brief We refresh the image with a timer, since this widget is only for preview during capture. */
62     QTimer m_refreshTimer;
63     /** @brief Re-calculate the display zone after a resize or aspect ratio change. */
64     void updateDisplayZone();
65 };
66
67
68
69 class AbstractRender: public QObject
70 {
71 Q_OBJECT public:
72
73     /** @brief Build an abstract MLT Renderer
74      *  @param name A unique identifier for this renderer
75      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
76      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
77     AbstractRender(const QString &name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {};
78
79     /** @brief Destroy the MLT Renderer. */
80     virtual ~AbstractRender() {};
81
82     /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */
83     bool sendFrameForAnalysis;
84     
85     /** @brief This property is used to decide if the renderer should send audio data for monitoring. */
86     bool analyseAudio;
87     
88     const QString &name() const {return m_name;};
89
90     /** @brief Someone needs us to send again a frame. */
91     virtual void sendFrameUpdate() = 0;
92
93 private:
94     QString m_name;
95     
96 signals:
97     /** @brief The renderer refreshed the current frame. */
98     void frameUpdated(QImage);
99
100     /** @brief This signal contains the audio of the current frame. */
101     void audioSamplesSignal(QVector<int16_t>,int,int,int);
102 };
103
104 class AbstractMonitor : public QWidget
105 {
106     Q_OBJECT
107 public:
108     AbstractMonitor(QWidget *parent = 0): QWidget(parent) {};
109     virtual ~AbstractMonitor() {};
110     virtual AbstractRender *abstractRender() = 0;
111     virtual const QString name() const = 0;
112
113 public slots:
114     virtual void stop() = 0;
115     virtual void start() = 0;
116 };
117
118 #endif