]> git.sesse.net Git - kdenlive/blob - src/kthumb.h
Rewrote the handling of timeline in QGraphicsView. Now we use the built in zoom featu...
[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 <QThread>
24 #include <QMutex>
25 #include <QDomElement>
26
27 #include <KUrl>
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 recieve 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 class Miracle;
43 class Consumer;
44 class Producer;
45 class Frame;
46 class Profile;
47 };
48
49 class ClipManager;
50
51
52
53 class MyThread : public QThread {
54
55 public:
56     virtual void run();
57     void init(QObject *parent, KUrl url, QString target, double frame, double frameLength, int frequency, int channels, int arrayWidth);
58     bool isWorking();
59     bool stop_me;
60
61 private:
62     QFile f;
63     KUrl m_url;
64     double m_frame;
65     double m_frameLength;
66     int m_frequency;
67     int m_channels;
68     int m_arrayWidth;
69     bool m_isWorking;
70     QObject *m_parent;
71 };
72
73
74 class ThumbThread : public QThread {
75     Q_OBJECT
76 public:
77     virtual void run();
78     void init(QObject *parent, Mlt::Producer *prod, int width, int height);
79     void setThumbFrames(Mlt::Producer *prod, int frame1, int frame2);
80     bool isWorking();
81     bool stop_me;
82
83 private:
84     int m_width;
85     int m_height;
86     int m_frame1;
87     int m_frame2;
88     Mlt::Producer *m_prod;
89     bool m_isWorking;
90     QObject *m_parent;
91     //QMutex mutex;
92
93 signals:
94     void gotStartThumb(QImage);
95     void gotEndThumb(QImage);
96
97 };
98
99 class KThumb: public QObject {
100 Q_OBJECT public:
101
102
103     KThumb(ClipManager *clipManager, KUrl url, QObject * parent = 0, const char *name = 0);
104     ~KThumb();
105     void setProducer(Mlt::Producer *producer);
106
107 public slots:
108     void extractImage(int frame, int frame2);
109     QPixmap extractImage(int frame, int width, int height);
110     void updateClipUrl(KUrl url);
111     static QPixmap getImage(KUrl url, int width, int height);
112 //    static QPixmap getImage(QDomElement xml, int frame, int width, int height);
113     /* void getImage(KUrl url, int frame, int width, int height);
114      void getThumbs(KUrl url, int startframe, int endframe, int width, int height);*/
115     void stopAudioThumbs();
116     void removeAudioThumb();
117     void getAudioThumbs(int channel, double frame, double frameLength, int arrayWidth);
118     static QPixmap getImage(KUrl url, int frame, int width, int height);
119     static QPixmap getFrame(Mlt::Producer *producer, int framepos, int width, int height);
120
121 protected:
122     virtual void customEvent(QEvent * event);
123
124 private:
125     MyThread audioThumbProducer;
126     KUrl m_url;
127     QString m_thumbFile;
128     double m_dar;
129     Mlt::Producer *m_producer;
130     ClipManager *m_clipManager;
131
132 signals:
133     void thumbReady(int frame, QPixmap pm);
134     void audioThumbReady(QMap <int, QMap <int, QByteArray> >);
135 };
136
137 #endif