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

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: Move EME completely from core::HTMLMediaElement to modules::HTMLMediaElementEncryptedMedia (Based o… 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 playerDestroyed();
acolwell GONE FROM CHROMIUM 2014/02/26 17:19:19 This looks like the only call to this method so I
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(*static_cast<HTMLMediaElement*>(m_c lient), keySystem, sessionId);
acolwell GONE FROM CHROMIUM 2014/02/26 17:19:19 nit: Please put the static_cast into a HTMLMediaEl
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(*static_cast<HTMLMediaElement*>(m_c lient), keySystem, sessionId, 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(*static_cast<HTMLMediaElement*>(m _client), keySystem, sessionId, 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(*static_cast<HTMLMediaElement*>(m_ client), contentType, initData, 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
157 WebPlugin* plugin = m_helperPlugin->getPlugin(); 161 WebPlugin* plugin = m_helperPlugin->getPlugin();
158 if (!plugin) { 162 if (!plugin) {
159 // There is no need to keep the helper plugin around and the caller 163 // There is no need to keep the helper plugin around and the caller
160 // should not be expected to call close after a failure (null pointer). 164 // should not be expected to call close after a failure (null pointer).
161 closeHelperPluginSoon(frame); 165 closeHelperPluginSoon(frame);
162 return 0; 166 return 0;
163 } 167 }
164 168
165 return plugin; 169 return plugin;
166 } 170 }
167 171
168 // FIXME: |frame| no longer needed. 172 void WebMediaPlayerClientImpl::closeHelperPluginSoon(WebFrame*)
169 void WebMediaPlayerClientImpl::closeHelperPluginSoon(WebFrame* frame)
170 { 173 {
171 ASSERT(m_helperPlugin); 174 ASSERT(m_helperPlugin);
172 m_helperPlugin.clear(); 175 m_helperPlugin.clear();
173 } 176 }
174 177
178 void WebMediaPlayerClientImpl::playerDestroyed()
179 {
180 HTMLMediaElementEncryptedMedia::playerDestroyed(*static_cast<HTMLMediaElemen t*>(m_client));
181 }
182
175 void WebMediaPlayerClientImpl::setWebLayer(blink::WebLayer* layer) 183 void WebMediaPlayerClientImpl::setWebLayer(blink::WebLayer* layer)
176 { 184 {
177 m_client->mediaPlayerSetWebLayer(layer); 185 m_client->mediaPlayerSetWebLayer(layer);
178 } 186 }
179 187
180 void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack) 188 void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack)
181 { 189 {
182 m_client->mediaPlayerDidAddTrack(textTrack); 190 m_client->mediaPlayerDidAddTrack(textTrack);
183 } 191 }
184 192
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 loadInternal(); 228 loadInternal();
221 } 229 }
222 230
223 void WebMediaPlayerClientImpl::loadInternal() 231 void WebMediaPlayerClientImpl::loadInternal()
224 { 232 {
225 #if ENABLE(WEB_AUDIO) 233 #if ENABLE(WEB_AUDIO)
226 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider. 234 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
227 #endif 235 #endif
228 236
229 // FIXME: Remove this cast 237 // FIXME: Remove this cast
230 Frame* frame = static_cast<HTMLMediaElement*>(m_client)->document().frame(); 238 Frame* frame = static_cast<HTMLMediaElement*>(m_client)->document().frame();
acolwell GONE FROM CHROMIUM 2014/02/26 17:19:19 nit: Change this to use the the new mediaElement()
231 239
232 WebURL poster = m_client->mediaPlayerPosterURL(); 240 WebURL poster = m_client->mediaPlayerPosterURL();
233 241
234 // This does not actually check whether the hardware can support accelerated 242 // 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 243 // compositing, but only if the flag is set. However, this is checked lazily
236 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there 244 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there
237 // if necessary. 245 // if necessary.
238 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing(); 246 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing();
239 247
240 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame); 248 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
241 if (m_webMediaPlayer) { 249 if (m_webMediaPlayer) {
242 #if ENABLE(WEB_AUDIO) 250 #if ENABLE(WEB_AUDIO)
243 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper. 251 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper.
244 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); 252 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
245 #endif 253 #endif
246 254
247 // Tell WebMediaPlayer about the poster image URL. 255 // Tell WebMediaPlayer about the poster image URL.
248 m_webMediaPlayer->setPoster(poster); 256 m_webMediaPlayer->setPoster(poster);
249 257
250 // Tell WebMediaPlayer about any connected CDM (may be null). 258 // Tell WebMediaPlayer about any connected CDM (may be null).
251 m_webMediaPlayer->setContentDecryptionModule(m_cdm); 259 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMe dia::contentDecryptionModule(*static_cast<HTMLMediaElement*>(m_client)));
252 260
253 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode()); 261 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode());
254 m_webMediaPlayer->load(m_loadType, m_url, corsMode); 262 m_webMediaPlayer->load(m_loadType, m_url, corsMode);
255 } 263 }
256 } 264 }
257 265
258 void WebMediaPlayerClientImpl::play() 266 void WebMediaPlayerClientImpl::play()
259 { 267 {
260 if (m_webMediaPlayer) 268 if (m_webMediaPlayer)
261 m_webMediaPlayer->play(); 269 m_webMediaPlayer->play();
(...skipping 15 matching lines...) Expand all
277 { 285 {
278 if (m_webMediaPlayer) 286 if (m_webMediaPlayer)
279 m_webMediaPlayer->exitFullscreen(); 287 m_webMediaPlayer->exitFullscreen();
280 } 288 }
281 289
282 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const 290 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const
283 { 291 {
284 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); 292 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen();
285 } 293 }
286 294
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() 295 void WebMediaPlayerClientImpl::prepareToPlay()
322 { 296 {
323 if (m_delayingLoad) 297 if (m_delayingLoad)
324 startDelayedLoad(); 298 startDelayedLoad();
325 } 299 }
326 300
327 IntSize WebMediaPlayerClientImpl::naturalSize() const 301 IntSize WebMediaPlayerClientImpl::naturalSize() const
328 { 302 {
329 if (m_webMediaPlayer) 303 if (m_webMediaPlayer)
330 return m_webMediaPlayer->naturalSize(); 304 return m_webMediaPlayer->naturalSize();
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 588 }
615 589
616 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) 590 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client)
617 : m_client(client) 591 : m_client(client)
618 , m_delayingLoad(false) 592 , m_delayingLoad(false)
619 , m_preload(MediaPlayer::Auto) 593 , m_preload(MediaPlayer::Auto)
620 , m_needsWebLayerForVideo(false) 594 , m_needsWebLayerForVideo(false)
621 , m_volume(1.0) 595 , m_volume(1.0)
622 , m_muted(false) 596 , m_muted(false)
623 , m_rate(1.0) 597 , m_rate(1.0)
624 , m_cdm(0)
625 , m_loadType(WebMediaPlayer::LoadTypeURL) 598 , m_loadType(WebMediaPlayer::LoadTypeURL)
626 { 599 {
627 ASSERT(m_client); 600 ASSERT(m_client);
628 } 601 }
629 602
630 #if ENABLE(WEB_AUDIO) 603 #if ENABLE(WEB_AUDIO)
631 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider) 604 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider)
632 { 605 {
633 MutexLocker locker(provideInputLock); 606 MutexLocker locker(provideInputLock);
634 607
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 649
677 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate) 650 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate)
678 { 651 {
679 if (m_client) 652 if (m_client)
680 m_client->setFormat(numberOfChannels, sampleRate); 653 m_client->setFormat(numberOfChannels, sampleRate);
681 } 654 }
682 655
683 #endif 656 #endif
684 657
685 } // namespace blink 658 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698