]> git.sesse.net Git - kdenlive/blob - src/kthumb.h
Use const'ref.
[kdenlive] / src / kthumb.h
1 /***************************************************************************
2                          kthumb.h  -  description
3                             -------------------
4    begin                : Fri Nov 22 2002
5    copyright            : (C) 2002 by Jason Wood
6    email                : jasonwood@blueyonder.co.uk
7 ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef KTHUMB_H
19 #define KTHUMB_H
20
21 #include <QPixmap>
22 #include <QFile>
23 #include <QDomElement>
24 #include <QFuture>
25
26 #include <KUrl>
27 #include <kdeversion.h>
28
29 #include <mlt++/Mlt.h>
30
31
32 /**KRender encapsulates the client side of the interface to a renderer.
33 From Kdenlive's point of view, you treat the KRender object as the
34 renderer, and simply use it as if it was local. Calls are asyncrhonous -
35 you send a call out, and then receive the return value through the
36 relevant signal that get's emitted once the call completes.
37   *@author Jason Wood
38   */
39
40
41 namespace Mlt
42 {
43 class Producer;
44 class Frame;
45 };
46
47 class ClipManager;
48
49 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
50
51 class KThumb: public QObject
52 {
53    Q_OBJECT 
54 public:
55
56     KThumb(ClipManager *clipManager, const KUrl &url, const QString &id, const QString &hash, QObject * parent = 0);
57     ~KThumb();
58     void setProducer(Mlt::Producer *producer);
59     bool hasProducer() const;
60     void clearProducer();
61     void updateThumbUrl(const QString &hash);
62     void extractImage(QList <int> frames);
63     QImage extractImage(int frame, int width, int height);
64 #if KDE_IS_VERSION(4,5,0)
65     /** @brief Request thumbnails for the frame range. */
66     void queryIntraThumbs(QList <int> missingFrames);
67     /** @brief Query cached thumbnail. */
68     QImage findCachedThumb(const QString &path);
69 #endif
70     void getThumb(int frame);
71     void getGenericThumb(int frame, int height, int type);
72
73 public slots:
74     void updateClipUrl(KUrl url, const QString &hash);
75     static QPixmap getImage(KUrl url, int width, int height);
76 //    static QPixmap getImage(QDomElement xml, int frame, int width, int height);
77     /* void getImage(KUrl url, int frame, int width, int height);
78      void getThumbs(KUrl url, int startframe, int endframe, int width, int height);*/
79     void slotCreateAudioThumbs();
80     static QPixmap getImage(KUrl url, int frame, int width, int height);
81     static QImage getFrame(Mlt::Producer *producer, int framepos, int frameWidth, int displayWidth, int height);
82     static QImage getFrame(Mlt::Frame *frame, int frameWidth, int displayWidth, int height);
83     /** @brief Calculates image variance, useful to know if a thumbnail is interesting. 
84      *  @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
85      * */
86     static uint imageVariance(QImage image);
87
88 private slots:
89 #if KDE_IS_VERSION(4,5,0)
90     /** @brief Fetch all requested frames. */ 
91     void slotGetIntraThumbs();
92 #endif
93
94 private:
95     KUrl m_url;
96     QString m_thumbFile;
97     double m_dar;
98     double m_ratio;
99     Mlt::Producer *m_producer;
100     ClipManager *m_clipManager;
101     QString m_id;
102     /** @brief Controls the intra frames thumbnails process (cached thumbnails). */
103     QFuture<void> m_intra;
104     /** @brief List of frame numbers from which we want to extract thumbnails. */
105     QList <int> m_intraFramesQueue;
106     QMutex m_mutex;
107     QImage getProducerFrame(int framepos, int frameWidth, int displayWidth, int height);
108
109 signals:
110     void thumbReady(int, QImage);
111     void mainThumbReady(const QString &, QPixmap);
112     void audioThumbReady(const audioByteArray&);
113     /** @brief We have finished caching all requested thumbs. */
114     void thumbsCached();
115 };
116
117 #endif