|
1 /* This file is part of the KDE project. |
|
2 |
|
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
|
5 This library is free software: you can redistribute it and/or modify |
|
6 it under the terms of the GNU Lesser General Public License as published by |
|
7 the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU Lesser General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Lesser General Public License |
|
15 along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 */ |
|
17 |
|
18 #ifndef Phonon_QT7_QUICKTIMEVIDEOPLAYER_H |
|
19 #define Phonon_QT7_QUICKTIMEVIDEOPLAYER_H |
|
20 |
|
21 #include "backendheader.h" |
|
22 |
|
23 #include <QtGui/qmacdefines_mac.h> |
|
24 #import <QTKit/QTDataReference.h> |
|
25 #import <QTKit/QTMovie.h> |
|
26 |
|
27 #include <phonon/mediasource.h> |
|
28 #include <Carbon/Carbon.h> |
|
29 #include <QtCore/QString> |
|
30 #include <QtOpenGL/QGLPixelBuffer> |
|
31 #include "videoframe.h" |
|
32 |
|
33 QT_BEGIN_NAMESPACE |
|
34 |
|
35 class QGLContext; |
|
36 |
|
37 namespace Phonon |
|
38 { |
|
39 namespace QT7 |
|
40 { |
|
41 class QuickTimeStreamReader; |
|
42 class QuickTimeMetaData; |
|
43 class VideoRenderWidgetQTMovieView; |
|
44 |
|
45 class QuickTimeVideoPlayer : QObject |
|
46 { |
|
47 public: |
|
48 enum StateEnum { |
|
49 Playing = 0x1, |
|
50 Paused = 0x2, |
|
51 NoMedia = 0x4, |
|
52 }; |
|
53 Q_DECLARE_FLAGS(State, StateEnum); |
|
54 |
|
55 QuickTimeVideoPlayer(); |
|
56 virtual ~QuickTimeVideoPlayer(); |
|
57 |
|
58 void setMediaSource(const MediaSource &source); |
|
59 MediaSource mediaSource() const; |
|
60 void unsetCurrentMediaSource(); |
|
61 |
|
62 void play(); |
|
63 void pause(); |
|
64 void seek(quint64 milliseconds); |
|
65 |
|
66 bool videoFrameChanged(); |
|
67 CVOpenGLTextureRef currentFrameAsCVTexture(); |
|
68 GLuint currentFrameAsGLTexture(); |
|
69 void *currentFrameAsCIImage(); |
|
70 QImage currentFrameAsQImage(); |
|
71 void releaseImageCache(); |
|
72 QRect videoRect() const; |
|
73 |
|
74 quint64 duration() const; |
|
75 quint64 currentTime() const; |
|
76 long timeScale() const; |
|
77 float staticFps(); |
|
78 QString currentTimeString(); |
|
79 |
|
80 void setColors(qreal brightness = 0, qreal contrast = 1, qreal hue = 0, qreal saturation = 1); |
|
81 void setMasterVolume(float volume); |
|
82 void setRelativeVolume(float volume); |
|
83 void setVolume(float masterVolume, float relativeVolume); |
|
84 void setMute(bool mute); |
|
85 void enableAudio(bool enable); |
|
86 bool audioEnabled(); |
|
87 bool setAudioDevice(int id); |
|
88 void setPlaybackRate(float rate); |
|
89 QTMovie *qtMovie() const; |
|
90 QMultiMap<QString, QString> metaData(); |
|
91 |
|
92 float playbackRate() const; |
|
93 float prefferedPlaybackRate() const; |
|
94 |
|
95 QuickTimeVideoPlayer::State state() const; |
|
96 |
|
97 bool hasAudio() const; |
|
98 bool hasVideo() const; |
|
99 bool hasMovie() const; |
|
100 bool canPlayMedia() const; |
|
101 bool isPlaying() const; |
|
102 bool isSeekable() const; |
|
103 bool isDrmProtected() const; |
|
104 bool isDrmAuthorized() const; |
|
105 |
|
106 bool preRollMovie(qint64 startTime = 0); |
|
107 float percentageLoaded(); |
|
108 quint64 timeLoaded(); |
|
109 |
|
110 int trackCount() const; |
|
111 int currentTrack() const; |
|
112 void setCurrentTrack(int track); |
|
113 QString movieCompactDiscPath() const; |
|
114 QString currentTrackPath() const; |
|
115 |
|
116 static QString timeToString(quint64 ms); |
|
117 |
|
118 // Help functions when drawing to more that one widget in cocoa 64: |
|
119 void *m_primaryRenderingTarget; |
|
120 void setPrimaryRenderingTarget(NSObject *target); |
|
121 |
|
122 void *primaryRenderingCIImage(); |
|
123 void setPrimaryRenderingCIImage(void *ciImage); |
|
124 |
|
125 private: |
|
126 QTMovie *m_QTMovie; |
|
127 State m_state; |
|
128 QGLPixelBuffer *m_QImagePixelBuffer; |
|
129 QuickTimeMetaData *m_metaData; |
|
130 |
|
131 CVOpenGLTextureRef m_cachedCVTextureRef; |
|
132 QImage m_cachedQImage; |
|
133 |
|
134 bool m_playbackRateSat; |
|
135 bool m_isDrmProtected; |
|
136 bool m_isDrmAuthorized; |
|
137 bool m_mute; |
|
138 bool m_audioEnabled; |
|
139 bool m_hasVideo; |
|
140 float m_masterVolume; |
|
141 float m_relativeVolume; |
|
142 float m_playbackRate; |
|
143 float m_staticFps; |
|
144 quint64 m_currentTime; |
|
145 MediaSource m_mediaSource; |
|
146 |
|
147 void *m_primaryRenderingCIImage; |
|
148 qreal m_brightness; |
|
149 qreal m_contrast; |
|
150 qreal m_hue; |
|
151 qreal m_saturation; |
|
152 NSArray *m_folderTracks; |
|
153 int m_currentTrack; |
|
154 QString m_movieCompactDiscPath; |
|
155 |
|
156 #ifdef QUICKTIME_C_API_AVAILABLE |
|
157 QTVisualContextRef m_visualContext; |
|
158 #endif |
|
159 VideoFrame m_currentFrame; |
|
160 QuickTimeStreamReader *m_streamReader; |
|
161 |
|
162 void prepareCurrentMovieForPlayback(); |
|
163 void createVisualContext(); |
|
164 void openMovieFromCurrentMediaSource(); |
|
165 void openMovieFromDataRef(QTDataReference *dataRef); |
|
166 void openMovieFromFile(); |
|
167 void openMovieFromUrl(); |
|
168 void openMovieFromStream(); |
|
169 void openMovieFromCompactDisc(); |
|
170 void openMovieFromData(QByteArray *data, char *fileType); |
|
171 void openMovieFromDataGuessType(QByteArray *data); |
|
172 QString mediaSourcePath(); |
|
173 bool codecExistsAccordingToSuffix(const QString &fileName); |
|
174 NSString* pathToCompactDisc(); |
|
175 bool isCompactDisc(NSString *path); |
|
176 NSArray* scanFolder(NSString *path); |
|
177 |
|
178 void setError(NSError *error); |
|
179 bool errorOccured(); |
|
180 void readProtection(); |
|
181 void calculateStaticFps(); |
|
182 void checkIfVideoAwailable(); |
|
183 bool movieNotLoaded(); |
|
184 void waitStatePlayable(); |
|
185 }; |
|
186 |
|
187 Q_DECLARE_OPERATORS_FOR_FLAGS(QuickTimeVideoPlayer::State); |
|
188 |
|
189 }} // namespace Phonon::QT7 |
|
190 |
|
191 QT_END_NAMESPACE |
|
192 |
|
193 #endif // Phonon_QT7_QUICKTIMEVIDEOPLAYER_H |