1 /* 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 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 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. 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 APPLE COMPUTER, INC. ``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 MediaPlayerPrivate_h 27 #define MediaPlayerPrivate_h 28 29 #if ENABLE(VIDEO) 30 31 #include "MediaPlayer.h" 32 #include <wtf/Forward.h> 33 34 namespace WebCore { 35 36 class IntRect; 37 class IntSize; 38 39 class MediaPlayerPrivateInterface { 40 WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED; 41 public: MediaPlayerPrivateInterface()42 MediaPlayerPrivateInterface() { } ~MediaPlayerPrivateInterface()43 virtual ~MediaPlayerPrivateInterface() { } 44 45 virtual void load(const String& url) = 0; 46 virtual void cancelLoad() = 0; 47 prepareToPlay()48 virtual void prepareToPlay() { } platformMedia()49 virtual PlatformMedia platformMedia() const { return NoPlatformMedia; } 50 #if USE(ACCELERATED_COMPOSITING) platformLayer()51 virtual PlatformLayer* platformLayer() const { return 0; } 52 #endif 53 54 virtual void play() = 0; 55 virtual void pause() = 0; 56 supportsFullscreen()57 virtual bool supportsFullscreen() const { return false; } supportsSave()58 virtual bool supportsSave() const { return false; } 59 60 virtual IntSize naturalSize() const = 0; 61 62 virtual bool hasVideo() const = 0; 63 virtual bool hasAudio() const = 0; 64 65 virtual void setVisible(bool) = 0; 66 67 virtual float duration() const = 0; 68 69 virtual float currentTime() const = 0; 70 virtual void seek(float time) = 0; 71 virtual bool seeking() const = 0; 72 startTime()73 virtual float startTime() const { return 0; } 74 75 virtual void setRate(float) = 0; setPreservesPitch(bool)76 virtual void setPreservesPitch(bool) { } 77 78 virtual bool paused() const = 0; 79 80 virtual void setVolume(float) = 0; 81 supportsMuting()82 virtual bool supportsMuting() const { return false; } setMuted(bool)83 virtual void setMuted(bool) { } 84 hasClosedCaptions()85 virtual bool hasClosedCaptions() const { return false; } setClosedCaptionsVisible(bool)86 virtual void setClosedCaptionsVisible(bool) { } 87 88 virtual MediaPlayer::NetworkState networkState() const = 0; 89 virtual MediaPlayer::ReadyState readyState() const = 0; 90 91 virtual float maxTimeSeekable() const = 0; 92 virtual PassRefPtr<TimeRanges> buffered() const = 0; 93 94 virtual unsigned bytesLoaded() const = 0; 95 96 virtual void setSize(const IntSize&) = 0; 97 98 virtual void paint(GraphicsContext*, const IntRect&) = 0; 99 paintCurrentFrameInContext(GraphicsContext * c,const IntRect & r)100 virtual void paintCurrentFrameInContext(GraphicsContext* c, const IntRect& r) { paint(c, r); } 101 setPreload(MediaPlayer::Preload)102 virtual void setPreload(MediaPlayer::Preload) { }; 103 hasAvailableVideoFrame()104 virtual bool hasAvailableVideoFrame() const { return readyState() >= MediaPlayer::HaveCurrentData; } 105 canLoadPoster()106 virtual bool canLoadPoster() const { return false; } setPoster(const String &)107 virtual void setPoster(const String&) { } 108 109 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 110 virtual void deliverNotification(MediaPlayerProxyNotificationType) = 0; 111 virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) = 0; setControls(bool)112 virtual void setControls(bool) { } enterFullscreen()113 virtual void enterFullscreen() { } exitFullscreen()114 virtual void exitFullscreen() { } 115 #endif 116 #if PLATFORM(ANDROID) enterFullscreenMode()117 virtual void enterFullscreenMode() { } 118 #endif 119 #if USE(ACCELERATED_COMPOSITING) 120 // whether accelerated rendering is supported by the media engine for the current media. supportsAcceleratedRendering()121 virtual bool supportsAcceleratedRendering() const { return false; } 122 // called when the rendering system flips the into or out of accelerated rendering mode. acceleratedRenderingStateChanged()123 virtual void acceleratedRenderingStateChanged() { } 124 #endif 125 hasSingleSecurityOrigin()126 virtual bool hasSingleSecurityOrigin() const { return false; } 127 movieLoadType()128 virtual MediaPlayer::MovieLoadType movieLoadType() const { return MediaPlayer::Unknown; } 129 prepareForRendering()130 virtual void prepareForRendering() { } 131 132 // Time value in the movie's time scale. It is only necessary to override this if the media 133 // engine uses rational numbers to represent media time. mediaTimeForTimeValue(float timeValue)134 virtual float mediaTimeForTimeValue(float timeValue) const { return timeValue; } 135 136 // Overide this if it is safe for HTMLMediaElement to cache movie time and report 137 // 'currentTime' as [cached time + elapsed wall time]. Returns the maximum wall time 138 // it is OK to calculate movie time before refreshing the cached time. maximumDurationToCacheMediaTime()139 virtual double maximumDurationToCacheMediaTime() const { return 0; } 140 decodedFrameCount()141 virtual unsigned decodedFrameCount() const { return 0; } droppedFrameCount()142 virtual unsigned droppedFrameCount() const { return 0; } audioDecodedByteCount()143 virtual unsigned audioDecodedByteCount() const { return 0; } videoDecodedByteCount()144 virtual unsigned videoDecodedByteCount() const { return 0; } 145 getSitesInMediaCache(Vector<String> &)146 void getSitesInMediaCache(Vector<String>&) { } clearMediaCache()147 void clearMediaCache() { } clearMediaCacheForSite(const String &)148 void clearMediaCacheForSite(const String&) { } 149 setPrivateBrowsingMode(bool)150 virtual void setPrivateBrowsingMode(bool) { } 151 }; 152 153 } 154 155 #endif 156 #endif 157