Skip to content

Commit

Permalink
Work-in-progress: Refine srcObject's MediaSourceHandle behavior
Browse files Browse the repository at this point in the history
Adds text intending to help prevent using one or more
`MediaSourceHandle` for the same underlying `MediaSource` for
simultaneous, concurrent attachments to media elements:

* Updates `MediaSource.getHandle()` to succeed at most once per
  `MediaSource` instance.
* Updates `MediaSourceHandle` transfer section to more clearly indicate
  that transferring a handle out of a context makes that handle
  unavailable for transferring again out of the same context (unless it
  is first transferred back to that context).
* Updates the "attaching to a media element" text to indicate that a
  `MediaSourceHandle` can be attached successfully to at most one media
  element at a time, and with the previous 2 clarifications, ensures
  that the underlying worker context `MediaSource` can only be attached
  successfully to at most one media element at a time.

Note that legacy MSE object URL attachments similarly already achieve
the same intent in existing implementations. The switch to more clear
`srcObject` usage for worker MSE attachment affords the spec an
opportunity to be more clear about this intent.

This refinement originates from discussion on the previous PR with
@karlt: w3c#305
  • Loading branch information
wolenetz committed Mar 30, 2022
1 parent 89bd50e commit 9516970
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions media-source-respec.html
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,16 @@ <h3>Attributes</h3>
<p class="issue">Consider requiring conforming implementations to let such handle be created on a {{Window}}
{{MediaSource}} object, too?</p>
</li>
<li>If the {{MediaSource/readyState}} attribute is not {{ReadyState/""closed""}} then throw an {{InvalidStateError}} exception and abort these steps.</li>
<li>If BIG TODO the INTERNAL SLOT is true, then throw an {{InvalidStateError}} exception and abort these steps.</li>
<li>Create a new {{MediaSourceHandle}} object and associated resources.</li>
<li>Update BIG TODO the INTERNAL SLOT to be true.
<p class="note">This will prevent creation of multiple {{MediaSourceHandle}} objects for this
{{MediaSource}} instance, to help prevent this {{MediaSource}} from being attached using distinct handles
simultaneously to distinct media elements. Legacy object URL attachments allow distinct object URLs for
the same {{MediaSource}} instance, though simultaneous attachment of the same {{MediaSource}} via those
distinct object URLs to distinct media elements should also succeed for at most one media element.</p>
</li>
<li>Return the new object.</li>
</ol>
<div><em>No parameters.</em></div><div><em>Return type: </em>{{MediaSourceHandle}}</div></dd>
Expand Down Expand Up @@ -770,6 +779,7 @@ <h4><dfn>Attaching to a media element</dfn></h4>
object mentioned there, and the {{MediaSourceHandle}} object is the media provider object.
<p class="issue">MediaSourceHandle needs to be added to HTMLMediaElement's MediaProvider IDL typedef and
related text involving media provider objects.</p>
BIG TODO: add text around preventing using the handle simultaneously for for than one media element.
</li>
</ul>

Expand Down Expand Up @@ -1169,6 +1179,12 @@ <h2><dfn>MediaSourceHandle</dfn> Object</h2>
maintain an implicit internal slot referencing the underlying {{MediaSource}} to enable [=attaching to a media
element=] using {{HTMLMediaElement/srcObject}} and consequent setup of an attachment's [=cross-context
communication model=].

Once transferred out of a context, the handle MUST no longer be usable in that context.
<p class="note">For example, once a worker transfers a {{MediaSourceHandle}} to another context, it cannot
transfer that handle again unless the another context first transfers it back to the worker. This prevents
ability to clone {{MediaSourceHandle}} instances and helps prevent simultaneous attachment to distinct media
elements using handles to the same underlying {{MediaSource}}.</p>
</section>
</section>

Expand Down

0 comments on commit 9516970

Please sign in to comment.