Bug 160524

Summary: ⛱: Implement Types for Constrainable Properties
Product: WebKit Reporter: George Ruan <gruan>
Component: MediaAssignee: George Ruan <gruan>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Minor CC: adam.bergkvist, commit-queue, eric.carlson, jonlee, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Other   
OS: All   
Bug Depends on: 160602, 160606    
Bug Blocks: 160798    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

George Ruan
Reported 2016-08-03 13:53:18 PDT
Currently, the class CapabilityValueOrRange only supports long and double types along with each type only supporting min, max, and exact values for Media Capabilities and Media Constraints. According to https://w3c.github.io/mediacapture-main/#idl-def-constraindomstring, constrainable properties (and so also constraints) should be able to handle long, boolean, double, and String types along with having each type support a min, max, exact, and ideal member value.
Attachments
Patch (20.90 KB, patch)
2016-08-03 14:08 PDT, George Ruan
no flags
Patch (19.60 KB, patch)
2016-08-03 16:05 PDT, George Ruan
no flags
Patch (20.24 KB, patch)
2016-08-04 11:01 PDT, George Ruan
no flags
Patch (20.14 KB, patch)
2016-08-04 11:44 PDT, George Ruan
no flags
Patch (20.92 KB, patch)
2016-08-04 13:06 PDT, George Ruan
no flags
Patch (20.93 KB, patch)
2016-08-04 13:24 PDT, George Ruan
no flags
Patch (20.02 KB, patch)
2016-08-04 14:28 PDT, George Ruan
no flags
Radar WebKit Bug Importer
Comment 1 2016-08-03 13:56:51 PDT
George Ruan
Comment 2 2016-08-03 14:08:01 PDT
George Ruan
Comment 3 2016-08-03 16:05:27 PDT
Alex Christensen
Comment 4 2016-08-03 22:39:47 PDT
Comment on attachment 285286 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=285286&action=review Can this be tested? > Source/WebCore/platform/mediastream/MediaConstraints.cpp:2 > + * Copyright (C) 2012 Google Inc. All rights reserved. probably not necessary. It doesn't look like you moved this from anywhere. It looks like you just copied the copyright after adding Apple to the other file.
Eric Carlson
Comment 5 2016-08-04 06:39:05 PDT
Comment on attachment 285286 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=285286&action=review > Source/WebCore/platform/mediastream/MediaConstraints.cpp:42 > +RefPtr<BaseConstraint> BaseConstraint::create(String name) const String& name > Source/WebCore/platform/mediastream/MediaConstraints.cpp:68 > +Ref<LongConstraint> LongConstraint::create(String name) const String& > Source/WebCore/platform/mediastream/MediaConstraints.cpp:105 > + LOG(Media, "LongConstraint::initializeWithDictionary(%p) - failed to get dictionary value for key", this); Please log the key as well, e.g.: LOG(Media, "LongConstraint::initializeWithDictionary(%p) - failed to get dictionary value for key '%s'", this, key.utf8().data()); > Source/WebCore/platform/mediastream/MediaConstraints.cpp:120 > +Ref<DoubleConstraint> DoubleConstraint::create(String name) const String& > Source/WebCore/platform/mediastream/MediaConstraints.cpp:157 > + LOG(Media, "DoubleConstraint::initializeWithDictionary(%p) - failed to get dictionary value for key.", this); Log the key. > Source/WebCore/platform/mediastream/MediaConstraints.cpp:172 > +Ref<BooleanConstraint> BooleanConstraint::create(String name) const String& > Source/WebCore/platform/mediastream/MediaConstraints.cpp:197 > + LOG(Media, "BooleanConstraint::initializeWithDictionary(%p) - failed to get dictionary value for key.", this); Log the name. > Source/WebCore/platform/mediastream/MediaConstraints.cpp:208 > +Ref<StringConstraint> StringConstraint::create(String name) const String& > Source/WebCore/platform/mediastream/MediaConstraints.cpp:231 > + LOG(Media, "StringConstraint::initializeWithDictionary(%p) - failed to get dictionary value for key.", this); Log the key. > Source/WebCore/platform/mediastream/MediaConstraints.h:51 > + virtual ~BaseConstraint() { /* No-op */ }; Nit: the comment isn't necessary. > Source/WebCore/platform/mediastream/MediaConstraints.h:54 > + virtual void initializeWithDictionary(const Dictionary&) = 0; Does this need to be public? > Source/WebCore/platform/mediastream/MediaConstraints.h:101 > + static Ref<LongConstraint> create(String name, const Dictionary&); I don't see this in the patch.
George Ruan
Comment 6 2016-08-04 10:57:54 PDT
(In reply to comment #4) > Comment on attachment 285286 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=285286&action=review > > Can this be tested? Not in its current state, since nothing is hooked up. It will be tested once parsing for constraints in getUserMedia is done! > > > Source/WebCore/platform/mediastream/MediaConstraints.cpp:2 > > + * Copyright (C) 2012 Google Inc. All rights reserved. > > probably not necessary. It doesn't look like you moved this from anywhere. > It looks like you just copied the copyright after adding Apple to the other > file.
George Ruan
Comment 7 2016-08-04 11:01:09 PDT
George Ruan
Comment 8 2016-08-04 11:44:02 PDT
Eric Carlson
Comment 9 2016-08-04 12:49:33 PDT
Comment on attachment 285341 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=285341&action=review > Source/WebCore/ChangeLog:9 > + No new tests, no new functionality. I would say something like: "This isn't testable yet, but tests will be added in a future patch." > Source/WebCore/platform/mediastream/MediaConstraints.cpp:75 > +RefPtr<BaseConstraint> BaseConstraint::createEmptyDerivedConstraint(const String& name) > +{ > + const RealtimeMediaSourceSupportedConstraints& supportedConstraints = RealtimeMediaSourceCenter::singleton().supportedConstraints(); > + MediaConstraintType constraintType = supportedConstraints.constraintFromName(name); > + > + switch (constraintType) { > + case MediaConstraintType::Width: > + case MediaConstraintType::Height: > + case MediaConstraintType::SampleRate: > + case MediaConstraintType::SampleSize: > + return LongConstraint::create(name); > + case MediaConstraintType::AspectRatio: > + case MediaConstraintType::FrameRate: > + case MediaConstraintType::Volume: > + return DoubleConstraint::create(name); > + case MediaConstraintType::EchoCancellation: > + return BooleanConstraint::create(name); > + case MediaConstraintType::FacingMode: > + case MediaConstraintType::DeviceId: > + case MediaConstraintType::GroupId: > + return StringConstraint::create(name); > + case MediaConstraintType::Unknown: > + return nullptr; > + } > +} Unless this will be used by other methods, I would put it inline in create. > Source/WebCore/platform/mediastream/MediaConstraints.cpp:126 > + setIdeal(value); > + } Future engineers will thank you if you add something like: LOG(Media, "LongConstraint::initializeWithDictionary(%p) - ignoring invalid key/value pair: '%s' : %f", this, key.utf8().data(), value); > Source/WebCore/platform/mediastream/MediaConstraints.cpp:178 > + setIdeal(value); > + } Ditto. > Source/WebCore/platform/mediastream/MediaConstraints.cpp:215 > + } > +} Ditto. > Source/WebCore/platform/mediastream/MediaConstraints.cpp:248 > + setIdeal(value); > + } Ditto.
George Ruan
Comment 10 2016-08-04 13:06:38 PDT
George Ruan
Comment 11 2016-08-04 13:24:23 PDT
George Ruan
Comment 12 2016-08-04 14:28:46 PDT
WebKit Commit Bot
Comment 13 2016-08-04 15:16:30 PDT
The commit-queue encountered the following flaky tests while processing attachment 285365 [details]: The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 14 2016-08-04 15:16:51 PDT
The commit-queue encountered the following flaky tests while processing attachment 285365 [details]: editing/spelling/spellcheck-async.html bug 160571 (authors: g.czajkowski@samsung.com and mark.lam@apple.com) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 15 2016-08-04 15:35:48 PDT
Comment on attachment 285365 [details] Patch Clearing flags on attachment: 285365 Committed r204147: <http://trac.webkit.org/changeset/204147>
WebKit Commit Bot
Comment 16 2016-08-04 15:35:54 PDT
All reviewed patches have been landed. Closing bug.
Sam Weinig
Comment 17 2016-08-04 18:05:18 PDT
This doesn't look right to me. Rather than passing Dictionaries into c++ land, this conversion should be happening in the bindings. And we certainly shouldn't be doing String -> Number conversions like this. It should all happen at the JSValue level.
WebKit Commit Bot
Comment 18 2016-08-05 10:40:25 PDT
Re-opened since this is blocked by bug 160602
Note You need to log in before you can comment on or make changes to this bug.