summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc')
-rw-r--r--chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc93
1 files changed, 57 insertions, 36 deletions
diff --git a/chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc b/chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc
index 06e0ae7b328..8a2ca93c251 100644
--- a/chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc
+++ b/chromium/third_party/blink/renderer/modules/mediastream/user_media_request.cc
@@ -298,12 +298,12 @@ WebMediaConstraints ParseOptions(ExecutionContext* context,
if (options.IsNull()) {
// Do nothing.
} else if (options.IsMediaTrackConstraints()) {
- constraints = MediaConstraintsImpl::Create(
+ constraints = media_constraints_impl::Create(
context, options.GetAsMediaTrackConstraints(), error_state);
} else {
DCHECK(options.IsBoolean());
if (options.GetAsBoolean()) {
- constraints = MediaConstraintsImpl::Create();
+ constraints = media_constraints_impl::Create();
}
}
@@ -317,9 +317,13 @@ class UserMediaRequest::V8Callbacks final : public UserMediaRequest::Callbacks {
static V8Callbacks* Create(
V8NavigatorUserMediaSuccessCallback* success_callback,
V8NavigatorUserMediaErrorCallback* error_callback) {
- return new V8Callbacks(success_callback, error_callback);
+ return MakeGarbageCollected<V8Callbacks>(success_callback, error_callback);
}
+ V8Callbacks(V8NavigatorUserMediaSuccessCallback* success_callback,
+ V8NavigatorUserMediaErrorCallback* error_callback)
+ : success_callback_(ToV8PersistentCallbackFunction(success_callback)),
+ error_callback_(ToV8PersistentCallbackFunction(error_callback)) {}
~V8Callbacks() override = default;
void Trace(blink::Visitor* visitor) override {
@@ -338,11 +342,6 @@ class UserMediaRequest::V8Callbacks final : public UserMediaRequest::Callbacks {
}
private:
- V8Callbacks(V8NavigatorUserMediaSuccessCallback* success_callback,
- V8NavigatorUserMediaErrorCallback* error_callback)
- : success_callback_(ToV8PersistentCallbackFunction(success_callback)),
- error_callback_(ToV8PersistentCallbackFunction(error_callback)) {}
-
// As Blink does not hold a UserMediaRequest and lets content/ hold it,
// we cannot use wrapper-tracing to keep the underlying callback functions.
// Plus, it's guaranteed that the callbacks are one-shot type (not repeated
@@ -358,39 +357,61 @@ UserMediaRequest* UserMediaRequest::Create(
ExecutionContext* context,
UserMediaController* controller,
WebUserMediaRequest::MediaType media_type,
- const MediaStreamConstraints& options,
+ const MediaStreamConstraints* options,
Callbacks* callbacks,
MediaErrorState& error_state) {
WebMediaConstraints audio =
- ParseOptions(context, options.audio(), error_state);
+ ParseOptions(context, options->audio(), error_state);
if (error_state.HadException())
return nullptr;
WebMediaConstraints video =
- ParseOptions(context, options.video(), error_state);
+ ParseOptions(context, options->video(), error_state);
if (error_state.HadException())
return nullptr;
if (media_type == WebUserMediaRequest::MediaType::kDisplayMedia) {
- // TODO(emircan): Support constraints after the spec change.
- // https://w3c.github.io/mediacapture-screen-share/#constraints
- // 5.2 Constraining Display Surface Selection
- // The getDisplayMedia function does not permit the use of constraints for
- // selection of a source as described in the getUserMedia() algorithm.
- // Prior to invoking the getUserMedia() algorithm, if either of the video
- // and audio attributes are set to a MediaTrackConstraints value (as
- // opposed to being absent or set to a Boolean value), reject the promise
- // with a InvalidAccessError and abort.
- if (options.audio().IsMediaTrackConstraints() ||
- options.video().IsMediaTrackConstraints()) {
- error_state.ThrowDOMException(
- DOMExceptionCode::kInvalidAccessError,
- "getDisplayMedia() does not permit the use of constraints.");
+ // https://w3c.github.io/mediacapture-screen-share/#navigator-additions
+ // 5.1 Navigator Additions
+ // 1. Let constraints be the method's first argument.
+ // 2. For each member present in constraints whose value, value, is a
+ // dictionary, run the following steps:
+ // 1. If value contains a member named advanced, return a promise rejected
+ // with a newly created TypeError.
+ // 2. If value contains a member which in turn is a dictionary containing
+ // a member named either min or exact, return a promise rejected with a
+ // newly created TypeError.
+ // 3. Let requestedMediaTypes be the set of media types in constraints with
+ // either a dictionary value or a value of true.
+ // 4. If requestedMediaTypes is the empty set, set requestedMediaTypes to a
+ // set containing "video".
+ if ((!audio.IsNull() && !audio.Advanced().empty()) ||
+ (!video.IsNull() && !video.Advanced().empty())) {
+ error_state.ThrowTypeError("Advanced constraints are not supported");
+ return nullptr;
+ }
+ if ((!audio.IsNull() && audio.Basic().HasMin()) ||
+ (!video.IsNull() && video.Basic().HasMin())) {
+ error_state.ThrowTypeError("min constraints are not supported");
return nullptr;
}
- // TODO(emircan): Enable when audio capture is supported.
- if (!options.audio().IsNull() && options.audio().GetAsBoolean()) {
- error_state.ThrowTypeError("Audio is not supported");
+ if ((!audio.IsNull() && audio.Basic().HasExact()) ||
+ (!video.IsNull() && video.Basic().HasExact())) {
+ error_state.ThrowTypeError("exact constraints are not supported");
+ return nullptr;
+ }
+ if (audio.IsNull() && video.IsNull()) {
+ video = ParseOptions(context,
+ BooleanOrMediaTrackConstraints::FromBoolean(true),
+ error_state);
+ if (error_state.HadException())
+ return nullptr;
+ }
+
+ // TODO(emircan): Enable when audio capture is actually supported, see
+ // https://crbug.com/896333.
+ if (!options->audio().IsNull() && options->audio().GetAsBoolean()) {
+ error_state.ThrowTypeError("Audio capture is not supported");
return nullptr;
}
}
@@ -406,14 +427,14 @@ UserMediaRequest* UserMediaRequest::Create(
if (!video.IsNull())
CountVideoConstraintUses(context, video);
- return new UserMediaRequest(context, controller, media_type, audio, video,
- callbacks);
+ return MakeGarbageCollected<UserMediaRequest>(context, controller, media_type,
+ audio, video, callbacks);
}
UserMediaRequest* UserMediaRequest::Create(
ExecutionContext* context,
UserMediaController* controller,
- const MediaStreamConstraints& options,
+ const MediaStreamConstraints* options,
V8NavigatorUserMediaSuccessCallback* success_callback,
V8NavigatorUserMediaErrorCallback* error_callback,
MediaErrorState& error_state) {
@@ -425,9 +446,9 @@ UserMediaRequest* UserMediaRequest::Create(
UserMediaRequest* UserMediaRequest::CreateForTesting(
const WebMediaConstraints& audio,
const WebMediaConstraints& video) {
- return new UserMediaRequest(nullptr, nullptr,
- WebUserMediaRequest::MediaType::kUserMedia, audio,
- video, nullptr);
+ return MakeGarbageCollected<UserMediaRequest>(
+ nullptr, nullptr, WebUserMediaRequest::MediaType::kUserMedia, audio,
+ video, nullptr);
}
UserMediaRequest::UserMediaRequest(ExecutionContext* context,
@@ -441,14 +462,14 @@ UserMediaRequest::UserMediaRequest(ExecutionContext* context,
audio_(audio),
video_(video),
should_disable_hardware_noise_suppression_(
- OriginTrials::DisableHardwareNoiseSuppressionEnabled(context)),
+ origin_trials::DisableHardwareNoiseSuppressionEnabled(context)),
controller_(controller),
callbacks_(callbacks) {
if (should_disable_hardware_noise_suppression_) {
UseCounter::Count(context,
WebFeature::kUserMediaDisableHardwareNoiseSuppression);
}
- if (OriginTrials::ExperimentalHardwareEchoCancellationEnabled(context)) {
+ if (origin_trials::ExperimentalHardwareEchoCancellationEnabled(context)) {
UseCounter::Count(
context,
WebFeature::kUserMediaEnableExperimentalHardwareEchoCancellation);