]> git.sesse.net Git - kdenlive/blob - src/abstractmonitor.h
Fix buttons in capture monitor and crash when changing profile
[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 class VideoPreviewContainer : public QFrame
32 {
33     Q_OBJECT
34 public:
35     VideoPreviewContainer(QWidget *parent = 0);
36     ~VideoPreviewContainer();
37     void setImage(QImage img);
38     void start();
39     void stop();
40
41 protected:
42     virtual void paintEvent(QPaintEvent */*event*/);
43
44 private:
45     QList <QImage *> m_imageQueue;
46     QTimer m_refreshTimer;
47 };
48
49
50
51 class AbstractRender: public QObject
52 {
53 Q_OBJECT public:
54
55     /** @brief Build an abstract MLT Renderer
56      *  @param name A unique identifier for this renderer
57      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
58      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
59     AbstractRender(const QString &name, QWidget *parent = 0):QObject(parent), m_name(name), sendFrameForAnalysis(false) {};
60
61     /** @brief Destroy the MLT Renderer. */
62     virtual ~AbstractRender() {};
63
64     /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */
65     bool sendFrameForAnalysis;
66     
67     const QString &name() const {return m_name;};
68
69     /** @brief Someone needs us to send again a frame. */
70     virtual void sendFrameUpdate() = 0;
71
72 private:
73     QString m_name;
74     
75 signals:
76     /** @brief The renderer refreshed the current frame. */
77     void frameUpdated(QImage);
78
79     /** @brief This signal contains the audio of the current frame. */
80     void audioSamplesSignal(QVector<int16_t>, int, int, int);
81 };
82
83 class AbstractMonitor : public QWidget
84 {
85     Q_OBJECT
86 public:
87     AbstractMonitor(QWidget *parent = 0): QWidget(parent) {};
88     virtual ~AbstractMonitor() {};
89     virtual AbstractRender *abstractRender() = 0;
90     virtual const QString name() const = 0;
91
92 public slots:
93     virtual void stop() = 0;
94     virtual void start() = 0;
95 };
96
97 #endif