WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
146837
Media Session: add plumbing for delivering start/end-of-interruption events
https://bugs.webkit.org/show_bug.cgi?id=146837
Summary
Media Session: add plumbing for delivering start/end-of-interruption events
Matt Rajca
Reported
2015-07-10 10:23:57 PDT
The platform should be able to send start-of-interruption events to MediaSessions so we can invoke the media session interruption algorithm (4.5.2).
Attachments
Patch
(12.77 KB, patch)
2015-07-10 10:39 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(17.81 KB, patch)
2015-07-10 10:42 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(18.06 KB, patch)
2015-07-10 13:50 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(20.90 KB, patch)
2015-07-13 10:43 PDT
,
Matt Rajca
no flags
Details
Formatted Diff
Diff
Patch
(20.68 KB, patch)
2015-07-13 11:46 PDT
,
Matt Rajca
thorton
: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2015-07-10 10:24:56 PDT
<
rdar://problem/21768356
>
Matt Rajca
Comment 2
2015-07-10 10:39:05 PDT
Created
attachment 256588
[details]
Patch
Matt Rajca
Comment 3
2015-07-10 10:42:38 PDT
Created
attachment 256589
[details]
Patch
Eric Carlson
Comment 4
2015-07-10 10:57:18 PDT
Comment on
attachment 256589
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256589&action=review
> Source/WebCore/Modules/mediasession/MediaSessionEvents.h:33 > +enum MediaEventType {
This should be "enum class".
> Source/WebCore/Modules/mediasession/MediaSessionEvents.h:39 > +enum MediaSessionInterruptingCategory {
Ditto.
> Source/WebCore/page/Page.cpp:1230 > +void Page::handleStartOfInterruptionEvent(MediaSessionInterruptingCategory category) > +{ > +}
Please add notImplemented();
Matt Rajca
Comment 5
2015-07-10 11:11:27 PDT
(In reply to
comment #4
)
> Comment on
attachment 256589
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=256589&action=review
> > > Source/WebCore/Modules/mediasession/MediaSessionEvents.h:33 > > +enum MediaEventType { > > This should be "enum class".
These are "enums" so we can cast to them from WKMediaEventTypes. We can't do that with a strongly-typed "enum class".
> > > Source/WebCore/Modules/mediasession/MediaSessionEvents.h:39 > > +enum MediaSessionInterruptingCategory { > > Ditto. > > > Source/WebCore/page/Page.cpp:1230 > > +void Page::handleStartOfInterruptionEvent(MediaSessionInterruptingCategory category) > > +{ > > +} > > Please add notImplemented();
Added.
Matt Rajca
Comment 6
2015-07-10 13:50:51 PDT
Created
attachment 256610
[details]
Patch
Tim Horton
Comment 7
2015-07-10 14:16:44 PDT
Comment on
attachment 256610
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256610&action=review
> Source/WebKit2/UIProcess/API/C/WKPage.cpp:2197 > + switch (wkCategory) {
I realize there's only one user, but the enum conversion functions are usually separate static methods. Maybe just keep that in mind if we end up needing this code again?
> Source/WebKit2/WebProcess/WebPage/WebPage.h:746 > + void handleStartOfInterruptionEvent(uint32_t /* WebCore::MediaSessionInterruptingCategory */);
Since this is on WebPage, it should be more clear that it's about media. Also, maybe just "handleMediaInterruptionEvent", with a state/phase to indicate whether it's starting or ending? Won't you eventually need the end case too?
Eric Carlson
Comment 8
2015-07-10 14:31:08 PDT
Comment on
attachment 256610
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256610&action=review
> Source/WebKit2/UIProcess/API/C/WKPage.cpp:2192 > +void WKPageHandleStartOfInterruptionEvent(WKPageRef page, WKMediaSessionInterruptingCategory wkCategory)
You should COMPILE_ASSERT([value in MediaEventType] == [value in WKMediaEventTypes] for each value to make sure the enums stay in sync. See HTMLTrackElement.cpp for an example.
Eric Carlson
Comment 9
2015-07-10 14:32:18 PDT
Comment on
attachment 256610
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256610&action=review
>> Source/WebKit2/UIProcess/API/C/WKPage.cpp:2192 >> +void WKPageHandleStartOfInterruptionEvent(WKPageRef page, WKMediaSessionInterruptingCategory wkCategory) > > You should COMPILE_ASSERT([value in MediaEventType] == [value in WKMediaEventTypes] for each value to make sure the enums stay in sync. See HTMLTrackElement.cpp for an example.
Or rather, if you do that then you can use a static_cast to convert values.
Matt Rajca
Comment 10
2015-07-13 10:43:55 PDT
Created
attachment 256706
[details]
Patch
Matt Rajca
Comment 11
2015-07-13 10:46:02 PDT
(In reply to
comment #7
)
> Comment on
attachment 256610
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=256610&action=review
> > > Source/WebKit2/UIProcess/API/C/WKPage.cpp:2197 > > + switch (wkCategory) { > > I realize there's only one user, but the enum conversion functions are > usually separate static methods. Maybe just keep that in mind if we end up > needing this code again?
Will do.
> > > Source/WebKit2/WebProcess/WebPage/WebPage.h:746 > > + void handleStartOfInterruptionEvent(uint32_t /* WebCore::MediaSessionInterruptingCategory */); > > Since this is on WebPage, it should be more clear that it's about media. > Also, maybe just "handleMediaInterruptionEvent", with a state/phase to > indicate whether it's starting or ending? Won't you eventually need the end > case too?
I renamed it to 'handleMediaSessionInterruptionEvent' and added an enum for the event type (currently either start-of-interruption and end-of-interruption).
Matt Rajca
Comment 12
2015-07-13 10:47:09 PDT
(In reply to
comment #9
)
> Comment on
attachment 256610
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=256610&action=review
> > >> Source/WebKit2/UIProcess/API/C/WKPage.cpp:2192 > >> +void WKPageHandleStartOfInterruptionEvent(WKPageRef page, WKMediaSessionInterruptingCategory wkCategory) > > > > You should COMPILE_ASSERT([value in MediaEventType] == [value in WKMediaEventTypes] for each value to make sure the enums stay in sync. See HTMLTrackElement.cpp for an example. > > Or rather, if you do that then you can use a static_cast to convert values.
Added the static assertions.
Tim Horton
Comment 13
2015-07-13 11:21:05 PDT
Comment on
attachment 256706
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256706&action=review
> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:191 > +#include "WKPagePrivate.h"
Put the enums in a new header (probably in Shared/API/C) that you include in both places (and install as a private header), do not import UIProcess API headers here!
Matt Rajca
Comment 14
2015-07-13 11:46:35 PDT
Created
attachment 256708
[details]
Patch
Matt Rajca
Comment 15
2015-07-13 11:46:45 PDT
(In reply to
comment #13
)
> Comment on
attachment 256706
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=256706&action=review
> > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:191 > > +#include "WKPagePrivate.h" > > Put the enums in a new header (probably in Shared/API/C) that you include in > both places (and install as a private header), do not import UIProcess API > headers here!
That header import was left over from a previous revision of the patch. Removed.
Tim Horton
Comment 16
2015-07-13 15:11:25 PDT
Comment on
attachment 256708
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=256708&action=review
> Source/WebKit2/UIProcess/API/C/WKPage.cpp:2193 > +// NOTE: The values in the WKMediaSessionInterruptingCategory enum must stay in sync with those in WebCore::MediaSessionInterruptingCategory.
Why must they? You do a proper conversion below.
Matt Rajca
Comment 17
2015-07-13 15:45:55 PDT
(In reply to
comment #16
)
> Comment on
attachment 256708
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=256708&action=review
> > > Source/WebKit2/UIProcess/API/C/WKPage.cpp:2193 > > +// NOTE: The values in the WKMediaSessionInterruptingCategory enum must stay in sync with those in WebCore::MediaSessionInterruptingCategory. > > Why must they? You do a proper conversion below.
We cast from a WKMediaSessionInterruptionEvent to a MediaSessionInterruptionEvent in WebPage.cpp. We need to ensure the enums' values are the same, otherwise we'll get them mixed up after casting.
Matt Rajca
Comment 18
2015-07-13 15:52:47 PDT
Committed
r186791
: <
http://trac.webkit.org/changeset/186791
>
Tim Horton
Comment 19
2015-07-13 16:40:37 PDT
(In reply to
comment #17
)
> (In reply to
comment #16
) > > Comment on
attachment 256708
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=256708&action=review
> > > > > Source/WebKit2/UIProcess/API/C/WKPage.cpp:2193 > > > +// NOTE: The values in the WKMediaSessionInterruptingCategory enum must stay in sync with those in WebCore::MediaSessionInterruptingCategory. > > > > Why must they? You do a proper conversion below. > > We cast from a WKMediaSessionInterruptionEvent to a > MediaSessionInterruptionEvent in WebPage.cpp. We need to ensure the enums' > values are the same, otherwise we'll get them mixed up after casting.
I'm not sure why we have a proper conversion function in one direction and just cast in the other direction?
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