OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 const char kMaxAspectRatio[] = "maxAspectRatio"; | 56 const char kMaxAspectRatio[] = "maxAspectRatio"; |
57 const char kMaxWidth[] = "maxWidth"; | 57 const char kMaxWidth[] = "maxWidth"; |
58 const char kMinWidth[] = "minWidth"; | 58 const char kMinWidth[] = "minWidth"; |
59 const char kMaxHeight[] = "maxHeight"; | 59 const char kMaxHeight[] = "maxHeight"; |
60 const char kMinHeight[] = "minHeight"; | 60 const char kMinHeight[] = "minHeight"; |
61 const char kMaxFrameRate[] = "maxFrameRate"; | 61 const char kMaxFrameRate[] = "maxFrameRate"; |
62 const char kMinFrameRate[] = "minFrameRate"; | 62 const char kMinFrameRate[] = "minFrameRate"; |
63 // From content/common/media/media_stream_options.cc | 63 // From content/common/media/media_stream_options.cc |
64 const char kMediaStreamSource[] = "chromeMediaSource"; | 64 const char kMediaStreamSource[] = "chromeMediaSource"; |
65 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; // mapped to deviceId | 65 const char kMediaStreamSourceId[] = "chromeMediaSourceId"; // mapped to deviceId |
| 66 const char kMediaStreamSourceInfoId[] = "sourceId"; // mapped to deviceId |
66 const char kMediaStreamRenderToAssociatedSink[] = "chromeRenderToAssociatedSink"
; | 67 const char kMediaStreamRenderToAssociatedSink[] = "chromeRenderToAssociatedSink"
; |
67 // RenderToAssociatedSink will be going away in M50-M60 some time. | 68 // RenderToAssociatedSink will be going away in M50-M60 some time. |
68 const char kMediaStreamAudioHotword[] = "googHotword"; | 69 const char kMediaStreamAudioHotword[] = "googHotword"; |
69 // TODO(hta): googHotword should go away. https://crbug.com/577627 | 70 // TODO(hta): googHotword should go away. https://crbug.com/577627 |
70 // From content/renderer/media/media_stream_audio_processor_options.cc | 71 // From content/renderer/media/media_stream_audio_processor_options.cc |
71 const char kEchoCancellation[] = "echoCancellation"; | 72 const char kEchoCancellation[] = "echoCancellation"; |
72 const char kGoogEchoCancellation[] = "googEchoCancellation"; | 73 const char kGoogEchoCancellation[] = "googEchoCancellation"; |
73 const char kGoogExperimentalEchoCancellation[] = "googEchoCancellation2"; | 74 const char kGoogExperimentalEchoCancellation[] = "googEchoCancellation2"; |
74 const char kGoogAutoGainControl[] = "googAutoGainControl"; | 75 const char kGoogAutoGainControl[] = "googAutoGainControl"; |
75 const char kGoogExperimentalAutoGainControl[] = "googAutoGainControl2"; | 76 const char kGoogExperimentalAutoGainControl[] = "googAutoGainControl2"; |
76 const char kGoogNoiseSuppression[] = "googNoiseSuppression"; | 77 const char kGoogNoiseSuppression[] = "googNoiseSuppression"; |
77 const char kGoogExperimentalNoiseSuppression[] = "googNoiseSuppression2"; | 78 const char kGoogExperimentalNoiseSuppression[] = "googNoiseSuppression2"; |
78 const char kGoogBeamforming[] = "googBeamforming"; | 79 const char kGoogBeamforming[] = "googBeamforming"; |
79 const char kGoogArrayGeometry[] = "googArrayGeometry"; | 80 const char kGoogArrayGeometry[] = "googArrayGeometry"; |
80 const char kGoogHighpassFilter[] = "googHighpassFilter"; | 81 const char kGoogHighpassFilter[] = "googHighpassFilter"; |
81 const char kGoogTypingNoiseDetection[] = "googTypingNoiseDetection"; | 82 const char kGoogTypingNoiseDetection[] = "googTypingNoiseDetection"; |
82 const char kGoogAudioMirroring[] = "googAudioMirroring"; | 83 const char kGoogAudioMirroring[] = "googAudioMirroring"; |
83 | 84 |
| 85 // From third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.c
c |
| 86 // Audio constraints. |
| 87 // const char kExtendedFilterEchoCancellation[] = "googEchoCancellation2"; // du
plicate k-name |
| 88 const char kDAEchoCancellation[] = "googDAEchoCancellation"; |
| 89 // const char kNoiseSuppression[] = "googNoiseSuppression"; // duplicate k-name |
| 90 // const char kExperimentalNoiseSuppression[] = "googNoiseSuppression2"; // dupl
icate k-name |
| 91 // const char kHighpassFilter[] = "googHighpassFilter"; // duplicate k-name |
| 92 // const char kTypingNoiseDetection[] = "googTypingNoiseDetection"; // duplicate
k-name |
| 93 // const char kAudioMirroring[] = "googAudioMirroring"; // duplicate k-name |
| 94 const char kAecDump[] = "audioDebugRecording"; |
| 95 |
| 96 // Google-specific constraint keys for a local video source (getUserMedia). |
| 97 const char kNoiseReduction[] = "googNoiseReduction"; |
| 98 |
| 99 // Constraint keys for CreateOffer / CreateAnswer defined in W3C specification. |
| 100 const char kOfferToReceiveAudio[] = "OfferToReceiveAudio"; |
| 101 const char kOfferToReceiveVideo[] = "OfferToReceiveVideo"; |
| 102 const char kVoiceActivityDetection[] = "VoiceActivityDetection"; |
| 103 const char kIceRestart[] = "IceRestart"; |
| 104 // Google specific constraint for BUNDLE enable/disable. |
| 105 const char kUseRtpMux[] = "googUseRtpMUX"; |
| 106 // Below constraints should be used during PeerConnection construction. |
| 107 const char kEnableDtlsSrtp[] = "DtlsSrtpKeyAgreement"; |
| 108 const char kEnableRtpDataChannels[] = "RtpDataChannels"; |
| 109 // Google-specific constraint keys. |
| 110 const char kEnableDscp[] = "googDscp"; |
| 111 const char kEnableIPv6[] = "googIPv6"; |
| 112 const char kEnableVideoSuspendBelowMinBitrate[] = "googSuspendBelowMinBitrate"; |
| 113 const char kNumUnsignalledRecvStreams[] = "googNumUnsignalledRecvStreams"; |
| 114 const char kCombinedAudioVideoBwe[] = "googCombinedAudioVideoBwe"; |
| 115 const char kScreencastMinBitrate[] = "googScreencastMinBitrate"; |
| 116 const char kCpuOveruseDetection[] = "googCpuOveruseDetection"; |
| 117 const char kCpuUnderuseThreshold[] = "googCpuUnderuseThreshold"; |
| 118 const char kCpuOveruseThreshold[] = "googCpuOveruseThreshold"; |
| 119 const char kCpuUnderuseEncodeRsdThreshold[] = "googCpuUnderuseEncodeRsdThreshold
"; |
| 120 const char kCpuOveruseEncodeRsdThreshold[] = "googCpuOveruseEncodeRsdThreshold"; |
| 121 const char kCpuOveruseEncodeUsage[] = "googCpuOveruseEncodeUsage"; |
| 122 const char kHighStartBitrate[] = "googHighStartBitrate"; |
| 123 const char kPayloadPadding[] = "googPayloadPadding"; |
| 124 // End of names from libjingle |
| 125 |
84 // Names used for testing. | 126 // Names used for testing. |
85 const char kTestConstraint1[] = "valid_and_supported_1"; | 127 const char kTestConstraint1[] = "valid_and_supported_1"; |
86 const char kTestConstraint2[] = "valid_and_supported_2"; | 128 const char kTestConstraint2[] = "valid_and_supported_2"; |
87 | 129 |
88 static bool parseMandatoryConstraintsDictionary(const Dictionary& mandatoryConst
raintsDictionary, WebVector<WebMediaConstraint>& mandatory) | 130 static bool parseMandatoryConstraintsDictionary(const Dictionary& mandatoryConst
raintsDictionary, WebVector<WebMediaConstraint>& mandatory) |
89 { | 131 { |
90 Vector<WebMediaConstraint> mandatoryConstraintsVector; | 132 Vector<WebMediaConstraint> mandatoryConstraintsVector; |
91 HashMap<String, String> mandatoryConstraintsHashMap; | 133 HashMap<String, String> mandatoryConstraintsHashMap; |
92 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(man
datoryConstraintsHashMap); | 134 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(man
datoryConstraintsHashMap); |
93 if (!ok) | 135 if (!ok) |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 result.frameRate.setMin(atof(constraint.m_value.utf8().c_str())); | 265 result.frameRate.setMin(atof(constraint.m_value.utf8().c_str())); |
224 } else if (constraint.m_name.equals(kMaxFrameRate)) { | 266 } else if (constraint.m_name.equals(kMaxFrameRate)) { |
225 result.frameRate.setMax(atof(constraint.m_value.utf8().c_str())); | 267 result.frameRate.setMax(atof(constraint.m_value.utf8().c_str())); |
226 } else if (constraint.m_name.equals(kEchoCancellation)) { | 268 } else if (constraint.m_name.equals(kEchoCancellation)) { |
227 result.echoCancellation.setExact(toBoolean(constraint.m_value)); | 269 result.echoCancellation.setExact(toBoolean(constraint.m_value)); |
228 } else if (constraint.m_name.equals(kMediaStreamSource)) { | 270 } else if (constraint.m_name.equals(kMediaStreamSource)) { |
229 // TODO(hta): This has only a few legal values. Should be | 271 // TODO(hta): This has only a few legal values. Should be |
230 // represented as an enum, and cause type errors. | 272 // represented as an enum, and cause type errors. |
231 // https://crbug.com/576582 | 273 // https://crbug.com/576582 |
232 result.mediaStreamSource.setExact(constraint.m_value); | 274 result.mediaStreamSource.setExact(constraint.m_value); |
233 } else if (constraint.m_name.equals(kMediaStreamSourceId)) { | 275 } else if (constraint.m_name.equals(kMediaStreamSourceId) |
| 276 || constraint.m_name.equals(kMediaStreamSourceInfoId)) { |
234 result.deviceId.setExact(constraint.m_value); | 277 result.deviceId.setExact(constraint.m_value); |
235 } else if (constraint.m_name.equals(kMediaStreamRenderToAssociatedSink))
{ | 278 } else if (constraint.m_name.equals(kMediaStreamRenderToAssociatedSink))
{ |
236 // TODO(hta): This is a boolean represented as string. | 279 // TODO(hta): This is a boolean represented as string. |
237 // Should give TypeError when it's not parseable. | 280 // Should give TypeError when it's not parseable. |
238 // https://crbug.com/576582 | 281 // https://crbug.com/576582 |
239 result.renderToAssociatedSink.setExact(toBoolean(constraint.m_value)
); | 282 result.renderToAssociatedSink.setExact(toBoolean(constraint.m_value)
); |
240 } else if (constraint.m_name.equals(kMediaStreamAudioHotword)) { | 283 } else if (constraint.m_name.equals(kMediaStreamAudioHotword)) { |
241 result.hotwordEnabled.setExact(toBoolean(constraint.m_value)); | 284 result.hotwordEnabled.setExact(toBoolean(constraint.m_value)); |
242 } else if (constraint.m_name.equals(kGoogEchoCancellation)) { | 285 } else if (constraint.m_name.equals(kGoogEchoCancellation)) { |
243 result.googEchoCancellation.setExact(toBoolean(constraint.m_value)); | 286 result.googEchoCancellation.setExact(toBoolean(constraint.m_value)); |
(...skipping 10 matching lines...) Expand all Loading... |
254 } else if (constraint.m_name.equals(kGoogBeamforming)) { | 297 } else if (constraint.m_name.equals(kGoogBeamforming)) { |
255 result.googBeamforming.setExact(toBoolean(constraint.m_value)); | 298 result.googBeamforming.setExact(toBoolean(constraint.m_value)); |
256 } else if (constraint.m_name.equals(kGoogArrayGeometry)) { | 299 } else if (constraint.m_name.equals(kGoogArrayGeometry)) { |
257 result.googArrayGeometry.setExact(constraint.m_value); | 300 result.googArrayGeometry.setExact(constraint.m_value); |
258 } else if (constraint.m_name.equals(kGoogHighpassFilter)) { | 301 } else if (constraint.m_name.equals(kGoogHighpassFilter)) { |
259 result.googHighpassFilter.setExact(toBoolean(constraint.m_value)); | 302 result.googHighpassFilter.setExact(toBoolean(constraint.m_value)); |
260 } else if (constraint.m_name.equals(kGoogTypingNoiseDetection)) { | 303 } else if (constraint.m_name.equals(kGoogTypingNoiseDetection)) { |
261 result.googTypingNoiseDetection.setExact(toBoolean(constraint.m_valu
e)); | 304 result.googTypingNoiseDetection.setExact(toBoolean(constraint.m_valu
e)); |
262 } else if (constraint.m_name.equals(kGoogAudioMirroring)) { | 305 } else if (constraint.m_name.equals(kGoogAudioMirroring)) { |
263 result.googAudioMirroring.setExact(toBoolean(constraint.m_value)); | 306 result.googAudioMirroring.setExact(toBoolean(constraint.m_value)); |
| 307 } else if (constraint.m_name.equals(kDAEchoCancellation)) { |
| 308 result.googDAEchoCancellation.setExact(toBoolean(constraint.m_value)
); |
| 309 } else if (constraint.m_name.equals(kAecDump)) { |
| 310 result.googAecDump.setExact(toBoolean(constraint.m_value)); |
| 311 } else if (constraint.m_name.equals(kNoiseReduction)) { |
| 312 result.googNoiseReduction.setExact(toBoolean(constraint.m_value)); |
| 313 } else if (constraint.m_name.equals(kOfferToReceiveAudio)) { |
| 314 result.offerToReceiveAudio.setExact(constraint.m_value); |
| 315 } else if (constraint.m_name.equals(kOfferToReceiveVideo)) { |
| 316 result.offerToReceiveVideo.setExact(constraint.m_value); |
| 317 } else if (constraint.m_name.equals(kVoiceActivityDetection)) { |
| 318 result.voiceActivityDetection.setExact(toBoolean(constraint.m_value)
); |
| 319 } else if (constraint.m_name.equals(kIceRestart)) { |
| 320 result.iceRestart.setExact(toBoolean(constraint.m_value)); |
| 321 } else if (constraint.m_name.equals(kUseRtpMux)) { |
| 322 result.googUseRtpMux.setExact(toBoolean(constraint.m_value)); |
| 323 } else if (constraint.m_name.equals(kEnableDtlsSrtp)) { |
| 324 result.enableDtlsSrtp.setExact(toBoolean(constraint.m_value)); |
| 325 } else if (constraint.m_name.equals(kEnableRtpDataChannels)) { |
| 326 result.enableRtpDataChannels.setExact(toBoolean(constraint.m_value))
; |
| 327 } else if (constraint.m_name.equals(kEnableDscp)) { |
| 328 result.enableDscp.setExact(toBoolean(constraint.m_value)); |
| 329 } else if (constraint.m_name.equals(kEnableIPv6)) { |
| 330 result.enableIPv6.setExact(toBoolean(constraint.m_value)); |
| 331 } else if (constraint.m_name.equals(kEnableVideoSuspendBelowMinBitrate))
{ |
| 332 result.googEnableVideoSuspendBelowMinBitrate.setExact(toBoolean(cons
traint.m_value)); |
| 333 } else if (constraint.m_name.equals(kNumUnsignalledRecvStreams)) { |
| 334 result.googNumUnsignalledRecvStreams.setExact(atoi(constraint.m_valu
e.utf8().c_str())); |
| 335 } else if (constraint.m_name.equals(kCombinedAudioVideoBwe)) { |
| 336 result.googCombinedAudioVideoBwe.setExact(toBoolean(constraint.m_val
ue)); |
| 337 } else if (constraint.m_name.equals(kScreencastMinBitrate)) { |
| 338 result.googScreencastMinBitrate.setExact(atoi(constraint.m_value.utf
8().c_str())); |
| 339 } else if (constraint.m_name.equals(kCpuOveruseDetection)) { |
| 340 result.googCpuOveruseDetection.setExact(toBoolean(constraint.m_value
)); |
| 341 } else if (constraint.m_name.equals(kCpuUnderuseThreshold)) { |
| 342 result.googCpuUnderuseThreshold.setExact(atoi(constraint.m_value.utf
8().c_str())); |
| 343 } else if (constraint.m_name.equals(kCpuOveruseThreshold)) { |
| 344 result.googCpuOveruseThreshold.setExact(atoi(constraint.m_value.utf8
().c_str())); |
| 345 } else if (constraint.m_name.equals(kCpuUnderuseEncodeRsdThreshold)) { |
| 346 result.googCpuUnderuseEncodeRsdThreshold.setExact(atoi(constraint.m_
value.utf8().c_str())); |
| 347 } else if (constraint.m_name.equals(kCpuOveruseEncodeRsdThreshold)) { |
| 348 result.googCpuOveruseEncodeRsdThreshold.setExact(atoi(constraint.m_v
alue.utf8().c_str())); |
| 349 } else if (constraint.m_name.equals(kCpuOveruseEncodeUsage)) { |
| 350 result.googCpuOveruseEncodeUsage.setExact(toBoolean(constraint.m_val
ue)); |
| 351 } else if (constraint.m_name.equals(kHighStartBitrate)) { |
| 352 result.googHighStartBitrate.setExact(atoi(constraint.m_value.utf8().
c_str())); |
| 353 } else if (constraint.m_name.equals(kPayloadPadding)) { |
| 354 result.googPayloadPadding.setExact(toBoolean(constraint.m_value)); |
264 } else if (constraint.m_name.equals(kTestConstraint1) | 355 } else if (constraint.m_name.equals(kTestConstraint1) |
265 || constraint.m_name.equals(kTestConstraint2)) { | 356 || constraint.m_name.equals(kTestConstraint2)) { |
266 // These constraints are only for testing parsing. Ignore them. | 357 // These constraints are only for testing parsing. Ignore them. |
267 } else { | 358 } else { |
268 // TODO(hta): UMA stats for unknown constraints passed. | 359 // TODO(hta): UMA stats for unknown constraints passed. |
269 // https://crbug.com/576613 | 360 // https://crbug.com/576613 |
270 WTF_LOG(Media, "Unknown constraint name detected"); | 361 WTF_LOG(Media, "Unknown constraint name detected"); |
271 errorState.throwConstraintError("Unknown name of constraint detected
", constraint.m_name); | 362 errorState.throwConstraintError("Unknown name of constraint detected
", constraint.m_name); |
272 } | 363 } |
273 } | 364 } |
274 } | 365 } |
275 | 366 |
276 static WebMediaConstraints createFromNamedConstraints(WebVector<WebMediaConstrai
nt>& mandatory, const WebVector<WebMediaConstraint>& optional, MediaErrorState&
errorState) | 367 static WebMediaConstraints createFromNamedConstraints(WebVector<WebMediaConstrai
nt>& mandatory, const WebVector<WebMediaConstraint>& optional, MediaErrorState&
errorState) |
277 { | 368 { |
278 WebMediaTrackConstraintSet basic; | 369 WebMediaTrackConstraintSet basic; |
279 WebMediaTrackConstraintSet advanced; | 370 WebMediaTrackConstraintSet advanced; |
280 WebMediaConstraints constraints; | 371 WebMediaConstraints constraints; |
281 if (RuntimeEnabledFeatures::mediaConstraintsEnabled()) { | 372 parseOldStyleNames(mandatory, basic, errorState); |
282 parseOldStyleNames(mandatory, basic, errorState); | 373 if (errorState.hadException()) |
283 if (errorState.hadException()) | 374 return constraints; |
284 return constraints; | 375 // We ignore errors in optional constraints. |
285 // We ignore errors in optional constraints. | 376 MediaErrorState ignoredErrorState; |
286 MediaErrorState ignoredErrorState; | 377 parseOldStyleNames(optional, advanced, ignoredErrorState); |
287 parseOldStyleNames(optional, advanced, ignoredErrorState); | |
288 } | |
289 WebVector<WebMediaTrackConstraintSet> advancedVector(&advanced, 1); | 378 WebVector<WebMediaTrackConstraintSet> advancedVector(&advanced, 1); |
290 // Use the 4-argument initializer until Chrome has been converted. | 379 // Use the 4-argument initializer until Chrome has been converted. |
291 constraints.initialize(optional, mandatory, basic, advancedVector); | 380 constraints.initialize(optional, mandatory, basic, advancedVector); |
292 return constraints; | 381 return constraints; |
293 } | 382 } |
294 | 383 |
295 // Deprecated. | 384 // Deprecated. |
296 WebMediaConstraints create(const Dictionary& constraintsDictionary, MediaErrorSt
ate& errorState) | 385 WebMediaConstraints create(const Dictionary& constraintsDictionary, MediaErrorSt
ate& errorState) |
297 { | 386 { |
298 WebVector<WebMediaConstraint> optional; | 387 WebVector<WebMediaConstraint> optional; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 518 |
430 WebMediaConstraints create() | 519 WebMediaConstraints create() |
431 { | 520 { |
432 WebMediaConstraints constraints; | 521 WebMediaConstraints constraints; |
433 constraints.initialize(); | 522 constraints.initialize(); |
434 return constraints; | 523 return constraints; |
435 } | 524 } |
436 | 525 |
437 } // namespace MediaConstraintsImpl | 526 } // namespace MediaConstraintsImpl |
438 } // namespace blink | 527 } // namespace blink |
OLD | NEW |