| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" |
| 12 #include "base/location.h" | 13 #include "base/location.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 17 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
| 18 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "content/browser/media/capture/web_contents_video_capture_device.h" | 21 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
| 21 #include "content/browser/media/media_internals.h" | 22 #include "content/browser/media/media_internals.h" |
| 22 #include "content/browser/renderer_host/media/video_capture_controller.h" | 23 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 23 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 24 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/desktop_media_id.h" | 26 #include "content/public/browser/desktop_media_id.h" |
| 26 #include "content/public/common/media_stream_request.h" | 27 #include "content/public/common/media_stream_request.h" |
| 27 #include "media/base/bind_to_current_loop.h" | 28 #include "media/base/bind_to_current_loop.h" |
| 29 #include "media/base/media_switches.h" |
| 28 #include "media/video/capture/video_capture_device.h" | 30 #include "media/video/capture/video_capture_device.h" |
| 29 #include "media/video/capture/video_capture_device_factory.h" | 31 #include "media/video/capture/video_capture_device_factory.h" |
| 30 | 32 |
| 31 #if defined(ENABLE_SCREEN_CAPTURE) | 33 #if defined(ENABLE_SCREEN_CAPTURE) |
| 32 #include "content/browser/media/capture/desktop_capture_device.h" | 34 #include "content/browser/media/capture/desktop_capture_device.h" |
| 33 #if defined(USE_AURA) | 35 #if defined(USE_AURA) |
| 34 #include "content/browser/media/capture/desktop_capture_device_aura.h" | 36 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
| 35 #endif | 37 #endif |
| 36 #endif | 38 #endif |
| 37 | 39 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 318 |
| 317 const int serial_id = request->serial_id(); | 319 const int serial_id = request->serial_id(); |
| 318 DeviceEntries::iterator entry_it = std::find_if( | 320 DeviceEntries::iterator entry_it = std::find_if( |
| 319 devices_.begin(), devices_.end(), | 321 devices_.begin(), devices_.end(), |
| 320 [serial_id] (const DeviceEntry* e) { | 322 [serial_id] (const DeviceEntry* e) { |
| 321 return e->serial_id == serial_id; | 323 return e->serial_id == serial_id; |
| 322 }); | 324 }); |
| 323 DCHECK(entry_it != devices_.end()); | 325 DCHECK(entry_it != devices_.end()); |
| 324 DeviceEntry* entry = (*entry_it); | 326 DeviceEntry* entry = (*entry_it); |
| 325 | 327 |
| 328 media::VideoCaptureParams params = request->params(); |
| 329 #if defined(OS_LINUX) |
| 330 params.use_native_gpu_memory_buffers = |
| 331 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 332 switches::kUseNativeGpuMemoryBuffersForCapture); |
| 333 #endif |
| 334 |
| 326 DVLOG(3) << "HandleQueuedStartRequest, Post start to device thread, device = " | 335 DVLOG(3) << "HandleQueuedStartRequest, Post start to device thread, device = " |
| 327 << entry->id << " start id = " << entry->serial_id; | 336 << entry->id << " start id = " << entry->serial_id; |
| 328 base::PostTaskAndReplyWithResult( | 337 base::PostTaskAndReplyWithResult( |
| 329 device_task_runner_.get(), | 338 device_task_runner_.get(), |
| 330 FROM_HERE, | 339 FROM_HERE, |
| 331 base::Bind( | 340 base::Bind( |
| 332 &VideoCaptureManager::DoStartDeviceOnDeviceThread, | 341 &VideoCaptureManager::DoStartDeviceOnDeviceThread, |
| 333 this, | 342 this, |
| 334 request->session_id(), | 343 request->session_id(), |
| 335 entry->id, | 344 entry->id, |
| 336 entry->stream_type, | 345 entry->stream_type, |
| 337 request->params(), | 346 params, |
| 338 base::Passed(entry->video_capture_controller()->NewDeviceClient( | 347 base::Passed(entry->video_capture_controller()->NewDeviceClient( |
| 339 device_task_runner_))), | 348 device_task_runner_))), |
| 340 base::Bind(&VideoCaptureManager::OnDeviceStarted, this, | 349 base::Bind(&VideoCaptureManager::OnDeviceStarted, this, |
| 341 request->serial_id())); | 350 request->serial_id())); |
| 342 } | 351 } |
| 343 | 352 |
| 344 void VideoCaptureManager::OnDeviceStarted( | 353 void VideoCaptureManager::OnDeviceStarted( |
| 345 int serial_id, | 354 int serial_id, |
| 346 scoped_ptr<media::VideoCaptureDevice> device) { | 355 scoped_ptr<media::VideoCaptureDevice> device) { |
| 347 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 356 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 DCHECK(IsOnDeviceThread()); | 870 DCHECK(IsOnDeviceThread()); |
| 862 #if defined(ENABLE_SCREEN_CAPTURE) | 871 #if defined(ENABLE_SCREEN_CAPTURE) |
| 863 DesktopCaptureDevice* desktop_device = | 872 DesktopCaptureDevice* desktop_device = |
| 864 static_cast<DesktopCaptureDevice*>(device); | 873 static_cast<DesktopCaptureDevice*>(device); |
| 865 desktop_device->SetNotificationWindowId(window_id); | 874 desktop_device->SetNotificationWindowId(window_id); |
| 866 VLOG(2) << "Screen capture notification window passed on device thread."; | 875 VLOG(2) << "Screen capture notification window passed on device thread."; |
| 867 #endif | 876 #endif |
| 868 } | 877 } |
| 869 | 878 |
| 870 } // namespace content | 879 } // namespace content |
| OLD | NEW |