Title: [206193] trunk/Source/WebCore
Revision
206193
Author
jer.no...@apple.com
Date
2016-09-20 18:10:18 -0700 (Tue, 20 Sep 2016)

Log Message

Adopt MRMediaRemoteSetParentApplication.
https://bugs.webkit.org/show_bug.cgi?id=162259
<rdar://problem/28376161>

Reviewed by Anders Carlsson.

Allow MediaSessionManagerMac to retrieve the correct parent application identifier
from a PlatformMediaSession so that it can pass that identifier through to MediaRemote
via MRMediaRemoteSetParentApplication.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::sourceApplicationIdentifier):
* Modules/webaudio/AudioContext.h:
* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::sourceApplicationIdentifier):
* platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSession::resetPlaybackSessionState): Deleted.
* platform/audio/mac/MediaSessionManagerMac.mm:
(WebCore::MediaSessionManagerMac::updateNowPlayingInfo):
* platform/mac/MediaRemoteSoftLink.cpp:
* platform/mac/MediaRemoteSoftLink.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206192 => 206193)


--- trunk/Source/WebCore/ChangeLog	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/ChangeLog	2016-09-21 01:10:18 UTC (rev 206193)
@@ -1,3 +1,28 @@
+2016-09-20  Jer Noble  <jer.no...@apple.com>
+
+        Adopt MRMediaRemoteSetParentApplication.
+        https://bugs.webkit.org/show_bug.cgi?id=162259
+        <rdar://problem/28376161>
+
+        Reviewed by Anders Carlsson.
+
+        Allow MediaSessionManagerMac to retrieve the correct parent application identifier
+        from a PlatformMediaSession so that it can pass that identifier through to MediaRemote
+        via MRMediaRemoteSetParentApplication.
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::sourceApplicationIdentifier):
+        * Modules/webaudio/AudioContext.h:
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::PlatformMediaSession::sourceApplicationIdentifier):
+        * platform/audio/PlatformMediaSession.h:
+        (WebCore::PlatformMediaSession::resetPlaybackSessionState): Deleted.
+        * platform/audio/mac/MediaSessionManagerMac.mm:
+        (WebCore::MediaSessionManagerMac::updateNowPlayingInfo):
+        * platform/mac/MediaRemoteSoftLink.cpp:
+        * platform/mac/MediaRemoteSoftLink.h:
+
+
 2016-09-20  Nan Wang  <n_w...@apple.com>
 
         AX: AppleVisUser: VO can't navigate web dialogs iOS10

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (206192 => 206193)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2016-09-21 01:10:18 UTC (rev 206193)
@@ -48,11 +48,13 @@
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "FFTFrame.h"
+#include "Frame.h"
 #include "GainNode.h"
 #include "GenericEventQueue.h"
 #include "HRTFDatabaseLoader.h"
 #include "HRTFPanner.h"
 #include "JSDOMPromise.h"
+#include "NetworkingContext.h"
 #include "OfflineAudioCompletionEvent.h"
 #include "OfflineAudioDestinationNode.h"
 #include "OscillatorNode.h"
@@ -353,6 +355,16 @@
     return downcast<Document>(m_scriptExecutionContext);
 }
 
+String AudioContext::sourceApplicationIdentifier() const
+{
+    Document* document = this->document();
+    if (Frame* frame = document ? document->frame() : nullptr) {
+        if (NetworkingContext* networkingContext = frame->loader().networkingContext())
+            return networkingContext->sourceApplicationIdentifier();
+    }
+    return emptyString();
+}
+
 RefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate, ExceptionCode& ec)
 {
     RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate);

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (206192 => 206193)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2016-09-21 01:10:18 UTC (rev 206193)
@@ -317,6 +317,7 @@
     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override { }
     bool supportsSeeking() const override { return false; }
     bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
+    String sourceApplicationIdentifier() const override;
 
     // EventTarget
     void refEventTarget() override { ref(); }

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (206192 => 206193)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2016-09-21 01:10:18 UTC (rev 206193)
@@ -6518,7 +6518,7 @@
     return true;
 }
 
-String HTMLMediaElement::mediaPlayerSourceApplicationIdentifier() const
+String HTMLMediaElement::sourceApplicationIdentifier() const
 {
     if (Frame* frame = document().frame()) {
         if (NetworkingContext* networkingContext = frame->loader().networkingContext())

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (206192 => 206193)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2016-09-21 01:10:18 UTC (rev 206193)
@@ -627,7 +627,8 @@
 
     bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) override;
     void mediaPlayerHandlePlaybackCommand(PlatformMediaSession::RemoteControlCommandType command) override { didReceiveRemoteControlCommand(command, nullptr); }
-    String mediaPlayerSourceApplicationIdentifier() const override;
+    String sourceApplicationIdentifier() const override;
+    String mediaPlayerSourceApplicationIdentifier() const override { return sourceApplicationIdentifier(); }
     Vector<String> mediaPlayerPreferredAudioCharacteristics() const override;
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp (206192 => 206193)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2016-09-21 01:10:18 UTC (rev 206193)
@@ -289,6 +289,11 @@
     m_client.setShouldBufferData(PlatformMediaSessionManager::sharedManager().sessionCanLoadMedia(*this));
 }
 
