| 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/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::ProcessHandle render_process, | 146 base::ProcessHandle render_process, |
| 147 const media::VideoCaptureParams& params) { | 147 const media::VideoCaptureParams& params) { |
| 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 149 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id | 149 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id |
| 150 << ", (" << params.requested_format.width | 150 << ", (" << params.requested_format.width |
| 151 << ", " << params.requested_format.height | 151 << ", " << params.requested_format.height |
| 152 << ", " << params.requested_format.frame_rate | 152 << ", " << params.requested_format.frame_rate |
| 153 << ", " << params.session_id | 153 << ", " << params.session_id |
| 154 << ")"; | 154 << ")"; |
| 155 | 155 |
| 156 // If this is the first client added to the controller, cache the parameters. |
| 157 if (!controller_clients_.size()) |
| 158 video_capture_format_ = params.requested_format; |
| 159 |
| 156 // Signal error in case device is already in error state. | 160 // Signal error in case device is already in error state. |
| 157 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { | 161 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { |
| 158 event_handler->OnError(id); | 162 event_handler->OnError(id); |
| 159 return; | 163 return; |
| 160 } | 164 } |
| 161 | 165 |
| 162 // Do nothing if this client has called AddClient before. | 166 // Do nothing if this client has called AddClient before. |
| 163 if (FindClient(id, event_handler, controller_clients_)) | 167 if (FindClient(id, event_handler, controller_clients_)) |
| 164 return; | 168 return; |
| 165 | 169 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // If this buffer is not held by this client, or this client doesn't exist | 226 // If this buffer is not held by this client, or this client doesn't exist |
| 223 // in controller, do nothing. | 227 // in controller, do nothing. |
| 224 if (!client || !client->active_buffers.erase(buffer_id)) { | 228 if (!client || !client->active_buffers.erase(buffer_id)) { |
| 225 NOTREACHED(); | 229 NOTREACHED(); |
| 226 return; | 230 return; |
| 227 } | 231 } |
| 228 | 232 |
| 229 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); | 233 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); |
| 230 } | 234 } |
| 231 | 235 |
| 236 const media::VideoCaptureFormat& |
| 237 VideoCaptureController::GetVideoCaptureFormat() const { |
| 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 239 return video_capture_format_; |
| 240 } |
| 241 |
| 232 scoped_refptr<media::VideoFrame> | 242 scoped_refptr<media::VideoFrame> |
| 233 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( | 243 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( |
| 234 const gfx::Size& size) { | 244 const gfx::Size& size) { |
| 235 return DoReserveI420VideoFrame(size, 0); | 245 return DoReserveI420VideoFrame(size, 0); |
| 236 } | 246 } |
| 237 | 247 |
| 238 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( | 248 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( |
| 239 const uint8* data, | 249 const uint8* data, |
| 240 int length, | 250 int length, |
| 241 base::Time timestamp, | 251 base::Time timestamp, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 568 } |
| 559 return NULL; | 569 return NULL; |
| 560 } | 570 } |
| 561 | 571 |
| 562 int VideoCaptureController::GetClientCount() { | 572 int VideoCaptureController::GetClientCount() { |
| 563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 573 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 564 return controller_clients_.size(); | 574 return controller_clients_.size(); |
| 565 } | 575 } |
| 566 | 576 |
| 567 } // namespace content | 577 } // namespace content |
| OLD | NEW |