| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // may play without a surface texture. When we finally get the valid video | 656 // may play without a surface texture. When we finally get the valid video |
| 657 // size here, we should call EstablishSurfaceTexturePeer() if it has not been | 657 // size here, we should call EstablishSurfaceTexturePeer() if it has not been |
| 658 // previously called. | 658 // previously called. |
| 659 if (!paused() && needs_establish_peer_) | 659 if (!paused() && needs_establish_peer_) |
| 660 EstablishSurfaceTexturePeer(); | 660 EstablishSurfaceTexturePeer(); |
| 661 #endif // defined(VIDEO_HOLE) | 661 #endif // defined(VIDEO_HOLE) |
| 662 | 662 |
| 663 natural_size_.width = width; | 663 natural_size_.width = width; |
| 664 natural_size_.height = height; | 664 natural_size_.height = height; |
| 665 ReallocateVideoFrame(); | 665 ReallocateVideoFrame(); |
| 666 CreateWebLayerIfNeeded(); | 666 |
| 667 // Lazily allocate compositing layer. |
| 668 if (!video_weblayer_) { |
| 669 video_weblayer_.reset( |
| 670 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); |
| 671 client_->setWebLayer(video_weblayer_.get()); |
| 672 } |
| 673 |
| 667 // TODO(qinmin): This is a hack. We need the media element to stop showing the | 674 // TODO(qinmin): This is a hack. We need the media element to stop showing the |
| 668 // poster image by forcing it to call setDisplayMode(video). Should move the | 675 // poster image by forcing it to call setDisplayMode(video). Should move the |
| 669 // logic into HTMLMediaElement.cpp. | 676 // logic into HTMLMediaElement.cpp. |
| 670 client_->timeChanged(); | 677 client_->timeChanged(); |
| 671 } | 678 } |
| 672 | 679 |
| 673 void WebMediaPlayerAndroid::OnTimeUpdate(const base::TimeDelta& current_time) { | 680 void WebMediaPlayerAndroid::OnTimeUpdate(const base::TimeDelta& current_time) { |
| 674 DCHECK(main_thread_checker_.CalledOnValidThread()); | 681 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 675 current_time_ = current_time.InSecondsF(); | 682 current_time_ = current_time.InSecondsF(); |
| 676 } | 683 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 media::VideoFrame::ReleaseMailboxCB(), | 989 media::VideoFrame::ReleaseMailboxCB(), |
| 983 natural_size_, | 990 natural_size_, |
| 984 gfx::Rect(natural_size_), | 991 gfx::Rect(natural_size_), |
| 985 natural_size_, | 992 natural_size_, |
| 986 base::TimeDelta(), | 993 base::TimeDelta(), |
| 987 VideoFrame::ReadPixelsCB()); | 994 VideoFrame::ReadPixelsCB()); |
| 988 SetCurrentFrameInternal(new_frame); | 995 SetCurrentFrameInternal(new_frame); |
| 989 } | 996 } |
| 990 } | 997 } |
| 991 | 998 |
| 992 void WebMediaPlayerAndroid::CreateWebLayerIfNeeded() { | |
| 993 if (!hasVideo() || video_weblayer_ || !client_->needsWebLayerForVideo()) | |
| 994 return; | |
| 995 video_weblayer_.reset(new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); | |
| 996 client_->setWebLayer(video_weblayer_.get()); | |
| 997 } | |
| 998 | |
| 999 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 999 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
| 1000 cc::VideoFrameProvider::Client* client) { | 1000 cc::VideoFrameProvider::Client* client) { |
| 1001 // This is called from both the main renderer thread and the compositor | 1001 // This is called from both the main renderer thread and the compositor |
| 1002 // thread (when the main thread is blocked). | 1002 // thread (when the main thread is blocked). |
| 1003 if (video_frame_provider_client_) | 1003 if (video_frame_provider_client_) |
| 1004 video_frame_provider_client_->StopUsingProvider(); | 1004 video_frame_provider_client_->StopUsingProvider(); |
| 1005 video_frame_provider_client_ = client; | 1005 video_frame_provider_client_ = client; |
| 1006 | 1006 |
| 1007 // Set the callback target when a frame is produced. | 1007 // Set the callback target when a frame is produced. |
| 1008 if (stream_texture_proxy_) | 1008 if (stream_texture_proxy_) |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 | 1473 |
| 1474 void WebMediaPlayerAndroid::exitFullscreen() { | 1474 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1475 manager_->ExitFullscreen(player_id_); | 1475 manager_->ExitFullscreen(player_id_); |
| 1476 } | 1476 } |
| 1477 | 1477 |
| 1478 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1478 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1479 return manager_->CanEnterFullscreen(frame_); | 1479 return manager_->CanEnterFullscreen(frame_); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 } // namespace content | 1482 } // namespace content |
| OLD | NEW |