| 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/webmediaplayer_ms.h" | 5 #include "content/renderer/media/webmediaplayer_ms.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.h" | 10 #include "base/callback.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "cc/layers/video_layer.h" | 13 #include "cc/layers/video_layer.h" |
| 14 #include "content/renderer/media/media_stream_audio_renderer.h" | 14 #include "content/renderer/media/media_stream_audio_renderer.h" |
| 15 #include "content/renderer/media/media_stream_client.h" | 15 #include "content/renderer/media/media_stream_client.h" |
| 16 #include "content/renderer/media/video_frame_provider.h" | 16 #include "content/renderer/media/video_frame_provider.h" |
| 17 #include "content/renderer/media/webmediaplayer_delegate.h" | 17 #include "content/renderer/media/webmediaplayer_delegate.h" |
| 18 #include "content/renderer/media/webmediaplayer_util.h" | 18 #include "content/renderer/media/webmediaplayer_util.h" |
| 19 #include "media/base/media_log.h" | 19 #include "media/base/media_log.h" |
| 20 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
| 21 #include "third_party/WebKit/public/platform/WebRect.h" | 21 #include "third_party/WebKit/public/platform/WebRect.h" |
| 22 #include "third_party/WebKit/public/platform/WebSize.h" | 22 #include "third_party/WebKit/public/platform/WebSize.h" |
| 23 #include "third_party/WebKit/public/platform/WebURL.h" | 23 #include "third_party/WebKit/public/platform/WebURL.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" | 25 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 27 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 27 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| 28 | 28 |
| 29 using WebKit::WebCanvas; | 29 using blink::WebCanvas; |
| 30 using WebKit::WebMediaPlayer; | 30 using blink::WebMediaPlayer; |
| 31 using WebKit::WebRect; | 31 using blink::WebRect; |
| 32 using WebKit::WebSize; | 32 using blink::WebSize; |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 WebMediaPlayerMS::WebMediaPlayerMS( | 36 WebMediaPlayerMS::WebMediaPlayerMS( |
| 37 WebKit::WebFrame* frame, | 37 blink::WebFrame* frame, |
| 38 WebKit::WebMediaPlayerClient* client, | 38 blink::WebMediaPlayerClient* client, |
| 39 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 39 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 40 MediaStreamClient* media_stream_client, | 40 MediaStreamClient* media_stream_client, |
| 41 media::MediaLog* media_log) | 41 media::MediaLog* media_log) |
| 42 : frame_(frame), | 42 : frame_(frame), |
| 43 network_state_(WebMediaPlayer::NetworkStateEmpty), | 43 network_state_(WebMediaPlayer::NetworkStateEmpty), |
| 44 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 44 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 45 buffered_(static_cast<size_t>(1)), | 45 buffered_(static_cast<size_t>(1)), |
| 46 client_(client), | 46 client_(client), |
| 47 delegate_(delegate), | 47 delegate_(delegate), |
| 48 media_stream_client_(media_stream_client), | 48 media_stream_client_(media_stream_client), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 75 audio_renderer_->Stop(); | 75 audio_renderer_->Stop(); |
| 76 | 76 |
| 77 media_log_->AddEvent( | 77 media_log_->AddEvent( |
| 78 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); | 78 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED)); |
| 79 | 79 |
| 80 if (delegate_.get()) | 80 if (delegate_.get()) |
| 81 delegate_->PlayerGone(this); | 81 delegate_->PlayerGone(this); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void WebMediaPlayerMS::load(LoadType load_type, | 84 void WebMediaPlayerMS::load(LoadType load_type, |
| 85 const WebKit::WebURL& url, | 85 const blink::WebURL& url, |
| 86 CORSMode cors_mode) { | 86 CORSMode cors_mode) { |
| 87 DVLOG(1) << "WebMediaPlayerMS::load"; | 87 DVLOG(1) << "WebMediaPlayerMS::load"; |
| 88 DCHECK(thread_checker_.CalledOnValidThread()); | 88 DCHECK(thread_checker_.CalledOnValidThread()); |
| 89 | 89 |
| 90 // TODO(acolwell): Change this to DCHECK_EQ(load_type, | 90 // TODO(acolwell): Change this to DCHECK_EQ(load_type, |
| 91 // LoadTypeMediaStream) once Blink-side changes land. | 91 // LoadTypeMediaStream) once Blink-side changes land. |
| 92 DCHECK_NE(load_type, LoadTypeMediaSource); | 92 DCHECK_NE(load_type, LoadTypeMediaSource); |
| 93 | 93 |
| 94 GURL gurl(url); | 94 GURL gurl(url); |
| 95 | 95 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool WebMediaPlayerMS::hasVideo() const { | 197 bool WebMediaPlayerMS::hasVideo() const { |
| 198 DCHECK(thread_checker_.CalledOnValidThread()); | 198 DCHECK(thread_checker_.CalledOnValidThread()); |
| 199 return (video_frame_provider_.get() != NULL); | 199 return (video_frame_provider_.get() != NULL); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool WebMediaPlayerMS::hasAudio() const { | 202 bool WebMediaPlayerMS::hasAudio() const { |
| 203 DCHECK(thread_checker_.CalledOnValidThread()); | 203 DCHECK(thread_checker_.CalledOnValidThread()); |
| 204 return (audio_renderer_.get() != NULL); | 204 return (audio_renderer_.get() != NULL); |
| 205 } | 205 } |
| 206 | 206 |
| 207 WebKit::WebSize WebMediaPlayerMS::naturalSize() const { | 207 blink::WebSize WebMediaPlayerMS::naturalSize() const { |
| 208 DCHECK(thread_checker_.CalledOnValidThread()); | 208 DCHECK(thread_checker_.CalledOnValidThread()); |
| 209 | 209 |
| 210 gfx::Size size; | 210 gfx::Size size; |
| 211 if (current_frame_.get()) | 211 if (current_frame_.get()) |
| 212 size = current_frame_->natural_size(); | 212 size = current_frame_->natural_size(); |
| 213 DVLOG(3) << "WebMediaPlayerMS::naturalSize, " << size.ToString(); | 213 DVLOG(3) << "WebMediaPlayerMS::naturalSize, " << size.ToString(); |
| 214 return WebKit::WebSize(size); | 214 return blink::WebSize(size); |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool WebMediaPlayerMS::paused() const { | 217 bool WebMediaPlayerMS::paused() const { |
| 218 DCHECK(thread_checker_.CalledOnValidThread()); | 218 DCHECK(thread_checker_.CalledOnValidThread()); |
| 219 return paused_; | 219 return paused_; |
| 220 } | 220 } |
| 221 | 221 |
| 222 bool WebMediaPlayerMS::seeking() const { | 222 bool WebMediaPlayerMS::seeking() const { |
| 223 DCHECK(thread_checker_.CalledOnValidThread()); | 223 DCHECK(thread_checker_.CalledOnValidThread()); |
| 224 return false; | 224 return false; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 244 DVLOG(1) << "WebMediaPlayerMS::networkState, state:" << network_state_; | 244 DVLOG(1) << "WebMediaPlayerMS::networkState, state:" << network_state_; |
| 245 return network_state_; | 245 return network_state_; |
| 246 } | 246 } |
| 247 | 247 |
| 248 WebMediaPlayer::ReadyState WebMediaPlayerMS::readyState() const { | 248 WebMediaPlayer::ReadyState WebMediaPlayerMS::readyState() const { |
| 249 DCHECK(thread_checker_.CalledOnValidThread()); | 249 DCHECK(thread_checker_.CalledOnValidThread()); |
| 250 DVLOG(1) << "WebMediaPlayerMS::readyState, state:" << ready_state_; | 250 DVLOG(1) << "WebMediaPlayerMS::readyState, state:" << ready_state_; |
| 251 return ready_state_; | 251 return ready_state_; |
| 252 } | 252 } |
| 253 | 253 |
| 254 const WebKit::WebTimeRanges& WebMediaPlayerMS::buffered() { | 254 const blink::WebTimeRanges& WebMediaPlayerMS::buffered() { |
| 255 DCHECK(thread_checker_.CalledOnValidThread()); | 255 DCHECK(thread_checker_.CalledOnValidThread()); |
| 256 return buffered_; | 256 return buffered_; |
| 257 } | 257 } |
| 258 | 258 |
| 259 double WebMediaPlayerMS::maxTimeSeekable() const { | 259 double WebMediaPlayerMS::maxTimeSeekable() const { |
| 260 DCHECK(thread_checker_.CalledOnValidThread()); | 260 DCHECK(thread_checker_.CalledOnValidThread()); |
| 261 return 0.0; | 261 return 0.0; |
| 262 } | 262 } |
| 263 | 263 |
| 264 bool WebMediaPlayerMS::didLoadingProgress() const { | 264 bool WebMediaPlayerMS::didLoadingProgress() const { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 GetClient()->networkStateChanged(); | 416 GetClient()->networkStateChanged(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { | 419 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { |
| 420 DCHECK(thread_checker_.CalledOnValidThread()); | 420 DCHECK(thread_checker_.CalledOnValidThread()); |
| 421 ready_state_ = state; | 421 ready_state_ = state; |
| 422 // Always notify to ensure client has the latest value. | 422 // Always notify to ensure client has the latest value. |
| 423 GetClient()->readyStateChanged(); | 423 GetClient()->readyStateChanged(); |
| 424 } | 424 } |
| 425 | 425 |
| 426 WebKit::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 426 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
| 427 DCHECK(thread_checker_.CalledOnValidThread()); | 427 DCHECK(thread_checker_.CalledOnValidThread()); |
| 428 DCHECK(client_); | 428 DCHECK(client_); |
| 429 return client_; | 429 return client_; |
| 430 } | 430 } |
| 431 | 431 |
| 432 } // namespace content | 432 } // namespace content |
| OLD | NEW |