1 /* 2 * Copyright 2009,2010 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 #include "TimeRanges.h" 35 #include "VideoLayerAndroid.h" 36 37 namespace WebCore { 38 39 class MediaPlayerPrivate : public MediaPlayerPrivateInterface { 40 public: 41 virtual ~MediaPlayerPrivate(); 42 43 static void registerMediaEngine(MediaEngineRegistrar); 44 45 virtual void load(const String& url) = 0; 46 virtual void cancelLoad() { } 47 48 virtual void play() = 0; 49 virtual void pause(); 50 51 virtual IntSize naturalSize() const { return m_naturalSize; } 52 53 virtual bool supportsFullscreen() const = 0; 54 virtual bool hasAudio() const = 0; 55 virtual bool hasVideo() const = 0; 56 57 virtual void setVisible(bool); 58 59 virtual float duration() const { return m_duration; } 60 61 virtual float currentTime() const { return m_currentTime; }; 62 virtual void seek(float time); 63 virtual bool seeking() const { return false; } 64 65 virtual void setEndTime(float time) { } 66 67 virtual void setRate(float) { } 68 virtual bool paused() const { return m_paused; } 69 70 virtual void setVolume(float) { } 71 72 virtual MediaPlayer::NetworkState networkState() const { return m_networkState; } 73 virtual MediaPlayer::ReadyState readyState() const { return m_readyState; } 74 75 virtual float maxTimeSeekable() const { return 0; } 76 virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); } 77 78 virtual int dataRate() const { return 0; } 79 80 virtual bool totalBytesKnown() const { return totalBytes() > 0; } 81 virtual unsigned totalBytes() const { return 0; } 82 virtual unsigned bytesLoaded() const { return 0; } 83 84 virtual void setSize(const IntSize&) { } 85 86 virtual bool canLoadPoster() const { return false; } 87 virtual void setPoster(const String&) { } 88 virtual void prepareToPlay(); 89 90 virtual void paint(GraphicsContext*, const IntRect&) { } 91 92 virtual void onPrepared(int duration, int width, int height) { } 93 void onEnded(); 94 void onPaused(); 95 virtual void onPosterFetched(SkBitmap*) { } 96 void onBuffering(int percent); 97 void onTimeupdate(int position); 98 99 // These following two functions are used to turn on inline video support 100 bool supportsAcceleratedRendering() const { return true; } 101 LayerAndroid* platformLayer() const 102 { 103 return m_videoLayer; 104 } 105 void onStopFullscreen(); 106 107 protected: 108 // Android-specific methods and fields. 109 static MediaPlayerPrivateInterface* create(MediaPlayer* player); 110 static void getSupportedTypes(HashSet<String>&) { } 111 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs); 112 113 MediaPlayerPrivate(MediaPlayer *); 114 virtual void createJavaPlayerIfNeeded() { } 115 116 MediaPlayer* m_player; 117 String m_url; 118 struct JavaGlue; 119 JavaGlue* m_glue; 120 121 float m_duration; 122 float m_currentTime; 123 124 bool m_paused; 125 MediaPlayer::ReadyState m_readyState; 126 MediaPlayer::NetworkState m_networkState; 127 128 SkBitmap* m_poster; // not owned 129 String m_posterUrl; 130 131 IntSize m_naturalSize; 132 bool m_naturalSizeUnknown; 133 134 bool m_isVisible; 135 VideoLayerAndroid* m_videoLayer; 136 }; 137 138 } // namespace WebCore 139 140 #endif 141 142 #endif // MediaPlayerPrivateAndroid_h 143