W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2013

[whatwg] Assigning media resources represented as DOM objects to a media element

From: Robert O'Callahan <robert@ocallahan.org>
Date: Wed, 23 Jan 2013 16:19:44 +1300
Message-ID: <CAOp6jLYUnKsBxg7Urf==1ZDSkj9QXG8x6or8iwSTzaG9B8-yQg@mail.gmail.com>
To: whatwg <whatwg@lists.whatwg.org>
Currently there are three kinds of (proposed) DOM objects which can be used
as the source of a media element: Blobs, MediaStreams and MediaSources.
https://dvcs.w3.org/hg/html-media/raw-file/tip/media-source/media-source.html
http://dev.w3.org/2011/webrtc/editor/getusermedia.html
http://www.w3.org/TR/FileAPI/
Currently the only way to use one of these objects as the source of a media
element is via "element.src = URL.createObjectURL(object)". This is
problematic because the URLs minted by createObjectURL require manual
revocation. (Forms of auto-revocation have been proposed but a) they seem
difficult to spec in a rational way and b) we will not be able to make
auto-revocation the default.) Forcing authors to deal with manual
revocation makes their lives difficult and increases the chance that users
will encounter resource leaks in Web apps.

The createObjectURL approach also has the downside that there is no
standard way to recover the media element's source as a DOM object.

In Gecko we have implemented a prototype extension to media elements: the
srcObject attribute (currently prefixed). Thus an author can simply write
"element.srcObject = object". (Currently this only works for MediaStream
objects, but the other types are not difficult to support.) This is simpler
for authors, allows recovery of the source object, and most importantly
allows the resource to be managed automatically by standard garbage
collection.

Setting srcObject mostly behaves "just like" setting 'src' to
createObjectURL(object). However, 'src' and its corresponding content
attribute are not affected. The rules for choosing a media resource are
modified to check 'srcObject' before 'src'.

I think this would be a worthwhile addition to the Web platform.

Rob
-- 
Jesus called them together and said, “You know that the rulers of the
Gentiles lord it over them, and their high officials exercise authority
over them. Not so with you. Instead, whoever wants to become great among
you must be your servant, and whoever wants to be first must be your
slave — just
as the Son of Man did not come to be served, but to serve, and to give his
life as a ransom for many.” [Matthew 20:25-28]
Received on Wednesday, 23 January 2013 03:20:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:12 GMT