1 /* 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef MediaPlayerPrivateQTKit_h 27 #define MediaPlayerPrivateQTKit_h 28 29 #if ENABLE(VIDEO) 30 31 #include "MediaPlayerPrivate.h" 32 #include "Timer.h" 33 #include <QTMovieWin.h> 34 #include <wtf/OwnPtr.h> 35 36 #ifndef DRAW_FRAME_RATE 37 #define DRAW_FRAME_RATE 0 38 #endif 39 40 namespace WebCore { 41 42 class GraphicsContext; 43 class IntSize; 44 class IntRect; 45 class String; 46 47 class MediaPlayerPrivate : public MediaPlayerPrivateInterface, public QTMovieWinClient { 48 public: 49 static void registerMediaEngine(MediaEngineRegistrar); 50 51 ~MediaPlayerPrivate(); 52 53 IntSize naturalSize() const; 54 bool hasVideo() const; 55 56 void load(const String& url); 57 void cancelLoad(); 58 59 void play(); 60 void pause(); 61 62 bool paused() const; 63 bool seeking() const; 64 65 float duration() const; 66 float currentTime() const; 67 void seek(float time); 68 void setEndTime(float); 69 70 void setRate(float); 71 void setVolume(float); 72 void setPreservesPitch(bool); 73 74 int dataRate() const; 75 networkState()76 MediaPlayer::NetworkState networkState() const { return m_networkState; } readyState()77 MediaPlayer::ReadyState readyState() const { return m_readyState; } 78 79 float maxTimeBuffered() const; 80 float maxTimeSeekable() const; 81 unsigned bytesLoaded() const; 82 bool totalBytesKnown() const; 83 unsigned totalBytes() const; 84 85 void setVisible(bool); 86 void setSize(const IntSize&); 87 88 void loadStateChanged(); 89 void didEnd(); 90 91 void paint(GraphicsContext*, const IntRect&); 92 93 bool hasSingleSecurityOrigin() const; 94 95 private: 96 MediaPlayerPrivate(MediaPlayer*); 97 98 void updateStates(); 99 void doSeek(); 100 void cancelSeek(); 101 void seekTimerFired(Timer<MediaPlayerPrivate>*); 102 float maxTimeLoaded() const; 103 void sawUnsupportedTracks(); 104 105 virtual void movieEnded(QTMovieWin*); 106 virtual void movieLoadStateChanged(QTMovieWin*); 107 virtual void movieTimeChanged(QTMovieWin*); 108 virtual void movieNewImageAvailable(QTMovieWin*); 109 110 // engine support 111 static MediaPlayerPrivateInterface* create(MediaPlayer*); 112 static void getSupportedTypes(HashSet<String>& types); 113 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs); 114 static bool isAvailable(); 115 116 MediaPlayer* m_player; 117 OwnPtr<QTMovieWin> m_qtMovie; 118 float m_seekTo; 119 float m_endTime; 120 Timer<MediaPlayerPrivate> m_seekTimer; 121 MediaPlayer::NetworkState m_networkState; 122 MediaPlayer::ReadyState m_readyState; 123 unsigned m_enabledTrackCount; 124 unsigned m_totalTrackCount; 125 bool m_hasUnsupportedTracks; 126 bool m_startedPlaying; 127 bool m_isStreaming; 128 #if DRAW_FRAME_RATE 129 int m_frameCountWhilePlaying; 130 int m_timeStartedPlaying; 131 int m_timeStoppedPlaying; 132 #endif 133 }; 134 135 } 136 137 #endif 138 #endif 139