2 * Copyright 2009,2010 The Android Open Source Project
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef MediaPlayerPrivateAndroid_h
27 #define MediaPlayerPrivateAndroid_h
33 #include "MediaPlayerPrivate.h"
34 #include "TimeRanges.h"
35 #include "VideoLayerAndroid.h"
39 class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
41 virtual ~MediaPlayerPrivate();
43 static void registerMediaEngine(MediaEngineRegistrar);
45 virtual void load(const String& url) = 0;
46 virtual void cancelLoad() { }
48 virtual void play() = 0;
51 virtual IntSize naturalSize() const { return m_naturalSize; }
53 virtual bool hasAudio() const { return false; }
54 virtual bool hasVideo() const { return false; }
56 virtual void setVisible(bool);
58 virtual float duration() const { return m_duration; }
60 virtual float currentTime() const { return m_currentTime; };
61 virtual void seek(float time);
62 virtual bool seeking() const { return false; }
64 virtual void setEndTime(float time) { }
66 virtual void setRate(float) { }
67 virtual bool paused() const { return m_paused; }
69 virtual void setVolume(float) { }
71 virtual MediaPlayer::NetworkState networkState() const { return m_networkState; }
72 virtual MediaPlayer::ReadyState readyState() const { return m_readyState; }
74 virtual float maxTimeSeekable() const { return 0; }
75 virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
77 virtual int dataRate() const { return 0; }
79 virtual bool totalBytesKnown() const { return totalBytes() > 0; }
80 virtual unsigned totalBytes() const { return 0; }
81 virtual unsigned bytesLoaded() const { return 0; }
83 virtual void setSize(const IntSize&) { }
85 virtual bool canLoadPoster() const { return false; }
86 virtual void setPoster(const String&) { }
87 virtual void prepareToPlay();
89 virtual void paint(GraphicsContext*, const IntRect&) { }
91 virtual void onPrepared(int duration, int width, int height) { }
94 virtual void onPosterFetched(SkBitmap*) { }
95 void onBuffering(int percent);
96 void onTimeupdate(int position);
98 // These following two functions are used to turn on inline video support
99 bool supportsAcceleratedRendering() const { return true; }
100 LayerAndroid* platformLayer() const
106 // Android-specific methods and fields.
107 static MediaPlayerPrivateInterface* create(MediaPlayer* player);
108 static void getSupportedTypes(HashSet<String>&) { }
109 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
111 MediaPlayerPrivate(MediaPlayer *);
112 virtual void createJavaPlayerIfNeeded() { }
114 MediaPlayer* m_player;
124 MediaPlayer::ReadyState m_readyState;
125 MediaPlayer::NetworkState m_networkState;
127 SkBitmap* m_poster; // not owned
130 IntSize m_naturalSize;
131 bool m_naturalSizeUnknown;
134 VideoLayerAndroid* m_videoLayer;
137 } // namespace WebCore
141 #endif // MediaPlayerPrivateAndroid_h