OSDN Git Service

66b35dd00a29c1c36605385e9681440fd758eefb
[android-x86/external-webkit.git] / WebCore / platform / graphics / android / MediaPlayerPrivateAndroid.h
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 hasAudio() const { return false; }
54     virtual bool hasVideo() const { return false; }
55
56     virtual void setVisible(bool);
57
58     virtual float duration() const { return m_duration; }
59
60     virtual float currentTime() const { return m_currentTime; };
61     virtual void seek(float time);
62     virtual bool seeking() const { return false; }
63
64     virtual void setEndTime(float time) { }
65
66     virtual void setRate(float) { }
67     virtual bool paused() const { return m_paused; }
68
69     virtual void setVolume(float) { }
70
71     virtual MediaPlayer::NetworkState networkState() const { return m_networkState; }
72     virtual MediaPlayer::ReadyState readyState() const { return m_readyState; }
73
74     virtual float maxTimeSeekable() const { return 0; }
75     virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
76
77     virtual int dataRate() const { return 0; }
78
79     virtual bool totalBytesKnown() const { return totalBytes() > 0; }
80     virtual unsigned totalBytes() const { return 0; }
81     virtual unsigned bytesLoaded() const { return 0; }
82
83     virtual void setSize(const IntSize&) { }
84
85     virtual bool canLoadPoster() const { return false; }
86     virtual void setPoster(const String&) { }
87     virtual void prepareToPlay();
88
89     virtual void paint(GraphicsContext*, const IntRect&) { }
90
91     virtual void onPrepared(int duration, int width, int height) { }
92     void onEnded();
93     void onPaused();
94     virtual void onPosterFetched(SkBitmap*) { }
95     void onBuffering(int percent);
96     void onTimeupdate(int position);
97
98     // These following two functions are used to turn on inline video support
99     bool supportsAcceleratedRendering() const { return true; }
100     LayerAndroid* platformLayer() const
101     {
102         return m_videoLayer;
103     }
104
105 protected:
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);
110
111     MediaPlayerPrivate(MediaPlayer *);
112     virtual void createJavaPlayerIfNeeded() { }
113
114     MediaPlayer* m_player;
115     String m_url;
116     struct JavaGlue;
117     JavaGlue* m_glue;
118
119     float m_duration;
120     float m_currentTime;
121
122     bool m_paused;
123     bool m_hasVideo;
124     MediaPlayer::ReadyState m_readyState;
125     MediaPlayer::NetworkState m_networkState;
126
127     SkBitmap* m_poster; // not owned
128     String m_posterUrl;
129
130     IntSize m_naturalSize;
131     bool m_naturalSizeUnknown;
132
133     bool m_isVisible;
134     VideoLayerAndroid* m_videoLayer;
135 };
136
137 } // namespace WebCore
138
139 #endif
140
141 #endif // MediaPlayerPrivateAndroid_h