| 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 m_webMediaPlayer->setVolume(mediaElement().playerVolume()); | 206 m_webMediaPlayer->setVolume(mediaElement().playerVolume()); |
| 222 | 207 |
| 223 // Tell WebMediaPlayer about the poster image URL. | 208 m_webMediaPlayer->setPoster(poster); |
| 224 m_webMediaPlayer->setPoster(poster); | |
| 225 | 209 |
| 226 // Tell WebMediaPlayer about any connected CDM (may be null). | 210 // Tell WebMediaPlayer about any connected CDM (may be null). |
| 227 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMe
dia::contentDecryptionModule(mediaElement())); | 211 m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia:
:contentDecryptionModule(mediaElement())); |
| 228 | 212 m_webMediaPlayer->load(loadType, kurl, corsMode); |
| 229 WebMediaPlayer::CORSMode corsMode = static_cast<WebMediaPlayer::CORSMode
>(m_client->mediaPlayerCORSMode()); | |
| 230 m_webMediaPlayer->load(m_loadType, m_url, corsMode); | |
| 231 } | |
| 232 } | 213 } |
| 233 | 214 |
| 234 void WebMediaPlayerClientImpl::play() | 215 void WebMediaPlayerClientImpl::play() |
| 235 { | 216 { |
| 236 if (m_webMediaPlayer) | 217 if (m_webMediaPlayer) |
| 237 m_webMediaPlayer->play(); | 218 m_webMediaPlayer->play(); |
| 238 } | 219 } |
| 239 | 220 |
| 240 void WebMediaPlayerClientImpl::pause() | 221 void WebMediaPlayerClientImpl::pause() |
| 241 { | 222 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 253 { | 234 { |
| 254 if (m_webMediaPlayer) | 235 if (m_webMediaPlayer) |
| 255 m_webMediaPlayer->exitFullscreen(); | 236 m_webMediaPlayer->exitFullscreen(); |
| 256 } | 237 } |
| 257 | 238 |
| 258 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const | 239 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const |
| 259 { | 240 { |
| 260 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); | 241 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); |
| 261 } | 242 } |
| 262 | 243 |
| 263 void WebMediaPlayerClientImpl::prepareToPlay() | |
| 264 { | |
| 265 if (m_delayingLoad) | |
| 266 startDelayedLoad(); | |
| 267 } | |
| 268 | |
| 269 IntSize WebMediaPlayerClientImpl::naturalSize() const | 244 IntSize WebMediaPlayerClientImpl::naturalSize() const |
| 270 { | 245 { |
| 271 if (m_webMediaPlayer) | 246 if (m_webMediaPlayer) |
| 272 return m_webMediaPlayer->naturalSize(); | 247 return m_webMediaPlayer->naturalSize(); |
| 273 return IntSize(); | 248 return IntSize(); |
| 274 } | 249 } |
| 275 | 250 |
| 276 bool WebMediaPlayerClientImpl::hasVideo() const | 251 bool WebMediaPlayerClientImpl::hasVideo() const |
| 277 { | 252 { |
| 278 if (m_webMediaPlayer) | 253 if (m_webMediaPlayer) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 382 |
| 408 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture,
level, internalFormat, type, premultiplyAlpha, flipY); | 383 return m_webMediaPlayer->copyVideoTextureToPlatformTexture(context, texture,
level, internalFormat, type, premultiplyAlpha, flipY); |
| 409 } | 384 } |
| 410 | 385 |
| 411 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) | 386 void WebMediaPlayerClientImpl::setPreload(MediaPlayer::Preload preload) |
| 412 { | 387 { |
| 413 m_preload = preload; | 388 m_preload = preload; |
| 414 | 389 |
| 415 if (m_webMediaPlayer) | 390 if (m_webMediaPlayer) |
| 416 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa
d)); | 391 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa
d)); |
| 417 | |
| 418 if (m_delayingLoad && m_preload != MediaPlayer::None) | |
| 419 startDelayedLoad(); | |
| 420 } | 392 } |
| 421 | 393 |
| 422 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const | 394 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const |
| 423 { | 395 { |
| 424 if (m_webMediaPlayer) | 396 if (m_webMediaPlayer) |
| 425 return m_webMediaPlayer->hasSingleSecurityOrigin(); | 397 return m_webMediaPlayer->hasSingleSecurityOrigin(); |
| 426 return false; | 398 return false; |
| 427 } | 399 } |
| 428 | 400 |
| 429 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const | 401 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // the texture based bitmap will be readbacked to system memory then draw on
to the canvas. | 494 // the texture based bitmap will be readbacked to system memory then draw on
to the canvas. |
| 523 SkRect dest; | 495 SkRect dest; |
| 524 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height
()); | 496 dest.set(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height
()); |
| 525 SkPaint paint; | 497 SkPaint paint; |
| 526 paint.setAlpha(alpha); | 498 paint.setAlpha(alpha); |
| 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. | 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. |
| 528 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); | 500 canvas->drawBitmapRect(m_bitmap, NULL, dest, &paint); |
| 529 } | 501 } |
| 530 #endif | 502 #endif |
| 531 | 503 |
| 532 void WebMediaPlayerClientImpl::startDelayedLoad() | |
| 533 { | |
| 534 ASSERT(m_delayingLoad); | |
| 535 ASSERT(!m_webMediaPlayer); | |
| 536 | |
| 537 m_delayingLoad = false; | |
| 538 | |
| 539 loadInternal(); | |
| 540 } | |
| 541 | |
| 542 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) | 504 WebMediaPlayerClientImpl::WebMediaPlayerClientImpl(MediaPlayerClient* client) |
| 543 : m_client(client) | 505 : m_client(client) |
| 544 , m_delayingLoad(false) | |
| 545 , m_preload(MediaPlayer::Auto) | 506 , m_preload(MediaPlayer::Auto) |
| 546 , m_needsWebLayerForVideo(false) | 507 , m_needsWebLayerForVideo(false) |
| 547 , m_rate(1.0) | 508 , m_rate(1.0) |
| 548 , m_loadType(WebMediaPlayer::LoadTypeURL) | |
| 549 { | 509 { |
| 550 ASSERT(m_client); | 510 ASSERT(m_client); |
| 551 } | 511 } |
| 552 | 512 |
| 553 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const | 513 WebCore::HTMLMediaElement& WebMediaPlayerClientImpl::mediaElement() const |
| 554 { | 514 { |
| 555 return *static_cast<HTMLMediaElement*>(m_client); | 515 return *static_cast<HTMLMediaElement*>(m_client); |
| 556 } | 516 } |
| 557 | 517 |
| 558 #if ENABLE(WEB_AUDIO) | 518 #if ENABLE(WEB_AUDIO) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 | 564 |
| 605 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 565 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
| 606 { | 566 { |
| 607 if (m_client) | 567 if (m_client) |
| 608 m_client->setFormat(numberOfChannels, sampleRate); | 568 m_client->setFormat(numberOfChannels, sampleRate); |
| 609 } | 569 } |
| 610 | 570 |
| 611 #endif | 571 #endif |
| 612 | 572 |
| 613 } // namespace blink | 573 } // namespace blink |
| OLD | NEW |