2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
26 #ifndef MediaPlayerPrivate_h
27 #define MediaPlayerPrivate_h
31 #include "MediaPlayer.h"
32 #include "TimeRanges.h"
33 #include <wtf/Forward.h>
40 class MediaPlayerPrivateInterface {
41 #if !ENABLE(TIZEN_INHERIT_REF_COUNT_TO_TEXTURE_MAPPER_LAYER)
42 WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED;
45 MediaPlayerPrivateInterface() { }
46 virtual ~MediaPlayerPrivateInterface() { }
48 virtual void load(const String& url) = 0;
49 virtual void cancelLoad() = 0;
51 virtual void prepareToPlay() { }
52 virtual PlatformMedia platformMedia() const { return NoPlatformMedia; }
53 #if USE(ACCELERATED_COMPOSITING)
54 virtual PlatformLayer* platformLayer() const { return 0; }
57 virtual void play() = 0;
58 virtual void pause() = 0;
60 virtual bool supportsFullscreen() const { return false; }
61 virtual bool supportsSave() const { return false; }
62 virtual bool supportsScanning() const { return false; }
64 virtual IntSize naturalSize() const = 0;
66 virtual bool hasVideo() const = 0;
67 virtual bool hasAudio() const = 0;
69 virtual void setVisible(bool) = 0;
71 virtual float duration() const = 0;
73 virtual float currentTime() const = 0;
74 virtual void seek(float time) = 0;
75 virtual bool seeking() const = 0;
77 virtual float startTime() const { return 0; }
79 virtual double initialTime() const { return 0; }
81 virtual void setRate(float) = 0;
82 virtual void setPreservesPitch(bool) { }
84 virtual bool paused() const = 0;
86 virtual void setVolume(float) = 0;
88 virtual bool supportsMuting() const { return false; }
89 virtual void setMuted(bool) { }
91 virtual bool hasClosedCaptions() const { return false; }
92 virtual void setClosedCaptionsVisible(bool) { }
94 virtual MediaPlayer::NetworkState networkState() const = 0;
95 virtual MediaPlayer::ReadyState readyState() const = 0;
97 virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekable() ? TimeRanges::create(0, maxTimeSeekable()) : TimeRanges::create(); }
98 virtual float maxTimeSeekable() const = 0;
99 virtual PassRefPtr<TimeRanges> buffered() const = 0;
101 virtual bool didLoadingProgress() const = 0;
103 virtual void setSize(const IntSize&) = 0;
105 virtual void paint(GraphicsContext*, const IntRect&) = 0;
107 virtual void paintCurrentFrameInContext(GraphicsContext* c, const IntRect& r) { paint(c, r); }
109 virtual void setPreload(MediaPlayer::Preload) { };
111 virtual bool hasAvailableVideoFrame() const { return readyState() >= MediaPlayer::HaveCurrentData; }
113 virtual bool canLoadPoster() const { return false; }
114 virtual void setPoster(const String&) { }
116 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
117 virtual void deliverNotification(MediaPlayerProxyNotificationType) = 0;
118 virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) = 0;
119 virtual void setControls(bool) { }
122 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) || USE(NATIVE_FULLSCREEN_VIDEO)
123 virtual void enterFullscreen() { }
124 virtual void exitFullscreen() { }
127 #if USE(NATIVE_FULLSCREEN_VIDEO)
128 virtual bool canEnterFullscreen() const { return false; }
131 #if USE(ACCELERATED_COMPOSITING)
132 // whether accelerated rendering is supported by the media engine for the current media.
133 virtual bool supportsAcceleratedRendering() const { return false; }
134 // called when the rendering system flips the into or out of accelerated rendering mode.
135 virtual void acceleratedRenderingStateChanged() { }
138 virtual bool hasSingleSecurityOrigin() const { return false; }
140 virtual bool didPassCORSAccessCheck() const { return false; }
142 virtual MediaPlayer::MovieLoadType movieLoadType() const { return MediaPlayer::Unknown; }
144 virtual void prepareForRendering() { }
146 // Time value in the movie's time scale. It is only necessary to override this if the media
147 // engine uses rational numbers to represent media time.
148 virtual float mediaTimeForTimeValue(float timeValue) const { return timeValue; }
150 // Overide this if it is safe for HTMLMediaElement to cache movie time and report
151 // 'currentTime' as [cached time + elapsed wall time]. Returns the maximum wall time
152 // it is OK to calculate movie time before refreshing the cached time.
153 virtual double maximumDurationToCacheMediaTime() const { return 0; }
155 virtual unsigned decodedFrameCount() const { return 0; }
156 virtual unsigned droppedFrameCount() const { return 0; }
157 virtual unsigned audioDecodedByteCount() const { return 0; }
158 virtual unsigned videoDecodedByteCount() const { return 0; }
160 void getSitesInMediaCache(Vector<String>&) { }
161 void clearMediaCache() { }
162 void clearMediaCacheForSite(const String&) { }
164 virtual void setPrivateBrowsingMode(bool) { }
166 virtual String engineDescription() const { return emptyString(); }
168 #if ENABLE(WEB_AUDIO)
169 virtual AudioSourceProvider* audioSourceProvider() { return 0; }
172 #if ENABLE(MEDIA_SOURCE)
173 virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
174 virtual PassRefPtr<TimeRanges> sourceBuffered(const String& id) { return TimeRanges::create(); }
175 virtual bool sourceRemoveId(const String& id) { return false; }
176 virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
177 virtual bool sourceAbort(const String& id) { return false; }
178 virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { };
181 #if ENABLE(ENCRYPTED_MEDIA)
182 virtual MediaPlayer::MediaKeyException addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId) { return MediaPlayer::KeySystemNotSupported; }
183 virtual MediaPlayer::MediaKeyException generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength) { return MediaPlayer::KeySystemNotSupported; }
184 virtual MediaPlayer::MediaKeyException cancelKeyRequest(const String& keySystem, const String& sessionId) { return MediaPlayer::KeySystemNotSupported; }