| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webmediaplayer_proxy.h" | 5 #include "webkit/media/webmediaplayer_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "media/base/pipeline_status.h" | 10 #include "media/base/pipeline_status.h" |
| 11 #include "media/filters/chunk_demuxer.h" | 11 #include "media/filters/chunk_demuxer.h" |
| 12 #include "webkit/media/web_video_renderer.h" | 12 #include "webkit/media/web_video_renderer.h" |
| 13 #include "webkit/media/webmediaplayer_impl.h" | 13 #include "webkit/media/webmediaplayer_impl.h" |
| 14 | 14 |
| 15 using media::NetworkEvent; |
| 15 using media::PipelineStatus; | 16 using media::PipelineStatus; |
| 16 | 17 |
| 17 namespace webkit_media { | 18 namespace webkit_media { |
| 18 | 19 |
| 19 // Limits the maximum outstanding repaints posted on render thread. | 20 // Limits the maximum outstanding repaints posted on render thread. |
| 20 // This number of 50 is a guess, it does not take too much memory on the task | 21 // This number of 50 is a guess, it does not take too much memory on the task |
| 21 // queue but gives up a pretty good latency on repaint. | 22 // queue but gives up a pretty good latency on repaint. |
| 22 static const int kMaxOutstandingRepaints = 50; | 23 static const int kMaxOutstandingRepaints = 50; |
| 23 | 24 |
| 24 WebMediaPlayerProxy::WebMediaPlayerProxy(MessageLoop* render_loop, | 25 WebMediaPlayerProxy::WebMediaPlayerProxy(MessageLoop* render_loop, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 121 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 121 this, &WebMediaPlayerProxy::PipelineEndedTask, status)); | 122 this, &WebMediaPlayerProxy::PipelineEndedTask, status)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) { | 125 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) { |
| 125 DCHECK_NE(error, media::PIPELINE_OK); | 126 DCHECK_NE(error, media::PIPELINE_OK); |
| 126 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 127 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 127 this, &WebMediaPlayerProxy::PipelineErrorTask, error)); | 128 this, &WebMediaPlayerProxy::PipelineErrorTask, error)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void WebMediaPlayerProxy::NetworkEventCallback(bool is_downloading_data) { | 131 void WebMediaPlayerProxy::NetworkEventCallback(NetworkEvent type) { |
| 131 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 132 render_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 132 this, &WebMediaPlayerProxy::NetworkEventTask, is_downloading_data)); | 133 this, &WebMediaPlayerProxy::NetworkEventTask, type)); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void WebMediaPlayerProxy::AddDataSource(WebDataSource* data_source) { | 136 void WebMediaPlayerProxy::AddDataSource(WebDataSource* data_source) { |
| 136 base::AutoLock auto_lock(data_sources_lock_); | 137 base::AutoLock auto_lock(data_sources_lock_); |
| 137 data_sources_.push_back(make_scoped_refptr(data_source)); | 138 data_sources_.push_back(make_scoped_refptr(data_source)); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void WebMediaPlayerProxy::RepaintTask() { | 141 void WebMediaPlayerProxy::RepaintTask() { |
| 141 DCHECK(MessageLoop::current() == render_loop_); | 142 DCHECK(MessageLoop::current() == render_loop_); |
| 142 { | 143 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 166 if (webmediaplayer_) | 167 if (webmediaplayer_) |
| 167 webmediaplayer_->OnPipelineEnded(status); | 168 webmediaplayer_->OnPipelineEnded(status); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) { | 171 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) { |
| 171 DCHECK(MessageLoop::current() == render_loop_); | 172 DCHECK(MessageLoop::current() == render_loop_); |
| 172 if (webmediaplayer_) | 173 if (webmediaplayer_) |
| 173 webmediaplayer_->OnPipelineError(error); | 174 webmediaplayer_->OnPipelineError(error); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void WebMediaPlayerProxy::NetworkEventTask(bool is_downloading_data) { | 177 void WebMediaPlayerProxy::NetworkEventTask(NetworkEvent type) { |
| 177 DCHECK(MessageLoop::current() == render_loop_); | 178 DCHECK(MessageLoop::current() == render_loop_); |
| 178 if (webmediaplayer_) | 179 if (webmediaplayer_) |
| 179 webmediaplayer_->OnNetworkEvent(is_downloading_data); | 180 webmediaplayer_->OnNetworkEvent(type); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void WebMediaPlayerProxy::GetCurrentFrame( | 183 void WebMediaPlayerProxy::GetCurrentFrame( |
| 183 scoped_refptr<media::VideoFrame>* frame_out) { | 184 scoped_refptr<media::VideoFrame>* frame_out) { |
| 184 if (video_renderer_) | 185 if (video_renderer_) |
| 185 video_renderer_->GetCurrentFrame(frame_out); | 186 video_renderer_->GetCurrentFrame(frame_out); |
| 186 } | 187 } |
| 187 | 188 |
| 188 void WebMediaPlayerProxy::PutCurrentFrame( | 189 void WebMediaPlayerProxy::PutCurrentFrame( |
| 189 scoped_refptr<media::VideoFrame> frame) { | 190 scoped_refptr<media::VideoFrame> frame) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 chunk_demuxer_ = demuxer; | 230 chunk_demuxer_ = demuxer; |
| 230 if (webmediaplayer_) | 231 if (webmediaplayer_) |
| 231 webmediaplayer_->OnDemuxerOpened(); | 232 webmediaplayer_->OnDemuxerOpened(); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void WebMediaPlayerProxy::DemuxerClosedTask() { | 235 void WebMediaPlayerProxy::DemuxerClosedTask() { |
| 235 chunk_demuxer_ = NULL; | 236 chunk_demuxer_ = NULL; |
| 236 } | 237 } |
| 237 | 238 |
| 238 } // namespace webkit_media | 239 } // namespace webkit_media |
| OLD | NEW |