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 "webkit/renderer/media/android/webmediaplayer_android.h" | 5 #include "webkit/renderer/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 client_(client), | 67 client_(client), |
68 buffered_(1u), | 68 buffered_(1u), |
69 main_loop_(base::MessageLoopProxy::current()), | 69 main_loop_(base::MessageLoopProxy::current()), |
70 ignore_metadata_duration_change_(false), | 70 ignore_metadata_duration_change_(false), |
71 pending_seek_(0), | 71 pending_seek_(0), |
72 seeking_(false), | 72 seeking_(false), |
73 did_loading_progress_(false), | 73 did_loading_progress_(false), |
74 manager_(manager), | 74 manager_(manager), |
75 network_state_(WebMediaPlayer::NetworkStateEmpty), | 75 network_state_(WebMediaPlayer::NetworkStateEmpty), |
76 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 76 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 77 texture_id_(0), |
| 78 texture_mailbox_sync_point_(0), |
| 79 stream_id_(0), |
77 is_playing_(false), | 80 is_playing_(false), |
78 needs_establish_peer_(true), | 81 needs_establish_peer_(true), |
79 stream_texture_proxy_initialized_(false), | 82 stream_texture_proxy_initialized_(false), |
80 has_size_info_(false), | 83 has_size_info_(false), |
81 has_media_metadata_(false), | 84 has_media_metadata_(false), |
82 has_media_info_(false), | 85 has_media_info_(false), |
83 stream_texture_factory_(factory), | 86 stream_texture_factory_(factory), |
84 needs_external_surface_(false), | 87 needs_external_surface_(false), |
85 video_frame_provider_client_(NULL), | 88 video_frame_provider_client_(NULL), |
86 source_type_(MediaPlayerAndroid::SOURCE_TYPE_URL), | 89 source_type_(MediaPlayerAndroid::SOURCE_TYPE_URL), |
87 proxy_(proxy), | 90 proxy_(proxy), |
88 current_time_(0), | 91 current_time_(0), |
89 media_log_(media_log), | 92 media_log_(media_log), |
90 media_stream_client_(NULL) { | 93 media_stream_client_(NULL) { |
91 DCHECK(proxy_); | 94 DCHECK(proxy_); |
92 | 95 |
93 // We want to be notified of |main_loop_| destruction. | 96 // We want to be notified of |main_loop_| destruction. |
94 base::MessageLoop::current()->AddDestructionObserver(this); | 97 base::MessageLoop::current()->AddDestructionObserver(this); |
95 | 98 |
96 if (manager_) | 99 if (manager_) |
97 player_id_ = manager_->RegisterMediaPlayer(this); | 100 player_id_ = manager_->RegisterMediaPlayer(this); |
98 | 101 |
99 if (stream_texture_factory_) { | 102 if (stream_texture_factory_) { |
100 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); | 103 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); |
101 stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_); | 104 stream_id_ = stream_texture_factory_->CreateStreamTexture( |
| 105 kGLTextureExternalOES, |
| 106 &texture_id_, |
| 107 &texture_mailbox_, |
| 108 &texture_mailbox_sync_point_); |
102 ReallocateVideoFrame(); | 109 ReallocateVideoFrame(); |
103 } | 110 } |
104 | 111 |
105 #if defined(GOOGLE_TV) | 112 #if defined(GOOGLE_TV) |
106 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) { | 113 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) { |
107 // |decryptor_| is owned, so Unretained() is safe here. | 114 // |decryptor_| is owned, so Unretained() is safe here. |
108 decryptor_.reset(new ProxyDecryptor( | 115 decryptor_.reset(new ProxyDecryptor( |
109 client, | 116 client, |
110 frame, | 117 frame, |
111 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)), | 118 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)), |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 if (needs_external_surface_) { | 743 if (needs_external_surface_) { |
737 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. | 744 // VideoFrame::CreateHoleFrame is only defined under GOOGLE_TV. |
738 #if defined(GOOGLE_TV) | 745 #if defined(GOOGLE_TV) |
739 if (!natural_size_.isEmpty()) | 746 if (!natural_size_.isEmpty()) |
740 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); | 747 current_frame_ = VideoFrame::CreateHoleFrame(natural_size_); |
741 #else | 748 #else |
742 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; | 749 NOTIMPLEMENTED() << "Hole punching not supported outside of Google TV"; |
743 #endif | 750 #endif |
744 } else if (texture_id_) { | 751 } else if (texture_id_) { |
745 current_frame_ = VideoFrame::WrapNativeTexture( | 752 current_frame_ = VideoFrame::WrapNativeTexture( |
746 texture_id_, kGLTextureExternalOES, natural_size_, | 753 texture_mailbox_, texture_mailbox_sync_point_, |
| 754 kGLTextureExternalOES, natural_size_, |
747 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), | 755 gfx::Rect(natural_size_), natural_size_, base::TimeDelta(), |
748 VideoFrame::ReadPixelsCB(), | 756 VideoFrame::ReadPixelsCB(), |
| 757 VideoFrame::TextureNoLongerNeededCallback(), |
749 base::Closure()); | 758 base::Closure()); |
750 } | 759 } |
751 } | 760 } |
752 | 761 |
753 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 762 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
754 cc::VideoFrameProvider::Client* client) { | 763 cc::VideoFrameProvider::Client* client) { |
755 // This is called from both the main renderer thread and the compositor | 764 // This is called from both the main renderer thread and the compositor |
756 // thread (when the main thread is blocked). | 765 // thread (when the main thread is blocked). |
757 if (video_frame_provider_client_) | 766 if (video_frame_provider_client_) |
758 video_frame_provider_client_->StopUsingProvider(); | 767 video_frame_provider_client_->StopUsingProvider(); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 | 1130 |
1122 void WebMediaPlayerAndroid::exitFullscreen() { | 1131 void WebMediaPlayerAndroid::exitFullscreen() { |
1123 proxy_->ExitFullscreen(player_id_); | 1132 proxy_->ExitFullscreen(player_id_); |
1124 } | 1133 } |
1125 | 1134 |
1126 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1135 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
1127 return manager_->CanEnterFullscreen(frame_); | 1136 return manager_->CanEnterFullscreen(frame_); |
1128 } | 1137 } |
1129 | 1138 |
1130 } // namespace webkit_media | 1139 } // namespace webkit_media |
OLD | NEW |