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 
117 #if USE(ACCELERATED_COMPOSITING)
118     // whether accelerated rendering is supported by the media engine for the current media.
supportsAcceleratedRendering()119     virtual bool supportsAcceleratedRendering() const { return false; }
120     // called when the rendering system flips the into or out of accelerated rendering mode.
acceleratedRenderingStateChanged()121     virtual void acceleratedRenderingStateChanged() { }
122 #endif
123 
hasSingleSecurityOrigin()124     virtual bool hasSingleSecurityOrigin() const { return false; }
125 
movieLoadType()126     virtual MediaPlayer::MovieLoadType movieLoadType() const { return MediaPlayer::Unknown; }
127 
prepareForRendering()128     virtual void prepareForRendering() { }
129 
130     // Time value in the movie's time scale. It is only necessary to override this if the media
131     // engine uses rational numbers to represent media time.
mediaTimeForTimeValue(float timeValue)132     virtual float mediaTimeForTimeValue(float timeValue) const { return timeValue; }
133 
134     // Overide this if it is safe for HTMLMediaElement to cache movie time and report
135     // 'currentTime' as [cached time + elapsed wall time]. Returns the maximum wall time
136     // it is OK to calculate movie time before refreshing the cached time.
maximumDurationToCacheMediaTime()137     virtual double maximumDurationToCacheMediaTime() const { return 0; }
138 
decodedFrameCount()139     virtual unsigned decodedFrameCount() const { return 0; }
droppedFrameCount()140     virtual unsigned droppedFrameCount() const { return 0; }
audioDecodedByteCount()141     virtual unsigned audioDecodedByteCount() const { return 0; }
videoDecodedByteCount()142     virtual unsigned videoDecodedByteCount() const { return 0; }
143 
getSitesInMediaCache(Vector<String> &)144     void getSitesInMediaCache(Vector<String>&) { }
clearMediaCache()145     void clearMediaCache() { }
clearMediaCacheForSite(const String &)146     void clearMediaCacheForSite(const String&) { }
147 
setPrivateBrowsingMode(bool)148     virtual void setPrivateBrowsingMode(bool) { }
149 };
150 
151 }
152 
153 #endif
154 #endif
155