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;
34 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
35 #include "TextureMapper.h"
40 class MediaPlayerPrivateQt : public QObject, public MediaPlayerPrivateInterface
41 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
42 , public TextureMapperPlatformLayer
49 static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
50 ~MediaPlayerPrivateQt();
52 static void registerMediaEngine(MediaEngineRegistrar);
53 static void getSupportedTypes(HashSet<String>&);
54 static MediaPlayer::SupportsType supportsType(const String&, const String&);
55 static bool isAvailable() { return true; }
57 bool hasVideo() const;
58 bool hasAudio() const;
60 void load(const String &url);
61 void commitLoad(const String& url);
72 float duration() const;
73 float currentTime() const;
77 void setVolume(float);
79 bool supportsMuting() const;
82 void setPreload(MediaPlayer::Preload);
84 MediaPlayer::NetworkState networkState() const;
85 MediaPlayer::ReadyState readyState() const;
87 PassRefPtr<TimeRanges> buffered() const;
88 float maxTimeSeekable() const;
89 unsigned bytesLoaded() const;
90 unsigned totalBytes() const;
92 void setVisible(bool);
94 IntSize naturalSize() const;
95 void setSize(const IntSize&);
97 void paint(GraphicsContext*, const IntRect&);
98 // reimplemented for canvas drawImage(HTMLVideoElement)
99 void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
101 bool supportsFullscreen() const { return true; }
103 #if USE(ACCELERATED_COMPOSITING)
104 #if USE(TEXTURE_MAPPER)
105 // whether accelerated rendering is supported by the media engine for the current media.
106 virtual bool supportsAcceleratedRendering() const { return false; }
107 // called when the rendering system flips the into or out of accelerated rendering mode.
108 virtual void acceleratedRenderingStateChanged() { }
109 // Const-casting here is safe, since all of TextureMapperPlatformLayer's functions are const.g
110 virtual PlatformLayer* platformLayer() const { return 0; }
111 virtual void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask) const;
113 virtual bool supportsAcceleratedRendering() const { return false; }
114 virtual void acceleratedRenderingStateChanged() { }
115 virtual PlatformLayer* platformLayer() const { return 0; }
119 virtual PlatformMedia platformMedia() const;
121 QMediaPlayer* mediaPlayer() const { return m_mediaPlayer; }
122 void removeVideoItem();
123 void restoreVideoItem();
126 void mediaStatusChanged(QMediaPlayer::MediaStatus);
127 void handleError(QMediaPlayer::Error);
128 void stateChanged(QMediaPlayer::State);
129 void nativeSizeChanged(const QSizeF&);
130 void positionChanged(qint64);
131 void durationChanged(qint64);
132 void bufferStatusChanged(int);
133 void volumeChanged(int);
134 void mutedChanged(bool);
141 MediaPlayerPrivateQt(MediaPlayer*);
143 MediaPlayer* m_webCorePlayer;
144 QMediaPlayer* m_mediaPlayer;
145 QMediaPlayerControl* m_mediaPlayerControl;
146 QGraphicsVideoItem* m_videoItem;
147 QGraphicsScene* m_videoScene;
149 mutable MediaPlayer::NetworkState m_networkState;
150 mutable MediaPlayer::ReadyState m_readyState;
152 IntSize m_currentSize;
153 IntSize m_naturalSize;
154 IntSize m_oldNaturalSize;
158 MediaPlayer::Preload m_preload;
161 bool m_suppressNextPlaybackChanged;
166 #endif // MediaPlayerPrivateQt_h