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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (state_ == video_capture::kStarted) | 87 if (state_ == video_capture::kStarted) |
88 Send(new VideoCaptureHostMsg_Stop(device_id_)); | 88 Send(new VideoCaptureHostMsg_Stop(device_id_)); |
89 | 89 |
90 io_message_loop_proxy_->PostTask(FROM_HERE, | 90 io_message_loop_proxy_->PostTask(FROM_HERE, |
91 base::Bind(&VideoCaptureImpl::RemoveDelegateOnIOThread, | 91 base::Bind(&VideoCaptureImpl::RemoveDelegateOnIOThread, |
92 base::Unretained(this), task)); | 92 base::Unretained(this), task)); |
93 } | 93 } |
94 | 94 |
95 void VideoCaptureImpl::StartCapture( | 95 void VideoCaptureImpl::StartCapture( |
96 media::VideoCapture::EventHandler* handler, | 96 media::VideoCapture::EventHandler* handler, |
97 const VideoCaptureCapability& capability) { | 97 const media::VideoCaptureCapability& capability) { |
98 DCHECK_EQ(capability.raw_type, media::VideoFrame::I420); | 98 DCHECK_EQ(capability.color, media::VideoFrame::I420); |
99 | 99 |
100 capture_message_loop_proxy_->PostTask(FROM_HERE, | 100 capture_message_loop_proxy_->PostTask(FROM_HERE, |
101 base::Bind(&VideoCaptureImpl::DoStartCapture, | 101 base::Bind(&VideoCaptureImpl::DoStartCapture, |
102 base::Unretained(this), handler, capability)); | 102 base::Unretained(this), handler, capability)); |
103 } | 103 } |
104 | 104 |
105 void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler) { | 105 void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler) { |
106 capture_message_loop_proxy_->PostTask(FROM_HERE, | 106 capture_message_loop_proxy_->PostTask(FROM_HERE, |
107 base::Bind(&VideoCaptureImpl::DoStopCapture, | 107 base::Bind(&VideoCaptureImpl::DoStopCapture, |
108 base::Unretained(this), handler)); | 108 base::Unretained(this), handler)); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { | 144 void VideoCaptureImpl::OnDelegateAdded(int32 device_id) { |
145 capture_message_loop_proxy_->PostTask(FROM_HERE, | 145 capture_message_loop_proxy_->PostTask(FROM_HERE, |
146 base::Bind(&VideoCaptureImpl::DoDelegateAdded, | 146 base::Bind(&VideoCaptureImpl::DoDelegateAdded, |
147 base::Unretained(this), device_id)); | 147 base::Unretained(this), device_id)); |
148 } | 148 } |
149 | 149 |
150 void VideoCaptureImpl::DoStartCapture( | 150 void VideoCaptureImpl::DoStartCapture( |
151 media::VideoCapture::EventHandler* handler, | 151 media::VideoCapture::EventHandler* handler, |
152 const VideoCaptureCapability& capability) { | 152 const media::VideoCaptureCapability& capability) { |
153 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 153 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
154 | 154 |
155 if (state_ == video_capture::kError) { | 155 if (state_ == video_capture::kError) { |
156 handler->OnError(this, 1); | 156 handler->OnError(this, 1); |
157 handler->OnRemoved(this); | 157 handler->OnRemoved(this); |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 ClientInfo::iterator it1 = clients_pending_on_filter_.find(handler); | 161 ClientInfo::iterator it1 = clients_pending_on_filter_.find(handler); |
162 ClientInfo::iterator it2 = clients_pending_on_restart_.find(handler); | 162 ClientInfo::iterator it2 = clients_pending_on_restart_.find(handler); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (state_ == video_capture::kStopping) { | 195 if (state_ == video_capture::kStopping) { |
196 clients_pending_on_restart_[handler] = capability; | 196 clients_pending_on_restart_[handler] = capability; |
197 DVLOG(1) << "StartCapture: Got new resolution (" | 197 DVLOG(1) << "StartCapture: Got new resolution (" |
198 << capability.width << ", " << capability.height << ") " | 198 << capability.width << ", " << capability.height << ") " |
199 << ", during stopping."; | 199 << ", during stopping."; |
200 return; | 200 return; |
201 } | 201 } |
202 | 202 |
203 clients_[handler] = capability; | 203 clients_[handler] = capability; |
204 DCHECK_EQ(clients_.size(), 1ul); | 204 DCHECK_EQ(clients_.size(), 1ul); |
205 video_type_ = capability.raw_type; | 205 video_type_ = capability.color; |
206 current_params_.width = capability.width; | 206 current_params_.width = capability.width; |
207 current_params_.height = capability.height; | 207 current_params_.height = capability.height; |
208 current_params_.frame_per_second = capability.max_fps; | 208 current_params_.frame_per_second = capability.frame_rate; |
209 DVLOG(1) << "StartCapture: starting with first resolution (" | 209 DVLOG(1) << "StartCapture: starting with first resolution (" |
210 << current_params_.width << ", " << current_params_.height << ")"; | 210 << current_params_.width << ", " << current_params_.height << ")"; |
211 | 211 |
212 StartCaptureInternal(); | 212 StartCaptureInternal(); |
213 } | 213 } |
214 | 214 |
215 void VideoCaptureImpl::DoStopCapture( | 215 void VideoCaptureImpl::DoStopCapture( |
216 media::VideoCapture::EventHandler* handler) { | 216 media::VideoCapture::EventHandler* handler) { |
217 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 217 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
218 | 218 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 } | 352 } |
353 | 353 |
354 void VideoCaptureImpl::DoDelegateAdded(int32 device_id) { | 354 void VideoCaptureImpl::DoDelegateAdded(int32 device_id) { |
355 DVLOG(1) << "DoDelegateAdded: device_id " << device_id; | 355 DVLOG(1) << "DoDelegateAdded: device_id " << device_id; |
356 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 356 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
357 | 357 |
358 device_id_ = device_id; | 358 device_id_ = device_id; |
359 for (ClientInfo::iterator it = clients_pending_on_filter_.begin(); | 359 for (ClientInfo::iterator it = clients_pending_on_filter_.begin(); |
360 it != clients_pending_on_filter_.end(); ) { | 360 it != clients_pending_on_filter_.end(); ) { |
361 media::VideoCapture::EventHandler* handler = it->first; | 361 media::VideoCapture::EventHandler* handler = it->first; |
362 const VideoCaptureCapability capability = it->second; | 362 const media::VideoCaptureCapability capability = it->second; |
363 clients_pending_on_filter_.erase(it++); | 363 clients_pending_on_filter_.erase(it++); |
364 StartCapture(handler, capability); | 364 StartCapture(handler, capability); |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 void VideoCaptureImpl::StopDevice() { | 368 void VideoCaptureImpl::StopDevice() { |
369 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 369 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
370 | 370 |
371 device_info_available_ = false; | 371 device_info_available_ = false; |
372 if (state_ == video_capture::kStarted) { | 372 if (state_ == video_capture::kStarted) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 } | 431 } |
432 | 432 |
433 bool VideoCaptureImpl::ClientHasDIB() { | 433 bool VideoCaptureImpl::ClientHasDIB() { |
434 CachedDIB::iterator it; | 434 CachedDIB::iterator it; |
435 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { | 435 for (it = cached_dibs_.begin(); it != cached_dibs_.end(); it++) { |
436 if (it->second->references > 0) | 436 if (it->second->references > 0) |
437 return true; | 437 return true; |
438 } | 438 } |
439 return false; | 439 return false; |
440 } | 440 } |
OLD | NEW |