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

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

Issue 203213006: Revert 169465 "Move deferred loading logic from WebMediaPlayerCl..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « trunk/Source/web/WebMediaPlayerClientImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 { 171 {
172 m_client->mediaPlayerRequestFullscreen(); 172 m_client->mediaPlayerRequestFullscreen();
173 } 173 }
174 174
175 void WebMediaPlayerClientImpl::requestSeek(double time) 175 void WebMediaPlayerClientImpl::requestSeek(double time)
176 { 176 {
177 m_client->mediaPlayerRequestSeek(time); 177 m_client->mediaPlayerRequestSeek(time);
178 } 178 }
179 179
180 // MediaPlayer ------------------------------------------------- 180 // MediaPlayer -------------------------------------------------
181 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF ::String& url, WebMediaPlayer::CORSMode corsMode) 181
182 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF ::String& url)
182 { 183 {
183 ASSERT(!m_webMediaPlayer); 184 m_url = KURL(ParsedURLString, url);
185 m_loadType = loadType;
186
187 if (m_preload == MediaPlayer::None) {
188 #if ENABLE(WEB_AUDIO)
189 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlay er's WebAudioSourceProvider.
190 #endif
191 m_webMediaPlayer.clear();
192 m_delayingLoad = true;
193 } else
194 loadInternal();
195 }
196
197 void WebMediaPlayerClientImpl::loadInternal()
198 {
199 #if ENABLE(WEB_AUDIO)
200 m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
201 #endif
184 202
185 // FIXME: Remove this cast 203 // FIXME: Remove this cast
186 LocalFrame* frame = mediaElement().document().frame(); 204 LocalFrame* frame = mediaElement().document().frame();
187 205
188 WebURL poster = m_client->mediaPlayerPosterURL(); 206 WebURL poster = m_client->mediaPlayerPosterURL();
189 207
190 // This does not actually check whether the hardware can support accelerated 208 // This does not actually check whether the hardware can support accelerated
191 // compositing, but only if the flag is set. However, this is checked lazily 209 // compositing, but only if the flag is set. However, this is checked lazily
192 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there 210 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there
193 // if necessary. 211 // if necessary.
194 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing(); 212 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing();
195 213
196 KURL kurl(ParsedURLString, url); 214 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame);
197 m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame); 215 if (m_webMediaPlayer) {
198 if (!m_webMediaPlayer)
199 return;
200
201 #if ENABLE(WEB_AUDIO) 216 #if ENABLE(WEB_AUDIO)
202 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper. 217 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper.
203 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); 218 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
204 #endif 219 #endif
205 220
206 m_webMediaPlayer->setVolume(mediaElement().playerVolume()); 221 m_webMediaPlayer->setVolume(mediaElement().playerVolume());
207 222
208 m_webMediaPlayer->setPoster(poster); 223 // Tell WebMediaPlayer about the poster image URL.
224 m_webMediaPlayer->setPoster(poster);
209 225
210 // Tell WebMediaPlayer about any connected CDM (may be null). 226 // Tell WebMediaPlayer about any connected CDM (may be null).
211 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia: :contentDecryptionModule(mediaElement())); 227 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMe dia::contentDecryptionModule(mediaElement()));
212 m_webMediaPlayer->load(loadType, kurl, corsMode); 228
229 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode());
230 m_webMediaPlayer->load(m_loadType, m_url, corsMode);
231 }
213 } 232 }
214 233
215 void WebMediaPlayerClientImpl::play() 234 void WebMediaPlayerClientImpl::play()
216 { 235 {
217 if (m_webMediaPlayer) 236 if (m_webMediaPlayer)
218 m_webMediaPlayer->play(); 237 m_webMediaPlayer->play();
219 } 238 }
220 239
221 void WebMediaPlayerClientImpl::pause() 240 void WebMediaPlayerClientImpl::pause()
222 { 241 {
(...skipping 11 matching lines...) Expand all
234 { 253 {
235 if (m_webMediaPlayer) 254 if (m_webMediaPlayer)
236 m_webMediaPlayer->exitFullscreen(); 255 m_webMediaPlayer->exitFullscreen();
237 } 256 }
238 257
239 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const 258 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const
240 { 259 {
241 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); 260 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen();
242 } 261 }
243 262
263 void WebMediaPlayerClientImpl::prepareToPlay()
264 {
265 if (m_delayingLoad)
266 startDelayedLoad();
267 }
268
244 IntSize WebMediaPlayerClientImpl::naturalSize() const 269 IntSize WebMediaPlayerClientImpl::naturalSize() const
245 { 270 {
246 if (m_webMediaPlayer) 271 if (m_webMediaPlayer)
247 return m_webMediaPlayer->naturalSize(); 272 return m_webMediaPlayer->naturalSize();
248 return IntSize(); 273 return IntSize();
249 } 274 }
250 275
251 bool WebMediaPlayerClientImpl::hasVideo() const 276 bool WebMediaPlayerClientImpl::hasVideo() const
252 { 277 {
253 if (m_webMediaPlayer) 278 if (m_webMediaPlayer)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 407
383 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture, level, internalFormat, type, premultiplyAlpha, flipY); 408 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture, level, internalFormat, type, premultiplyAlpha, flipY);
384 } 409 }
385 410
386 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) 411 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload)
387 { 412 {
388 m_preload = preload; 413 m_preload = preload;
389 414
390 if (m_webMediaPlayer) 415 if (m_webMediaPlayer)
391 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa d)); 416 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa d));
417
418 if (m_delayingLoad && m_preload != MediaPlayer::None)
419 startDelayedLoad();
392 } 420 }
393 421
394 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const 422 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const
395 { 423 {
396 if (m_webMediaPlayer) 424 if (m_webMediaPlayer)
397 return m_webMediaPlayer->hasSingleSecurityOrigin(); 425 return m_webMediaPlayer->hasSingleSecurityOrigin();
398 return false; 426 return false;
399 } 427 }
400 428
401 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const 429 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // the texture based bitmap will be readbacked to system memory then draw on to the canvas. 522 // the texture based bitmap will be readbacked to system memory then draw on to the canvas.
495 SkRect dest; 523 SkRect dest;
496 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height ()); 524 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height ());
497 SkPaint paint; 525 SkPaint paint;
498 paint.setAlpha(alpha); 526 paint.setAlpha(alpha);
499 // It is not necessary to pass the dest into the drawBitmap call since all t he context have been set up before calling paintCurrentFrameInContext. 527 // It is not necessary to pass the dest into the drawBitmap call since all t he context have been set up before calling paintCurrentFrameInContext.
500 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); 528 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint);
501 } 529 }
502 #endif 530 #endif
503 531
532 void WebMediaPlayerClientImpl::startDelayedLoad()
533 {
534 ASSERT(m_delayingLoad);
535 ASSERT(!m_webMediaPlayer);
536
537 m_delayingLoad = false;
538
539 loadInternal();
540 }
541
504 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) 542 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client)
505 : m_client(client) 543 : m_client(client)
544 , m_delayingLoad(false)
506 , m_preload(MediaPlayer::Auto) 545 , m_preload(MediaPlayer::Auto)
507 , m_needsWebLayerForVideo(false) 546 , m_needsWebLayerForVideo(false)
508 , m_rate(1.0) 547 , m_rate(1.0)
548 , m_loadType(WebMediaPlayer::LoadTypeURL)
509 { 549 {
510 ASSERT(m_client); 550 ASSERT(m_client);
511 } 551 }
512 552
513 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const 553 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const
514 { 554 {
515 return *static_cast<HTMLMediaElement*>(m_client); 555 return *static_cast<HTMLMediaElement*>(m_client);
516 } 556 }
517 557
518 #if ENABLE(WEB_AUDIO) 558 #if ENABLE(WEB_AUDIO)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 604
565 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate) 605 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel s, float sampleRate)
566 { 606 {
567 if (m_client) 607 if (m_client)
568 m_client->setFormat(numberOfChannels, sampleRate); 608 m_client->setFormat(numberOfChannels, sampleRate);
569 } 609 }
570 610
571 #endif 611 #endif
572 612
573 } // namespace blink 613 } // namespace blink
OLDNEW
« no previous file with comments | « trunk/Source/web/WebMediaPlayerClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698