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/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.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/browser/renderer_host/media/media_stream_manager.h" | 9 #include "content/browser/renderer_host/media/media_stream_manager.h" |
10 #include "content/browser/renderer_host/media/video_capture_manager.h" | 10 #include "content/browser/renderer_host/media/video_capture_manager.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (!client || dib_it == owned_dibs_.end()) | 215 if (!client || dib_it == owned_dibs_.end()) |
216 return; | 216 return; |
217 | 217 |
218 client->buffers.remove(buffer_id); | 218 client->buffers.remove(buffer_id); |
219 // If this client has called StopCapture and doesn't hold any buffer after | 219 // If this client has called StopCapture and doesn't hold any buffer after |
220 // after this return, ready to delete this client. | 220 // after this return, ready to delete this client. |
221 if (client->report_ready_to_delete && client->buffers.empty()) { | 221 if (client->report_ready_to_delete && client->buffers.empty()) { |
222 client->event_handler->OnReadyToDelete(client->controller_id); | 222 client->event_handler->OnReadyToDelete(client->controller_id); |
223 delete client; | 223 delete client; |
224 controller_clients_.remove(client); | 224 controller_clients_.remove(client); |
| 225 |
| 226 if (controller_clients_.empty()) { |
| 227 // No more clients. Stop device. |
| 228 video_capture_manager_->Stop(current_params_.session_id, |
| 229 base::Bind(&VideoCaptureController::OnDeviceStopped, this)); |
| 230 frame_info_available_ = false; |
| 231 state_ = video_capture::kStopping; |
| 232 } |
225 } | 233 } |
226 { | 234 { |
227 base::AutoLock lock(lock_); | 235 base::AutoLock lock(lock_); |
228 DCHECK_GT(dib_it->second->references, 0) | 236 DCHECK_GT(dib_it->second->references, 0) |
229 << "The buffer is not used by renderer."; | 237 << "The buffer is not used by renderer."; |
230 dib_it->second->references -= 1; | 238 dib_it->second->references -= 1; |
231 if (dib_it->second->references > 0) | 239 if (dib_it->second->references > 0) |
232 return; | 240 return; |
233 } | 241 } |
234 | 242 |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 } | 522 } |
515 | 523 |
516 void VideoCaptureController::DoDeviceStoppedOnIOThread() { | 524 void VideoCaptureController::DoDeviceStoppedOnIOThread() { |
517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 525 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
518 device_in_use_ = false; | 526 device_in_use_ = false; |
519 if (state_ == video_capture::kStopping) { | 527 if (state_ == video_capture::kStopping) { |
520 PostStopping(); | 528 PostStopping(); |
521 } | 529 } |
522 } | 530 } |
523 | 531 |
OLD | NEW |