]> git.sesse.net Git - kdenlive/blob - src/abstractmonitor.h
Moves VideoSurface into widgets folder.
[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 <stdint.h>
24
25 #include <QObject>
26 #include <QVector>
27 #include <QWidget>
28 #include <QImage>
29 #include <QFrame>
30
31 #include "definitions.h"
32 #include "widgets/videosurface.h"
33
34 class MonitorManager;
35 class VideoContainer;
36 class VideoSurface;
37
38 class AbstractRender: public QObject
39 {
40 Q_OBJECT public:
41
42     /** @brief Build an abstract MLT Renderer
43      *  @param name A unique identifier for this renderer
44      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
45      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
46     explicit AbstractRender(Kdenlive::MonitorId name, QWidget *parent = 0)
47         : QObject(parent),
48           sendFrameForAnalysis(false),
49           analyseAudio(false),
50           m_name(name)
51     {
52     }
53
54     /** @brief Destroy the MLT Renderer. */
55     virtual ~AbstractRender() {}
56
57     /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */
58     bool sendFrameForAnalysis;
59     
60     /** @brief This property is used to decide if the renderer should send audio data for monitoring. */
61     bool analyseAudio;
62     
63     const QString &name() const {return m_name;}
64
65     /** @brief Someone needs us to send again a frame. */
66     virtual void sendFrameUpdate() = 0;
67
68 private:
69     QString m_name;
70     
71 signals:
72     /** @brief The renderer refreshed the current frame. */
73     void frameUpdated(const QImage &);
74
75     /** @brief This signal contains the audio of the current frame. */
76     void audioSamplesSignal(const QVector<int16_t>&,int,int,int);
77 };
78
79 class AbstractMonitor : public QWidget
80 {
81     Q_OBJECT
82 public:
83     AbstractMonitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *parent = 0);
84     Kdenlive::MonitorId id() {return m_id;}
85     virtual ~AbstractMonitor();
86     virtual AbstractRender *abstractRender() = 0;
87     bool isActive() const;
88     VideoContainer *videoBox;
89     VideoSurface *videoSurface;
90     void createVideoSurface();
91     
92     
93 public slots:
94     virtual void stop() = 0;
95     virtual void start() = 0;
96     virtual void slotPlay() = 0;
97     virtual void slotMouseSeek(int eventDelta, bool fast) = 0;
98     bool slotActivateMonitor(bool forceRefresh = false);
99     virtual void slotSwitchFullScreen() = 0;
100
101 protected:
102     Kdenlive::MonitorId m_id;
103     MonitorManager *m_monitorManager;
104 };
105
106 class VideoContainer : public QFrame
107 {
108     Q_OBJECT
109 public:
110     explicit VideoContainer(AbstractMonitor *monitor, QWidget *parent = 0);
111     void switchFullScreen();
112
113 protected:
114     virtual void mouseDoubleClickEvent(QMouseEvent * event);
115     virtual void mouseReleaseEvent(QMouseEvent *event);
116     void keyPressEvent(QKeyEvent *event);
117     virtual void wheelEvent(QWheelEvent * event);
118
119 private:
120     Qt::WindowFlags m_baseFlags;
121     AbstractMonitor *m_monitor;
122 };
123
124 #endif