| 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 "web/WebMediaPlayerClientImpl.h" | 6 #include "web/WebMediaPlayerClientImpl.h" |
| 7 | 7 |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/html/HTMLMediaElement.h" | 9 #include "core/html/HTMLMediaElement.h" |
| 10 #include "core/html/TimeRanges.h" | 10 #include "core/html/TimeRanges.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 { | 227 { |
| 228 if (m_webMediaPlayer) | 228 if (m_webMediaPlayer) |
| 229 m_webMediaPlayer->exitFullscreen(); | 229 m_webMediaPlayer->exitFullscreen(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const | 232 bool WebMediaPlayerClientImpl::canShowFullscreenOverlay() const |
| 233 { | 233 { |
| 234 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); | 234 return m_webMediaPlayer && m_webMediaPlayer->canEnterFullscreen(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 IntSize WebMediaPlayerClientImpl::naturalSize() const | |
| 238 { | |
| 239 if (m_webMediaPlayer) | |
| 240 return m_webMediaPlayer->naturalSize(); | |
| 241 return IntSize(); | |
| 242 } | |
| 243 | |
| 244 bool WebMediaPlayerClientImpl::hasVideo() const | |
| 245 { | |
| 246 if (m_webMediaPlayer) | |
| 247 return m_webMediaPlayer->hasVideo(); | |
| 248 return false; | |
| 249 } | |
| 250 | |
| 251 bool WebMediaPlayerClientImpl::hasAudio() const | |
| 252 { | |
| 253 if (m_webMediaPlayer) | |
| 254 return m_webMediaPlayer->hasAudio(); | |
| 255 return false; | |
| 256 } | |
| 257 | |
| 258 double WebMediaPlayerClientImpl::duration() const | 237 double WebMediaPlayerClientImpl::duration() const |
| 259 { | 238 { |
| 260 if (m_webMediaPlayer) | 239 if (m_webMediaPlayer) |
| 261 return m_webMediaPlayer->duration(); | 240 return m_webMediaPlayer->duration(); |
| 262 return 0.0; | 241 return 0.0; |
| 263 } | 242 } |
| 264 | 243 |
| 265 double WebMediaPlayerClientImpl::currentTime() const | 244 double WebMediaPlayerClientImpl::currentTime() const |
| 266 { | 245 { |
| 267 if (m_webMediaPlayer) | 246 if (m_webMediaPlayer) |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa
d)); | 363 m_webMediaPlayer->setPreload(static_cast<WebMediaPlayer::Preload>(preloa
d)); |
| 385 } | 364 } |
| 386 | 365 |
| 387 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const | 366 bool WebMediaPlayerClientImpl::hasSingleSecurityOrigin() const |
| 388 { | 367 { |
| 389 if (m_webMediaPlayer) | 368 if (m_webMediaPlayer) |
| 390 return m_webMediaPlayer->hasSingleSecurityOrigin(); | 369 return m_webMediaPlayer->hasSingleSecurityOrigin(); |
| 391 return false; | 370 return false; |
| 392 } | 371 } |
| 393 | 372 |
| 394 bool WebMediaPlayerClientImpl::didPassCORSAccessCheck() const | |
| 395 { | |
| 396 if (m_webMediaPlayer) | |
| 397 return m_webMediaPlayer->didPassCORSAccessCheck(); | |
| 398 return false; | |
| 399 } | |
| 400 | |
| 401 double WebMediaPlayerClientImpl::mediaTimeForTimeValue(double timeValue) const | 373 double WebMediaPlayerClientImpl::mediaTimeForTimeValue(double timeValue) const |
| 402 { | 374 { |
| 403 if (m_webMediaPlayer) | 375 if (m_webMediaPlayer) |
| 404 return m_webMediaPlayer->mediaTimeForTimeValue(timeValue); | 376 return m_webMediaPlayer->mediaTimeForTimeValue(timeValue); |
| 405 return timeValue; | 377 return timeValue; |
| 406 } | 378 } |
| 407 | 379 |
| 408 unsigned WebMediaPlayerClientImpl::decodedFrameCount() const | |
| 409 { | |
| 410 if (m_webMediaPlayer) | |
| 411 return m_webMediaPlayer->decodedFrameCount(); | |
| 412 return 0; | |
| 413 } | |
| 414 | |
| 415 unsigned WebMediaPlayerClientImpl::droppedFrameCount() const | |
| 416 { | |
| 417 if (m_webMediaPlayer) | |
| 418 return m_webMediaPlayer->droppedFrameCount(); | |
| 419 return 0; | |
| 420 } | |
| 421 | |
| 422 unsigned WebMediaPlayerClientImpl::corruptedFrameCount() const | |
| 423 { | |
| 424 if (m_webMediaPlayer) | |
| 425 return m_webMediaPlayer->corruptedFrameCount(); | |
| 426 return 0; | |
| 427 } | |
| 428 | |
| 429 unsigned WebMediaPlayerClientImpl::audioDecodedByteCount() const | |
| 430 { | |
| 431 if (m_webMediaPlayer) | |
| 432 return m_webMediaPlayer->audioDecodedByteCount(); | |
| 433 return 0; | |
| 434 } | |
| 435 | |
| 436 unsigned WebMediaPlayerClientImpl::videoDecodedByteCount() const | |
| 437 { | |
| 438 if (m_webMediaPlayer) | |
| 439 return m_webMediaPlayer->videoDecodedByteCount(); | |
| 440 return 0; | |
| 441 } | |
| 442 | |
| 443 #if ENABLE(WEB_AUDIO) | 380 #if ENABLE(WEB_AUDIO) |
| 444 AudioSourceProvider* WebMediaPlayerClientImpl::audioSourceProvider() | 381 AudioSourceProvider* WebMediaPlayerClientImpl::audioSourceProvider() |
| 445 { | 382 { |
| 446 return &m_audioSourceProvider; | 383 return &m_audioSourceProvider; |
| 447 } | 384 } |
| 448 #endif | 385 #endif |
| 449 | 386 |
| 450 PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* clie
nt) | 387 PassOwnPtr<MediaPlayer> WebMediaPlayerClientImpl::create(MediaPlayerClient* clie
nt) |
| 451 { | 388 { |
| 452 return adoptPtr(new WebMediaPlayerClientImpl(client)); | 389 return adoptPtr(new WebMediaPlayerClientImpl(client)); |
| 453 } | 390 } |
| 454 | 391 |
| 455 #if OS(ANDROID) | 392 #if OS(ANDROID) |
| 456 void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context,
const IntRect& rect, uint8_t alpha) | 393 void WebMediaPlayerClientImpl::paintOnAndroid(WebCore::GraphicsContext* context,
const IntRect& rect, uint8_t alpha) |
| 457 { | 394 { |
| 458 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); | 395 OwnPtr<blink::WebGraphicsContext3DProvider> provider = adoptPtr(blink::Platf
orm::current()->createSharedOffscreenGraphicsContext3DProvider()); |
| 459 if (!provider) | 396 if (!provider) |
| 460 return; | 397 return; |
| 461 WebGraphicsContext3D* context3D = provider->context3d(); | 398 WebGraphicsContext3D* context3D = provider->context3d(); |
| 462 if (!context || !context3D || !m_webMediaPlayer || context->paintingDisabled
()) | 399 if (!context || !context3D || !m_webMediaPlayer || context->paintingDisabled
()) |
| 463 return; | 400 return; |
| 464 | 401 |
| 465 if (!context3D->makeContextCurrent()) | 402 if (!context3D->makeContextCurrent()) |
| 466 return; | 403 return; |
| 467 | 404 |
| 468 // Copy video texture into a RGBA texture based bitmap first as video textur
e on Android is GL_TEXTURE_EXTERNAL_OES | 405 // Copy video texture into a RGBA texture based bitmap first as video textur
e on Android is GL_TEXTURE_EXTERNAL_OES |
| 469 // which is not supported by Skia yet. The bitmap's size needs to be the sam
e as the video and use naturalSize() here. | 406 // which is not supported by Skia yet. The bitmap's size needs to be the sam
e as the video and use naturalSize() here. |
| 470 // Check if we could reuse existing texture based bitmap. | 407 // Check if we could reuse existing texture based bitmap. |
| 471 // Otherwise, release existing texture based bitmap and allocate a new one b
ased on video size. | 408 // Otherwise, release existing texture based bitmap and allocate a new one b
ased on video size. |
| 472 if (!ensureTextureBackedSkBitmap(provider->grContext(), m_bitmap, naturalSiz
e(), kTopLeft_GrSurfaceOrigin, kSkia8888_GrPixelConfig)) | 409 if (!ensureTextureBackedSkBitmap(provider->grContext(), m_bitmap, m_webMedia
Player->naturalSize(), kTopLeft_GrSurfaceOrigin, kSkia8888_GrPixelConfig)) |
| 473 return; | 410 return; |
| 474 | 411 |
| 475 // Copy video texture to bitmap texture. | 412 // Copy video texture to bitmap texture. |
| 476 WebCanvas* canvas = context->canvas(); | 413 WebCanvas* canvas = context->canvas(); |
| 477 unsigned textureId = static_cast<unsigned>((m_bitmap.getTexture())->getTextu
reHandle()); | 414 unsigned textureId = static_cast<unsigned>((m_bitmap.getTexture())->getTextu
reHandle()); |
| 478 if (!m_webMediaPlayer->copyVideoTextureToPlatformTexture(context3D, textureI
d, 0, GL_RGBA, GL_UNSIGNED_BYTE, true, false)) | 415 if (!m_webMediaPlayer->copyVideoTextureToPlatformTexture(context3D, textureI
d, 0, GL_RGBA, GL_UNSIGNED_BYTE, true, false)) |
| 479 return; | 416 return; |
| 480 | 417 |
| 481 // Draw the texture based bitmap onto the Canvas. If the canvas is hardware
based, this will do a GPU-GPU texture copy. If the canvas is software based, | 418 // Draw the texture based bitmap onto the Canvas. If the canvas is hardware
based, this will do a GPU-GPU texture copy. If the canvas is software based, |
| 482 // the texture based bitmap will be readbacked to system memory then draw on
to the canvas. | 419 // the texture based bitmap will be readbacked to system memory then draw on
to the canvas. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 491 |
| 555 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) | 492 void WebMediaPlayerClientImpl::AudioClientImpl::setFormat(size_t numberOfChannel
s, float sampleRate) |
| 556 { | 493 { |
| 557 if (m_client) | 494 if (m_client) |
| 558 m_client->setFormat(numberOfChannels, sampleRate); | 495 m_client->setFormat(numberOfChannels, sampleRate); |
| 559 } | 496 } |
| 560 | 497 |
| 561 #endif | 498 #endif |
| 562 | 499 |
| 563 } // namespace blink | 500 } // namespace blink |
| OLD | NEW |