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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 std::unique(formats->begin(), formats->end(), IsCaptureFormatSizeEqual); | 63 std::unique(formats->begin(), formats->end(), IsCaptureFormatSizeEqual); |
64 formats->erase(last, formats->end()); | 64 formats->erase(last, formats->end()); |
65 // Mark all formats as I420, since this is what the renderer side will get | 65 // Mark all formats as I420, since this is what the renderer side will get |
66 // anyhow: the actual pixel format is decided at the device level. | 66 // anyhow: the actual pixel format is decided at the device level. |
67 for (media::VideoCaptureFormats::iterator it = formats->begin(); | 67 for (media::VideoCaptureFormats::iterator it = formats->begin(); |
68 it != formats->end(); ++it) { | 68 it != formats->end(); ++it) { |
69 it->pixel_format = media::PIXEL_FORMAT_I420; | 69 it->pixel_format = media::PIXEL_FORMAT_I420; |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
| 73 // The maximum number of buffers in the capture pipeline. See |
| 74 // VideoCaptureController ctor comments for more details. |
| 75 const int kMaxNumberOfBuffers = 3; |
| 76 const int kMaxNumberOfBuffersForTabCapture = 5; |
| 77 |
73 } // namespace | 78 } // namespace |
74 | 79 |
75 namespace content { | 80 namespace content { |
76 | 81 |
77 VideoCaptureManager::DeviceEntry::DeviceEntry( | 82 VideoCaptureManager::DeviceEntry::DeviceEntry( |
78 MediaStreamType stream_type, | 83 MediaStreamType stream_type, |
79 const std::string& id, | 84 const std::string& id, |
80 scoped_ptr<VideoCaptureController> controller) | 85 scoped_ptr<VideoCaptureController> controller) |
81 : stream_type(stream_type), | 86 : stream_type(stream_type), |
82 id(id), | 87 id(id), |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 580 |
576 // Check if another session has already opened this device. If so, just | 581 // Check if another session has already opened this device. If so, just |
577 // use that opened device. | 582 // use that opened device. |
578 DeviceEntry* const existing_device = | 583 DeviceEntry* const existing_device = |
579 GetDeviceEntryForMediaStreamDevice(device_info); | 584 GetDeviceEntryForMediaStreamDevice(device_info); |
580 if (existing_device) { | 585 if (existing_device) { |
581 DCHECK_EQ(device_info.type, existing_device->stream_type); | 586 DCHECK_EQ(device_info.type, existing_device->stream_type); |
582 return existing_device; | 587 return existing_device; |
583 } | 588 } |
584 | 589 |
| 590 const int max_buffers = device_info.type == MEDIA_TAB_VIDEO_CAPTURE ? |
| 591 kMaxNumberOfBuffersForTabCapture : kMaxNumberOfBuffers; |
585 scoped_ptr<VideoCaptureController> video_capture_controller( | 592 scoped_ptr<VideoCaptureController> video_capture_controller( |
586 new VideoCaptureController()); | 593 new VideoCaptureController(max_buffers)); |
587 DeviceEntry* new_device = new DeviceEntry(device_info.type, | 594 DeviceEntry* new_device = new DeviceEntry(device_info.type, |
588 device_info.id, | 595 device_info.id, |
589 video_capture_controller.Pass()); | 596 video_capture_controller.Pass()); |
590 devices_.insert(new_device); | 597 devices_.insert(new_device); |
591 return new_device; | 598 return new_device; |
592 } | 599 } |
593 | 600 |
594 VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById( | 601 VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById( |
595 const std::string& id, | 602 const std::string& id, |
596 DeviceInfos& device_vector) { | 603 DeviceInfos& device_vector) { |
(...skipping 20 matching lines...) Expand all Loading... |
617 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( | 624 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( |
618 media::VideoCaptureSessionId session_id, | 625 media::VideoCaptureSessionId session_id, |
619 gfx::NativeViewId window_id) { | 626 gfx::NativeViewId window_id) { |
620 DCHECK(IsOnDeviceThread()); | 627 DCHECK(IsOnDeviceThread()); |
621 DCHECK(notification_window_ids_.find(session_id) == | 628 DCHECK(notification_window_ids_.find(session_id) == |
622 notification_window_ids_.end()); | 629 notification_window_ids_.end()); |
623 notification_window_ids_[session_id] = window_id; | 630 notification_window_ids_[session_id] = window_id; |
624 } | 631 } |
625 | 632 |
626 } // namespace content | 633 } // namespace content |
OLD | NEW |