CuteLogger
Fast and simple logging solution for Qt based applications
qmlproducer.h
1 /*
2  * Copyright (c) 2016-2018 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef QMLPRODUCER_H
20 #define QMLPRODUCER_H
21 
22 #include <QObject>
23 #include <QString>
24 #include <QVariant>
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(QString resource READ resource() NOTIFY producerChanged)
37  Q_PROPERTY(QString mlt_service READ mlt_service() NOTIFY producerChanged)
38  Q_PROPERTY(QString hash READ hash() NOTIFY producerChanged)
39  Q_PROPERTY(QString name READ name() NOTIFY producerChanged)
40  Q_PROPERTY(QVariant audioLevels READ audioLevels NOTIFY audioLevelsChanged)
41  Q_PROPERTY(int fadeIn READ fadeIn NOTIFY producerChanged)
42  Q_PROPERTY(int fadeOut READ fadeOut NOTIFY producerChanged)
43  Q_PROPERTY(double speed READ speed NOTIFY producerChanged)
44  Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
45  Q_PROPERTY(double displayAspectRatio READ displayAspectRatio NOTIFY producerChanged)
46 
47 public:
48  explicit QmlProducer(QObject *parent = 0);
49 
50  int in();
51  int out();
52  double aspectRatio();
53  int duration() { return m_producer.is_valid()? out() - in() + 1 : 0; }
54  QString resource();
55  QString mlt_service() { return m_producer.is_valid()? m_producer.get("mlt_service") : QString(); }
56  QString hash() { return m_producer.is_valid()? m_producer.get(kShotcutHashProperty) : QString(); }
57  QString name();
58  QVariant audioLevels();
59  int fadeIn();
60  int fadeOut();
61  double speed();
62  int position() const { return m_position; }
63  void setPosition(int position);
64  void seek(int position);
65  Mlt::Producer& producer() { return m_producer; }
66  Q_INVOKABLE void audioLevelsReady(const QModelIndex &index);
67  Q_INVOKABLE void remakeAudioLevels();
68  double displayAspectRatio();
69 
70 signals:
71  void producerChanged();
72  void positionChanged(int position);
73  void seeked(int position);
74  void inChanged(int delta);
75  void outChanged(int delta);
76  void audioLevelsChanged();
77  void durationChanged();
78 
79 public slots:
80  void setProducer(Mlt::Producer& producer);
81  void remakeAudioLevels(bool isKeyframesVisible);
82 
83 private:
84  Mlt::Producer m_producer;
85  int m_position;
86 };
87 
88 #endif // QMLPRODUCER_H