Chromium Code Reviews| 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/renderer/media/user_media_client_impl.h" | 5 #include "content/renderer/media/user_media_client_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 | 168 |
| 169 if (audio_constraints.basic().disableLocalEcho.hasExact()) { | 169 if (audio_constraints.basic().disableLocalEcho.hasExact()) { |
| 170 controls->disable_local_echo = | 170 controls->disable_local_echo = |
| 171 audio_constraints.basic().disableLocalEcho.exact(); | 171 audio_constraints.basic().disableLocalEcho.exact(); |
| 172 } else { | 172 } else { |
| 173 controls->disable_local_echo = | 173 controls->disable_local_echo = |
| 174 controls->audio.stream_source != kMediaStreamSourceDesktop; | 174 controls->audio.stream_source != kMediaStreamSourceDesktop; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool CopyVideoKindToStreamControls( | |
| 179 const blink::WebMediaConstraints& video_constraints, | |
| 180 StreamControls* controls) { | |
| 181 if (video_constraints.isNull()) | |
| 182 return true; | |
| 183 | |
| 184 std::string video_kind_string; | |
| 185 if (!GetConstraintValueAsString(video_constraints, | |
| 186 &blink::WebMediaTrackConstraintSet::videoKind, | |
| 187 &video_kind_string)) | |
| 188 return true; | |
| 189 if (video_kind_string == "color") { | |
|
Guido Urdaneta
2017/02/07 10:26:04
nit: perhaps make the constants that were already
aleksandar.stojiljkovic
2017/02/07 11:33:49
Done.
| |
| 190 controls->video_kind = VIDEO_KIND_COLOR; | |
| 191 return true; | |
| 192 } | |
| 193 if (video_kind_string == "depth") { | |
| 194 controls->video_kind = VIDEO_KIND_DEPTH; | |
| 195 return true; | |
| 196 } | |
| 197 LOG(ERROR) << "Invalid videoKind value = " << video_kind_string; | |
| 198 return false; | |
| 199 } | |
| 200 | |
| 178 bool IsSameDevice(const StreamDeviceInfo& device, | 201 bool IsSameDevice(const StreamDeviceInfo& device, |
| 179 const StreamDeviceInfo& other_device) { | 202 const StreamDeviceInfo& other_device) { |
| 180 return device.device.id == other_device.device.id && | 203 return device.device.id == other_device.device.id && |
| 181 device.device.type == other_device.device.type && | 204 device.device.type == other_device.device.type && |
| 182 device.session_id == other_device.session_id; | 205 device.session_id == other_device.session_id; |
| 183 } | 206 } |
| 184 | 207 |
| 185 bool IsSameSource(const blink::WebMediaStreamSource& source, | 208 bool IsSameSource(const blink::WebMediaStreamSource& source, |
| 186 const blink::WebMediaStreamSource& other_source) { | 209 const blink::WebMediaStreamSource& other_source) { |
| 187 MediaStreamSource* const source_extra_data = | 210 MediaStreamSource* const source_extra_data = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 GetConstraintValueAsBoolean( | 292 GetConstraintValueAsBoolean( |
| 270 user_media_request.audioConstraints(), | 293 user_media_request.audioConstraints(), |
| 271 &blink::WebMediaTrackConstraintSet::renderToAssociatedSink, | 294 &blink::WebMediaTrackConstraintSet::renderToAssociatedSink, |
| 272 &enable_automatic_output_device_selection); | 295 &enable_automatic_output_device_selection); |
| 273 } | 296 } |
| 274 bool request_video_input_devices = false; | 297 bool request_video_input_devices = false; |
| 275 if (user_media_request.video()) { | 298 if (user_media_request.video()) { |
| 276 CopyConstraintsToTrackControls(user_media_request.videoConstraints(), | 299 CopyConstraintsToTrackControls(user_media_request.videoConstraints(), |
| 277 &controls->video, | 300 &controls->video, |
| 278 &request_video_input_devices); | 301 &request_video_input_devices); |
| 302 if (!CopyVideoKindToStreamControls(user_media_request.videoConstraints(), | |
| 303 controls.get())) { | |
| 304 GetUserMediaRequestFailed(user_media_request, MEDIA_DEVICE_NO_HARDWARE, | |
| 305 ""); | |
| 306 return; | |
| 307 } | |
| 279 } | 308 } |
| 280 | 309 |
| 281 url::Origin security_origin = user_media_request.getSecurityOrigin(); | 310 url::Origin security_origin = user_media_request.getSecurityOrigin(); |
| 282 if (request_audio_input_devices || request_video_input_devices) { | 311 if (request_audio_input_devices || request_video_input_devices) { |
| 283 GetMediaDevicesDispatcher()->EnumerateDevices( | 312 GetMediaDevicesDispatcher()->EnumerateDevices( |
| 284 request_audio_input_devices, request_video_input_devices, | 313 request_audio_input_devices, request_video_input_devices, |
| 285 false /* request_audio_output_devices */, security_origin, | 314 false /* request_audio_output_devices */, security_origin, |
| 286 base::Bind(&UserMediaClientImpl::SelectUserMediaDevice, | 315 base::Bind(&UserMediaClientImpl::SelectUserMediaDevice, |
| 287 weak_factory_.GetWeakPtr(), request_id, user_media_request, | 316 weak_factory_.GetWeakPtr(), request_id, user_media_request, |
| 288 base::Passed(&controls), | 317 base::Passed(&controls), |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 sources_waiting_for_callback_.end(), source); | 1187 sources_waiting_for_callback_.end(), source); |
| 1159 if (found != sources_waiting_for_callback_.end()) | 1188 if (found != sources_waiting_for_callback_.end()) |
| 1160 OnTrackStarted(source, result, result_name); | 1189 OnTrackStarted(source, result, result_name); |
| 1161 } | 1190 } |
| 1162 | 1191 |
| 1163 void UserMediaClientImpl::OnDestruct() { | 1192 void UserMediaClientImpl::OnDestruct() { |
| 1164 delete this; | 1193 delete this; |
| 1165 } | 1194 } |
| 1166 | 1195 |
| 1167 } // namespace content | 1196 } // namespace content |
| OLD | NEW |