1
/* This file is part of the KDE project.
3
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
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.
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.
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/>.
18
#ifndef Phonon_QT7_QUICKTIMEVIDEOPLAYER_H
19
#define Phonon_QT7_QUICKTIMEVIDEOPLAYER_H
21
#include "backendheader.h"
23
#import <QTKit/QTDataReference.h>
24
#import <QTKit/QTMovie.h>
26
#include <phonon/mediasource.h>
27
#include <Carbon/Carbon.h>
28
#include <QtCore/QString>
29
#include <QtOpenGL/QGLPixelBuffer>
30
#include "videoframe.h"
40
class QuickTimeStreamReader;
41
class VideoRenderWidgetQTMovieView;
43
class QuickTimeVideoPlayer : QObject
51
Q_DECLARE_FLAGS(State, StateEnum);
53
QuickTimeVideoPlayer();
54
virtual ~QuickTimeVideoPlayer();
56
void setMediaSource(const MediaSource &source);
57
MediaSource mediaSource() const;
62
void seek(quint64 milliseconds);
64
bool videoFrameChanged();
65
CVOpenGLTextureRef currentFrameAsCVTexture();
66
GLuint currentFrameAsGLTexture();
67
void *currentFrameAsCIImage();
68
QImage currentFrameAsQImage();
69
QRect videoRect() const;
71
quint64 duration() const;
72
quint64 currentTime() const;
73
long timeScale() const;
74
QString currentTimeString();
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);
83
bool setAudioDevice(int id);
84
void setPlaybackRate(float rate);
85
QTMovie *qtMovie() const;
87
float playbackRate() const;
88
float prefferedPlaybackRate() const;
90
QuickTimeVideoPlayer::State state() const;
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;
101
bool preRollMovie(qint64 startTime = 0);
102
float percentageLoaded();
103
quint64 timeLoaded();
105
static QString timeToString(quint64 ms);
107
// Help functions when drawing to more that one widget in cocoa 64:
108
void *m_primaryRenderingTarget;
109
void setPrimaryRenderingTarget(NSObject *target);
111
void *primaryRenderingCIImage();
112
void setPrimaryRenderingCIImage(void *ciImage);
117
QGLPixelBuffer *m_QImagePixelBuffer;
119
bool m_playbackRateSat;
120
bool m_isDrmProtected;
121
bool m_isDrmAuthorized;
125
float m_masterVolume;
126
float m_relativeVolume;
127
float m_playbackRate;
128
quint64 m_currentTime;
129
MediaSource m_mediaSource;
130
void *m_primaryRenderingCIImage;
136
#ifdef QUICKTIME_C_API_AVAILABLE
137
QTVisualContextRef m_visualContext;
139
VideoFrame m_currentFrame;
140
QuickTimeStreamReader *m_streamReader;
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);
153
void setError(NSError *error);
155
void readProtection();
156
void checkIfVideoAwailable();
157
bool movieNotLoaded();
158
void waitStatePlayable();
161
Q_DECLARE_OPERATORS_FOR_FLAGS(QuickTimeVideoPlayer::State);
163
}} // namespace Phonon::QT7
167
#endif // Phonon_QT7_QUICKTIMEVIDEOPLAYER_H