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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 VideoCaptureController::NewDeviceClient() { | 137 VideoCaptureController::NewDeviceClient() { |
138 scoped_ptr<media::VideoCaptureDevice::Client> result( | 138 scoped_ptr<media::VideoCaptureDevice::Client> result( |
139 new VideoCaptureDeviceClient(this->GetWeakPtr(), buffer_pool_)); | 139 new VideoCaptureDeviceClient(this->GetWeakPtr(), buffer_pool_)); |
140 return result.Pass(); | 140 return result.Pass(); |
141 } | 141 } |
142 | 142 |
143 void VideoCaptureController::AddClient( | 143 void VideoCaptureController::AddClient( |
144 const VideoCaptureControllerID& id, | 144 const VideoCaptureControllerID& id, |
145 VideoCaptureControllerEventHandler* event_handler, | 145 VideoCaptureControllerEventHandler* event_handler, |
146 base::ProcessHandle render_process, | 146 base::ProcessHandle render_process, |
147 const media::VideoCaptureParams& params) { | 147 const media::VideoCaptureParams& params) { |
ncarter (slow)
2013/11/12 20:56:46
It might be slightly better to cache off just para
mcasas
2013/11/13 11:40:37
Done.
| |
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 video_capture_params_ = params; | |
ncarter (slow)
2013/11/12 20:56:46
It may make sense to update this only if it's the
mcasas
2013/11/13 11:40:37
Done.
| |
157 | |
156 // Signal error in case device is already in error state. | 158 // Signal error in case device is already in error state. |
157 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { | 159 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { |
158 event_handler->OnError(id); | 160 event_handler->OnError(id); |
159 return; | 161 return; |
160 } | 162 } |
161 | 163 |
162 // Do nothing if this client has called AddClient before. | 164 // Do nothing if this client has called AddClient before. |
163 if (FindClient(id, event_handler, controller_clients_)) | 165 if (FindClient(id, event_handler, controller_clients_)) |
164 return; | 166 return; |
165 | 167 |
(...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 | 224 // If this buffer is not held by this client, or this client doesn't exist |
223 // in controller, do nothing. | 225 // in controller, do nothing. |
224 if (!client || !client->active_buffers.erase(buffer_id)) { | 226 if (!client || !client->active_buffers.erase(buffer_id)) { |
225 NOTREACHED(); | 227 NOTREACHED(); |
226 return; | 228 return; |
227 } | 229 } |
228 | 230 |
229 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); | 231 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); |
230 } | 232 } |
231 | 233 |
234 const media::VideoCaptureParams& | |
235 VideoCaptureController::GetVideoCaptureParams() const { | |
236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
237 return video_capture_params_; | |
238 } | |
239 | |
232 scoped_refptr<media::VideoFrame> | 240 scoped_refptr<media::VideoFrame> |
233 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( | 241 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( |
234 const gfx::Size& size) { | 242 const gfx::Size& size) { |
235 return DoReserveI420VideoFrame(size, 0); | 243 return DoReserveI420VideoFrame(size, 0); |
236 } | 244 } |
237 | 245 |
238 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( | 246 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( |
239 const uint8* data, | 247 const uint8* data, |
240 int length, | 248 int length, |
241 base::Time timestamp, | 249 base::Time timestamp, |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
558 } | 566 } |
559 return NULL; | 567 return NULL; |
560 } | 568 } |
561 | 569 |
562 int VideoCaptureController::GetClientCount() { | 570 int VideoCaptureController::GetClientCount() { |
563 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 571 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
564 return controller_clients_.size(); | 572 return controller_clients_.size(); |
565 } | 573 } |
566 | 574 |
567 } // namespace content | 575 } // namespace content |
OLD | NEW |