| OLD | NEW |
| 1 /* | 1 #include "../../../../public/webview/WebMediaPlayer.h" |
| 2 * Copyright (C) 2009 Google 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 are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef WebMediaPlayer_h | |
| 32 #define WebMediaPlayer_h | |
| 33 | |
| 34 #include "../../../../public/platform/WebCanvas.h" | |
| 35 #include "../../../../public/platform/WebString.h" | |
| 36 #include "WebTimeRange.h" | |
| 37 | |
| 38 namespace WebKit { | |
| 39 | |
| 40 class WebAudioSourceProvider; | |
| 41 class WebAudioSourceProviderClient; | |
| 42 class WebMediaPlayerClient; | |
| 43 class WebMediaSource; | |
| 44 class WebString; | |
| 45 class WebURL; | |
| 46 struct WebRect; | |
| 47 struct WebSize; | |
| 48 class WebGraphicsContext3D; | |
| 49 | |
| 50 class WebMediaPlayer { | |
| 51 public: | |
| 52 enum NetworkState { | |
| 53 NetworkStateEmpty, | |
| 54 NetworkStateIdle, | |
| 55 NetworkStateLoading, | |
| 56 NetworkStateLoaded, | |
| 57 NetworkStateFormatError, | |
| 58 NetworkStateNetworkError, | |
| 59 NetworkStateDecodeError, | |
| 60 }; | |
| 61 | |
| 62 enum ReadyState { | |
| 63 ReadyStateHaveNothing, | |
| 64 ReadyStateHaveMetadata, | |
| 65 ReadyStateHaveCurrentData, | |
| 66 ReadyStateHaveFutureData, | |
| 67 ReadyStateHaveEnoughData, | |
| 68 }; | |
| 69 | |
| 70 enum MovieLoadType { | |
| 71 MovieLoadTypeUnknown, | |
| 72 MovieLoadTypeDownload, | |
| 73 MovieLoadTypeStoredStream, | |
| 74 MovieLoadTypeLiveStream, | |
| 75 }; | |
| 76 | |
| 77 enum Preload { | |
| 78 PreloadNone, | |
| 79 PreloadMetaData, | |
| 80 PreloadAuto, | |
| 81 }; | |
| 82 | |
| 83 // Represents synchronous exceptions that can be thrown from the Encrypted | |
| 84 // Media methods. This is different from the asynchronous MediaKeyError. | |
| 85 enum MediaKeyException { | |
| 86 MediaKeyExceptionNoError, | |
| 87 MediaKeyExceptionInvalidPlayerState, | |
| 88 MediaKeyExceptionKeySystemNotSupported, | |
| 89 }; | |
| 90 | |
| 91 enum CORSMode { | |
| 92 CORSModeUnspecified, | |
| 93 CORSModeAnonymous, | |
| 94 CORSModeUseCredentials, | |
| 95 }; | |
| 96 | |
| 97 virtual ~WebMediaPlayer() {} | |
| 98 | |
| 99 virtual void load(const WebURL&, CORSMode) = 0; | |
| 100 virtual void load(const WebURL&, WebMediaSource*, CORSMode) = 0; | |
| 101 virtual void cancelLoad() { } // FIXME: Remove once Chromium no longer overr
ides | |
| 102 | |
| 103 // Playback controls. | |
| 104 virtual void play() = 0; | |
| 105 virtual void pause() = 0; | |
| 106 virtual bool supportsFullscreen() const = 0; | |
| 107 virtual bool supportsSave() const = 0; | |
| 108 virtual void seek(double seconds) = 0; | |
| 109 virtual void setRate(double rate) = 0; | |
| 110 virtual void setVolume(double volume) = 0; | |
| 111 virtual void setVisible(bool) = 0; | |
| 112 virtual void setPreload(Preload) { }; | |
| 113 virtual bool totalBytesKnown() = 0; | |
| 114 virtual const WebTimeRanges& buffered() = 0; | |
| 115 virtual double maxTimeSeekable() const = 0; | |
| 116 | |
| 117 virtual void setSize(const WebSize&) = 0; | |
| 118 | |
| 119 virtual void paint(WebCanvas*, const WebRect&, unsigned char alpha) = 0; | |
| 120 | |
| 121 // True if the loaded media has a playable video/audio track. | |
| 122 virtual bool hasVideo() const = 0; | |
| 123 virtual bool hasAudio() const = 0; | |
| 124 | |
| 125 // Dimension of the video. | |
| 126 virtual WebSize naturalSize() const = 0; | |
| 127 | |
| 128 // Getters of playback state. | |
| 129 virtual bool paused() const = 0; | |
| 130 virtual bool seeking() const = 0; | |
| 131 virtual double duration() const = 0; | |
| 132 virtual double currentTime() const = 0; | |
| 133 | |
| 134 // Get rate of loading the resource. | |
| 135 virtual int dataRate() const = 0; | |
| 136 | |
| 137 // Internal states of loading and network. | |
| 138 virtual NetworkState networkState() const = 0; | |
| 139 virtual ReadyState readyState() const = 0; | |
| 140 | |
| 141 virtual bool didLoadingProgress() const = 0; | |
| 142 virtual unsigned long long totalBytes() const = 0; | |
| 143 | |
| 144 virtual bool hasSingleSecurityOrigin() const = 0; | |
| 145 virtual bool didPassCORSAccessCheck() const = 0; | |
| 146 virtual MovieLoadType movieLoadType() const = 0; | |
| 147 | |
| 148 virtual double mediaTimeForTimeValue(double timeValue) const = 0; | |
| 149 | |
| 150 virtual unsigned decodedFrameCount() const = 0; | |
| 151 virtual unsigned droppedFrameCount() const = 0; | |
| 152 virtual unsigned audioDecodedByteCount() const = 0; | |
| 153 virtual unsigned videoDecodedByteCount() const = 0; | |
| 154 | |
| 155 // Do a GPU-GPU textures copy if possible. | |
| 156 virtual bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, unsign
ed texture, unsigned level, unsigned internalFormat, unsigned type, bool premult
iplyAlpha, bool flipY) { return false; } | |
| 157 | |
| 158 virtual WebAudioSourceProvider* audioSourceProvider() { return 0; } | |
| 159 | |
| 160 // Returns whether keySystem is supported. If true, the result will be | |
| 161 // reported by an event. | |
| 162 virtual MediaKeyException generateKeyRequest(const WebString& keySystem, con
st unsigned char* initData, unsigned initDataLength) { return MediaKeyExceptionK
eySystemNotSupported; } | |
| 163 virtual MediaKeyException addKey(const WebString& keySystem, const unsigned
char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataL
ength, const WebString& sessionId) { return MediaKeyExceptionKeySystemNotSupport
ed; } | |
| 164 virtual MediaKeyException cancelKeyRequest(const WebString& keySystem, const
WebString& sessionId) { return MediaKeyExceptionKeySystemNotSupported; } | |
| 165 | |
| 166 // Instruct WebMediaPlayer to enter/exit fullscreen. | |
| 167 virtual void enterFullscreen() { } | |
| 168 virtual void exitFullscreen() { } | |
| 169 // Returns true if the player can enter fullscreen. | |
| 170 virtual bool canEnterFullscreen() const { return false; } | |
| 171 }; | |
| 172 | |
| 173 } // namespace WebKit | |
| 174 | |
| 175 #endif | |
| OLD | NEW |