Bug 160524 - ⛱: Implement Types for Constrainable Properties
Summary: ⛱: Implement Types for Constrainable Properties
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Local Build
Hardware: Other All
: P2 Minor
Assignee: George Ruan
URL:
Keywords: InRadar
Depends on: 160602 160606
Blocks: 160798
  Show dependency treegraph
 
Reported: 2016-08-03 13:53 PDT by George Ruan
Modified: 2017-08-30 11:48 PDT (History)
6 users (show)

See Also:


Attachments
Patch (20.90 KB, patch)
2016-08-03 14:08 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (19.60 KB, patch)
2016-08-03 16:05 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (20.24 KB, patch)
2016-08-04 11:01 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (20.14 KB, patch)
2016-08-04 11:44 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (20.92 KB, patch)
2016-08-04 13:06 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (20.93 KB, patch)
2016-08-04 13:24 PDT, George Ruan
no flags Details | Formatted Diff | Diff
Patch (20.02 KB, patch)
2016-08-04 14:28 PDT, George Ruan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description George Ruan 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.
Comment 1 Radar WebKit Bug Importer 2016-08-03 13:56:51 PDT
<rdar://problem/27685132>
Comment 2 George Ruan 2016-08-03 14:08:01 PDT
Created attachment 285269 [details]
Patch
Comment 3 George Ruan 2016-08-03 16:05:27 PDT
Created attachment 285286 [details]
Patch
Comment 4 Alex Christensen 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.
Comment 5 Eric Carlson 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.
Comment 6 George Ruan 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.
Comment 7 George Ruan 2016-08-04 11:01:09 PDT
Created attachment 285338 [details]
Patch
Comment 8 George Ruan 2016-08-04 11:44:02 PDT
Created attachment 285341 [details]
Patch
Comment 9 Eric Carlson 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.
Comment 10 George Ruan 2016-08-04 13:06:38 PDT
Created attachment 285351 [details]
Patch
Comment 11 George Ruan 2016-08-04 13:24:23 PDT
Created attachment 285357 [details]
Patch
Comment 12 George Ruan 2016-08-04 14:28:46 PDT
Created attachment 285365 [details]
Patch
Comment 13 WebKit Commit Bot 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.
Comment 14 WebKit Commit Bot 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.
Comment 15 WebKit Commit Bot 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>
Comment 16 WebKit Commit Bot 2016-08-04 15:35:54 PDT
All reviewed patches have been landed.  Closing bug.
Comment 17 Sam Weinig 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.
Comment 18 WebKit Commit Bot 2016-08-05 10:40:25 PDT
Re-opened since this is blocked by bug 160602