source: trunk/src/3rdparty/phonon/qt7/quicktimevideoplayer.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.2 KB
Line 
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#import <QTKit/QTDataReference.h>
24#import <QTKit/QTMovie.h>
25
26#include <phonon/mediasource.h>
27#include <Carbon/Carbon.h>
28#include <QtCore/QString>
29#include <QtOpenGL/QGLPixelBuffer>
30#include "videoframe.h"
31
32QT_BEGIN_NAMESPACE
33
34class QGLContext;
35
36namespace Phonon
37{
38namespace QT7
39{
40 class QuickTimeStreamReader;
41 class VideoRenderWidgetQTMovieView;
42
43 class QuickTimeVideoPlayer : QObject
44 {
45 public:
46 enum StateEnum {
47 Playing = 0x1,
48 Paused = 0x2,
49 NoMedia = 0x4,
50 };
51 Q_DECLARE_FLAGS(State, StateEnum);
52
53 QuickTimeVideoPlayer();
54 virtual ~QuickTimeVideoPlayer();
55
56 void setMediaSource(const MediaSource &source);
57 MediaSource mediaSource() const;
58 void unsetVideo();
59
60 void play();
61 void pause();
62 void seek(quint64 milliseconds);
63
64 bool videoFrameChanged();
65 CVOpenGLTextureRef currentFrameAsCVTexture();
66 GLuint currentFrameAsGLTexture();
67 void *currentFrameAsCIImage();
68 QImage currentFrameAsQImage();
69 QRect videoRect() const;
70
71 quint64 duration() const;
72 quint64 currentTime() const;
73 long timeScale() const;
74 QString currentTimeString();
75
76 void setColors(qreal brightness = 0, qreal contrast = 1, qreal hue = 0, qreal saturation = 1);
77 void setMasterVolume(float volume);
78 void setRelativeVolume(float volume);
79 void setVolume(float masterVolume, float relativeVolume);
80 void setMute(bool mute);
81 void enableAudio(bool enable);
82 bool audioEnabled();
83 bool setAudioDevice(int id);
84 void setPlaybackRate(float rate);
85 QTMovie *qtMovie() const;
86
87 float playbackRate() const;
88 float prefferedPlaybackRate() const;
89
90 QuickTimeVideoPlayer::State state() const;
91
92 bool hasAudio() const;
93 bool hasVideo() const;
94 bool hasMovie() const;
95 bool canPlayMedia() const;
96 bool isPlaying() const;
97 bool isSeekable() const;
98 bool isDrmProtected() const;
99 bool isDrmAuthorized() const;
100
101 bool preRollMovie(qint64 startTime = 0);
102 float percentageLoaded();
103 quint64 timeLoaded();
104
105 static QString timeToString(quint64 ms);
106
107 // Help functions when drawing to more that one widget in cocoa 64:
108 void *m_primaryRenderingTarget;
109 void setPrimaryRenderingTarget(NSObject *target);
110
111 void *primaryRenderingCIImage();
112 void setPrimaryRenderingCIImage(void *ciImage);
113
114 private:
115 QTMovie *m_QTMovie;
116 State m_state;
117 QGLPixelBuffer *m_QImagePixelBuffer;
118
119 bool m_playbackRateSat;
120 bool m_isDrmProtected;
121 bool m_isDrmAuthorized;
122 bool m_mute;
123 bool m_audioEnabled;
124 bool m_hasVideo;
125 float m_masterVolume;
126 float m_relativeVolume;
127 float m_playbackRate;
128 quint64 m_currentTime;
129 MediaSource m_mediaSource;
130 void *m_primaryRenderingCIImage;
131 qreal m_brightness;
132 qreal m_contrast;
133 qreal m_hue;
134 qreal m_saturation;
135
136#ifdef QUICKTIME_C_API_AVAILABLE
137 QTVisualContextRef m_visualContext;
138#endif
139 VideoFrame m_currentFrame;
140 QuickTimeStreamReader *m_streamReader;
141
142 void createVisualContext();
143 void openMovieFromCurrentMediaSource();
144 void openMovieFromDataRef(QTDataReference *dataRef);
145 void openMovieFromFile();
146 void openMovieFromUrl();
147 void openMovieFromStream();
148 void openMovieFromData(QByteArray *data, char *fileType);
149 void openMovieFromDataGuessType(QByteArray *data);
150 QString mediaSourcePath();
151 bool codecExistsAccordingToSuffix(const QString &fileName);
152
153 void setError(NSError *error);
154 bool errorOccured();
155 void readProtection();
156 void checkIfVideoAwailable();
157 bool movieNotLoaded();
158 void waitStatePlayable();
159 };
160
161 Q_DECLARE_OPERATORS_FOR_FLAGS(QuickTimeVideoPlayer::State);
162
163}} // namespace Phonon::QT7
164
165QT_END_NAMESPACE
166
167#endif // Phonon_QT7_QUICKTIMEVIDEOPLAYER_H
Note: See TracBrowser for help on using the repository browser.