<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213683] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213683">213683</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-09 15:58:02 -0800 (Thu, 09 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>WKWebView should provide a way for clients to know the specific media state.
https://bugs.webkit.org/show_bug.cgi?id=169140
&lt;rdar://problem/30838285&gt;

Patch by Andrew Gold &lt;agold@apple.com&gt; on 2017-03-09
Reviewed by Alex Christensen.

Instead of notifying the UIDelegate only when a capture begins and ends,
we now notify the UIDelegate of any change in capture state.

* UIProcess/API/APIUIClient.h:

(API::UIClient::mediaCaptureStateDidChange):
(API::UIClient::didBeginCaptureSession): Deleted.
(API::UIClient::didEndCaptureSession): Deleted.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:

* UIProcess/API/Cocoa/WKWebViewPrivate.h:

* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::mediaCaptureStateDidChange):
(WebKit::UIDelegate::UIClient::didBeginCaptureSession): Deleted.
(WebKit::UIDelegate::UIClient::didEndCaptureSession): Deleted.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::isPlayingMediaDidChange):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUIClienth">trunk/Source/WebKit2/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegateh">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegatemm">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2017-03-09  Andrew Gold  &lt;agold@apple.com&gt;
+
+        WKWebView should provide a way for clients to know the specific media state.
+        https://bugs.webkit.org/show_bug.cgi?id=169140
+        &lt;rdar://problem/30838285&gt;
+
+        Reviewed by Alex Christensen.
+
+        Instead of notifying the UIDelegate only when a capture begins and ends, 
+        we now notify the UIDelegate of any change in capture state.
+
+        * UIProcess/API/APIUIClient.h:
+
+        (API::UIClient::mediaCaptureStateDidChange):
+        (API::UIClient::didBeginCaptureSession): Deleted.
+        (API::UIClient::didEndCaptureSession): Deleted.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate):
+        (WebKit::UIDelegate::UIClient::mediaCaptureStateDidChange):
+        (WebKit::UIDelegate::UIClient::didBeginCaptureSession): Deleted.
+        (WebKit::UIDelegate::UIClient::didEndCaptureSession): Deleted.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::isPlayingMediaDidChange):
+
</ins><span class="cx"> 2017-03-09  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Show HTTP protocol version and other Network Load Metrics (IP Address, Priority, Connection ID)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -150,8 +150,7 @@
</span><span class="cx">     virtual void pinnedStateDidChange(WebKit::WebPageProxy&amp;) { }
</span><span class="cx"> 
</span><span class="cx">     virtual void isPlayingAudioDidChange(WebKit::WebPageProxy&amp;) { }
</span><del>-    virtual void didBeginCaptureSession() { }
-    virtual void didEndCaptureSession() { }
</del><ins>+    virtual void mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags) { }
</ins><span class="cx">     virtual void handleAutoplayEvent(WebKit::WebPageProxy&amp;, WebCore::AutoplayEvent) { }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><span class="cx"> #import &lt;WebKit/WKSecurityOrigin.h&gt;
</span><ins>+#import &lt;WebKit/WKWebViewPrivate.h&gt;
</ins><span class="cx"> #import &lt;WebKit/_WKActivatedElementInfo.h&gt;
</span><span class="cx"> 
</span><span class="cx"> @class UIItemProvider;
</span><span class="lines">@@ -63,8 +64,7 @@
</span><span class="cx"> - (NSDictionary *)_dataDetectionContextForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForMicrophone:(BOOL)microphone camera:(BOOL)camera url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorizedMicrophone, BOOL authorizedCamera))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</span><del>-- (void)_webViewDidBeginCaptureSession:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (void)_webViewDidEndCaptureSession:(WKWebView *)webView WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</del><ins>+- (void)_webView:(WKWebView *)webView mediaCaptureStateDidChange:(_WKMediaCaptureState)state WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> - (BOOL)_webView:(WKWebView *)webView shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(9.0));
</span><span class="cx"> - (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray&lt;_WKElementAction *&gt; *)defaultActions;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -39,6 +39,12 @@
</span><span class="cx">     _WKPaginationModeBottomToTop,
</span><span class="cx"> } WK_API_AVAILABLE(macosx(10.10), ios(8.0));
</span><span class="cx"> 
</span><ins>+typedef NS_OPTIONS(NSInteger, _WKMediaCaptureState) {
+    _WKMediaCaptureStateNone = 0,
+    _WKMediaCaptureStateMicrophone = 1 &lt;&lt; 0,
+    _WKMediaCaptureStateCamera = 1 &lt;&lt; 1,
+} WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
</ins><span class="cx"> #if !TARGET_OS_IPHONE
</span><span class="cx"> 
</span><span class="cx"> typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -91,8 +91,7 @@
</span><span class="cx"> #endif
</span><span class="cx">         bool decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&amp;, WebKit::WebFrameProxy&amp;, API::SecurityOrigin&amp;, API::SecurityOrigin&amp;, WebKit::UserMediaPermissionRequestProxy&amp;) override;
</span><span class="cx">         bool checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&amp;, WebKit::WebFrameProxy&amp;, API::SecurityOrigin&amp;, API::SecurityOrigin&amp;, WebKit::UserMediaPermissionCheckProxy&amp;) override;
</span><del>-        void didBeginCaptureSession() override;
-        void didEndCaptureSession() override;
</del><ins>+        void mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags) override;
</ins><span class="cx">         void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #if HAVE(APP_LINKS)
</span><span class="lines">@@ -136,8 +135,7 @@
</span><span class="cx">         bool webViewDidExitFullscreen : 1;
</span><span class="cx">         bool webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler : 1;
</span><span class="cx">         bool webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler : 1;
</span><del>-        bool webViewDidBeginCaptureSession : 1;
-        bool webViewDidEndCaptureSession : 1;
</del><ins>+        bool webViewMediaCaptureStateDidChange : 1;
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #if HAVE(APP_LINKS)
</span><span class="cx">         bool webViewShouldIncludeAppLinkActionsForElement : 1;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -116,8 +116,7 @@
</span><span class="cx">     m_delegateMethods.webViewDidNotHandleTapAsClickAtPoint = [delegate respondsToSelector:@selector(_webView:didNotHandleTapAsClickAtPoint:)];
</span><span class="cx">     m_delegateMethods.webViewRequestUserMediaAuthorizationForMicrophoneCameraURLMainFrameURLDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestUserMediaAuthorizationForMicrophone:camera:url:mainFrameURL:decisionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewCheckUserMediaPermissionForURLMainFrameURLFrameIdentifierDecisionHandler = [delegate respondsToSelector:@selector(_webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:)];
</span><del>-    m_delegateMethods.webViewDidBeginCaptureSession = [delegate respondsToSelector:@selector(_webViewDidBeginCaptureSession:)];
-    m_delegateMethods.webViewDidEndCaptureSession = [delegate respondsToSelector:@selector(_webViewDidEndCaptureSession:)];
</del><ins>+    m_delegateMethods.webViewMediaCaptureStateDidChange = [delegate respondsToSelector:@selector(_webView:mediaCaptureStateDidChange:)];
</ins><span class="cx">     m_delegateMethods.presentingViewControllerForWebView = [delegate respondsToSelector:@selector(_presentingViewControllerForWebView:)];
</span><span class="cx"> #endif
</span><span class="cx">     m_delegateMethods.dataDetectionContextForWebView = [delegate respondsToSelector:@selector(_dataDetectionContextForWebView:)];
</span><span class="lines">@@ -435,22 +434,20 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UIDelegate::UIClient::didBeginCaptureSession()
</del><ins>+void UIDelegate::UIClient::mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags state)
</ins><span class="cx"> {
</span><ins>+    WKWebView *webView = m_uiDelegate.m_webView;
</ins><span class="cx">     auto delegate = m_uiDelegate.m_delegate.get();
</span><del>-    if (!delegate || !m_uiDelegate.m_delegateMethods.webViewDidBeginCaptureSession)
</del><ins>+    if (!delegate || !m_uiDelegate.m_delegateMethods.webViewMediaCaptureStateDidChange)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    [(id &lt;WKUIDelegatePrivate&gt;)delegate _webViewDidBeginCaptureSession:m_uiDelegate.m_webView];
-}
</del><ins>+    _WKMediaCaptureState mediaCaptureState = _WKMediaCaptureStateNone;
+    if (state &amp; WebCore::MediaProducer::HasActiveAudioCaptureDevice)
+        mediaCaptureState |= _WKMediaCaptureStateMicrophone;
+    if (state &amp; WebCore::MediaProducer::HasActiveVideoCaptureDevice)
+        mediaCaptureState |= _WKMediaCaptureStateCamera;
</ins><span class="cx"> 
</span><del>-void UIDelegate::UIClient::didEndCaptureSession()
-{
-    auto delegate = m_uiDelegate.m_delegate.get();
-    if (!delegate || !m_uiDelegate.m_delegateMethods.webViewDidEndCaptureSession)
-        return;
-
-    [(id &lt;WKUIDelegatePrivate&gt;)delegate _webViewDidEndCaptureSession:m_uiDelegate.m_webView];
</del><ins>+    [(id &lt;WKUIDelegatePrivate&gt;)delegate _webView:webView mediaCaptureStateDidChange:mediaCaptureState];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UIDelegate::UIClient::reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&amp; securityOrigin, uint64_t currentQuota, uint64_t totalBytesNeeded, Function&lt;void (unsigned long long)&gt;&amp;&amp; completionHandler)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (213682 => 213683)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-03-09 23:44:12 UTC (rev 213682)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2017-03-09 23:58:02 UTC (rev 213683)
</span><span class="lines">@@ -6446,9 +6446,10 @@
</span><span class="cx">     if (state == m_mediaState)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    WebCore::MediaProducer::MediaStateFlags activeCaptureMask = WebCore::MediaProducer::HasActiveAudioCaptureDevice | WebCore::MediaProducer::HasActiveVideoCaptureDevice;
</ins><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><del>-    WebCore::MediaProducer::MediaStateFlags oldMediaStateHasActiveCapture = m_mediaState &amp; (WebCore::MediaProducer::HasActiveAudioCaptureDevice | WebCore::MediaProducer::HasActiveVideoCaptureDevice);
-    WebCore::MediaProducer::MediaStateFlags newMediaStateHasActiveCapture = state &amp; (WebCore::MediaProducer::HasActiveAudioCaptureDevice | WebCore::MediaProducer::HasActiveVideoCaptureDevice);
</del><ins>+    WebCore::MediaProducer::MediaStateFlags oldMediaStateHasActiveCapture = m_mediaState &amp; activeCaptureMask;
+    WebCore::MediaProducer::MediaStateFlags newMediaStateHasActiveCapture = state &amp; activeCaptureMask;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     MediaProducer::MediaStateFlags playingMediaMask = MediaProducer::IsPlayingAudio | MediaProducer::IsPlayingVideo;
</span><span class="lines">@@ -6456,18 +6457,17 @@
</span><span class="cx">     m_mediaState = state;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><del>-    if (!oldMediaStateHasActiveCapture &amp;&amp; newMediaStateHasActiveCapture) {
-        m_uiClient-&gt;didBeginCaptureSession();
</del><ins>+    if (oldMediaStateHasActiveCapture != newMediaStateHasActiveCapture)
+        m_uiClient-&gt;mediaCaptureStateDidChange(m_mediaState);
+    if (!oldMediaStateHasActiveCapture &amp;&amp; newMediaStateHasActiveCapture)
</ins><span class="cx">         userMediaPermissionRequestManager().startedCaptureSession();
</span><del>-    } else if (oldMediaStateHasActiveCapture &amp;&amp; !newMediaStateHasActiveCapture) {
-        m_uiClient-&gt;didEndCaptureSession();
</del><ins>+    else if (oldMediaStateHasActiveCapture &amp;&amp; !newMediaStateHasActiveCapture)
</ins><span class="cx">         userMediaPermissionRequestManager().endedCaptureSession();
</span><del>-    }
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     activityStateDidChange(ActivityState::IsAudible);
</span><span class="cx"> 
</span><del>-    playingMediaMask |= MediaProducer::HasActiveAudioCaptureDevice | MediaProducer::HasActiveVideoCaptureDevice;
</del><ins>+    playingMediaMask |= activeCaptureMask;
</ins><span class="cx">     if ((oldState &amp; playingMediaMask) != (m_mediaState &amp; playingMediaMask))
</span><span class="cx">         m_uiClient-&gt;isPlayingAudioDidChange(*this);
</span><span class="cx"> #if PLATFORM(MAC)
</span></span></pre>
</div>
</div>

</body>
</html>