Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | 181 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF ::String& url, WebMediaPlayer::CORSMode corsMode) |
| 182 void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF ::String& url) | |
| 183 { | 182 { |
| 184 m_url = KURL(ParsedURLString, url); | 183 ASSERT(!m_webMediaPlayer); |
| 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 | |
| 202 | 184 |
| 203 // FIXME: Remove this cast | 185 // FIXME: Remove this cast |
| 204 LocalFrame* frame = mediaElement().document().frame(); | 186 LocalFrame* frame = mediaElement().document().frame(); |
| 205 | 187 |
| 206 WebURL poster = m_client->mediaPlayerPosterURL(); | 188 WebURL poster = m_client->mediaPlayerPosterURL(); |
| 207 | 189 |
| 208 // This does not actually check whether the hardware can support accelerated | 190 // This does not actually check whether the hardware can support accelerated |
| 209 // compositing, but only if the flag is set. However, this is checked lazily | 191 // compositing, but only if the flag is set. However, this is checked lazily |
| 210 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there | 192 // in WebViewImpl::setIsAcceleratedCompositingActive() and will fail there |
| 211 // if necessary. | 193 // if necessary. |
| 212 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing(); | 194 m_needsWebLayerForVideo = frame->contentRenderer()->compositor()->hasAcceler atedCompositing(); |
| 213 | 195 |
| 214 m_webMediaPlayer = createWebMediaPlayer(this, m_url, frame); | 196 KURL kurl(ParsedURLString, url); |
| 215 if (m_webMediaPlayer) { | 197 m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame); |
| 198 if (!m_webMediaPlayer) | |
| 199 return; | |
| 200 | |
| 216 #if ENABLE(WEB_AUDIO) | 201 #if ENABLE(WEB_AUDIO) |
| 217 // Make sure if we create/re-create the WebMediaPlayer that we update ou r wrapper. | 202 // Make sure if we create/re-create the WebMediaPlayer that we update our wr apper. |
| 218 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); | 203 m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider()); |
| 219 #endif | 204 #endif |
| 220 | 205 |
| 221 // Tell WebMediaPlayer about the poster image URL. | 206 // Tell WebMediaPlayer about the poster image URL. |
|
philipj_slow
2014/03/08 19:38:40
Re-indent this comment too? Or just remove it, it'
acolwell GONE FROM CHROMIUM
2014/03/10 21:53:31
Done.
| |
| 222 m_webMediaPlayer->setPoster(poster); | 207 m_webMediaPlayer->setPoster(poster); |
| 223 | 208 |
| 224 // Tell WebMediaPlayer about any connected CDM (may be null). | 209 // Tell WebMediaPlayer about any connected CDM (may be null). |
| 225 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMe dia::contentDecryptionModule(mediaElement())); | 210 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia: :contentDecryptionModule(mediaElement())); |
| 226 | 211 m_webMediaPlayer->load(loadType, kurl, corsMode); |
| 227 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode >(m_client->mediaPlayerCORSMode()); | |
| 228 m_webMediaPlayer->load(m_loadType, m_url, corsMode); | |
| 229 } | |
| 230 } | 212 } |
| 231 | 213 |
| 232 void WebMediaPlayerClientImpl::play() | 214 void WebMediaPlayerClientImpl::play() |
| 233 { | 215 { |
| 234 if (m_webMediaPlayer) | 216 if (m_webMediaPlayer) |
| 235 m_webMediaPlayer->play(); | 217 m_webMediaPlayer->play(); |
| 236 } | 218 } |
| 237 | 219 |
| 238 void WebMediaPlayerClientImpl::pause() | 220 void WebMediaPlayerClientImpl::pause() |
| 239 { | 221 { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 251 { | 233 { |
| 252 if (m_webMediaPlayer) | 234 if (m_webMediaPlayer) |
| 253 m_webMediaPlayer->exitFullscreen(); | 235 m_webMediaPlayer->exitFullscreen(); |
| 254 } | 236 } |
| 255 | 237 |
| 256 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const | 238 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const |
| 257 { | 239 { |
| 258 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); | 240 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); |
| 259 } | 241 } |
| 260 | 242 |
| 261 void WebMediaPlayerClientImpl::prepareToPlay() | |
| 262 { | |
| 263 if (m_delayingLoad) | |
| 264 startDelayedLoad(); | |
| 265 } | |
| 266 | |
| 267 IntSize WebMediaPlayerClientImpl::naturalSize() const | 243 IntSize WebMediaPlayerClientImpl::naturalSize() const |
| 268 { | 244 { |
| 269 if (m_webMediaPlayer) | 245 if (m_webMediaPlayer) |
| 270 return m_webMediaPlayer->naturalSize(); | 246 return m_webMediaPlayer->naturalSize(); |
| 271 return IntSize(); | 247 return IntSize(); |
| 272 } | 248 } |
| 273 | 249 |
| 274 bool WebMediaPlayerClientImpl::hasVideo() const | 250 bool WebMediaPlayerClientImpl::hasVideo() const |
| 275 { | 251 { |
| 276 if (m_webMediaPlayer) | 252 if (m_webMediaPlayer) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 | 398 |
| 423 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture, level, internalFormat, type, premultiplyAlpha, flipY); | 399 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture, level, internalFormat, type, premultiplyAlpha, flipY); |
| 424 } | 400 } |
| 425 | 401 |
| 426 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) | 402 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) |
| 427 { | 403 { |
| 428 m_preload = preload; | 404 m_preload = preload; |
| 429 | 405 |
| 430 if (m_webMediaPlayer) | 406 if (m_webMediaPlayer) |
| 431 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa d)); | 407 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa d)); |
| 432 | |
| 433 if (m_delayingLoad && m_preload != MediaPlayer::None) | |
| 434 startDelayedLoad(); | |
| 435 } | 408 } |
| 436 | 409 |
| 437 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const | 410 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const |
| 438 { | 411 { |
| 439 if (m_webMediaPlayer) | 412 if (m_webMediaPlayer) |
| 440 return m_webMediaPlayer->hasSingleSecurityOrigin(); | 413 return m_webMediaPlayer->hasSingleSecurityOrigin(); |
| 441 return false; | 414 return false; |
| 442 } | 415 } |
| 443 | 416 |
| 444 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const | 417 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 // the texture based bitmap will be readbacked to system memory then draw on to the canvas. | 509 // the texture based bitmap will be readbacked to system memory then draw on to the canvas. |
| 537 SkRect dest; | 510 SkRect dest; |
| 538 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height ()); | 511 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height ()); |
| 539 SkPaint paint; | 512 SkPaint paint; |
| 540 paint.setAlpha(alpha); | 513 paint.setAlpha(alpha); |
| 541 // It is not necessary to pass the dest into the drawBitmap call since all t he context have been set up before calling paintCurrentFrameInContext. | 514 // It is not necessary to pass the dest into the drawBitmap call since all t he context have been set up before calling paintCurrentFrameInContext. |
| 542 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); | 515 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); |
| 543 } | 516 } |
| 544 #endif | 517 #endif |
| 545 | 518 |
| 546 void WebMediaPlayerClientImpl::startDelayedLoad() | |
| 547 { | |
| 548 ASSERT(m_delayingLoad); | |
| 549 ASSERT(!m_webMediaPlayer); | |
| 550 | |
| 551 m_delayingLoad = false; | |
| 552 | |
| 553 loadInternal(); | |
| 554 } | |
| 555 | |
| 556 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) | 519 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) |
| 557 : m_client(client) | 520 : m_client(client) |
| 558 , m_delayingLoad(false) | |
| 559 , m_preload(MediaPlayer::Auto) | 521 , m_preload(MediaPlayer::Auto) |
| 560 , m_needsWebLayerForVideo(false) | 522 , m_needsWebLayerForVideo(false) |
| 561 , m_volume(1.0) | 523 , m_volume(1.0) |
| 562 , m_muted(false) | 524 , m_muted(false) |
| 563 , m_rate(1.0) | 525 , m_rate(1.0) |
| 564 , m_loadType(WebMediaPlayer::LoadTypeURL) | |
| 565 { | 526 { |
| 566 ASSERT(m_client); | 527 ASSERT(m_client); |
| 567 } | 528 } |
| 568 | 529 |
| 569 #if ENABLE(WEB_AUDIO) | 530 #if ENABLE(WEB_AUDIO) |
| 570 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider) | 531 void WebMediaPlayerClientImpl::AudioSourceProviderImpl::wrap(WebAudioSourceProvi der* provider) |
| 571 { | 532 { |
| 572 MutexLocker locker(provideInputLock); | 533 MutexLocker locker(provideInputLock); |
| 573 | 534 |
| 574 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) | 535 if (m_webAudioSourceProvider && provider != m_webAudioSourceProvider) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 } | 581 } |
| 621 | 582 |
| 622 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const | 583 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const |
| 623 { | 584 { |
| 624 return *static_cast<HTMLMediaElement*>(m_client); | 585 return *static_cast<HTMLMediaElement*>(m_client); |
| 625 } | 586 } |
| 626 | 587 |
| 627 #endif | 588 #endif |
| 628 | 589 |
| 629 } // namespace blink | 590 } // namespace blink |
| OLD | NEW |