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 "content/renderer/media/capture_video_decoder.h" | 5 #include "content/renderer/media/capture_video_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/renderer/media/video_capture_impl_manager.h" | 8 #include "content/renderer/media/video_capture_impl_manager.h" |
9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 this, callback)); | 60 this, callback)); |
61 } | 61 } |
62 | 62 |
63 void CaptureVideoDecoder::Pause(const base::Closure& callback) { | 63 void CaptureVideoDecoder::Pause(const base::Closure& callback) { |
64 message_loop_proxy_->PostTask( | 64 message_loop_proxy_->PostTask( |
65 FROM_HERE, | 65 FROM_HERE, |
66 base::Bind(&CaptureVideoDecoder::PauseOnDecoderThread, | 66 base::Bind(&CaptureVideoDecoder::PauseOnDecoderThread, |
67 this, callback)); | 67 this, callback)); |
68 } | 68 } |
69 | 69 |
| 70 void CaptureVideoDecoder::Flush(const base::Closure& callback) { |
| 71 message_loop_proxy_->PostTask( |
| 72 FROM_HERE, |
| 73 base::Bind(&CaptureVideoDecoder::FlushOnDecoderThread, |
| 74 this, callback)); |
| 75 } |
| 76 |
70 void CaptureVideoDecoder::Stop(const base::Closure& callback) { | 77 void CaptureVideoDecoder::Stop(const base::Closure& callback) { |
71 message_loop_proxy_->PostTask( | 78 message_loop_proxy_->PostTask( |
72 FROM_HERE, | 79 FROM_HERE, |
73 base::Bind(&CaptureVideoDecoder::StopOnDecoderThread, | 80 base::Bind(&CaptureVideoDecoder::StopOnDecoderThread, |
74 this, callback)); | 81 this, callback)); |
75 } | 82 } |
76 | 83 |
77 void CaptureVideoDecoder::Seek(base::TimeDelta time, | 84 void CaptureVideoDecoder::Seek(base::TimeDelta time, |
78 const media::FilterStatusCB& cb) { | 85 const media::FilterStatusCB& cb) { |
79 message_loop_proxy_->PostTask( | 86 message_loop_proxy_->PostTask( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 callback.Run(); | 158 callback.Run(); |
152 } | 159 } |
153 | 160 |
154 void CaptureVideoDecoder::PauseOnDecoderThread(const base::Closure& callback) { | 161 void CaptureVideoDecoder::PauseOnDecoderThread(const base::Closure& callback) { |
155 DVLOG(1) << "PauseOnDecoderThread"; | 162 DVLOG(1) << "PauseOnDecoderThread"; |
156 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 163 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
157 state_ = kPaused; | 164 state_ = kPaused; |
158 media::VideoDecoder::Pause(callback); | 165 media::VideoDecoder::Pause(callback); |
159 } | 166 } |
160 | 167 |
| 168 void CaptureVideoDecoder::FlushOnDecoderThread(const base::Closure& callback) { |
| 169 DVLOG(1) << "FlushOnDecoderThread"; |
| 170 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 171 if (!read_cb_.is_null()) { |
| 172 scoped_refptr<media::VideoFrame> video_frame = |
| 173 media::VideoFrame::CreateBlackFrame(natural_size_.width(), |
| 174 natural_size_.height()); |
| 175 DeliverFrame(video_frame); |
| 176 } |
| 177 media::VideoDecoder::Flush(callback); |
| 178 } |
| 179 |
161 void CaptureVideoDecoder::StopOnDecoderThread(const base::Closure& callback) { | 180 void CaptureVideoDecoder::StopOnDecoderThread(const base::Closure& callback) { |
162 DVLOG(1) << "StopOnDecoderThread"; | 181 DVLOG(1) << "StopOnDecoderThread"; |
163 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 182 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
164 pending_stop_cb_ = callback; | 183 pending_stop_cb_ = callback; |
165 state_ = kStopped; | 184 state_ = kStopped; |
166 capture_engine_->StopCapture(this); | 185 capture_engine_->StopCapture(this); |
167 } | 186 } |
168 | 187 |
169 void CaptureVideoDecoder::SeekOnDecoderThread(base::TimeDelta time, | 188 void CaptureVideoDecoder::SeekOnDecoderThread(base::TimeDelta time, |
170 const media::FilterStatusCB& cb) { | 189 const media::FilterStatusCB& cb) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 capture->FeedBuffer(buf); | 263 capture->FeedBuffer(buf); |
245 } | 264 } |
246 | 265 |
247 void CaptureVideoDecoder::DeliverFrame( | 266 void CaptureVideoDecoder::DeliverFrame( |
248 const scoped_refptr<media::VideoFrame>& video_frame) { | 267 const scoped_refptr<media::VideoFrame>& video_frame) { |
249 // Reset the callback before running to protect against reentrancy. | 268 // Reset the callback before running to protect against reentrancy. |
250 ReadCB read_cb = read_cb_; | 269 ReadCB read_cb = read_cb_; |
251 read_cb_.Reset(); | 270 read_cb_.Reset(); |
252 read_cb.Run(video_frame); | 271 read_cb.Run(video_frame); |
253 } | 272 } |
OLD | NEW |