WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
145581
Add basic Media Session support to HTMLMediaElement
https://bugs.webkit.org/show_bug.cgi?id=145581
Summary
Add basic Media Session support to HTMLMediaElement
Matt Rajca
Reported
2015-06-02 17:43:06 PDT
The Media Session spec adds to HTMLMediaElement: - a 'kind' attribute representing the intrinsic media category - a 'session' attribute representing the current media session, if any
Attachments
Patch
(14.74 KB, patch)
2015-06-02 18:00 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch (with build fixes)
(14.98 KB, patch)
2015-06-02 18:07 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(16.39 KB, patch)
2015-06-03 09:54 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(17.58 KB, patch)
2015-06-03 12:22 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch (speculative GTK build fix)
(17.71 KB, patch)
2015-06-03 13:10 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch (speculative Windows build fix)
(25.56 KB, patch)
2015-06-03 13:57 PDT
,
Matt Rajca
darin
: review-
darin
: commit-queue-
Details
Formatted Diff
Diff
Patch
(25.53 KB, patch)
2015-06-03 14:36 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(25.87 KB, patch)
2015-06-03 15:21 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2015-06-02 17:44:04 PDT
<
rdar://problem/21213287
>
Matt Rajca
Comment 2
2015-06-02 18:00:44 PDT
Created
attachment 254130
[details]
Patch
Matt Rajca
Comment 3
2015-06-02 18:07:58 PDT
Created
attachment 254131
[details]
Patch (with build fixes)
Matt Rajca
Comment 4
2015-06-03 09:54:19 PDT
Created
attachment 254183
[details]
Patch
Eric Carlson
Comment 5
2015-06-03 10:07:56 PDT
Comment on
attachment 254183
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=254183&action=review
> Source/WebCore/html/HTMLMediaElement.h:53 > +#if ENABLE(MEDIA_SESSION) > +#include "MediaSession.h" > +#endif
I think you can pre-declare "class MediaSession" here and put the include in the .cpp file.
Matt Rajca
Comment 6
2015-06-03 12:20:32 PDT
Comment on
attachment 254183
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=254183&action=review
>> Source/WebCore/html/HTMLMediaElement.h:53 >> +#endif > > I think you can pre-declare "class MediaSession" here and put the include in the .cpp file.
Done.
Matt Rajca
Comment 7
2015-06-03 12:22:37 PDT
Created
attachment 254194
[details]
Patch
Conrad Shultz
Comment 8
2015-06-03 12:31:40 PDT
The EWS failures look like they might be legit, e.g. DerivedSources/webkitdom/WebKitDOMHTMLMediaElement.h:654:40: error: 'WebKitDOMMediaSession' does not name a type
Matt Rajca
Comment 9
2015-06-03 12:33:51 PDT
The latest patch should fix a few more build errors. I'm going to wait until the EWS finishes before putting this in the commit queue. (In reply to
comment #8
)
> The EWS failures look like they might be legit, e.g. > > DerivedSources/webkitdom/WebKitDOMHTMLMediaElement.h:654:40: error: > 'WebKitDOMMediaSession' does not name a type
Matt Rajca
Comment 10
2015-06-03 13:10:18 PDT
Created
attachment 254200
[details]
Patch (speculative GTK build fix)
Matt Rajca
Comment 11
2015-06-03 13:57:26 PDT
Created
attachment 254206
[details]
Patch (speculative Windows build fix)
Darin Adler
Comment 12
2015-06-03 14:20:54 PDT
Comment on
attachment 254206
[details]
Patch (speculative Windows build fix) View in context:
https://bugs.webkit.org/attachment.cgi?id=254206&action=review
> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:32 > +#include <wtf/text/WTFString.h>
Don’t need this.
> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:36 > +class HTMLMediaElementMediaSession {
What determines the interface and name of this class? It seems quite strange and I am not sure exactly what it’s for. I might omit the second occurrence of the word “Media” but I’m not sure enough of context to know if that suggestion is OK.
> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:42 > + static const String& kind(HTMLMediaElement* element) { return element->kind(); } > + static void setKind(HTMLMediaElement* element, const String& kind) { return element->setKind(kind); } > + > + static MediaSession* session(HTMLMediaElement*, bool&); > + static void setSession(HTMLMediaElement* element, MediaSession* session) { element->setSession(session); }
These should all take HTMLMediaElement&, not HTMLMediaElement*.
> Source/WebCore/html/HTMLMediaElement.h:422 > + void setSession(MediaSession*);
Might want this to take RefPtr<MediaSession>&& instead, if callers are handing over ownership. If ownership is usually shared, then raw pointer is OK/better.
Matt Rajca
Comment 13
2015-06-03 14:35:48 PDT
Comment on
attachment 254206
[details]
Patch (speculative Windows build fix) View in context:
https://bugs.webkit.org/attachment.cgi?id=254206&action=review
>> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:32 >> +#include <wtf/text/WTFString.h> > > Don’t need this.
Removed.
>> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:36 >> +class HTMLMediaElementMediaSession { > > What determines the interface and name of this class? It seems quite strange and I am not sure exactly what it’s for. > > I might omit the second occurrence of the word “Media” but I’m not sure enough of context to know if that suggestion is OK.
I see it as MediaSession "extensions" on HTMLMediaElement. We do something similar for MediaStream in HTMLMediaElementMediaStream. I want to keep the second occurrence of the word "Media" in there so it's clear this is referring to the Media Session API rather than a different session.
>> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:42 >> + static void setSession(HTMLMediaElement* element, MediaSession* session) { element->setSession(session); } > > These should all take HTMLMediaElement&, not HTMLMediaElement*.
Per the Media Session spec, we should be able to set the session to null, which we won't be able to do with references.
>> Source/WebCore/html/HTMLMediaElement.h:422 >> + void setSession(MediaSession*); > > Might want this to take RefPtr<MediaSession>&& instead, if callers are handing over ownership. If ownership is usually shared, then raw pointer is OK/better.
A session can (and often will) be shared between multiple media elements. I'll keep this as is.
Matt Rajca
Comment 14
2015-06-03 14:36:12 PDT
Created
attachment 254210
[details]
Patch
Darin Adler
Comment 15
2015-06-03 14:38:24 PDT
Comment on
attachment 254206
[details]
Patch (speculative Windows build fix) View in context:
https://bugs.webkit.org/attachment.cgi?id=254206&action=review
>>> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:42 >>> + static void setSession(HTMLMediaElement* element, MediaSession* session) { element->setSession(session); } >> >> These should all take HTMLMediaElement&, not HTMLMediaElement*. > > Per the Media Session spec, we should be able to set the session to null, which we won't be able to do with references.
Then all the function bodies in this class, all of which unconditionally dereference the element pointer, are incorrect. Setting a session to null would depend on the type MediaSession*, not HTMLMediaElement*.
Matt Rajca
Comment 16
2015-06-03 15:10:37 PDT
(In reply to
comment #15
)
> Comment on
attachment 254206
[details]
> Patch (speculative Windows build fix) > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=254206&action=review
> > >>> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.h:42 > >>> + static void setSession(HTMLMediaElement* element, MediaSession* session) { element->setSession(session); } > >> > >> These should all take HTMLMediaElement&, not HTMLMediaElement*. > > > > Per the Media Session spec, we should be able to set the session to null, which we won't be able to do with references. > > Then all the function bodies in this class, all of which unconditionally > dereference the element pointer, are incorrect. > > Setting a session to null would depend on the type MediaSession*, not > HTMLMediaElement*.
I misread the original feedback. MediaSessions might be null, but HTMLMediaElements will never be null (when jsHTMLMediaElementSession calls these functions it will always pass in a HTMLMediaElement). We could use references, but those aren't compatible with the bindings generated. So I will leave pointers to HTMLMediaElements but add assertions (which is what we do in HTMLMediaElementMediaSource).
Matt Rajca
Comment 17
2015-06-03 15:21:32 PDT
Created
attachment 254216
[details]
Patch
WebKit Commit Bot
Comment 18
2015-06-03 16:42:18 PDT
Comment on
attachment 254216
[details]
Patch Clearing flags on attachment: 254216 Committed
r185179
: <
http://trac.webkit.org/changeset/185179
>
WebKit Commit Bot
Comment 19
2015-06-03 16:42:24 PDT
All reviewed patches have been landed. Closing bug.
Jon Lee
Comment 20
2015-06-03 18:10:48 PDT
Comment on
attachment 254216
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=254216&action=review
> Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.cpp:49 > + isNull = !session;
Why is this necessary, when the client can simply check the returned variable?
Jon Lee
Comment 21
2015-06-03 18:12:19 PDT
(In reply to
comment #16
)
> I misread the original feedback. MediaSessions might be null, but > HTMLMediaElements will never be null (when jsHTMLMediaElementSession calls > these functions it will always pass in a HTMLMediaElement). We could use > references, but those aren't compatible with the bindings generated. So I > will leave pointers to HTMLMediaElements but add assertions (which is what > we do in HTMLMediaElementMediaSource).
It sounds like we should a new bug filed to improve the bindings generation code to use references instead. Also, I see other examples of partial interfaces that make use of Supplement<>. Are we avoiding that here for a reason? Or are we abandoning that pattern?
Eric Carlson
Comment 22
2015-06-03 20:14:23 PDT
(In reply to
comment #20
)
> Comment on
attachment 254216
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=254216&action=review
> > > Source/WebCore/Modules/mediasession/HTMLMediaElementMediaSession.cpp:49 > > + isNull = !session; > > Why is this necessary, when the client can simply check the returned > variable?
That is the way our binding generator handles nullable types [1]. [1]
http://www.w3.org/TR/WebIDL/#idl-nullable-type
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug