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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 StopDevice(); | 231 StopDevice(); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 void VideoCaptureImpl::DoFeedBufferOnCaptureThread( | 235 void VideoCaptureImpl::DoFeedBufferOnCaptureThread( |
236 scoped_refptr<VideoFrameBuffer> buffer) { | 236 scoped_refptr<VideoFrameBuffer> buffer) { |
237 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 237 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
238 | 238 |
239 CachedDIB::iterator it; | 239 CachedDIB::iterator it; |
240 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); ++it) { | 240 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); ++it) { |
241 if (buffer == it->second->mapped_memory) | 241 if (buffer.get() == it->second->mapped_memory.get()) |
242 break; | 242 break; |
243 } | 243 } |
244 | 244 |
245 if (it != cached_dibs_.end() && it->second) { | 245 if (it != cached_dibs_.end() && it->second) { |
246 DCHECK_GT(it->second->references, 0); | 246 DCHECK_GT(it->second->references, 0); |
247 --it->second->references; | 247 --it->second->references; |
248 if (it->second->references == 0) { | 248 if (it->second->references == 0) { |
249 Send(new VideoCaptureHostMsg_BufferReady(device_id_, it->first)); | 249 Send(new VideoCaptureHostMsg_BufferReady(device_id_, it->first)); |
250 } | 250 } |
251 } | 251 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 int buffer_id, base::Time timestamp) { | 285 int buffer_id, base::Time timestamp) { |
286 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 286 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
287 | 287 |
288 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { | 288 if (state_ != VIDEO_CAPTURE_STATE_STARTED || suspended_) { |
289 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); | 289 Send(new VideoCaptureHostMsg_BufferReady(device_id_, buffer_id)); |
290 return; | 290 return; |
291 } | 291 } |
292 | 292 |
293 media::VideoCapture::VideoFrameBuffer* buffer; | 293 media::VideoCapture::VideoFrameBuffer* buffer; |
294 DCHECK(cached_dibs_.find(buffer_id) != cached_dibs_.end()); | 294 DCHECK(cached_dibs_.find(buffer_id) != cached_dibs_.end()); |
295 buffer = cached_dibs_[buffer_id]->mapped_memory; | 295 buffer = cached_dibs_[buffer_id]->mapped_memory.get(); |
296 buffer->timestamp = timestamp; | 296 buffer->timestamp = timestamp; |
297 | 297 |
298 for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) { | 298 for (ClientInfo::iterator it = clients_.begin(); it != clients_.end(); ++it) { |
299 it->first->OnBufferReady(this, buffer); | 299 it->first->OnBufferReady(this, buffer); |
300 } | 300 } |
301 cached_dibs_[buffer_id]->references = clients_.size(); | 301 cached_dibs_[buffer_id]->references = clients_.size(); |
302 } | 302 } |
303 | 303 |
304 void VideoCaptureImpl::DoStateChangedOnCaptureThread(VideoCaptureState state) { | 304 void VideoCaptureImpl::DoStateChangedOnCaptureThread(VideoCaptureState state) { |
305 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 305 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 if (it != clients->end()) { | 461 if (it != clients->end()) { |
462 handler->OnStopped(this); | 462 handler->OnStopped(this); |
463 handler->OnRemoved(this); | 463 handler->OnRemoved(this); |
464 clients->erase(it); | 464 clients->erase(it); |
465 found = true; | 465 found = true; |
466 } | 466 } |
467 return found; | 467 return found; |
468 } | 468 } |
469 | 469 |
470 } // namespace content | 470 } // namespace content |
OLD | NEW |