]> git.sesse.net Git - kdenlive/blob - src/kthumb.h
Fix some crashes on proxy operations
[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
28 #include <mlt++/Mlt.h>
29
30
31 /**KRender encapsulates the client side of the interface to a renderer.
32 From Kdenlive's point of view, you treat the KRender object as the
33 renderer, and simply use it as if it was local. Calls are asyncrhonous -
34 you send a call out, and then receive the return value through the
35 relevant signal that get's emitted once the call completes.
36   *@author Jason Wood
37   */
38
39
40 namespace Mlt
41 {
42 class Miracle;
43 class Consumer;
44 class Producer;
45 class Frame;
46 class Profile;
47 };
48
49 class ClipManager;
50
51 class KThumb: public QObject
52 {
53 Q_OBJECT public:
54
55
56     KThumb(ClipManager *clipManager, KUrl url, const QString &id, const QString &hash, QObject * parent = 0, const char *name = 0);
57     ~KThumb();
58     void setProducer(Mlt::Producer *producer);
59     void askForAudioThumbs(const QString &id);
60     bool hasProducer() const;
61     void clearProducer();
62     void updateThumbUrl(const QString &hash);
63     void extractImage(int frame, int frame2);
64     QPixmap extractImage(int frame, int width, int height);
65
66 public slots:
67     void updateClipUrl(KUrl url, const QString &hash);
68     static QPixmap getImage(KUrl url, int width, int height);
69 //    static QPixmap getImage(QDomElement xml, int frame, int width, int height);
70     /* void getImage(KUrl url, int frame, int width, int height);
71      void getThumbs(KUrl url, int startframe, int endframe, int width, int height);*/
72     void stopAudioThumbs();
73     void removeAudioThumb();
74     void getAudioThumbs(int channel, double frame, double frameLength, int arrayWidth);
75     static QPixmap getImage(KUrl url, int frame, int width, int height);
76     static QImage getFrame(Mlt::Producer *producer, int framepos, int width, int height);
77     /** @brief Calculates image variance, useful to know if a thumbnail is interesting. 
78      *  @return an integer between 0 and 100. 0 means no variance, eg. black image while bigger values mean contrasted image
79      * */
80     static uint imageVariance(QImage image);
81
82 private slots:
83     void slotAudioThumbOver();
84     void slotCreateAudioThumbs();
85
86 private:
87     QFuture<void> m_audioThumbProducer;
88     KUrl m_url;
89     QString m_thumbFile;
90     double m_dar;
91     Mlt::Producer *m_producer;
92     ClipManager *m_clipManager;
93     QString m_id;
94     QList <int> m_requestedThumbs;
95     QFuture<void> m_future;
96     QFile m_audioThumbFile;
97     bool m_stopAudioThumbs;
98     double m_frame;
99     double m_frameLength;
100     int m_frequency;
101     int m_channels;
102     int m_arrayWidth;
103     void doGetThumbs();
104
105 signals:
106     void thumbReady(int, QImage);
107     void mainThumbReady(const QString &, QPixmap);
108     void audioThumbReady(QMap <int, QMap <int, QByteArray> >);
109 };
110
111 #endif