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