Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate getDisplayMedia() algorithm; reintroduce constraints. #73

Merged
merged 4 commits into from
Sep 6, 2018

Conversation

jan-ivar
Copy link
Member

Fix for #49.

@jan-ivar
Copy link
Member Author

Some explanation of this PR:

After deliberating with other editors, I gave up trying to preserve the call to the getUserMedia algorithm. A growing number of differences made it hard to deduce exactly what to implement. The lower-level algorithm calls are intact.

I also added Privacy Indicator Requirements, since these were only implied before, and with the explicit call to getUserMedia gone, I wanted to make sure we didn't lose them.

Finally, the content changes:

  • constraints are supported by getDisplayMedia again, with these caveats:
    • Using advanced, min or exact constraints gives TypeError.
    • Added note on reason for allowing max constraint.
  • Use the right permission algorithm (prompt the user to choose)
  • Disallow persisting "granted" permissions only.
  • Proposes "screen" as permission descriptor name (do we prefer "display"?)

index.html Outdated
permissions, only the "Live" indicators are significant.
</p>
</div>
<p>The User Agent MUST NOT implement the <code><a href=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"MUST NOT implement" sounds a bit strange. Would it be clearer to say "MUST NOT fire the devicechange event based on changes in the set of available sources for getDisplayMedia"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Harald said.

Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. I think that we should settle on a single permission descriptor rather than two. I suggest "display", if only to match the API name. How browsers manage audio capture will be tricky enough in UX without having to worry about conjoined requests being hampered by permission discrepancies.

"!HTML52/browsers.html#top-level-browsing-context">top-level
browsing context</a>'s <a data-cite=
"!HTML52/browsers.html#active-document">active document</a>'s
origin.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, what a mouthful. It's correct, but do we not have a shorthand for this we can use instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's existing prose copied from getUserMedia.

different from <var>originIdentifier</var>, set
<var>originIdentifier</var> to the result of combining
<var>originIdentifier</var> and the <a>current settings
object</a>'s origin.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what this means. (If this is a process defined in Feature Policy, then) you need a citation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, copied from getUserMedia.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't make it good. It just means that you now have two incomprehensible statements.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinthomson As such it makes this a non-change as far as this PR is concerned. Can you open an issue on mediacapture-main, and can we take care of it that way? It

Just trying to unblock this PR on feature policy and w3c/mediacapture-main#434.

index.html Outdated
a display device, with a PermissionDescriptor with its name
member set to the permission name associated with
<var>kind</var> for obtaining display devices (e.g. "screen"
for video), resulting in a set of provided media.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that "display" is better, and that we don't want to distinguish between video and audio capture in this context.

That's just my intuition here, so I'm open to arguments that suggest otherwise.

index.html Outdated
<code><a>MediaStreamTrack</a></code> MUST NOT change.</p>
<p>User Agents are encouraged to warn users against sharing
<a>browser</a> display devices, or otherwise try to
steer users away from sharing them.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"or otherwise try to discourage their selection on the basis that these represent a significantly higher risk when shared"

