| 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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 video_capture_device.reset(DesktopCaptureDeviceAura::Create(id)); | 256 video_capture_device.reset(DesktopCaptureDeviceAura::Create(id)); |
| 257 } else | 257 } else |
| 258 #endif | 258 #endif |
| 259 if (id.type != DesktopMediaID::TYPE_NONE && | 259 if (id.type != DesktopMediaID::TYPE_NONE && |
| 260 id.type != DesktopMediaID::TYPE_AURA_WINDOW) { | 260 id.type != DesktopMediaID::TYPE_AURA_WINDOW) { |
| 261 video_capture_device = DesktopCaptureDevice::Create(id); | 261 video_capture_device = DesktopCaptureDevice::Create(id); |
| 262 if (notification_window_ids_.find(session_id) != | 262 if (notification_window_ids_.find(session_id) != |
| 263 notification_window_ids_.end()) { | 263 notification_window_ids_.end()) { |
| 264 static_cast<DesktopCaptureDevice*>(video_capture_device.get()) | 264 static_cast<DesktopCaptureDevice*>(video_capture_device.get()) |
| 265 ->SetNotificationWindowId(notification_window_ids_[session_id]); | 265 ->SetNotificationWindowId(notification_window_ids_[session_id]); |
| 266 VLOG(2) << "Screen capture notification window passed for session " |
| 267 << session_id; |
| 266 } | 268 } |
| 267 } | 269 } |
| 268 #endif // defined(ENABLE_SCREEN_CAPTURE) | 270 #endif // defined(ENABLE_SCREEN_CAPTURE) |
| 269 break; | 271 break; |
| 270 } | 272 } |
| 271 default: { | 273 default: { |
| 272 NOTIMPLEMENTED(); | 274 NOTIMPLEMENTED(); |
| 273 break; | 275 break; |
| 274 } | 276 } |
| 275 } | 277 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 formats_in_use->push_back( | 405 formats_in_use->push_back( |
| 404 device_in_use->video_capture_controller->GetVideoCaptureFormat()); | 406 device_in_use->video_capture_controller->GetVideoCaptureFormat()); |
| 405 } | 407 } |
| 406 return true; | 408 return true; |
| 407 } | 409 } |
| 408 | 410 |
| 409 void VideoCaptureManager::SetDesktopCaptureWindowId( | 411 void VideoCaptureManager::SetDesktopCaptureWindowId( |
| 410 media::VideoCaptureSessionId session_id, | 412 media::VideoCaptureSessionId session_id, |
| 411 gfx::NativeViewId window_id) { | 413 gfx::NativeViewId window_id) { |
| 412 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 414 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 415 VLOG(2) << "SetDesktopCaptureWindowId called for session " << session_id; |
| 416 |
| 413 SessionMap::iterator session_it = sessions_.find(session_id); | 417 SessionMap::iterator session_it = sessions_.find(session_id); |
| 414 if (session_it == sessions_.end()) { | 418 if (session_it == sessions_.end()) { |
| 419 VLOG(2) << "Session not found, will save the notification window."; |
| 415 device_task_runner_->PostTask( | 420 device_task_runner_->PostTask( |
| 416 FROM_HERE, | 421 FROM_HERE, |
| 417 base::Bind( | 422 base::Bind( |
| 418 &VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread, | 423 &VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread, |
| 419 this, | 424 this, |
| 420 session_id, | 425 session_id, |
| 421 window_id)); | 426 window_id)); |
| 422 return; | 427 return; |
| 423 } | 428 } |
| 424 | 429 |
| 425 DeviceEntry* const existing_device = | 430 DeviceEntry* const existing_device = |
| 426 GetDeviceEntryForMediaStreamDevice(session_it->second); | 431 GetDeviceEntryForMediaStreamDevice(session_it->second); |
| 427 if (!existing_device) | 432 if (!existing_device) { |
| 433 VLOG(2) << "Failed to find an existing device."; |
| 428 return; | 434 return; |
| 435 } |
| 429 | 436 |
| 430 DCHECK_EQ(MEDIA_DESKTOP_VIDEO_CAPTURE, existing_device->stream_type); | 437 DCHECK_EQ(MEDIA_DESKTOP_VIDEO_CAPTURE, existing_device->stream_type); |
| 431 DesktopMediaID id = DesktopMediaID::Parse(existing_device->id); | 438 DesktopMediaID id = DesktopMediaID::Parse(existing_device->id); |
| 432 if (id.type == DesktopMediaID::TYPE_NONE || | 439 if (id.type == DesktopMediaID::TYPE_NONE || |
| 433 id.type == DesktopMediaID::TYPE_AURA_WINDOW) { | 440 id.type == DesktopMediaID::TYPE_AURA_WINDOW) { |
| 441 VLOG(2) << "Video capture device type mismatch."; |
| 434 return; | 442 return; |
| 435 } | 443 } |
| 436 | 444 |
| 437 device_task_runner_->PostTask( | 445 device_task_runner_->PostTask( |
| 438 FROM_HERE, | 446 FROM_HERE, |
| 439 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread, | 447 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread, |
| 440 this, | 448 this, |
| 441 existing_device, | 449 existing_device, |
| 442 window_id)); | 450 window_id)); |
| 443 } | 451 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 | 641 |
| 634 void VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread( | 642 void VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread( |
| 635 DeviceEntry* entry, | 643 DeviceEntry* entry, |
| 636 gfx::NativeViewId window_id) { | 644 gfx::NativeViewId window_id) { |
| 637 DCHECK(IsOnDeviceThread()); | 645 DCHECK(IsOnDeviceThread()); |
| 638 DCHECK(entry->stream_type == MEDIA_DESKTOP_VIDEO_CAPTURE); | 646 DCHECK(entry->stream_type == MEDIA_DESKTOP_VIDEO_CAPTURE); |
| 639 #if defined(ENABLE_SCREEN_CAPTURE) | 647 #if defined(ENABLE_SCREEN_CAPTURE) |
| 640 DesktopCaptureDevice* device = | 648 DesktopCaptureDevice* device = |
| 641 static_cast<DesktopCaptureDevice*>(entry->video_capture_device.get()); | 649 static_cast<DesktopCaptureDevice*>(entry->video_capture_device.get()); |
| 642 device->SetNotificationWindowId(window_id); | 650 device->SetNotificationWindowId(window_id); |
| 651 VLOG(2) << "Screen capture notification window passed on device thread."; |
| 643 #endif | 652 #endif |
| 644 } | 653 } |
| 645 | 654 |
| 646 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( | 655 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( |
| 647 media::VideoCaptureSessionId session_id, | 656 media::VideoCaptureSessionId session_id, |
| 648 gfx::NativeViewId window_id) { | 657 gfx::NativeViewId window_id) { |
| 649 DCHECK(IsOnDeviceThread()); | 658 DCHECK(IsOnDeviceThread()); |
| 650 DCHECK(notification_window_ids_.find(session_id) == | 659 DCHECK(notification_window_ids_.find(session_id) == |
| 651 notification_window_ids_.end()); | 660 notification_window_ids_.end()); |
| 652 notification_window_ids_[session_id] = window_id; | 661 notification_window_ids_[session_id] = window_id; |
| 662 VLOG(2) << "Screen capture notification window saved for session " |
| 663 << session_id << " on device thread."; |
| 653 } | 664 } |
| 654 | 665 |
| 655 } // namespace content | 666 } // namespace content |
| OLD | NEW |