1 /* 2 * Copyright 2009, The Android Open Source Project 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 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * 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 THE COPYRIGHT HOLDERS ``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 THE COPYRIGHT OWNER 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 MediaPlayerPrivateAndroid_h 27 #define MediaPlayerPrivateAndroid_h 28 29 #if ENABLE(VIDEO) 30 31 class SkBitmap; 32 33 #include "MediaPlayerPrivate.h" 34 35 namespace WebCore { 36 37 class MediaPlayerPrivate : public MediaPlayerPrivateInterface { 38 public: 39 ~MediaPlayerPrivate(); 40 41 static void registerMediaEngine(MediaEngineRegistrar); 42 43 virtual void load(const String& url); 44 virtual void cancelLoad(); 45 46 virtual void play(); 47 virtual void pause(); 48 49 virtual IntSize naturalSize() const; 50 51 virtual bool hasAudio() const; 52 virtual bool hasVideo() const; 53 54 virtual void setVisible(bool); 55 56 virtual float duration() const; 57 58 virtual float currentTime() const; 59 virtual void seek(float time); 60 virtual bool seeking() const; 61 62 virtual void setEndTime(float time); 63 64 virtual void setRate(float); 65 virtual bool paused() const; 66 67 virtual void setVolume(float); 68 69 virtual MediaPlayer::NetworkState networkState() const; 70 virtual MediaPlayer::ReadyState readyState() const; 71 72 virtual float maxTimeSeekable() const; 73 virtual PassRefPtr<TimeRanges> buffered() const; 74 75 virtual int dataRate() const; 76 77 virtual bool totalBytesKnown() const { return totalBytes() > 0; } 78 virtual unsigned totalBytes() const; 79 virtual unsigned bytesLoaded() const; 80 81 virtual void setSize(const IntSize&); 82 83 virtual bool canLoadPoster() const { return true; } 84 virtual void setPoster(const String&); 85 virtual void prepareToPlay(); 86 87 virtual void paint(GraphicsContext*, const IntRect&); 88 89 void onPrepared(int duration, int width, int height); 90 void onEnded(); 91 void onPosterFetched(SkBitmap*); 92 void onTimeupdate(int position); 93 private: 94 // Android-specific methods and fields. 95 static MediaPlayerPrivateInterface* create(MediaPlayer* player); 96 static void getSupportedTypes(HashSet<String>&); 97 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs); 98 99 MediaPlayerPrivate(MediaPlayer *); 100 void createJavaPlayerIfNeeded(); 101 102 MediaPlayer* m_player; 103 String m_url; 104 struct JavaGlue; 105 JavaGlue* m_glue; 106 107 float m_duration; 108 float m_currentTime; 109 110 bool m_paused; 111 bool m_hasVideo; 112 MediaPlayer::ReadyState m_readyState; 113 MediaPlayer::NetworkState m_networkState; 114 115 SkBitmap* m_poster; // not owned 116 String m_posterUrl; 117 118 IntSize m_naturalSize; 119 bool m_naturalSizeUnknown; 120 121 bool m_isVisible; 122 }; 123 124 } // namespace WebCore 125 126 #endif 127 128 #endif // MediaPlayerPrivateAndroid_h 129