CuteLogger
Fast and simple logging solution for Qt based applications
qmlproducer.h
1 /*
2  * Copyright (c) 2016-2019 Meltytech, LLC
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 3 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, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef QMLPRODUCER_H
19 #define QMLPRODUCER_H
20 
21 #include <QObject>
22 #include <QString>
23 #include <QVariant>
24 #include <QRectF>
25 
26 #include <MltProducer.h>
27 #include "shotcut_mlt_properties.h"
28 
29 class QmlProducer : public QObject
30 {
31  Q_OBJECT
32  Q_PROPERTY(int in READ in() NOTIFY inChanged)
33  Q_PROPERTY(int out READ out() NOTIFY outChanged)
34  Q_PROPERTY(int aspectRatio READ aspectRatio() NOTIFY producerChanged)
35  Q_PROPERTY(int duration READ duration() NOTIFY durationChanged)
36  Q_PROPERTY(int length READ length() NOTIFY lengthChanged)
37  Q_PROPERTY(QString resource READ resource() NOTIFY producerChanged)
38  Q_PROPERTY(QString mlt_service READ mlt_service() NOTIFY producerChanged)
39  Q_PROPERTY(QString hash READ hash() NOTIFY producerChanged)
40  Q_PROPERTY(QString name READ name() NOTIFY producerChanged)
41  Q_PROPERTY(QVariant audioLevels READ audioLevels NOTIFY audioLevelsChanged)
42  Q_PROPERTY(int fadeIn READ fadeIn NOTIFY producerChanged)
43  Q_PROPERTY(int fadeOut READ fadeOut NOTIFY producerChanged)
44  Q_PROPERTY(double speed READ speed NOTIFY producerChanged)
45  Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
46  Q_PROPERTY(double displayAspectRatio READ displayAspectRatio NOTIFY producerChanged)
47 
48 public:
49  explicit QmlProducer(QObject *parent = 0);
50 
51  int in();
52  int out();
53  double aspectRatio();
54  int duration() { return m_producer.is_valid()? out() - in() + 1 : 0; }
55  int length() { return m_producer.is_valid()? m_producer.get_length() : 0; }
56  QString resource();
57  QString mlt_service() { return m_producer.is_valid()? m_producer.get("mlt_service") : QString(); }
58  QString hash() { return m_producer.is_valid()? m_producer.get(kShotcutHashProperty) : QString(); }
59  QString name();
60  QVariant audioLevels();
61  int fadeIn();
62  int fadeOut();
63  double speed();
64  int position() const { return m_position; }
65  void setPosition(int position);
66  void seek(int position);
67  Mlt::Producer& producer() { return m_producer; }
68  Q_INVOKABLE void audioLevelsReady(const QModelIndex &index);
69  Q_INVOKABLE void remakeAudioLevels();
70  double displayAspectRatio();
71  Q_INVOKABLE QString get(QString name, int position = -1);
72  Q_INVOKABLE double getDouble(QString name, int position = -1);
73  Q_INVOKABLE QRectF getRect(QString name, int position = -1);
74  Q_INVOKABLE bool outOfBounds();
75 
76 signals:
77  void producerChanged();
78  void positionChanged(int position);
79  void seeked(int position);
80  void inChanged(int delta);
81  void outChanged(int delta);
82  void audioLevelsChanged();
83  void durationChanged();
84  void lengthChanged();
85 
86 public slots:
87  void setProducer(Mlt::Producer& producer);
88  void remakeAudioLevels(bool isKeyframesVisible);
89 
90 private:
91  Mlt::Producer m_producer;
92  int m_position;
93 };
94 
95 #endif // QMLPRODUCER_H