2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 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.
29 #include "platform/PlatformExport.h"
30 #include "platform/graphics/GraphicsTypes3D.h"
31 #include "public/platform/WebMediaPlayer.h"
32 #include "wtf/Forward.h"
33 #include "wtf/Noncopyable.h"
36 class WebGraphicsContext3D;
37 class WebContentDecryptionModule;
38 class WebInbandTextTrack;
45 class AudioSourceProvider;
46 class GraphicsContext;
53 // GL types as defined in OpenGL ES 2.0 header file gl2.h from khronos.org.
54 // That header cannot be included directly due to a conflict with NPAPI headers.
55 // See crbug.com/328085.
56 typedef unsigned GC3Denum;
59 class MediaPlayerClient {
61 virtual ~MediaPlayerClient() { }
63 // the network state has changed
64 virtual void mediaPlayerNetworkStateChanged() = 0;
66 // the ready state has changed
67 virtual void mediaPlayerReadyStateChanged() = 0;
69 // time has jumped, eg. not as a result of normal playback
70 virtual void mediaPlayerTimeChanged() = 0;
72 // the media file duration has changed, or is now known
73 virtual void mediaPlayerDurationChanged() = 0;
75 // the play/pause status changed
76 virtual void mediaPlayerPlaybackStateChanged() = 0;
78 virtual void mediaPlayerRequestFullscreen() = 0;
80 virtual void mediaPlayerRequestSeek(double) = 0;
82 // The URL for video poster image.
83 // FIXME: Remove this when WebMediaPlayerClientImpl::loadInternal does not depend on it.
84 virtual KURL mediaPlayerPosterURL() = 0;
86 // Presentation-related methods
87 // a new frame of video is available
88 virtual void mediaPlayerRepaint() = 0;
90 // the movie size has changed
91 virtual void mediaPlayerSizeChanged() = 0;
93 virtual void mediaPlayerSetWebLayer(blink::WebLayer*) = 0;
95 virtual void mediaPlayerDidAddTextTrack(blink::WebInbandTextTrack*) = 0;
96 virtual void mediaPlayerDidRemoveTextTrack(blink::WebInbandTextTrack*) = 0;
98 virtual void mediaPlayerMediaSourceOpened(blink::WebMediaSource*) = 0;
101 typedef PassOwnPtr<MediaPlayer> (*CreateMediaEnginePlayer)(MediaPlayerClient*);
103 class PLATFORM_EXPORT MediaPlayer {
104 WTF_MAKE_NONCOPYABLE(MediaPlayer);
106 static PassOwnPtr<MediaPlayer> create(MediaPlayerClient*);
107 static void setMediaEngineCreateFunction(CreateMediaEnginePlayer);
109 static double invalidTime() { return -1.0; }
112 virtual ~MediaPlayer() { }
114 virtual void load(blink::WebMediaPlayer::LoadType, const String& url, blink::WebMediaPlayer::CORSMode) = 0;
116 virtual void play() = 0;
117 virtual void pause() = 0;
119 virtual bool supportsSave() const = 0;
120 virtual IntSize naturalSize() const = 0;
122 virtual bool hasVideo() const = 0;
123 virtual bool hasAudio() const = 0;
125 virtual double duration() const = 0;
127 virtual double currentTime() const = 0;
129 virtual void seek(double) = 0;
131 virtual bool seeking() const = 0;
133 virtual double rate() const = 0;
134 virtual void setRate(double) = 0;
136 virtual bool paused() const = 0;
138 virtual void setPoster(const KURL&) = 0;
140 enum NetworkState { Empty, Idle, Loading, Loaded, FormatError, NetworkError, DecodeError };
141 virtual NetworkState networkState() const = 0;
143 enum ReadyState { HaveNothing, HaveMetadata, HaveCurrentData, HaveFutureData, HaveEnoughData };
144 virtual ReadyState readyState() const = 0;
146 virtual double maxTimeSeekable() const = 0;
147 virtual PassRefPtr<TimeRanges> buffered() const = 0;
149 virtual bool didLoadingProgress() const = 0;
151 virtual void paint(GraphicsContext*, const IntRect&) = 0;
152 virtual bool copyVideoTextureToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject, GC3Dint, GC3Denum, GC3Denum, bool, bool) = 0;
154 enum Preload { None, MetaData, Auto };
155 virtual void setPreload(Preload) = 0;
157 virtual void showFullscreenOverlay() = 0;
158 virtual void hideFullscreenOverlay() = 0;
159 virtual bool canShowFullscreenOverlay() const = 0;
161 virtual bool hasSingleSecurityOrigin() const = 0;
163 virtual bool didPassCORSAccessCheck() const = 0;
165 // Time value in the movie's time scale. It is only necessary to override this if the media
166 // engine uses rational numbers to represent media time.
167 virtual double mediaTimeForTimeValue(double timeValue) const = 0;
169 virtual unsigned decodedFrameCount() const = 0;
170 virtual unsigned droppedFrameCount() const = 0;
171 virtual unsigned corruptedFrameCount() const = 0;
172 virtual unsigned audioDecodedByteCount() const = 0;
173 virtual unsigned videoDecodedByteCount() const = 0;
175 #if ENABLE(WEB_AUDIO)
176 virtual AudioSourceProvider* audioSourceProvider() = 0;
178 virtual blink::WebMediaPlayer* webMediaPlayer() const = 0;
183 #endif // MediaPlayer_h