Title: [187613] trunk/Source/WebCore
Revision
187613
Author
mra...@apple.com
Date
2015-07-30 15:26:20 -0700 (Thu, 30 Jul 2015)

Log Message

[Mac] Media Session: add support for more telephony interruptions
https://bugs.webkit.org/show_bug.cgi?id=147079

Reviewed by Eric Carlson.

* platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm:
(WebCore::callDidEndRinging): End 'Transient' interruptions.
(WebCore::callDidConnect): Forward this event to media sessions as a 'Content' interruption.
(WebCore::MediaSessionInterruptionProviderMac::beginListeningForInterruptions): Register observers for new
 notification types.
(WebCore::MediaSessionInterruptionProviderMac::stopListeningForInterruptions): Unregister all observers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187612 => 187613)


--- trunk/Source/WebCore/ChangeLog	2015-07-30 22:13:46 UTC (rev 187612)
+++ trunk/Source/WebCore/ChangeLog	2015-07-30 22:26:20 UTC (rev 187613)
@@ -1,3 +1,17 @@
+2015-07-18  Matt Rajca  <mra...@apple.com>
+
+        [Mac] Media Session: add support for more telephony interruptions
+        https://bugs.webkit.org/show_bug.cgi?id=147079
+
+        Reviewed by Eric Carlson.
+
+        * platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm:
+        (WebCore::callDidEndRinging): End 'Transient' interruptions.
+        (WebCore::callDidConnect): Forward this event to media sessions as a 'Content' interruption.
+        (WebCore::MediaSessionInterruptionProviderMac::beginListeningForInterruptions): Register observers for new
+         notification types.
+        (WebCore::MediaSessionInterruptionProviderMac::stopListeningForInterruptions): Unregister all observers.
+
 2015-07-29  Dean Jackson  <d...@apple.com>
 
         Don't use (Details) when exposing SPI

Modified: trunk/Source/WebCore/platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm (187612 => 187613)


--- trunk/Source/WebCore/platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm	2015-07-30 22:13:46 UTC (rev 187612)
+++ trunk/Source/WebCore/platform/mediasession/mac/MediaSessionInterruptionProviderMac.mm	2015-07-30 22:26:20 UTC (rev 187613)
@@ -33,6 +33,8 @@
 namespace WebCore {
 
 static const CFStringRef callDidBeginRingingNotification = CFSTR("CallDidBeginRinging");
+static const CFStringRef callDidEndRingingNotification = CFSTR("CallDidEndRinging");
+static const CFStringRef callDidConnectNotification = CFSTR("CallDidConnect");
 
 static void callDidBeginRinging(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
 {
@@ -41,14 +43,33 @@
     provider->client().didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory::Transient);
 }
 
+static void callDidEndRinging(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT_ARG(observer, observer);
+    MediaSessionInterruptionProviderMac* provider = (MediaSessionInterruptionProviderMac*)observer;
+    provider->client().didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory::Transient);
+}
+
+static void callDidConnect(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
+{
+    ASSERT_ARG(observer, observer);
+    MediaSessionInterruptionProviderMac* provider = (MediaSessionInterruptionProviderMac*)observer;
+    MediaSessionInterruptionProviderClient& client = provider->client();
+    client.didReceiveEndOfInterruptionNotification(MediaSessionInterruptingCategory::Transient);
+    client.didReceiveStartOfInterruptionNotification(MediaSessionInterruptingCategory::Content);
+}
+
 void MediaSessionInterruptionProviderMac::beginListeningForInterruptions()
 {
-    CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), this, callDidBeginRinging, callDidBeginRingingNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
+    CFNotificationCenterRef notificationCenter = CFNotificationCenterGetDistributedCenter();
+    CFNotificationCenterAddObserver(notificationCenter, this, callDidBeginRinging, callDidBeginRingingNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
+    CFNotificationCenterAddObserver(notificationCenter, this, callDidEndRinging, callDidEndRingingNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
+    CFNotificationCenterAddObserver(notificationCenter, this, callDidConnect, callDidConnectNotification, nullptr, CFNotificationSuspensionBehaviorDeliverImmediately);
 }
 
 void MediaSessionInterruptionProviderMac::stopListeningForInterruptions()
 {
-    CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), this, callDidBeginRingingNotification, nullptr);
+    CFNotificationCenterRemoveEveryObserver(CFNotificationCenterGetDistributedCenter(), this);
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to