| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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 "WebCanvas.h" | |
| 35 #include "WebMediaSource.h" | |
| 36 #include "WebString.h" | |
| 37 #include "WebTimeRange.h" | |
| 38 #include "third_party/skia/include/core/SkXfermode.h" | |
| 39 | |
| 40 namespace blink { | |
| 41 | |
| 42 class WebMediaPlayerClient; | |
| 43 class WebString; | |
| 44 class WebURL; | |
| 45 struct WebRect; | |
| 46 struct WebSize; | |
| 47 class WebGraphicsContext3D; | |
| 48 | |
| 49 class WebMediaPlayer { | |
| 50 public: | |
| 51 enum NetworkState { | |
| 52 NetworkStateEmpty, | |
| 53 NetworkStateIdle, | |
| 54 NetworkStateLoading, | |
| 55 NetworkStateLoaded, | |
| 56 NetworkStateFormatError, | |
| 57 NetworkStateNetworkError, | |
| 58 NetworkStateDecodeError, | |
| 59 }; | |
| 60 | |
| 61 enum ReadyState { | |
| 62 ReadyStateHaveNothing, | |
| 63 ReadyStateHaveMetadata, | |
| 64 ReadyStateHaveCurrentData, | |
| 65 ReadyStateHaveFutureData, | |
| 66 ReadyStateHaveEnoughData, | |
| 67 }; | |
| 68 | |
| 69 enum Preload { | |
| 70 PreloadNone, | |
| 71 PreloadMetaData, | |
| 72 PreloadAuto, | |
| 73 }; | |
| 74 | |
| 75 // Represents synchronous exceptions that can be thrown from the Encrypted | |
| 76 // Media methods. This is different from the asynchronous MediaKeyError. | |
| 77 enum MediaKeyException { | |
| 78 MediaKeyExceptionNoError, | |
| 79 MediaKeyExceptionInvalidPlayerState, | |
| 80 MediaKeyExceptionKeySystemNotSupported, | |
| 81 MediaKeyExceptionInvalidAccess, | |
| 82 }; | |
| 83 | |
| 84 enum CORSMode { | |
| 85 CORSModeUnspecified, | |
| 86 CORSModeAnonymous, | |
| 87 CORSModeUseCredentials, | |
| 88 }; | |
| 89 | |
| 90 enum LoadType { | |
| 91 LoadTypeURL, | |
| 92 LoadTypeMediaSource, | |
| 93 }; | |
| 94 | |
| 95 typedef unsigned TrackId; | |
| 96 | |
| 97 virtual ~WebMediaPlayer() { } | |
| 98 | |
| 99 virtual void load(LoadType, const WebURL&, CORSMode) = 0; | |
| 100 | |
| 101 // Playback controls. | |
| 102 virtual void play() = 0; | |
| 103 virtual void pause() = 0; | |
| 104 virtual bool supportsSave() const = 0; | |
| 105 virtual void seek(double seconds) = 0; | |
| 106 virtual void setRate(double) = 0; | |
| 107 virtual void setVolume(double) = 0; | |
| 108 virtual void setPreload(Preload) { }; | |
| 109 virtual WebTimeRanges buffered() const = 0; | |
| 110 virtual double maxTimeSeekable() const = 0; | |
| 111 | |
| 112 // True if the loaded media has a playable video/audio track. | |
| 113 virtual bool hasVideo() const = 0; | |
| 114 virtual bool hasAudio() const = 0; | |
| 115 | |
| 116 // Dimension of the video. | |
| 117 virtual WebSize naturalSize() const = 0; | |
| 118 | |
| 119 // Getters of playback state. | |
| 120 virtual bool paused() const = 0; | |
| 121 virtual bool seeking() const = 0; | |
| 122 virtual double duration() const = 0; | |
| 123 virtual double currentTime() const = 0; | |
| 124 | |
| 125 // Internal states of loading and network. | |
| 126 virtual NetworkState networkState() const = 0; | |
| 127 virtual ReadyState readyState() const = 0; | |
| 128 | |
| 129 virtual bool didLoadingProgress() = 0; | |
| 130 | |
| 131 virtual bool didPassCORSAccessCheck() const = 0; | |
| 132 | |
| 133 virtual double mediaTimeForTimeValue(double timeValue) const = 0; | |
| 134 | |
| 135 virtual unsigned decodedFrameCount() const = 0; | |
| 136 virtual unsigned droppedFrameCount() const = 0; | |
| 137 virtual unsigned corruptedFrameCount() const { return 0; }; | |
| 138 virtual unsigned audioDecodedByteCount() const = 0; | |
| 139 virtual unsigned videoDecodedByteCount() const = 0; | |
| 140 | |
| 141 virtual void paint(WebCanvas*, const WebRect&, unsigned char alpha, SkXfermo
de::Mode) = 0; | |
| 142 // Do a GPU-GPU textures copy if possible. | |
| 143 virtual bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, unsign
ed texture, unsigned level, unsigned internalFormat, unsigned type, bool premult
iplyAlpha, bool flipY) { return false; } | |
| 144 | |
| 145 // Returns whether keySystem is supported. If true, the result will be | |
| 146 // reported by an event. | |
| 147 virtual MediaKeyException generateKeyRequest(const WebString& keySystem, con
st unsigned char* initData, unsigned initDataLength) { return MediaKeyExceptionK
eySystemNotSupported; } | |
| 148 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; } | |
| 149 virtual MediaKeyException cancelKeyRequest(const WebString& keySystem, const
WebString& sessionId) { return MediaKeyExceptionKeySystemNotSupported; } | |
| 150 | |
| 151 // Sets the poster image URL. | |
| 152 virtual void setPoster(const WebURL& poster) { } | |
| 153 | |
| 154 // Instruct WebMediaPlayer to enter/exit fullscreen. | |
| 155 virtual void enterFullscreen() { } | |
| 156 // Returns true if the player can enter fullscreen. | |
| 157 virtual bool canEnterFullscreen() const { return false; } | |
| 158 | |
| 159 virtual void enabledAudioTracksChanged(const WebVector<TrackId>& enabledTrac
kIds) { } | |
| 160 // |selectedTrackId| is null if no track is selected. | |
| 161 virtual void selectedVideoTrackChanged(TrackId* selectedTrackId) { } | |
| 162 }; | |
| 163 | |
| 164 } // namespace blink | |
| 165 | |
| 166 #endif | |
| OLD | NEW |