15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)/* 25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * Copyright (C) 2009 Google Inc. All rights reserved. 35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * 45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * modification, are permitted provided that the following conditions are 65f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * met: 75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * 85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * * Redistributions of source code must retain the above copyright 95f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * * Redistributions in binary form must reproduce the above 115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * in the documentation and/or other materials provided with the 135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * distribution. 145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * contributors may be used to endorse or promote products derived from 165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * this software without specific prior written permission. 175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * 185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) */ 305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#ifndef WebMediaPlayer_h 325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#define WebMediaPlayer_h 335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "WebCanvas.h" 355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "WebContentDecryptionModule.h" 365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "WebMediaSource.h" 375f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "WebString.h" 385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "WebTimeRange.h" 395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "third_party/skia/include/core/SkXfermode.h" 405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace blink { 425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebAudioSourceProvider; 445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebAudioSourceProviderClient; 455f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebContentDecryptionModule; 465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebMediaPlayerClient; 475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebString; 485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebURL; 495f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)struct WebRect; 505f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)struct WebSize; 515f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebGraphicsContext3D; 525f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 535f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class WebMediaPlayer { 545f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)public: 555f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) enum NetworkState { 565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateEmpty, 575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateIdle, 585f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateLoading, 595f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateLoaded, 605f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateFormatError, 615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateNetworkError, 625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) NetworkStateDecodeError, 635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) }; 645f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 655f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) enum ReadyState { 665f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ReadyStateHaveNothing, 675f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ReadyStateHaveMetadata, 685f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ReadyStateHaveCurrentData, 695f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ReadyStateHaveFutureData, 705f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) ReadyStateHaveEnoughData, 715f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) }; 725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) enum Preload { 745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) PreloadNone, 755f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) PreloadMetaData, 765f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) PreloadAuto, 775f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) }; 785f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 79 // Represents synchronous exceptions that can be thrown from the Encrypted 80 // Media methods. This is different from the asynchronous MediaKeyError. 81 enum MediaKeyException { 82 MediaKeyExceptionNoError, 83 MediaKeyExceptionInvalidPlayerState, 84 MediaKeyExceptionKeySystemNotSupported, 85 MediaKeyExceptionInvalidAccess, 86 }; 87 88 enum CORSMode { 89 CORSModeUnspecified, 90 CORSModeAnonymous, 91 CORSModeUseCredentials, 92 }; 93 94 enum LoadType { 95 LoadTypeURL, 96 LoadTypeMediaSource, 97 LoadTypeMediaStream, 98 }; 99 100 typedef unsigned TrackId; 101 102 virtual ~WebMediaPlayer() { } 103 104 virtual void load(LoadType, const WebURL&, CORSMode) = 0; 105 106 // Playback controls. 107 virtual void play() = 0; 108 virtual void pause() = 0; 109 virtual bool supportsSave() const = 0; 110 virtual void seek(double seconds) = 0; 111 virtual void setRate(double) = 0; 112 virtual void setVolume(double) = 0; 113 virtual void requestRemotePlayback() { }; 114 virtual void requestRemotePlaybackControl() { }; 115 virtual void setPreload(Preload) { }; 116 virtual WebTimeRanges buffered() const = 0; 117 virtual double maxTimeSeekable() const = 0; 118 119 // True if the loaded media has a playable video/audio track. 120 virtual bool hasVideo() const = 0; 121 virtual bool hasAudio() const = 0; 122 123 // True if the media is being played on a remote device. 124 virtual bool isRemote() const { return false; } 125 126 // Dimension of the video. 127 virtual WebSize naturalSize() const = 0; 128 129 // Getters of playback state. 130 virtual bool paused() const = 0; 131 virtual bool seeking() const = 0; 132 virtual double duration() const = 0; 133 virtual double currentTime() const = 0; 134 135 // Internal states of loading and network. 136 virtual NetworkState networkState() const = 0; 137 virtual ReadyState readyState() const = 0; 138 139 virtual bool didLoadingProgress() = 0; 140 141 virtual bool hasSingleSecurityOrigin() const = 0; 142 virtual bool didPassCORSAccessCheck() const = 0; 143 144 virtual double mediaTimeForTimeValue(double timeValue) const = 0; 145 146 virtual unsigned decodedFrameCount() const = 0; 147 virtual unsigned droppedFrameCount() const = 0; 148 virtual unsigned corruptedFrameCount() const { return 0; }; 149 virtual unsigned audioDecodedByteCount() const = 0; 150 virtual unsigned videoDecodedByteCount() const = 0; 151 152 virtual void paint(WebCanvas*, const WebRect&, unsigned char alpha, SkXfermode::Mode) = 0; 153 // Do a GPU-GPU textures copy if possible. 154 virtual bool copyVideoTextureToPlatformTexture(WebGraphicsContext3D*, unsigned texture, unsigned level, unsigned internalFormat, unsigned type, bool premultiplyAlpha, bool flipY) { return false; } 155 156 virtual WebAudioSourceProvider* audioSourceProvider() { return 0; } 157 158 // Returns whether keySystem is supported. If true, the result will be 159 // reported by an event. 160 virtual MediaKeyException generateKeyRequest(const WebString& keySystem, const unsigned char* initData, unsigned initDataLength) { return MediaKeyExceptionKeySystemNotSupported; } 161 virtual MediaKeyException addKey(const WebString& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const WebString& sessionId) { return MediaKeyExceptionKeySystemNotSupported; } 162 virtual MediaKeyException cancelKeyRequest(const WebString& keySystem, const WebString& sessionId) { return MediaKeyExceptionKeySystemNotSupported; } 163 virtual void setContentDecryptionModule(WebContentDecryptionModule* cdm, WebContentDecryptionModuleResult result) { result.completeWithError(WebContentDecryptionModuleExceptionNotSupportedError, 0, "ERROR"); } 164 165 // Sets the poster image URL. 166 virtual void setPoster(const WebURL& poster) { } 167 168 // Instruct WebMediaPlayer to enter/exit fullscreen. 169 virtual void enterFullscreen() { } 170 // Returns true if the player can enter fullscreen. 171 virtual bool canEnterFullscreen() const { return false; } 172 173 virtual void enabledAudioTracksChanged(const WebVector<TrackId>& enabledTrackIds) { } 174 // |selectedTrackId| is null if no track is selected. 175 virtual void selectedVideoTrackChanged(TrackId* selectedTrackId) { } 176}; 177 178} // namespace blink 179 180#endif 181