• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 APPLE COMPUTER, INC. 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 hasVideo() const;
52 
53     virtual void setVisible(bool);
54 
55     virtual float duration() const;
56 
57     virtual float currentTime() const;
58     virtual void seek(float time);
59     virtual bool seeking() const;
60 
61     virtual void setEndTime(float time);
62 
63     virtual void setRate(float);
64     virtual bool paused() const;
65 
66     virtual void setVolume(float);
67 
68     virtual MediaPlayer::NetworkState networkState() const;
69     virtual MediaPlayer::ReadyState readyState() const;
70 
71     virtual float maxTimeSeekable() const;
72     virtual float maxTimeBuffered() const;
73 
74     virtual int dataRate() const;
75 
totalBytesKnown()76     virtual bool totalBytesKnown() const { return totalBytes() > 0; }
77     virtual unsigned totalBytes() const;
78     virtual unsigned bytesLoaded() const;
79 
80     virtual void setSize(const IntSize&);
81 
canLoadPoster()82     virtual bool canLoadPoster() const { return true; }
83     virtual void setPoster(const String&);
84     virtual void prepareToPlay();
85 
86     virtual void paint(GraphicsContext*, const IntRect&);
87 
88     void onPrepared(int duration, int width, int height);
89     void onEnded();
90     void onPosterFetched(SkBitmap*);
91 private:
92     // Android-specific methods and fields.
93     static MediaPlayerPrivateInterface* create(MediaPlayer* player);
94     static void getSupportedTypes(HashSet<String>&);
95     static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
96 
97     MediaPlayerPrivate(MediaPlayer *);
98     void createJavaPlayerIfNeeded();
99 
100     MediaPlayer* m_player;
101     String m_url;
102     struct JavaGlue;
103     JavaGlue* m_glue;
104 
105     float m_duration;
106     float m_currentTime;
107 
108     bool m_paused;
109     MediaPlayer::ReadyState m_readyState;
110     MediaPlayer::NetworkState m_networkState;
111 
112     SkBitmap* m_poster;  // not owned
113     String m_posterUrl;
114 
115     IntSize m_naturalSize;
116     bool m_naturalSizeUnknown;
117 
118     bool m_isVisible;
119 };
120 
121 }  // namespace WebCore
122 
123 #endif
124 
125 #endif // MediaPlayerPrivateAndroid_h
126