OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_device_settings.h" | 5 #include "content/browser/renderer_host/media/media_stream_device_settings.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
10 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" | 10 #include "content/browser/renderer_host/media/media_stream_settings_requester.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Security origin generated by WebKit. | 31 // Security origin generated by WebKit. |
32 std::string security_origin; | 32 std::string security_origin; |
33 // Request options. | 33 // Request options. |
34 StreamOptions options; | 34 StreamOptions options; |
35 // Map containing available devices for the requested capture types. | 35 // Map containing available devices for the requested capture types. |
36 DeviceMap devices; | 36 DeviceMap devices; |
37 }; | 37 }; |
38 | 38 |
39 MediaStreamDeviceSettings::MediaStreamDeviceSettings( | 39 MediaStreamDeviceSettings::MediaStreamDeviceSettings( |
40 SettingsRequester* requester) | 40 SettingsRequester* requester) |
41 : requester_(requester) { | 41 : requester_(requester), |
| 42 // TODO(macourteau) Change to false when UI exists. |
| 43 use_fake_ui_(true) { |
42 DCHECK(requester_); | 44 DCHECK(requester_); |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
44 } | 46 } |
45 | 47 |
46 MediaStreamDeviceSettings::~MediaStreamDeviceSettings() { | 48 MediaStreamDeviceSettings::~MediaStreamDeviceSettings() { |
47 STLDeleteValues(&requests_); | 49 STLDeleteValues(&requests_); |
48 } | 50 } |
49 | 51 |
50 void MediaStreamDeviceSettings::RequestCaptureDeviceUsage( | 52 void MediaStreamDeviceSettings::RequestCaptureDeviceUsage( |
51 const std::string& label, int render_process_id, int render_view_id, | 53 const std::string& label, int render_process_id, int render_view_id, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 size_t num_media_requests = 0; | 94 size_t num_media_requests = 0; |
93 if (request->options.audio) { | 95 if (request->options.audio) { |
94 num_media_requests++; | 96 num_media_requests++; |
95 } | 97 } |
96 if (request->options.video_option != StreamOptions::kNoCamera) { | 98 if (request->options.video_option != StreamOptions::kNoCamera) { |
97 num_media_requests++; | 99 num_media_requests++; |
98 } | 100 } |
99 | 101 |
100 if (request->devices.size() == num_media_requests) { | 102 if (request->devices.size() == num_media_requests) { |
101 // We have all answers needed. | 103 // We have all answers needed. |
102 | 104 if (!use_fake_ui_) { |
103 // TODO(mflodman) | 105 // TODO(macourteau) |
104 // This is the place to: | 106 // This is the place to: |
105 // - Choose what devices to use from some kind of settings, user dialog or | 107 // - Choose what devices to use from some kind of settings, user dialog or |
106 // default device. | 108 // default device. |
107 // - Request user permission / show we're using devices. | 109 // - Request user permission / show we're using devices. |
108 | 110 DCHECK(false); |
109 // Temporary solution: pick first non-opened device for each media type. | 111 } else { |
110 StreamDeviceInfoArray devices_to_use; | 112 // Used to fake UI, which is needed for server based testing. |
111 for (DeviceMap::iterator it = request->devices.begin(); | 113 // Choose first non-opened device for each media type. |
112 it != request->devices.end(); ++it) { | 114 StreamDeviceInfoArray devices_to_use; |
113 for (StreamDeviceInfoArray::iterator device_it = it->second.begin(); | 115 for (DeviceMap::iterator it = request->devices.begin(); |
114 device_it != it->second.end(); ++device_it) { | 116 it != request->devices.end(); ++it) { |
115 if (!device_it->in_use) { | 117 for (StreamDeviceInfoArray::iterator device_it = it->second.begin(); |
116 devices_to_use.push_back(*device_it); | 118 device_it != it->second.end(); ++device_it) { |
117 break; | 119 if (!device_it->in_use) { |
| 120 devices_to_use.push_back(*device_it); |
| 121 break; |
| 122 } |
118 } | 123 } |
119 } | 124 } |
| 125 // Post result and delete request. |
| 126 requester_->DevicesAccepted(label, devices_to_use); |
| 127 requests_.erase(request_it); |
| 128 delete request; |
120 } | 129 } |
121 // Post result and delete request. | |
122 requester_->DevicesAccepted(label, devices_to_use); | |
123 requests_.erase(request_it); | |
124 delete request; | |
125 } | 130 } |
126 } | 131 } |
127 | 132 |
| 133 void MediaStreamDeviceSettings::UseFakeUI() { |
| 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 135 use_fake_ui_ = true; |
| 136 } |
| 137 |
128 } // namespace media_stream | 138 } // namespace media_stream |
OLD | NEW |