Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 29 matching lines...) Expand all
40 #include "ui/gfx/image/image.h" 40 #include "ui/gfx/image/image.h"
41 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" 41 #include "webkit/renderer/compositor_bindings/web_layer_impl.h"
42 42
43 #if defined(GOOGLE_TV) 43 #if defined(GOOGLE_TV)
44 #include "content/renderer/media/media_stream_audio_renderer.h" 44 #include "content/renderer/media/media_stream_audio_renderer.h"
45 #include "content/renderer/media/media_stream_client.h" 45 #include "content/renderer/media/media_stream_client.h"
46 #endif 46 #endif
47 47
48 static const uint32 kGLTextureExternalOES = 0x8D65; 48 static const uint32 kGLTextureExternalOES = 0x8D65;
49 49
50 using WebKit::WebMediaPlayer; 50 using blink::WebMediaPlayer;
51 using WebKit::WebSize; 51 using blink::WebSize;
52 using WebKit::WebString; 52 using blink::WebString;
53 using WebKit::WebTimeRanges; 53 using blink::WebTimeRanges;
54 using WebKit::WebURL; 54 using blink::WebURL;
55 using media::MediaPlayerAndroid; 55 using media::MediaPlayerAndroid;
56 using media::VideoFrame; 56 using media::VideoFrame;
57 57
58 namespace { 58 namespace {
59 // Prefix for histograms related to Encrypted Media Extensions. 59 // Prefix for histograms related to Encrypted Media Extensions.
60 const char* kMediaEme = "Media.EME."; 60 const char* kMediaEme = "Media.EME.";
61 } // namespace 61 } // namespace
62 62
63 namespace content { 63 namespace content {
64 64
65 // static 65 // static
66 void WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture( 66 void WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture(
67 const scoped_refptr<base::MessageLoopProxy>& main_loop, 67 const scoped_refptr<base::MessageLoopProxy>& main_loop,
68 const base::WeakPtr<WebMediaPlayerAndroid>& player, 68 const base::WeakPtr<WebMediaPlayerAndroid>& player,
69 uint32 sync_point) { 69 uint32 sync_point) {
70 main_loop->PostTask( 70 main_loop->PostTask(
71 FROM_HERE, 71 FROM_HERE,
72 base::Bind(&WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture, 72 base::Bind(&WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture,
73 player, 73 player,
74 sync_point)); 74 sync_point));
75 } 75 }
76 76
77 WebMediaPlayerAndroid::WebMediaPlayerAndroid( 77 WebMediaPlayerAndroid::WebMediaPlayerAndroid(
78 WebKit::WebFrame* frame, 78 blink::WebFrame* frame,
79 WebKit::WebMediaPlayerClient* client, 79 blink::WebMediaPlayerClient* client,
80 base::WeakPtr<WebMediaPlayerDelegate> delegate, 80 base::WeakPtr<WebMediaPlayerDelegate> delegate,
81 RendererMediaPlayerManager* manager, 81 RendererMediaPlayerManager* manager,
82 StreamTextureFactory* factory, 82 StreamTextureFactory* factory,
83 const scoped_refptr<base::MessageLoopProxy>& media_loop, 83 const scoped_refptr<base::MessageLoopProxy>& media_loop,
84 media::MediaLog* media_log) 84 media::MediaLog* media_log)
85 : frame_(frame), 85 : frame_(frame),
86 client_(client), 86 client_(client),
87 delegate_(delegate), 87 delegate_(delegate),
88 buffered_(1u), 88 buffered_(1u),
89 main_loop_(base::MessageLoopProxy::current()), 89 main_loop_(base::MessageLoopProxy::current()),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 } 141 }
142 142
143 // Defer stream texture creation until we are sure it's necessary. 143 // Defer stream texture creation until we are sure it's necessary.
144 stream_id_ = 0; 144 stream_id_ = 0;
145 needs_establish_peer_ = false; 145 needs_establish_peer_ = false;
146 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); 146 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1));
147 #endif 147 #endif
148 TryCreateStreamTextureProxyIfNeeded(); 148 TryCreateStreamTextureProxyIfNeeded();
149 149
150 if (WebKit::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled()) { 150 if (blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled()) {
151 // TODO(xhwang): Report an error when there is encrypted stream but EME is 151 // TODO(xhwang): Report an error when there is encrypted stream but EME is
152 // not enabled. Currently the player just doesn't start and waits for ever. 152 // not enabled. Currently the player just doesn't start and waits for ever.
153 decryptor_.reset(new ProxyDecryptor( 153 decryptor_.reset(new ProxyDecryptor(
154 #if defined(ENABLE_PEPPER_CDMS) 154 #if defined(ENABLE_PEPPER_CDMS)
155 client, 155 client,
156 frame, 156 frame,
157 #else 157 #else
158 manager_, 158 manager_,
159 player_id_, // TODO(xhwang): Use media_keys_id when MediaKeys are 159 player_id_, // TODO(xhwang): Use media_keys_id when MediaKeys are
160 // separated from WebMediaPlayer. 160 // separated from WebMediaPlayer.
(...skipping 12 matching lines...) Expand all
173 173
174 if (manager_) { 174 if (manager_) {
175 manager_->DestroyPlayer(player_id_); 175 manager_->DestroyPlayer(player_id_);
176 manager_->UnregisterMediaPlayer(player_id_); 176 manager_->UnregisterMediaPlayer(player_id_);
177 } 177 }
178 178
179 if (stream_id_) 179 if (stream_id_)
180 stream_texture_factory_->DestroyStreamTexture(texture_id_); 180 stream_texture_factory_->DestroyStreamTexture(texture_id_);
181 181
182 if (remote_playback_texture_id_) { 182 if (remote_playback_texture_id_) {
183 WebKit::WebGraphicsContext3D* context = 183 blink::WebGraphicsContext3D* context =
184 stream_texture_factory_->Context3d(); 184 stream_texture_factory_->Context3d();
185 if (context->makeContextCurrent()) 185 if (context->makeContextCurrent())
186 context->deleteTexture(remote_playback_texture_id_); 186 context->deleteTexture(remote_playback_texture_id_);
187 } 187 }
188 188
189 if (base::MessageLoop::current()) 189 if (base::MessageLoop::current())
190 base::MessageLoop::current()->RemoveDestructionObserver(this); 190 base::MessageLoop::current()->RemoveDestructionObserver(this);
191 191
192 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_) 192 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_)
193 delegate_->PlayerGone(this); 193 delegate_->PlayerGone(this);
(...skipping 11 matching lines...) Expand all
205 } 205 }
206 } 206 }
207 if (demuxer_ && !destroy_demuxer_cb_.is_null()) { 207 if (demuxer_ && !destroy_demuxer_cb_.is_null()) {
208 media_source_delegate_.reset(); 208 media_source_delegate_.reset();
209 destroy_demuxer_cb_.Run(); 209 destroy_demuxer_cb_.Run();
210 } 210 }
211 #endif 211 #endif
212 } 212 }
213 213
214 void WebMediaPlayerAndroid::load(LoadType load_type, 214 void WebMediaPlayerAndroid::load(LoadType load_type,
215 const WebKit::WebURL& url, 215 const blink::WebURL& url,
216 CORSMode cors_mode) { 216 CORSMode cors_mode) {
217 switch (load_type) { 217 switch (load_type) {
218 case LoadTypeURL: 218 case LoadTypeURL:
219 player_type_ = MEDIA_PLAYER_TYPE_URL; 219 player_type_ = MEDIA_PLAYER_TYPE_URL;
220 break; 220 break;
221 221
222 case LoadTypeMediaSource: 222 case LoadTypeMediaSource:
223 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE; 223 player_type_ = MEDIA_PLAYER_TYPE_MEDIA_SOURCE;
224 break; 224 break;
225 225
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 // TODO(hclam): If this stream is not seekable this should return 0. 501 // TODO(hclam): If this stream is not seekable this should return 0.
502 return duration(); 502 return duration();
503 } 503 }
504 504
505 bool WebMediaPlayerAndroid::didLoadingProgress() const { 505 bool WebMediaPlayerAndroid::didLoadingProgress() const {
506 bool ret = did_loading_progress_; 506 bool ret = did_loading_progress_;
507 did_loading_progress_ = false; 507 did_loading_progress_ = false;
508 return ret; 508 return ret;
509 } 509 }
510 510
511 void WebMediaPlayerAndroid::paint(WebKit::WebCanvas* canvas, 511 void WebMediaPlayerAndroid::paint(blink::WebCanvas* canvas,
512 const WebKit::WebRect& rect, 512 const blink::WebRect& rect,
513 unsigned char alpha) { 513 unsigned char alpha) {
514 NOTIMPLEMENTED(); 514 NOTIMPLEMENTED();
515 } 515 }
516 516
517 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture( 517 bool WebMediaPlayerAndroid::copyVideoTextureToPlatformTexture(
518 WebKit::WebGraphicsContext3D* web_graphics_context, 518 blink::WebGraphicsContext3D* web_graphics_context,
519 unsigned int texture, 519 unsigned int texture,
520 unsigned int level, 520 unsigned int level,
521 unsigned int internal_format, 521 unsigned int internal_format,
522 unsigned int type, 522 unsigned int type,
523 bool premultiply_alpha, 523 bool premultiply_alpha,
524 bool flip_y) { 524 bool flip_y) {
525 if (is_remote_ || !texture_id_) 525 if (is_remote_ || !texture_id_)
526 return false; 526 return false;
527 527
528 // For hidden video element (with style "display:none"), ensure the texture 528 // For hidden video element (with style "display:none"), ensure the texture
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 current_frame_ = NULL; 901 current_frame_ = NULL;
902 } 902 }
903 is_remote_ = false; 903 is_remote_ = false;
904 manager_ = NULL; 904 manager_ = NULL;
905 } 905 }
906 906
907 void WebMediaPlayerAndroid::DrawRemotePlaybackIcon() { 907 void WebMediaPlayerAndroid::DrawRemotePlaybackIcon() {
908 DCHECK(main_thread_checker_.CalledOnValidThread()); 908 DCHECK(main_thread_checker_.CalledOnValidThread());
909 if (!video_weblayer_) 909 if (!video_weblayer_)
910 return; 910 return;
911 WebKit::WebGraphicsContext3D* context = stream_texture_factory_->Context3d(); 911 blink::WebGraphicsContext3D* context = stream_texture_factory_->Context3d();
912 if (!context->makeContextCurrent()) 912 if (!context->makeContextCurrent())
913 return; 913 return;
914 914
915 // TODO(johnme): Should redraw this frame if the layer bounds change; but 915 // TODO(johnme): Should redraw this frame if the layer bounds change; but
916 // there seems no easy way to listen for the layer resizing (as opposed to 916 // there seems no easy way to listen for the layer resizing (as opposed to
917 // OnVideoSizeChanged, which is when the frame sizes of the video file 917 // OnVideoSizeChanged, which is when the frame sizes of the video file
918 // change). Perhaps have to poll (on main thread of course)? 918 // change). Perhaps have to poll (on main thread of course)?
919 gfx::Size video_size_css_px = video_weblayer_->bounds(); 919 gfx::Size video_size_css_px = video_weblayer_->bounds();
920 float device_scale_factor = frame_->view()->deviceScaleFactor(); 920 float device_scale_factor = frame_->view()->deviceScaleFactor();
921 // canvas_size will be the size in device pixels when pageScaleFactor == 1 921 // canvas_size will be the size in device pixels when pageScaleFactor == 1
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 // The following EME related code is copied from WebMediaPlayerImpl. 1164 // The following EME related code is copied from WebMediaPlayerImpl.
1165 // TODO(xhwang): Remove duplicate code between WebMediaPlayerAndroid and 1165 // TODO(xhwang): Remove duplicate code between WebMediaPlayerAndroid and
1166 // WebMediaPlayerImpl. 1166 // WebMediaPlayerImpl.
1167 // TODO(kjyoun): Update Google TV EME implementation to use IPC. 1167 // TODO(kjyoun): Update Google TV EME implementation to use IPC.
1168 1168
1169 // Helper functions to report media EME related stats to UMA. They follow the 1169 // Helper functions to report media EME related stats to UMA. They follow the
1170 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and 1170 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and
1171 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is 1171 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is
1172 // that UMA_* macros require the names to be constant throughout the process' 1172 // that UMA_* macros require the names to be constant throughout the process'
1173 // lifetime. 1173 // lifetime.
1174 static void EmeUMAHistogramEnumeration(const WebKit::WebString& key_system, 1174 static void EmeUMAHistogramEnumeration(const blink::WebString& key_system,
1175 const std::string& method, 1175 const std::string& method,
1176 int sample, 1176 int sample,
1177 int boundary_value) { 1177 int boundary_value) {
1178 base::LinearHistogram::FactoryGet( 1178 base::LinearHistogram::FactoryGet(
1179 kMediaEme + KeySystemNameForUMA(key_system) + "." + method, 1179 kMediaEme + KeySystemNameForUMA(key_system) + "." + method,
1180 1, boundary_value, boundary_value + 1, 1180 1, boundary_value, boundary_value + 1,
1181 base::Histogram::kUmaTargetedHistogramFlag)->Add(sample); 1181 base::Histogram::kUmaTargetedHistogramFlag)->Add(sample);
1182 } 1182 }
1183 1183
1184 static void EmeUMAHistogramCounts(const WebKit::WebString& key_system, 1184 static void EmeUMAHistogramCounts(const blink::WebString& key_system,
1185 const std::string& method, 1185 const std::string& method,
1186 int sample) { 1186 int sample) {
1187 // Use the same parameters as UMA_HISTOGRAM_COUNTS. 1187 // Use the same parameters as UMA_HISTOGRAM_COUNTS.
1188 base::Histogram::FactoryGet( 1188 base::Histogram::FactoryGet(
1189 kMediaEme + KeySystemNameForUMA(key_system) + "." + method, 1189 kMediaEme + KeySystemNameForUMA(key_system) + "." + method,
1190 1, 1000000, 50, base::Histogram::kUmaTargetedHistogramFlag)->Add(sample); 1190 1, 1000000, 50, base::Histogram::kUmaTargetedHistogramFlag)->Add(sample);
1191 } 1191 }
1192 1192
1193 // Helper enum for reporting generateKeyRequest/addKey histograms. 1193 // Helper enum for reporting generateKeyRequest/addKey histograms.
1194 enum MediaKeyException { 1194 enum MediaKeyException {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 1344
1345 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, 1345 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id,
1346 media::MediaKeys::KeyError error_code, 1346 media::MediaKeys::KeyError error_code,
1347 int system_code) { 1347 int system_code) {
1348 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", 1348 EmeUMAHistogramEnumeration(current_key_system_, "KeyError",
1349 error_code, media::MediaKeys::kMaxKeyError); 1349 error_code, media::MediaKeys::kMaxKeyError);
1350 1350
1351 client_->keyError( 1351 client_->keyError(
1352 current_key_system_, 1352 current_key_system_,
1353 WebString::fromUTF8(session_id), 1353 WebString::fromUTF8(session_id),
1354 static_cast<WebKit::WebMediaPlayerClient::MediaKeyErrorCode>(error_code), 1354 static_cast<blink::WebMediaPlayerClient::MediaKeyErrorCode>(error_code),
1355 system_code); 1355 system_code);
1356 } 1356 }
1357 1357
1358 void WebMediaPlayerAndroid::OnKeyMessage(const std::string& session_id, 1358 void WebMediaPlayerAndroid::OnKeyMessage(const std::string& session_id,
1359 const std::vector<uint8>& message, 1359 const std::vector<uint8>& message,
1360 const std::string& destination_url) { 1360 const std::string& destination_url) {
1361 const GURL destination_url_gurl(destination_url); 1361 const GURL destination_url_gurl(destination_url);
1362 DLOG_IF(WARNING, !destination_url.empty() && !destination_url_gurl.is_valid()) 1362 DLOG_IF(WARNING, !destination_url.empty() && !destination_url_gurl.is_valid())
1363 << "Invalid URL in destination_url: " << destination_url; 1363 << "Invalid URL in destination_url: " << destination_url;
1364 1364
1365 client_->keyMessage(current_key_system_, 1365 client_->keyMessage(current_key_system_,
1366 WebString::fromUTF8(session_id), 1366 WebString::fromUTF8(session_id),
1367 message.empty() ? NULL : &message[0], 1367 message.empty() ? NULL : &message[0],
1368 message.size(), 1368 message.size(),
1369 destination_url_gurl); 1369 destination_url_gurl);
1370 } 1370 }
1371 1371
1372 void WebMediaPlayerAndroid::OnMediaSourceOpened( 1372 void WebMediaPlayerAndroid::OnMediaSourceOpened(
1373 WebKit::WebMediaSource* web_media_source) { 1373 blink::WebMediaSource* web_media_source) {
1374 client_->mediaSourceOpened(web_media_source); 1374 client_->mediaSourceOpened(web_media_source);
1375 } 1375 }
1376 1376
1377 void WebMediaPlayerAndroid::OnNeedKey(const std::string& type, 1377 void WebMediaPlayerAndroid::OnNeedKey(const std::string& type,
1378 const std::vector<uint8>& init_data) { 1378 const std::vector<uint8>& init_data) {
1379 DCHECK(main_loop_->BelongsToCurrentThread()); 1379 DCHECK(main_loop_->BelongsToCurrentThread());
1380 // Do not fire NeedKey event if encrypted media is not enabled. 1380 // Do not fire NeedKey event if encrypted media is not enabled.
1381 if (!WebKit::WebRuntimeFeatures::isEncryptedMediaEnabled() && 1381 if (!blink::WebRuntimeFeatures::isEncryptedMediaEnabled() &&
1382 !WebKit::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled()) { 1382 !blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled()) {
1383 return; 1383 return;
1384 } 1384 }
1385 1385
1386 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); 1386 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1);
1387 1387
1388 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); 1388 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_);
1389 if (init_data_type_.empty()) 1389 if (init_data_type_.empty())
1390 init_data_type_ = type; 1390 init_data_type_ = type;
1391 1391
1392 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; 1392 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0];
(...skipping 14 matching lines...) Expand all
1407 demuxer_ = demuxer; 1407 demuxer_ = demuxer;
1408 destroy_demuxer_cb_ = destroy_demuxer_cb; 1408 destroy_demuxer_cb_ = destroy_demuxer_cb;
1409 return true; 1409 return true;
1410 } 1410 }
1411 #endif 1411 #endif
1412 1412
1413 void WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture(uint32 sync_point) { 1413 void WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture(uint32 sync_point) {
1414 DCHECK(main_thread_checker_.CalledOnValidThread()); 1414 DCHECK(main_thread_checker_.CalledOnValidThread());
1415 DCHECK(remote_playback_texture_id_); 1415 DCHECK(remote_playback_texture_id_);
1416 1416
1417 WebKit::WebGraphicsContext3D* context = 1417 blink::WebGraphicsContext3D* context =
1418 stream_texture_factory_->Context3d(); 1418 stream_texture_factory_->Context3d();
1419 1419
1420 if (sync_point) 1420 if (sync_point)
1421 context->waitSyncPoint(sync_point); 1421 context->waitSyncPoint(sync_point);
1422 context->deleteTexture(remote_playback_texture_id_); 1422 context->deleteTexture(remote_playback_texture_id_);
1423 remote_playback_texture_id_ = 0; 1423 remote_playback_texture_id_ = 0;
1424 } 1424 }
1425 1425
1426 void WebMediaPlayerAndroid::enterFullscreen() { 1426 void WebMediaPlayerAndroid::enterFullscreen() {
1427 if (manager_->CanEnterFullscreen(frame_)) { 1427 if (manager_->CanEnterFullscreen(frame_)) {
1428 manager_->EnterFullscreen(player_id_); 1428 manager_->EnterFullscreen(player_id_);
1429 SetNeedsEstablishPeer(false); 1429 SetNeedsEstablishPeer(false);
1430 } 1430 }
1431 } 1431 }
1432 1432
1433 void WebMediaPlayerAndroid::exitFullscreen() { 1433 void WebMediaPlayerAndroid::exitFullscreen() {
1434 manager_->ExitFullscreen(player_id_); 1434 manager_->ExitFullscreen(player_id_);
1435 } 1435 }
1436 1436
1437 bool WebMediaPlayerAndroid::canEnterFullscreen() const { 1437 bool WebMediaPlayerAndroid::canEnterFullscreen() const {
1438 return manager_->CanEnterFullscreen(frame_); 1438 return manager_->CanEnterFullscreen(frame_);
1439 } 1439 }
1440 1440
1441 } // namespace content 1441 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | content/renderer/media/audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698