Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: Source/web/WebMediaPlayerClientImpl.cpp

Issue 157423003: Remove the dependency on encryptedmedia from HTMLMediaElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address ddorwin's review comments. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "WebMediaPlayerClientImpl.h" 6 #include "WebMediaPlayerClientImpl.h"
7 7
8 #include "WebDocument.h" 8 #include "WebDocument.h"
9 #include "WebFrameClient.h" 9 #include "WebFrameClient.h"
10 #include "WebFrameImpl.h" 10 #include "WebFrameImpl.h"
11 #include "WebHelperPlugin.h" 11 #include "WebHelperPlugin.h"
12 #include "WebViewImpl.h" 12 #include "WebViewImpl.h"
13 #include "core/frame/Frame.h" 13 #include "core/frame/Frame.h"
14 #include "core/html/HTMLMediaElement.h" 14 #include "core/html/HTMLMediaElement.h"
15 #include "core/html/TimeRanges.h" 15 #include "core/html/TimeRanges.h"
16 #include "core/rendering/RenderLayerCompositor.h" 16 #include "core/rendering/RenderLayerCompositor.h"
17 #include "core/rendering/RenderView.h" 17 #include "core/rendering/RenderView.h"
18 #include "modules/encryptedMedia/HTMLMediaElementEncryptedMedia.h"
19 #include "modules/encryptedMedia/MediaKeyNeededEvent.h"
18 #include "modules/mediastream/MediaStreamRegistry.h" 20 #include "modules/mediastream/MediaStreamRegistry.h"
19 #include "platform/audio/AudioBus.h" 21 #include "platform/audio/AudioBus.h"
20 #include "platform/audio/AudioSourceProviderClient.h" 22 #include "platform/audio/AudioSourceProviderClient.h"
21 #include "platform/geometry/IntSize.h" 23 #include "platform/geometry/IntSize.h"
22 #include "platform/graphics/GraphicsContext.h" 24 #include "platform/graphics/GraphicsContext.h"
23 #include "platform/graphics/GraphicsLayer.h" 25 #include "platform/graphics/GraphicsLayer.h"
24 #include "platform/graphics/gpu/Extensions3DUtil.h" 26 #include "platform/graphics/gpu/Extensions3DUtil.h"
25 #include "platform/graphics/skia/GaneshUtils.h" 27 #include "platform/graphics/skia/GaneshUtils.h"
26 #include "public/platform/Platform.h" 28 #include "public/platform/Platform.h"
27 #include "public/platform/WebAudioSourceProvider.h" 29 #include "public/platform/WebAudioSourceProvider.h"
(...skipping 25 matching lines...) Expand all
53 55
54 static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* cli ent, const WebURL& url, Frame* frame) 56 static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* cli ent, const WebURL& url, Frame* frame)
55 { 57 {
56 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame); 58 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
57 59
58 if (!webFrame->client()) 60 if (!webFrame->client())
59 return nullptr; 61 return nullptr;
60 return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client) ); 62 return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client) );
61 } 63 }
62 64
63 WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const 65 WebMediaPlayer* WebMediaPlayerClientImpl::webMediaPlayer() const
64 { 66 {
65 return m_webMediaPlayer.get(); 67 return m_webMediaPlayer.get();
66 } 68 }
67 69
68 // WebMediaPlayerClient -------------------------------------------------------- 70 // WebMediaPlayerClient --------------------------------------------------------
69 71
70 WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl() 72 WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl()
71 { 73 {
74 HTMLMediaElementEncryptedMedia::playerDestroyed(mediaElement());
75
72 // Explicitly destroy the WebMediaPlayer to allow verification of tear down. 76 // Explicitly destroy the WebMediaPlayer to allow verification of tear down.
73 m_webMediaPlayer.clear(); 77 m_webMediaPlayer.clear();
74 78
75 // Ensure the m_webMediaPlayer destroyed any WebHelperPlugin used. 79 // Ensure the m_webMediaPlayer destroyed any WebHelperPlugin used.
76 ASSERT(!m_helperPlugin); 80 ASSERT(!m_helperPlugin);
77 } 81 }
78 82
79 void WebMediaPlayerClientImpl::networkStateChanged() 83 void WebMediaPlayerClientImpl::networkStateChanged()
80 { 84 {
81 m_client->mediaPlayerNetworkStateChanged(); 85 m_client->mediaPlayerNetworkStateChanged();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 m_client->mediaPlayerPlaybackStateChanged(); 125 m_client->mediaPlayerPlaybackStateChanged();
122 } 126 }
123 127
124 WebMediaPlayer::Preload WebMediaPlayerClientImpl::preload() const 128 WebMediaPlayer::Preload WebMediaPlayerClientImpl::preload() const
125 { 129 {
126 return static_cast<WebMediaPlayer::Preload>(m_preload); 130 return static_cast<WebMediaPlayer::Preload>(m_preload);
127 } 131 }
128 132
129 void WebMediaPlayerClientImpl::keyAdded(const WebString& keySystem, const WebStr ing& sessionId) 133 void WebMediaPlayerClientImpl::keyAdded(const WebString& keySystem, const WebStr ing& sessionId)
130 { 134 {
131 m_client->mediaPlayerKeyAdded(keySystem, sessionId); 135 HTMLMediaElementEncryptedMedia::keyAdded(mediaElement(), keySystem, sessionI d);
132 } 136 }
133 137
134 void WebMediaPlayerClientImpl::keyError(const WebString& keySystem, const WebStr ing& sessionId, MediaKeyErrorCode errorCode, unsigned short systemCode) 138 void WebMediaPlayerClientImpl::keyError(const WebString& keySystem, const WebStr ing& sessionId, MediaKeyErrorCode errorCode, unsigned short systemCode)
135 { 139 {
136 m_client->mediaPlayerKeyError(keySystem, sessionId, static_cast<MediaPlayerC lient::MediaKeyErrorCode>(errorCode), systemCode); 140 HTMLMediaElementEncryptedMedia::keyError(mediaElement(), keySystem, sessionI d, errorCode, systemCode);
137 } 141 }
138 142
139 void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebS tring& sessionId, const unsigned char* message, unsigned messageLength, const We bURL& defaultURL) 143 void WebMediaPlayerClientImpl::keyMessage(const WebString& keySystem, const WebS tring& sessionId, const unsigned char* message, unsigned messageLength, const We bURL& defaultURL)
140 { 144 {
141 m_client->mediaPlayerKeyMessage(keySystem, sessionId, message, messageLength , defaultURL); 145 HTMLMediaElementEncryptedMedia::keyMessage(mediaElement(), keySystem, sessio nId, message, messageLength, defaultURL);
142 } 146 }
143 147
144 void WebMediaPlayerClientImpl::keyNeeded(const WebString& contentType, const uns igned char* initData, unsigned initDataLength) 148 void WebMediaPlayerClientImpl::keyNeeded(const WebString& contentType, const uns igned char* initData, unsigned initDataLength)
145 { 149 {
146 m_client->mediaPlayerKeyNeeded(contentType, initData, initDataLength); 150 HTMLMediaElementEncryptedMedia::keyNeeded(mediaElement(), contentType, initD ata, initDataLength);
147 } 151 }
148 152
149 WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginT ype, WebFrame* frame) 153 WebPlugin* WebMediaPlayerClientImpl::createHelperPlugin(const WebString& pluginT ype, WebFrame* frame)
150 { 154 {
151 ASSERT(!m_helperPlugin); 155 ASSERT(!m_helperPlugin);
152 156
153 m_helperPlugin = adoptPtr(frame->view()->createHelperPlugin(pluginType, fram e->document())); 157 m_helperPlugin = adoptPtr(frame->view()->createHelperPlugin(pluginType, fram e->document()));
154 if (!m_helperPlugin) 158 if (!m_helperPlugin)
155 return 0; 159 return 0;
156 160
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 loadInternal(); 224 loadInternal();
221 } 225 }
222 226
223 void WebMediaPlayerClientImpl::loadInternal() 227 void WebMediaPlayerClientImpl::loadInternal()
224 { 228 {
225 #if ENABLE(WEB_AUDIO) 229 #if ENABLE(WEB_AUDIO)
226 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider. 230 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
227 #endif 231 #endif
228 232
229 // FIXME: Remove this cast 233 // FIXME: Remove this cast
230 Frame* frame = static_cast<HTMLMediaElement*>(m_client)->document().frame(); 234 Frame* frame = mediaElement().document().frame();
231 235
232 WebURL poster = m_client->mediaPlayerPosterURL(); 236 WebURL poster = m_client->mediaPlayerPosterURL();
233 237
234 // This does not actually check whether the hardware can support accelerated 238 // This does not actually check whether the hardware can support accelerated
235 // compositing, but only if the flag is set. However, this is checked lazily 239 // compositing, but only if the flag is set. However, this is checked lazily
236 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there 240 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there
237 // if necessary. 241 // if necessary.
238 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing(); 242 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing();
239 243
240 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame); 244 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
241 if (m_webMediaPlayer) { 245 if (m_webMediaPlayer) {
242 #if ENABLE(WEB_AUDIO) 246 #if ENABLE(WEB_AUDIO)
243 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper. 247 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper.
244 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); 248 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
245 #endif 249 #endif
246 250
247 // Tell WebMediaPlayer about the poster image URL. 251 // Tell WebMediaPlayer about the poster image URL.
248 m_webMediaPlayer->setPoster(poster); 252 m_webMediaPlayer->setPoster(poster);
249 253
250 // Tell WebMediaPlayer about any connected CDM (may be null). 254 // Tell WebMediaPlayer about any connected CDM (may be null).
251 m_webMediaPlayer->setContentDecryptionModule(m_cdm); 255 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMe dia::contentDecryptionModule(mediaElement()));
252 256
253 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode()); 257 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode());
254 m_webMediaPlayer->load(m_loadType, m_url, corsMode); 258 m_webMediaPlayer->load(m_loadType, m_url, corsMode);
255 } 259 }
256 } 260 }
257 261
258 void WebMediaPlayerClientImpl::play() 262 void WebMediaPlayerClientImpl::play()
259 { 263 {
260 if (m_webMediaPlayer) 264 if (m_webMediaPlayer)
261 m_webMediaPlayer->play(); 265 m_webMediaPlayer->play();
(...skipping 15 matching lines...) Expand all
277 { 281 {
278 if (m_webMediaPlayer) 282 if (m_webMediaPlayer)
279 m_webMediaPlayer->exitFullscreen(); 283 m_webMediaPlayer->exitFullscreen();
280 } 284 }
281 285
282 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const 286 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const
283 { 287 {
284 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); 288 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen();
285 } 289 }
286 290
287 MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::generateKeyRequest(cons t String& keySystem, const unsigned char* initData, unsigned initDataLength)
288 {
289 if (!m_webMediaPlayer)
290 return MediaPlayer::InvalidPlayerState;
291
292 WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->generateKeyRequ est(keySystem, initData, initDataLength);
293 return static_cast<MediaPlayer::MediaKeyException>(result);
294 }
295
296 MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::addKey(const String& ke ySystem, const unsigned char* key, unsigned keyLength, const unsigned char* init Data, unsigned initDataLength, const String& sessionId)
297 {
298 if (!m_webMediaPlayer)
299 return MediaPlayer::InvalidPlayerState;
300
301 WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->addKey(keySyste m, key, keyLength, initData, initDataLength, sessionId);
302 return static_cast<MediaPlayer::MediaKeyException>(result);
303 }
304
305 MediaPlayer::MediaKeyException WebMediaPlayerClientImpl::cancelKeyRequest(const String& keySystem, const String& sessionId)
306 {
307 if (!m_webMediaPlayer)
308 return MediaPlayer::InvalidPlayerState;
309
310 WebMediaPlayer::MediaKeyException result = m_webMediaPlayer->cancelKeyReques t(keySystem, sessionId);
311 return static_cast<MediaPlayer::MediaKeyException>(result);
312 }
313
314 void WebMediaPlayerClientImpl::setContentDecryptionModule(WebContentDecryptionMo dule* cdm)
315 {
316 m_cdm = cdm;
317 if (m_webMediaPlayer)
318 m_webMediaPlayer->setContentDecryptionModule(cdm);
319 }
320
321 void WebMediaPlayerClientImpl::prepareToPlay() 291 void WebMediaPlayerClientImpl::prepareToPlay()
322 { 292 {
323 if (m_delayingLoad) 293 if (m_delayingLoad)
324 startDelayedLoad(); 294 startDelayedLoad();
325 } 295 }
326 296
327 IntSize WebMediaPlayerClientImpl::naturalSize() const 297 IntSize WebMediaPlayerClientImpl::naturalSize() const
328 { 298 {
329 if (m_webMediaPlayer) 299 if (m_webMediaPlayer)
330 return m_webMediaPlayer->naturalSize(); 300 return m_webMediaPlayer->naturalSize();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 584 }
615 585
616 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) 586 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client)
617 : m_client(client) 587 : m_client(client)
618 , m_delayingLoad(false) 588 , m_delayingLoad(false)
619 , m_preload(MediaPlayer::Auto) 589 , m_preload(MediaPlayer::Auto)
620 , m_needsWebLayerForVideo(false) 590 , m_needsWebLayerForVideo(false)
621 , m_volume(1.0) 591 , m_volume(1.0)
622 , m_muted(false) 592 , m_muted(false)
623 , m_rate(1.0) 593 , m_rate(1.0)
624 , m_cdm(0)
625 , m_loadType(WebMediaPlayer::LoadTypeURL) 594 , m_loadType(WebMediaPlayer::LoadTypeURL)
626 { 595 {
627 ASSERT(m_client); 596 ASSERT(m_client);
628 } 597 }
629 598
630 #if ENABLE(WEB_AUDIO) 599 #if ENABLE(WEB_AUDIO)
631 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider) 600 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider)
632 { 601 {
633 MutexLocker locker(provideInputLock); 602 MutexLocker locker(provideInputLock);
634 603
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 642
674 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); 643 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
675 } 644 }
676 645
677 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate) 646 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate)
678 { 647 {
679 if (m_client) 648 if (m_client)
680 m_client->setFormat(numberOfChannels, sampleRate); 649 m_client->setFormat(numberOfChannels, sampleRate);
681 } 650 }
682 651
652 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const
653 {
654 return *static_cast<HTMLMediaElement*>(m_client);
655 }
656
683 #endif 657 #endif
684 658
685 } // namespace blink 659 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698