and set the
[[\devicesAccessibleMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already
<code>true</code>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to establish what deviceId is here. My suggestion is that while it is valuable to interact with the gUM model in this way, you want to assign a unique deviceId every time a capture is started here, only reusing the identifier while the same source is active. That needs to be part of the preceding steps of the algorithm here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This per-device permission stuff—which no-one implements btw—has already received (legitimate) flak for being overly complicated, so I worry about adding complexity to this. Since the deviceIds are never exposed, can we perhaps use the raw internal ids which are stable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the point here is to support indicators, then sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs clarification too.

The max constraint type lets a web application provide a maximum envelope
for constrainable properties like width and height, should the
end-user resize a <a>window</a> or <a>browser</a> surface while it
is being captured.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reasonable conclusion, but the choice on min/max doesn't seem particularly principled. Are there other constraints that might need similar treatment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that only max is allowed. min and exact are disallowed.

There's no selection, only downscaling/decimating. We never upscale, so no min needed.

Eliminating min also avoids us having to worry about OverconstrainedError after selection.

I don't anticipate constraints other than width and height needing this.
I don't anticipate needing other constraints types than min, given this repurposing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might explicitly state what constraints are allowed/disallowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aboba I expect #31 will address that.

index.html Outdated
permissions, only the "Live" indicators are significant.
</p>
</div>
<p>The User Agent MUST NOT implement the <code><a href=
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Harald said.

@jan-ivar
Copy link
Member Author

@martinthomson @alvestrand Review feedback incorporated PTAL.

values. This prevents an application from influencing the selection of sources, see
<a href="#constraints"></a> for details.
This method is similar to <code><a>getUserMedia</a></code>, except that it
acquires media from one display device chosen by the end-user each time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"one display device" sounds like single-monitor only?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might add a definition of "a display device", something like "In this context, a display device consists of all the display surfaces that are presented to the user to choose from."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is covered by "Multiple monitors might also be aggregated into as a single logical monitor."

Copy link
Contributor

@henbos henbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put down several comments, but I think they can be addressed separately. This PR is blocking other stuff, and most of the nits are inherited from GUM.

<li>
<p>Let <var>requestedMediaTypes</var> be the set of media
types in <var>constraints</var> with either a dictionary
value or a value of <code>true</code>.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the set of media types in constraints" sounds like a specific member inside of constraints, can this be clarified? I think its meant to say that requestedMediaTypes is the set of the same members as in constraints but only those whose value is either a dictionary or the value true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henbos Copied from mediacapture-main.

"media type" seems defined by extension to be audio or video, referring here to the key names "audio" or "video" in e.g. constraints like {audio: true, video: {}}.

The type of elements in the set requestedMediaTypes doesn't seem super-relevant as long as it distinguishes audio vs. video and future types, though it seems safe to infer string IMHO. Please open an issue on mediacapture-main if you think this isn't clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really more of a template argument than a string I suppose. We do gymnastics like:

"For each media type T in requestedMediaTypes, ... If the value of the T entry of constraints is "true""

E.g. if unrolled, would read "if the value of the audio entry of constraints" and again for video.

<li>
<p>If <var>requestedMediaTypes</var> is the empty set, set
<var>requestedMediaTypes</var> to a set containing
<code>"video"</code>.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "video:true"?

<p>Run the following steps in parallel:</p>
<ol>
<li>
<p>For each media type <var>T</var> in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "media type" well defined? Should it be or a link, or somewhere clarified that this is "audio" or "video"?

<var>originIdentifier</var>, <a>prompt the user to choose</a>
a display device, with a PermissionDescriptor named
<code>"display"</code>, resulting in a set of
provided media.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'with a PermissionDescriptor named "display",'
I'm sure this was copied from GUM, but I don't know what this means, should we file an issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: '... or in "rejected".'?

each media type in <var>requestedMediaTypes</var>.
The devices chosen MUST be the ones determined by the user.
Once selected, the source of a
<code><a>MediaStreamTrack</a></code> MUST NOT change.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence may be up for interpretation and debatable. You may share an application, whose set of windows changes or resizes, or where the source is N/A during the time something is minimized, or we may add language about what to do if the set of monitors changes. Or something.

This is OK but we may need to revisit it.

and set the
[[\devicesAccessibleMap]]<var>[deviceId]</var> to
<code>true</code>, if it isn’t already
<code>true</code>.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs clarification too.

provided media.</p>
<p>The provided media MUST include precisely one track of
each media type in <var>requestedMediaTypes</var>.
The devices chosen MUST be the ones determined by the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Language like "devices" should be updated, we're talking about display surfaces.

<a href="#create-permission">create a permission storage entry</a>
with a value of "granted".
</p>
<p>If the result is "denied", jump to the step labeled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'm not sure its clear what the possible results are.

"https://w3c.github.io/mediacapture-main/#dfn-applyconstraints-algorithm">
<dfn>ApplyConstraints algorithm</dfn></a> on all
tracks in <var>stream</var> with the appropriate
constraints. Should this fail, let <var>failedConstraint</var>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "with the appropriate constraints" should be clarified. As-is, both boolean and constraint set values are allowed (do we need to convert "true" to "{}"?), and it is not explicit about applying "audio" constraints to audio and "video" constraints to video. This may seem obvious but as an algorithm step it is vague.

<li>
<p>If <var>value</var> contains a member which in turn
is a dictionary containing a member named either
<code>min</code> or <code>exact</code>, return a promise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(If it turns out that there are meaningful differences between exact and ideal in the case of boolean constraints we can revisit this separately.)

@aboba aboba merged commit 5245ceb into w3c:gh-pages Sep 6, 2018
@jan-ivar jan-ivar deleted the constraints branch September 6, 2018 14:42
@henbos
Copy link
Contributor

henbos commented Sep 6, 2018

Comments to be addressed separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants