Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 2606983002: Media Capture Depth Stream Extensions API: focal length and depth range. (Closed)
Patch Set: 80-char line fix in test html. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return MEDIA_DEVICE_TYPE_AUDIO_INPUT; 200 return MEDIA_DEVICE_TYPE_AUDIO_INPUT;
201 case MEDIA_DEVICE_VIDEO_CAPTURE: 201 case MEDIA_DEVICE_VIDEO_CAPTURE:
202 return MEDIA_DEVICE_TYPE_VIDEO_INPUT; 202 return MEDIA_DEVICE_TYPE_VIDEO_INPUT;
203 default: 203 default:
204 NOTREACHED(); 204 NOTREACHED();
205 } 205 }
206 206
207 return NUM_MEDIA_DEVICE_TYPES; 207 return NUM_MEDIA_DEVICE_TYPES;
208 } 208 }
209 209
210 MediaStreamDevices ConvertToMediaStreamDevices(
211 MediaStreamType stream_type,
212 const MediaDeviceInfoArray& device_infos) {
213 MediaStreamDevices devices;
214 for (const auto& info : device_infos) {
215 devices.emplace_back(stream_type, info.device_id, info.label);
216 }
217
218 return devices;
219 }
220
221 } // namespace 210 } // namespace
222 211
223 212
224 // MediaStreamManager::DeviceRequest represents a request to either enumerate 213 // MediaStreamManager::DeviceRequest represents a request to either enumerate
225 // available devices or open one or more devices. 214 // available devices or open one or more devices.
226 // TODO(perkj): MediaStreamManager still needs refactoring. I propose we create 215 // TODO(perkj): MediaStreamManager still needs refactoring. I propose we create
227 // several subclasses of DeviceRequest and move some of the responsibility of 216 // several subclasses of DeviceRequest and move some of the responsibility of
228 // the MediaStreamManager to the subclasses to get rid of the way too many if 217 // the MediaStreamManager to the subclasses to get rid of the way too many if
229 // statements in MediaStreamManager. 218 // statements in MediaStreamManager.
230 class MediaStreamManager::DeviceRequest { 219 class MediaStreamManager::DeviceRequest {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 if (IsVideoMediaType(video_type)) 927 if (IsVideoMediaType(video_type))
939 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 928 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
940 929
941 // If using the fake UI, it will just auto-select from the available devices. 930 // If using the fake UI, it will just auto-select from the available devices.
942 // The fake UI doesn't work for desktop sharing requests since we can't see 931 // The fake UI doesn't work for desktop sharing requests since we can't see
943 // its devices from here; always use the real UI for such requests. 932 // its devices from here; always use the real UI for such requests.
944 if (use_fake_ui_ && request->video_type() != MEDIA_DESKTOP_VIDEO_CAPTURE) { 933 if (use_fake_ui_ && request->video_type() != MEDIA_DESKTOP_VIDEO_CAPTURE) {
945 if (!fake_ui_) 934 if (!fake_ui_)
946 fake_ui_.reset(new FakeMediaStreamUIProxy()); 935 fake_ui_.reset(new FakeMediaStreamUIProxy());
947 936
948 MediaStreamDevices devices; 937 MediaStreamDevices devices = ConvertToMediaStreamDevices(
949 for (const auto& info : enumeration[MEDIA_DEVICE_TYPE_AUDIO_INPUT]) { 938 request->audio_type(), enumeration[MEDIA_DEVICE_TYPE_AUDIO_INPUT]);
950 devices.emplace_back(audio_type, info.device_id, info.label); 939 MediaStreamDevices video_devices = ConvertToMediaStreamDevices(
951 } 940 request->video_type(), enumeration[MEDIA_DEVICE_TYPE_VIDEO_INPUT]);
952 for (const auto& info : enumeration[MEDIA_DEVICE_TYPE_VIDEO_INPUT]) { 941 devices.reserve(devices.size() + video_devices.size());
953 devices.emplace_back(video_type, info.device_id, info.label); 942 devices.insert(devices.end(), video_devices.begin(), video_devices.end());
954 }
955 943
956 fake_ui_->SetAvailableDevices(devices); 944 fake_ui_->SetAvailableDevices(devices);
957 945
958 request->ui_proxy = std::move(fake_ui_); 946 request->ui_proxy = std::move(fake_ui_);
959 } else { 947 } else {
960 request->ui_proxy = MediaStreamUIProxy::Create(); 948 request->ui_proxy = MediaStreamUIProxy::Create();
961 } 949 }
962 950
963 request->ui_proxy->RequestAccess( 951 request->ui_proxy->RequestAccess(
964 request->DetachUIRequest(), 952 request->DetachUIRequest(),
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 GenerateStreamTestCallback test_callback) { 1730 GenerateStreamTestCallback test_callback) {
1743 generate_stream_test_callback_ = test_callback; 1731 generate_stream_test_callback_ = test_callback;
1744 } 1732 }
1745 1733
1746 #if defined(OS_WIN) 1734 #if defined(OS_WIN)
1747 void MediaStreamManager::FlushVideoCaptureThreadForTesting() { 1735 void MediaStreamManager::FlushVideoCaptureThreadForTesting() {
1748 video_capture_thread_.FlushForTesting(); 1736 video_capture_thread_.FlushForTesting();
1749 } 1737 }
1750 #endif 1738 #endif
1751 1739
1740 MediaStreamDevices MediaStreamManager::ConvertToMediaStreamDevices(
1741 MediaStreamType stream_type,
1742 const MediaDeviceInfoArray& device_infos) {
1743 MediaStreamDevices devices;
1744 for (const auto& info : device_infos)
1745 devices.emplace_back(stream_type, info.device_id, info.label);
1746
1747 if (stream_type != MEDIA_DEVICE_VIDEO_CAPTURE)
1748 return devices;
1749
1750 for (auto& device : devices) {
1751 device.camera_calibration =
1752 video_capture_manager()->GetCameraCalibration(device.id);
1753 }
1754 return devices;
1755 }
1756
1752 } // namespace content 1757 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698