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