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