1 /* 2 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 Copyright (C) 2009 Apple Inc. All rights reserved. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef MediaPlayerPrivatePhonon_h 22 #define MediaPlayerPrivatePhonon_h 23 24 #include "MediaPlayerPrivate.h" 25 26 #include <QObject> 27 #include <phononnamespace.h> 28 29 QT_BEGIN_NAMESPACE 30 class QWidget; 31 class QUrl; 32 33 namespace Phonon { 34 class MediaObject; 35 class VideoWidget; 36 class AudioOutput; 37 class MediaSource; 38 } 39 QT_END_NAMESPACE 40 41 namespace WebCore { 42 43 class MediaPlayerPrivate : public QObject, public MediaPlayerPrivateInterface { 44 45 Q_OBJECT 46 47 public: 48 static void registerMediaEngine(MediaEngineRegistrar); 49 ~MediaPlayerPrivate(); 50 51 // These enums are used for debugging 52 Q_ENUMS(ReadyState NetworkState PhononState) 53 54 enum ReadyState { 55 HaveNothing, 56 HaveMetadata, 57 HaveCurrentData, 58 HaveFutureData, 59 HaveEnoughData 60 }; 61 62 enum NetworkState { 63 Empty, 64 Idle, 65 Loading, 66 Loaded, 67 FormatError, 68 NetworkError, 69 DecodeError 70 }; 71 72 enum PhononState { 73 LoadingState, 74 StoppedState, 75 PlayingState, 76 BufferingState, 77 PausedState, 78 ErrorState 79 }; 80 81 IntSize naturalSize() const; 82 bool hasVideo() const; 83 bool hasAudio() const; 84 85 void load(const String &url); 86 void cancelLoad(); 87 88 void play(); 89 void pause(); 90 91 bool paused() const; 92 bool seeking() const; 93 94 float duration() const; 95 float currentTime() const; 96 void seek(float); 97 98 void setRate(float); 99 void setVolume(float); 100 void setMuted(bool); 101 102 MediaPlayer::NetworkState networkState() const; 103 MediaPlayer::ReadyState readyState() const; 104 105 PassRefPtr<TimeRanges> buffered() const; 106 float maxTimeSeekable() const; 107 unsigned bytesLoaded() const; 108 unsigned totalBytes() const; 109 110 void setVisible(bool); 111 void setSize(const IntSize&); 112 113 void paint(GraphicsContext*, const IntRect&); 114 115 protected: 116 bool eventFilter(QObject*, QEvent*); 117 118 private slots: 119 void stateChanged(Phonon::State, Phonon::State); 120 void metaDataChanged(); 121 void seekableChanged(bool); 122 void hasVideoChanged(bool); 123 void bufferStatus(int); 124 void finished(); 125 void currentSourceChanged(const Phonon::MediaSource&); 126 void aboutToFinish(); 127 void totalTimeChanged(qint64); 128 129 private: 130 MediaPlayerPrivate(MediaPlayer*); 131 static MediaPlayerPrivateInterface* create(MediaPlayer* player); 132 133 static void getSupportedTypes(HashSet<String>&); 134 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs); isAvailable()135 static bool isAvailable() { return true; } 136 137 void updateStates(); 138 139 MediaPlayer* m_player; 140 141 MediaPlayer::NetworkState m_networkState; 142 MediaPlayer::ReadyState m_readyState; 143 144 Phonon::MediaObject* m_mediaObject; 145 Phonon::VideoWidget* m_videoWidget; 146 Phonon::AudioOutput* m_audioOutput; 147 148 bool m_isVisible; 149 }; 150 } 151 152 #endif // MediaPlayerPrivatePhonon_h 153