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/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_proxy.h" | 9 #include "base/message_loop_proxy.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 "media/filters/video_renderer_base.h" | 12 #include "media/filters/video_renderer_base.h" |
13 #include "webkit/media/webmediaplayer_impl.h" | 13 #include "webkit/media/webmediaplayer_impl.h" |
14 | 14 |
15 using media::NetworkEvent; | |
16 using media::PipelineStatus; | 15 using media::PipelineStatus; |
17 | 16 |
18 namespace webkit_media { | 17 namespace webkit_media { |
19 | 18 |
20 // Limits the maximum outstanding repaints posted on render thread. | 19 // Limits the maximum outstanding repaints posted on render thread. |
21 // This number of 50 is a guess, it does not take too much memory on the task | 20 // This number of 50 is a guess, it does not take too much memory on the task |
22 // queue but gives up a pretty good latency on repaint. | 21 // queue but gives up a pretty good latency on repaint. |
23 static const int kMaxOutstandingRepaints = 50; | 22 static const int kMaxOutstandingRepaints = 50; |
24 | 23 |
25 WebMediaPlayerProxy::WebMediaPlayerProxy( | 24 WebMediaPlayerProxy::WebMediaPlayerProxy( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 render_loop_->PostTask(FROM_HERE, base::Bind( | 105 render_loop_->PostTask(FROM_HERE, base::Bind( |
107 &WebMediaPlayerProxy::PipelineEndedTask, this, status)); | 106 &WebMediaPlayerProxy::PipelineEndedTask, this, status)); |
108 } | 107 } |
109 | 108 |
110 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) { | 109 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) { |
111 DCHECK_NE(error, media::PIPELINE_OK); | 110 DCHECK_NE(error, media::PIPELINE_OK); |
112 render_loop_->PostTask(FROM_HERE, base::Bind( | 111 render_loop_->PostTask(FROM_HERE, base::Bind( |
113 &WebMediaPlayerProxy::PipelineErrorTask, this, error)); | 112 &WebMediaPlayerProxy::PipelineErrorTask, this, error)); |
114 } | 113 } |
115 | 114 |
116 void WebMediaPlayerProxy::NetworkEventCallback(NetworkEvent type) { | |
117 render_loop_->PostTask(FROM_HERE, base::Bind( | |
118 &WebMediaPlayerProxy::NetworkEventTask, this, type)); | |
119 } | |
120 | |
121 void WebMediaPlayerProxy::RepaintTask() { | 115 void WebMediaPlayerProxy::RepaintTask() { |
122 DCHECK(render_loop_->BelongsToCurrentThread()); | 116 DCHECK(render_loop_->BelongsToCurrentThread()); |
123 { | 117 { |
124 base::AutoLock auto_lock(lock_); | 118 base::AutoLock auto_lock(lock_); |
125 --outstanding_repaints_; | 119 --outstanding_repaints_; |
126 DCHECK_GE(outstanding_repaints_, 0); | 120 DCHECK_GE(outstanding_repaints_, 0); |
127 } | 121 } |
128 if (webmediaplayer_) { | 122 if (webmediaplayer_) { |
129 webmediaplayer_->Repaint(); | 123 webmediaplayer_->Repaint(); |
130 } | 124 } |
(...skipping 16 matching lines...) Expand all Loading... |
147 if (webmediaplayer_) | 141 if (webmediaplayer_) |
148 webmediaplayer_->OnPipelineEnded(status); | 142 webmediaplayer_->OnPipelineEnded(status); |
149 } | 143 } |
150 | 144 |
151 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) { | 145 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) { |
152 DCHECK(render_loop_->BelongsToCurrentThread()); | 146 DCHECK(render_loop_->BelongsToCurrentThread()); |
153 if (webmediaplayer_) | 147 if (webmediaplayer_) |
154 webmediaplayer_->OnPipelineError(error); | 148 webmediaplayer_->OnPipelineError(error); |
155 } | 149 } |
156 | 150 |
157 void WebMediaPlayerProxy::NetworkEventTask(NetworkEvent type) { | |
158 DCHECK(render_loop_->BelongsToCurrentThread()); | |
159 if (webmediaplayer_) | |
160 webmediaplayer_->OnNetworkEvent(type); | |
161 } | |
162 | |
163 void WebMediaPlayerProxy::SetOpaqueTask(bool opaque) { | 151 void WebMediaPlayerProxy::SetOpaqueTask(bool opaque) { |
164 DCHECK(render_loop_->BelongsToCurrentThread()); | 152 DCHECK(render_loop_->BelongsToCurrentThread()); |
165 if (webmediaplayer_) | 153 if (webmediaplayer_) |
166 webmediaplayer_->SetOpaque(opaque); | 154 webmediaplayer_->SetOpaque(opaque); |
167 } | 155 } |
168 | 156 |
169 void WebMediaPlayerProxy::GetCurrentFrame( | 157 void WebMediaPlayerProxy::GetCurrentFrame( |
170 scoped_refptr<media::VideoFrame>* frame_out) { | 158 scoped_refptr<media::VideoFrame>* frame_out) { |
171 if (frame_provider_) | 159 if (frame_provider_) |
172 frame_provider_->GetCurrentFrame(frame_out); | 160 frame_provider_->GetCurrentFrame(frame_out); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 } | 238 } |
251 | 239 |
252 void WebMediaPlayerProxy::KeyNeededTask(scoped_array<uint8> init_data, | 240 void WebMediaPlayerProxy::KeyNeededTask(scoped_array<uint8> init_data, |
253 int init_data_size) { | 241 int init_data_size) { |
254 DCHECK(render_loop_->BelongsToCurrentThread()); | 242 DCHECK(render_loop_->BelongsToCurrentThread()); |
255 if (webmediaplayer_) | 243 if (webmediaplayer_) |
256 webmediaplayer_->OnKeyNeeded(init_data.Pass(), init_data_size); | 244 webmediaplayer_->OnKeyNeeded(init_data.Pass(), init_data_size); |
257 } | 245 } |
258 | 246 |
259 } // namespace webkit_media | 247 } // namespace webkit_media |
OLD | NEW |