| 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_manager.h" | 5 #include "content/browser/renderer_host/media/video_capture_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (!video_capture_device) { | 176 if (!video_capture_device) { |
| 177 device_client->OnError(); | 177 device_client->OnError(); |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 video_capture_device->AllocateAndStart(capture_params, device_client.Pass()); | 181 video_capture_device->AllocateAndStart(capture_params, device_client.Pass()); |
| 182 entry->video_capture_device = video_capture_device.Pass(); | 182 entry->video_capture_device = video_capture_device.Pass(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void VideoCaptureManager::StartCaptureForClient( | 185 void VideoCaptureManager::StartCaptureForClient( |
| 186 const media::VideoCaptureParams& capture_params, | 186 const media::VideoCaptureParams& params, |
| 187 base::ProcessHandle client_render_process, | 187 base::ProcessHandle client_render_process, |
| 188 VideoCaptureControllerID client_id, | 188 VideoCaptureControllerID client_id, |
| 189 VideoCaptureControllerEventHandler* client_handler, | 189 VideoCaptureControllerEventHandler* client_handler, |
| 190 const DoneCB& done_cb) { | 190 const DoneCB& done_cb) { |
| 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 192 DVLOG(1) << "VideoCaptureManager::StartCaptureForClient, (" | 192 DVLOG(1) << "VideoCaptureManager::StartCaptureForClient, (" |
| 193 << capture_params.width | 193 << params.requested_format.width |
| 194 << ", " << capture_params.height | 194 << ", " << params.requested_format.height |
| 195 << ", " << capture_params.frame_rate | 195 << ", " << params.requested_format.frame_rate |
| 196 << ", #" << capture_params.session_id | 196 << ", #" << params.session_id |
| 197 << ")"; | 197 << ")"; |
| 198 | 198 |
| 199 DeviceEntry* entry = GetOrCreateDeviceEntry(capture_params.session_id); | 199 DeviceEntry* entry = GetOrCreateDeviceEntry(params.session_id); |
| 200 if (!entry) { | 200 if (!entry) { |
| 201 done_cb.Run(base::WeakPtr<VideoCaptureController>()); | 201 done_cb.Run(base::WeakPtr<VideoCaptureController>()); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 DCHECK(entry->video_capture_controller); | 205 DCHECK(entry->video_capture_controller); |
| 206 | 206 |
| 207 // First client starts the device. | 207 // First client starts the device. |
| 208 if (entry->video_capture_controller->GetClientCount() == 0) { | 208 if (entry->video_capture_controller->GetClientCount() == 0) { |
| 209 DVLOG(1) << "VideoCaptureManager starting device (type = " | 209 DVLOG(1) << "VideoCaptureManager starting device (type = " |
| 210 << entry->stream_type << ", id = " << entry->id << ")"; | 210 << entry->stream_type << ", id = " << entry->id << ")"; |
| 211 | 211 |
| 212 media::VideoCaptureCapability params_as_capability; | 212 media::VideoCaptureCapability params_as_capability; |
| 213 params_as_capability.width = capture_params.width; | 213 params_as_capability.session_id = params.session_id; |
| 214 params_as_capability.height = capture_params.height; | 214 params_as_capability.width = params.requested_format.width; |
| 215 params_as_capability.frame_rate = capture_params.frame_rate; | 215 params_as_capability.height = params.requested_format.height; |
| 216 params_as_capability.session_id = capture_params.session_id; | 216 params_as_capability.frame_rate = params.requested_format.frame_rate; |
| 217 params_as_capability.frame_size_type = capture_params.frame_size_type; | 217 params_as_capability.frame_size_type = |
| 218 params.requested_format.frame_size_type; |
| 218 | 219 |
| 219 device_loop_->PostTask(FROM_HERE, base::Bind( | 220 device_loop_->PostTask(FROM_HERE, base::Bind( |
| 220 &VideoCaptureManager::DoStartDeviceOnDeviceThread, this, | 221 &VideoCaptureManager::DoStartDeviceOnDeviceThread, this, |
| 221 entry, params_as_capability, | 222 entry, params_as_capability, |
| 222 base::Passed(entry->video_capture_controller->NewDeviceClient()))); | 223 base::Passed(entry->video_capture_controller->NewDeviceClient()))); |
| 223 } | 224 } |
| 224 // Run the callback first, as AddClient() may trigger OnFrameInfo(). | 225 // Run the callback first, as AddClient() may trigger OnFrameInfo(). |
| 225 done_cb.Run(entry->video_capture_controller->GetWeakPtr()); | 226 done_cb.Run(entry->video_capture_controller->GetWeakPtr()); |
| 226 entry->video_capture_controller->AddClient(client_id, | 227 entry->video_capture_controller->AddClient(client_id, |
| 227 client_handler, | 228 client_handler, |
| 228 client_render_process, | 229 client_render_process, |
| 229 capture_params); | 230 params); |
| 230 } | 231 } |
| 231 | 232 |
| 232 void VideoCaptureManager::StopCaptureForClient( | 233 void VideoCaptureManager::StopCaptureForClient( |
| 233 VideoCaptureController* controller, | 234 VideoCaptureController* controller, |
| 234 VideoCaptureControllerID client_id, | 235 VideoCaptureControllerID client_id, |
| 235 VideoCaptureControllerEventHandler* client_handler) { | 236 VideoCaptureControllerEventHandler* client_handler) { |
| 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 237 DCHECK(controller); | 238 DCHECK(controller); |
| 238 DCHECK(client_handler); | 239 DCHECK(client_handler); |
| 239 | 240 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 scoped_ptr<VideoCaptureController> video_capture_controller( | 415 scoped_ptr<VideoCaptureController> video_capture_controller( |
| 415 new VideoCaptureController()); | 416 new VideoCaptureController()); |
| 416 DeviceEntry* new_device = new DeviceEntry(device_info.type, | 417 DeviceEntry* new_device = new DeviceEntry(device_info.type, |
| 417 device_info.id, | 418 device_info.id, |
| 418 video_capture_controller.Pass()); | 419 video_capture_controller.Pass()); |
| 419 devices_.insert(new_device); | 420 devices_.insert(new_device); |
| 420 return new_device; | 421 return new_device; |
| 421 } | 422 } |
| 422 | 423 |
| 423 } // namespace content | 424 } // namespace content |
| OLD | NEW |