CuteLogger
Fast and simple logging solution for Qt based applications
mltcontroller.h
1 /*
2  * Copyright (c) 2011-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 MLTCONTROLLER_H
20 #define MLTCONTROLLER_H
21 
22 #include <QImage>
23 #include <QString>
24 #include <QUuid>
25 #include <QScopedPointer>
26 #include <Mlt.h>
27 #include "transportcontrol.h"
28 
29 // forward declarations
30 class QQuickView;
31 
32 namespace Mlt {
33 
34 const int kMaxImageDurationSecs = 3600 * 4;
35 extern const QString XmlMimeType;
36 
37 class TransportControl : public TransportControllable
38 {
39  Q_OBJECT
40 public slots:
41  void play(double speed = 1.0);
42  void pause();
43  void stop();
44  void seek(int position);
45  void rewind();
46  void fastForward();
47  void previous(int currentPosition);
48  void next(int currentPosition);
49  void setIn(int);
50  void setOut(int);
51 };
52 
53 class Controller
54 {
55 protected:
56  Controller();
57  virtual int reconfigure(bool isMulti) = 0;
58 
59 public:
60  static Controller& singleton(QObject *parent = 0);
61  virtual ~Controller();
62  static void destroy();
63 
64  virtual QObject* videoWidget() = 0;
65  virtual int setProducer(Mlt::Producer*, bool isMulti = false);
66  virtual int open(const QString& url);
67  bool openXML(const QString& filename);
68  virtual void close();
69  virtual int displayWidth() const = 0;
70  virtual int displayHeight() const = 0;
71 
72  void closeConsumer();
73  virtual void play(double speed = 1.0);
74  virtual void pause();
75  void stop();
76  bool enableJack(bool enable = true);
77  void setVolume(double volume, bool muteOnPause = true);
78  double volume() const;
79  void onWindowResize();
80  virtual void seek(int position);
81  void refreshConsumer(bool scrubAudio = false);
82  void saveXML(const QString& filename, Service* service = 0, bool withRelativePaths = true);
83  QString XML(Service* service = 0, bool withProfile = false);
84  int consumerChanged();
85  void setProfile(const QString& profile_name);
86  QString resource() const;
87  bool isSeekable(Mlt::Producer* p = 0) const;
88  bool isClip() const;
89  bool isSeekableClip();
90  bool isPlaylist() const;
91  bool isMultitrack() const;
92  bool isImageProducer(Service* service) const;
93  void rewind();
94  void fastForward();
95  void previous(int currentPosition);
96  void next(int currentPosition);
97  void setIn(int);
98  void setOut(int);
99  void restart();
100  void resetURL();
101  QImage image(Frame *frame, int width, int height);
102  QImage image(Mlt::Producer& producer, int frameNumber, int width, int height);
103  void updateAvformatCaching(int trackCount);
104  bool isAudioFilter(const QString& name);
105  int realTime() const;
106  void setImageDurationFromDefault(Service* service) const;
107  QUuid uuid(Mlt::Properties &properties) const;
108  void setUuid(Mlt::Properties &properties, QUuid uid) const;
109  QUuid ensureHasUuid(Mlt::Properties& properties) const;
110  static void copyFilters(Mlt::Producer& fromProducer, Mlt::Producer& toProducer);
111  void copyFilters(Mlt::Producer* producer = 0);
112  void pasteFilters(Mlt::Producer* producer = 0);
113  bool hasFiltersOnClipboard() const {
114  return m_filtersClipboard->is_valid() && m_filtersClipboard->filter_count() > 0;
115  }
116 
117  Mlt::Repository* repository() const {
118  return m_repo;
119  }
120  Mlt::Profile& profile() const {
121  return *m_profile;
122  }
123  Mlt::Producer* producer() const {
124  return m_producer;
125  }
126  Mlt::Consumer* consumer() const {
127  return m_consumer;
128  }
129  const QString& URL() const {
130  return m_url;
131  }
132  const TransportControllable* transportControl() const {
133  return &m_transportControl;
134  }
135  Mlt::Producer* savedProducer() const {
136  return m_savedProducer.data();
137  }
138  void setSavedProducer(Mlt::Producer* producer);
139 
140 protected:
141  Mlt::Repository* m_repo;
142  Mlt::Producer* m_producer;
143  Mlt::FilteredConsumer* m_consumer;
144 
145 private:
146  Mlt::Profile* m_profile;
147  Mlt::Filter* m_jackFilter;
148  QString m_url;
149  double m_volume;
150  TransportControl m_transportControl;
151  QScopedPointer<Mlt::Producer> m_savedProducer;
152  QScopedPointer<Mlt::Producer> m_filtersClipboard;
153  unsigned m_skipJackEvents;
154 
155  static void on_jack_started(mlt_properties owner, void* object, mlt_position *position);
156  void onJackStarted(int position);
157  static void on_jack_stopped(mlt_properties owner, void* object, mlt_position *position);
158  void onJackStopped(int position);
159  void stopJack();
160 };
161 
162 } // namespace
163 
164 #define MLT Mlt::Controller::singleton()
165 
166 #endif // MLTCONTROLLER_H
Definition: encodedock.h:35