+String PlatformMediaSession::sourceApplicationIdentifier() const
+{
+    return m_client.sourceApplicationIdentifier();
+}
+
 bool PlatformMediaSession::isHidden() const
 {
     return m_client.elementIsHidden();

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (206192 => 206193)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2016-09-21 01:10:18 UTC (rev 206193)
@@ -166,6 +166,7 @@
 
     void scheduleClientDataBufferingCheck();
     virtual void resetPlaybackSessionState() { }
+    String sourceApplicationIdentifier() const;
 
 protected:
     PlatformMediaSessionClient& client() const { return m_client; }
@@ -224,6 +225,7 @@
     virtual void setShouldPlayToPlaybackTarget(bool) { }
 
     virtual const Document* hostingDocument() const = 0;
+    virtual String sourceApplicationIdentifier() const = 0;
 
 protected:
     virtual ~PlatformMediaSessionClient() { }

Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (206192 => 206193)


--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm	2016-09-21 01:10:18 UTC (rev 206193)
@@ -112,11 +112,6 @@
     if (!isMediaRemoteFrameworkAvailable())
         return;
 
-    if (!MRMediaRemoteSetCanBeNowPlayingApplication(true)) {
-        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetCanBeNowPlayingApplication(true) failed");
-        return;
-    }
-
     const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession();
 
     LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - currentSession = %p", currentSession);
@@ -123,6 +118,7 @@
 
     if (!currentSession) {
         if (m_nowPlayingActive) {
+            MRMediaRemoteSetCanBeNowPlayingApplication(false);
             LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - clearing now playing info");
             MRMediaRemoteSetNowPlayingInfo(nullptr);
             m_nowPlayingActive = false;
@@ -138,6 +134,11 @@
         return;
     }
 
+    if (!MRMediaRemoteSetCanBeNowPlayingApplication(true)) {
+        LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetCanBeNowPlayingApplication(true) failed");
+        return;
+    }
+
     String title = currentSession->title();
     double duration = currentSession->duration();
     double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
@@ -172,6 +173,10 @@
     LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - title = \"%s\", rate = %f, duration = %f, now = %f",
         title.utf8().data(), rate, duration, currentTime);
 
+    String parentApplication = currentSession->sourceApplicationIdentifier();
+    if (canLoad_MediaRemote_MRMediaRemoteSetParentApplication() && !parentApplication.isEmpty())
+        MRMediaRemoteSetParentApplication(MRMediaRemoteGetLocalOrigin(), parentApplication.createCFString().get());
+
     m_nowPlayingActive = true;
     MRPlaybackState playbackState = (currentSession->state() == PlatformMediaSession::Playing) ? kMRPlaybackStatePlaying : kMRPlaybackStatePaused;
     MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(MRMediaRemoteGetLocalOrigin(), playbackState, dispatch_get_main_queue(), ^(MRMediaRemoteError error) {

Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp (206192 => 206193)


--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp	2016-09-21 01:10:18 UTC (rev 206193)
@@ -42,6 +42,7 @@
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetCanBeNowPlayingApplication, Boolean, (Boolean flag), (flag))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetNowPlayingInfo, void, (CFDictionaryRef info), (info))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin, void, (MROriginRef origin, MRPlaybackState playbackState, dispatch_queue_t replyQ, void(^completion)(MRMediaRemoteError)), (origin, playbackState, replyQ, completion))
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE(WebCore, MediaRemote, MRMediaRemoteSetParentApplication, void, (MROriginRef origin, CFStringRef parentAppDisplayID), (origin, parentAppDisplayID))
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoTitle, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoDuration, CFStringRef);
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoElapsedTime, CFStringRef);

Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h (206192 => 206193)


--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h	2016-09-21 01:03:22 UTC (rev 206192)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h	2016-09-21 01:10:18 UTC (rev 206193)
@@ -53,6 +53,8 @@
 #define MRMediaRemoteSetNowPlayingInfo softLink_MediaRemote_MRMediaRemoteSetNowPlayingInfo
 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin, void, (MROriginRef origin, MRPlaybackState playbackState, dispatch_queue_t replyQ, void(^completion)(MRMediaRemoteError)), (origin, playbackState, replyQ, completion))
 #define MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin softLink_MediaRemote_MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(WebCore, MediaRemote, MRMediaRemoteSetParentApplication, void, (MROriginRef origin, CFStringRef parentAppDisplayID), (origin, parentAppDisplayID))
+#define MRMediaRemoteSetParentApplication softLink_MediaRemote_MRMediaRemoteSetParentApplication
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoTitle, CFStringRef);
 #define kMRMediaRemoteNowPlayingInfoTitle get_MediaRemote_kMRMediaRemoteNowPlayingInfoTitle()
 SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoDuration, CFStringRef);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to