2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef MediaPlayerPrivateQt_h
21 #define MediaPlayerPrivateQt_h
23 #include "MediaPlayerPrivate.h"
25 #include <QMediaPlayer>
29 class QMediaPlayerControl;
30 class QGraphicsVideoItem;
36 class TextureMapperVideoLayer;
38 class MediaPlayerPrivateQt : public QObject, public MediaPlayerPrivateInterface {
43 static MediaPlayerPrivateInterface* create(MediaPlayer* player);
44 ~MediaPlayerPrivateQt();
46 static void registerMediaEngine(MediaEngineRegistrar);
47 static void getSupportedTypes(HashSet<String>&);
48 static MediaPlayer::SupportsType supportsType(const String&, const String&);
49 static bool isAvailable() { return true; }
51 bool hasVideo() const;
52 bool hasAudio() const;
54 void load(const String &url);
55 void commitLoad(const String& url);
66 float duration() const;
67 float currentTime() const;
71 void setVolume(float);
73 bool supportsMuting() const;
76 void setPreload(MediaPlayer::Preload);
78 MediaPlayer::NetworkState networkState() const;
79 MediaPlayer::ReadyState readyState() const;
81 PassRefPtr<TimeRanges> buffered() const;
82 float maxTimeSeekable() const;
83 unsigned bytesLoaded() const;
84 unsigned totalBytes() const;
86 void setVisible(bool);
88 IntSize naturalSize() const;
89 void setSize(const IntSize&);
91 void paint(GraphicsContext*, const IntRect&);
93 bool supportsFullscreen() const { return true; }
95 #if USE(ACCELERATED_COMPOSITING)
96 #if USE(TEXTURE_MAPPER)
97 // whether accelerated rendering is supported by the media engine for the current media.
98 virtual bool supportsAcceleratedRendering() const { return true; }
99 // called when the rendering system flips the into or out of accelerated rendering mode.
100 virtual void acceleratedRenderingStateChanged();
101 // returns an object that can be directly composited via GraphicsLayerQt (essentially a QGraphicsItem*)
102 virtual PlatformLayer* platformLayer() const;
104 virtual bool supportsAcceleratedRendering() const { return false; }
105 virtual void acceleratedRenderingStateChanged() { }
106 virtual PlatformLayer* platformLayer() const { return 0; }
110 virtual PlatformMedia platformMedia() const;
112 QMediaPlayer* mediaPlayer() const { return m_mediaPlayer; }
113 void removeVideoItem();
114 void restoreVideoItem();
117 void mediaStatusChanged(QMediaPlayer::MediaStatus);
118 void handleError(QMediaPlayer::Error);
119 void stateChanged(QMediaPlayer::State);
120 void nativeSizeChanged(const QSizeF&);
121 void queuedSeekTimeout();
123 void positionChanged(qint64);
124 void durationChanged(qint64);
125 void bufferStatusChanged(int);
126 void volumeChanged(int);
127 void mutedChanged(bool);
134 MediaPlayerPrivateQt(MediaPlayer*);
136 MediaPlayer* m_webCorePlayer;
137 QMediaPlayer* m_mediaPlayer;
138 QMediaPlayerControl* m_mediaPlayerControl;
139 QGraphicsVideoItem* m_videoItem;
140 QGraphicsScene* m_videoScene;
141 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
142 OwnPtr<TextureMapperVideoLayer> m_platformLayer;
145 mutable MediaPlayer::NetworkState m_networkState;
146 mutable MediaPlayer::ReadyState m_readyState;
148 IntSize m_currentSize;
149 IntSize m_naturalSize;
150 IntSize m_oldNaturalSize;
155 MediaPlayer::Preload m_preload;
162 #endif // MediaPlayerPrivateQt_h