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 "content/renderer/media/video_capture_impl.h" | 5 #include "content/renderer/media/video_capture_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
10 #include "content/common/media/video_capture_messages.h" | 10 #include "content/common/media/video_capture_messages.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 if (it != clients_pending_on_filter_.end()) { | 220 if (it != clients_pending_on_filter_.end()) { |
221 handler->OnStopped(this); | 221 handler->OnStopped(this); |
222 handler->OnRemoved(this); | 222 handler->OnRemoved(this); |
223 clients_pending_on_filter_.erase(it); | 223 clients_pending_on_filter_.erase(it); |
224 return; | 224 return; |
225 } | 225 } |
226 it = clients_pending_on_restart_.find(handler); | 226 it = clients_pending_on_restart_.find(handler); |
227 if (it != clients_pending_on_restart_.end()) { | 227 if (it != clients_pending_on_restart_.end()) { |
228 handler->OnStopped(this); | 228 handler->OnStopped(this); |
229 handler->OnRemoved(this); | 229 handler->OnRemoved(this); |
230 clients_pending_on_filter_.erase(it); | 230 clients_pending_on_restart_.erase(it); |
231 return; | 231 return; |
232 } | 232 } |
233 | 233 |
234 if (clients_.find(handler) == clients_.end()) | 234 if (clients_.find(handler) == clients_.end()) |
235 return; | 235 return; |
236 | 236 |
237 clients_.erase(handler); | 237 clients_.erase(handler); |
238 | 238 |
239 if (clients_.empty()) { | 239 if (clients_.empty()) { |
240 DVLOG(1) << "StopCapture: No more client, stopping ..."; | 240 DVLOG(1) << "StopCapture: No more client, stopping ..."; |
241 StopDevice(); | 241 StopDevice(); |
242 } | 242 } |
243 handler->OnStopped(this); | 243 handler->OnStopped(this); |
244 handler->OnRemoved(this); | 244 handler->OnRemoved(this); |
245 } | 245 } |
246 | 246 |
247 void VideoCaptureImpl::DoFeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) { | 247 void VideoCaptureImpl::DoFeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) { |
248 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 248 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
249 | 249 |
250 CachedDIB::iterator it; | 250 CachedDIB::iterator it; |
251 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { | 251 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { |
252 if (buffer == it->second->mapped_memory) | 252 if (buffer == it->second->mapped_memory) |
253 break; | 253 break; |
254 } | 254 } |
255 | 255 |
256 DCHECK(it != cached_dibs_.end()); | 256 if (it != cached_dibs_.end() && it->second) { |
257 DCHECK_GT(it->second->references, 0); | 257 DCHECK_GT(it->second->references, 0); |
258 it->second->references--; | 258 it->second->references--; |
259 if (it->second->references == 0) { | 259 if (it->second->references == 0) { |
260 Send(new VideoCaptureHostMsg_BufferReady(device_id_, it->first)); | 260 Send(new VideoCaptureHostMsg_BufferReady(device_id_, it->first)); |
| 261 } |
261 } | 262 } |
262 } | 263 } |
263 | 264 |
264 void VideoCaptureImpl::DoBufferCreated( | 265 void VideoCaptureImpl::DoBufferCreated( |
265 base::SharedMemoryHandle handle, | 266 base::SharedMemoryHandle handle, |
266 int length, int buffer_id) { | 267 int length, int buffer_id) { |
267 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 268 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
268 DCHECK(device_info_available_); | 269 DCHECK(device_info_available_); |
269 | 270 |
270 media::VideoCapture::VideoFrameBuffer* buffer; | 271 media::VideoCapture::VideoFrameBuffer* buffer; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 432 } |
432 | 433 |
433 bool VideoCaptureImpl::ClientHasDIB() { | 434 bool VideoCaptureImpl::ClientHasDIB() { |
434 CachedDIB::iterator it; | 435 CachedDIB::iterator it; |
435 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { | 436 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { |
436 if (it->second->references > 0) | 437 if (it->second->references > 0) |
437 return true; | 438 return true; |
438 } | 439 } |
439 return false; | 440 return false; |
440 } | 441 } |
OLD | NEW |