Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media/android/webmediaplayer_android.h" | 5 #include "webkit/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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 main_loop_->RemoveDestructionObserver(this); | 94 main_loop_->RemoveDestructionObserver(this); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { | 97 void WebMediaPlayerAndroid::load(const WebURL& url, CORSMode cors_mode) { |
| 98 load(url, NULL, cors_mode); | 98 load(url, NULL, cors_mode); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void WebMediaPlayerAndroid::load(const WebURL& url, | 101 void WebMediaPlayerAndroid::load(const WebURL& url, |
| 102 WebMediaSource* media_source, | 102 WebMediaSource* media_source, |
| 103 CORSMode cors_mode) { | 103 CORSMode cors_mode) { |
| 104 if (cors_mode != CORSModeUnspecified) | |
| 105 NOTIMPLEMENTED() << "No CORS support"; | |
| 106 | |
| 107 if (media_source) { | 104 if (media_source) { |
| 108 media_source_delegate_.reset( | 105 media_source_delegate_.reset( |
| 109 new MediaSourceDelegate( | 106 new MediaSourceDelegate( |
| 110 frame_, client_, proxy_, player_id_, media_log_)); | 107 frame_, client_, proxy_, player_id_, media_log_)); |
| 111 // |media_source_delegate_| is owned, so Unretained() is safe here. | |
| 112 media_source_delegate_->Initialize( | |
| 113 media_source, | |
| 114 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, | |
| 115 base::Unretained(this))); | |
| 116 } | 108 } |
| 117 | 109 |
| 118 url_ = url; | 110 url_ = url; |
| 119 GURL first_party_url = frame_->document().firstPartyForCookies(); | 111 pending_media_source_.reset(media_source); |
|
qinmin
2013/06/03 16:55:59
if you split MSE/non-MSE load() call, you don't ne
Sami
2013/06/03 17:12:56
Sorry, I don't know what MSE stands for :) Do you
| |
| 120 if (proxy_) { | 112 |
| 121 proxy_->Initialize(player_id_, url_, media_source != NULL, first_party_url); | 113 info_loader_.reset( |
|
qinmin
2013/06/03 16:55:59
I don't think CORS is needed for MSE.
You might w
Sami
2013/06/03 17:12:56
Done.
| |
| 122 if (manager_->IsInFullscreen(frame_)) | 114 new MediaInfoLoaderAndroid( |
| 123 proxy_->EnterFullscreen(player_id_); | 115 url_, |
| 124 } | 116 cors_mode, |
| 117 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo, | |
| 118 base::Unretained(this)))); | |
|
qinmin
2013/06/03 16:55:59
nit: indent
Sami
2013/06/03 17:12:56
Done.
| |
| 119 info_loader_->Start(frame_); | |
| 125 | 120 |
| 126 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); | 121 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 127 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 122 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 128 } | 123 } |
| 129 | 124 |
| 125 void WebMediaPlayerAndroid::DidLoadMediaInfo( | |
| 126 MediaInfoLoaderAndroid::Status status) { | |
| 127 if (status == MediaInfoLoaderAndroid::kFailed) { | |
| 128 info_loader_.reset(); | |
| 129 media_source_delegate_.reset(); | |
| 130 pending_media_source_.reset(); | |
| 131 return; | |
| 132 } | |
| 133 | |
| 134 bool is_media_source = pending_media_source_; | |
| 135 if (pending_media_source_) { | |
| 136 // |media_source_delegate_| is owned, so Unretained() is safe here. | |
| 137 media_source_delegate_->Initialize( | |
| 138 pending_media_source_.release(), | |
| 139 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, | |
| 140 base::Unretained(this))); | |
| 141 } | |
| 142 | |
| 143 GURL first_party_url = frame_->document().firstPartyForCookies(); | |
| 144 if (proxy_) { | |
| 145 proxy_->Initialize(player_id_, url_, is_media_source, first_party_url); | |
| 146 if (manager_->IsInFullscreen(frame_)) | |
| 147 proxy_->EnterFullscreen(player_id_); | |
| 148 } | |
| 149 } | |
| 150 | |
| 130 void WebMediaPlayerAndroid::cancelLoad() { | 151 void WebMediaPlayerAndroid::cancelLoad() { |
| 131 NOTIMPLEMENTED(); | 152 pending_media_source_.reset(); |
| 153 info_loader_.reset(); | |
| 132 } | 154 } |
| 133 | 155 |
| 134 void WebMediaPlayerAndroid::play() { | 156 void WebMediaPlayerAndroid::play() { |
| 135 #if defined(GOOGLE_TV) | 157 #if defined(GOOGLE_TV) |
| 136 if (hasVideo() && needs_external_surface_) { | 158 if (hasVideo() && needs_external_surface_) { |
| 137 DCHECK(!needs_establish_peer_); | 159 DCHECK(!needs_establish_peer_); |
| 138 if (proxy_) | 160 if (proxy_) |
| 139 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); | 161 proxy_->RequestExternalSurface(player_id_, last_computed_rect_); |
| 140 } | 162 } |
| 141 #endif | 163 #endif |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, | 337 web_graphics_context->copyTextureCHROMIUM(GL_TEXTURE_2D, texture_id_, |
| 316 texture, level, internal_format, | 338 texture, level, internal_format, |
| 317 type); | 339 type); |
| 318 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | 340 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); |
| 319 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 341 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 320 false); | 342 false); |
| 321 return true; | 343 return true; |
| 322 } | 344 } |
| 323 | 345 |
| 324 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 346 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
| 325 // TODO(qinmin): fix this for urls that are not file. | 347 if (info_loader_) |
| 326 // https://code.google.com/p/chromium/issues/detail?id=234710 | 348 return info_loader_->HasSingleOrigin(); |
| 327 if (url_.SchemeIsFile()) | |
| 328 return true; | |
| 329 return false; | 349 return false; |
| 330 } | 350 } |
| 331 | 351 |
| 332 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const { | 352 bool WebMediaPlayerAndroid::didPassCORSAccessCheck() const { |
| 353 if (info_loader_) | |
| 354 return info_loader_->DidPassCORSAccessCheck(); | |
| 333 return false; | 355 return false; |
| 334 } | 356 } |
| 335 | 357 |
| 336 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const { | 358 WebMediaPlayer::MovieLoadType WebMediaPlayerAndroid::movieLoadType() const { |
| 337 // Deprecated. | 359 // Deprecated. |
| 338 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. | 360 // TODO(qinmin): Remove this from WebKit::WebMediaPlayer as it is never used. |
| 339 return WebMediaPlayer::MovieLoadTypeUnknown; | 361 return WebMediaPlayer::MovieLoadTypeUnknown; |
| 340 } | 362 } |
| 341 | 363 |
| 342 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { | 364 double WebMediaPlayerAndroid::mediaTimeForTimeValue(double timeValue) const { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 void WebMediaPlayerAndroid::exitFullscreen() { | 751 void WebMediaPlayerAndroid::exitFullscreen() { |
| 730 if (proxy_) | 752 if (proxy_) |
| 731 proxy_->ExitFullscreen(player_id_); | 753 proxy_->ExitFullscreen(player_id_); |
| 732 } | 754 } |
| 733 | 755 |
| 734 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 756 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 735 return manager_->CanEnterFullscreen(frame_); | 757 return manager_->CanEnterFullscreen(frame_); |
| 736 } | 758 } |
| 737 | 759 |
| 738 } // namespace webkit_media | 760 } // namespace webkit_media |
| OLD | NEW |