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/logging.h" | 10 #include "base/logging.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 const media::VideoCaptureFormats& supported_formats) | 89 const media::VideoCaptureFormats& supported_formats) |
90 : name(name), | 90 : name(name), |
91 supported_formats(supported_formats) {} | 91 supported_formats(supported_formats) {} |
92 | 92 |
93 VideoCaptureManager::DeviceInfo::~DeviceInfo() {} | 93 VideoCaptureManager::DeviceInfo::~DeviceInfo() {} |
94 | 94 |
95 VideoCaptureManager::VideoCaptureManager( | 95 VideoCaptureManager::VideoCaptureManager( |
96 scoped_ptr<media::VideoCaptureDeviceFactory> factory) | 96 scoped_ptr<media::VideoCaptureDeviceFactory> factory) |
97 : listener_(NULL), | 97 : listener_(NULL), |
98 new_capture_session_id_(1), | 98 new_capture_session_id_(1), |
99 video_capture_device_factory_(factory.Pass()) { | 99 video_capture_device_factory_(factory.Pass()), |
100 display_rotation_(gfx::Display::ROTATE_0) { | |
100 } | 101 } |
101 | 102 |
102 VideoCaptureManager::~VideoCaptureManager() { | 103 VideoCaptureManager::~VideoCaptureManager() { |
103 DCHECK(devices_.empty()); | 104 DCHECK(devices_.empty()); |
104 } | 105 } |
105 | 106 |
107 void VideoCaptureManager::SetDisplayRotation(gfx::Display::Rotation rotation) { | |
108 display_rotation_ = rotation; | |
vrk (LEFT CHROMIUM)
2014/05/08 21:43:34
Set this field on IO thread as well so as to keep
Zachary Kuznia
2014/05/08 21:51:22
Done.
| |
109 device_task_runner_->PostTask( | |
110 FROM_HERE, | |
111 base::Bind(&VideoCaptureManager::SetDisplayRotationOnDeviceThread, | |
112 this, rotation)); | |
113 } | |
114 | |
106 void VideoCaptureManager::Register( | 115 void VideoCaptureManager::Register( |
107 MediaStreamProviderListener* listener, | 116 MediaStreamProviderListener* listener, |
108 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { | 117 const scoped_refptr<base::SingleThreadTaskRunner>& device_task_runner) { |
109 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 118 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
110 DCHECK(!listener_); | 119 DCHECK(!listener_); |
111 DCHECK(!device_task_runner_.get()); | 120 DCHECK(!device_task_runner_.get()); |
112 listener_ = listener; | 121 listener_ = listener; |
113 device_task_runner_ = device_task_runner; | 122 device_task_runner_ = device_task_runner; |
114 } | 123 } |
115 | 124 |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 // use that opened device. | 581 // use that opened device. |
573 DeviceEntry* const existing_device = | 582 DeviceEntry* const existing_device = |
574 GetDeviceEntryForMediaStreamDevice(device_info); | 583 GetDeviceEntryForMediaStreamDevice(device_info); |
575 if (existing_device) { | 584 if (existing_device) { |
576 DCHECK_EQ(device_info.type, existing_device->stream_type); | 585 DCHECK_EQ(device_info.type, existing_device->stream_type); |
577 return existing_device; | 586 return existing_device; |
578 } | 587 } |
579 | 588 |
580 scoped_ptr<VideoCaptureController> video_capture_controller( | 589 scoped_ptr<VideoCaptureController> video_capture_controller( |
581 new VideoCaptureController()); | 590 new VideoCaptureController()); |
591 | |
592 if (device_info.type == MEDIA_DEVICE_VIDEO_CAPTURE) | |
593 video_capture_controller->SetDisplayRotation(display_rotation_); | |
582 DeviceEntry* new_device = new DeviceEntry(device_info.type, | 594 DeviceEntry* new_device = new DeviceEntry(device_info.type, |
583 device_info.id, | 595 device_info.id, |
584 video_capture_controller.Pass()); | 596 video_capture_controller.Pass()); |
585 devices_.insert(new_device); | 597 devices_.insert(new_device); |
586 return new_device; | 598 return new_device; |
587 } | 599 } |
588 | 600 |
589 VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById( | 601 VideoCaptureManager::DeviceInfo* VideoCaptureManager::FindDeviceInfoById( |
590 const std::string& id, | 602 const std::string& id, |
591 DeviceInfos& device_vector) { | 603 DeviceInfos& device_vector) { |
(...skipping 19 matching lines...) Expand all Loading... | |
611 | 623 |
612 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( | 624 void VideoCaptureManager::SaveDesktopCaptureWindowIdOnDeviceThread( |
613 media::VideoCaptureSessionId session_id, | 625 media::VideoCaptureSessionId session_id, |
614 gfx::NativeViewId window_id) { | 626 gfx::NativeViewId window_id) { |
615 DCHECK(IsOnDeviceThread()); | 627 DCHECK(IsOnDeviceThread()); |
616 DCHECK(notification_window_ids_.find(session_id) == | 628 DCHECK(notification_window_ids_.find(session_id) == |
617 notification_window_ids_.end()); | 629 notification_window_ids_.end()); |
618 notification_window_ids_[session_id] = window_id; | 630 notification_window_ids_[session_id] = window_id; |
619 } | 631 } |
620 | 632 |
633 void VideoCaptureManager::SetDisplayRotationOnDeviceThread( | |
634 gfx::Display::Rotation rotation) { | |
635 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
636 for (DeviceEntries::iterator it = devices_.begin(); | |
637 it != devices_.end(); ++it) { | |
638 DeviceEntry* device = *it; | |
639 if (device->stream_type == MEDIA_DEVICE_VIDEO_CAPTURE) | |
640 device->video_capture_controller->SetDisplayRotation(rotation); | |
641 } | |
642 } | |
643 | |
621 } // namespace content | 644 } // namespace content |
OLD | NEW |