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