Title: [238148] branches/safari-606-branch
Revision
238148
Author
[email protected]
Date
2018-11-13 14:46:14 -0800 (Tue, 13 Nov 2018)

Log Message

Cherry-pick r237837. rdar://problem/45996796

    [MediaStream] An audio track should be muted when capture is interrupted by the OS.
    Source/WebCore:

    https://bugs.webkit.org/show_bug.cgi?id= 191283
     <rdar://problem/45773103>

    Patch by Eric Carlson <[email protected]> on 2018-11-05
    Reviewed by Jon Lee.

    Test: fast/mediastream/media-stream-track-interrupted.html

    * platform/mediastream/RealtimeMediaSource.cpp:
    (WebCore::RealtimeMediaSource::setInterruptedForTesting):
    * platform/mediastream/RealtimeMediaSource.h:
    * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
    (WebCore::CoreAudioCaptureSource::beginInterruption):
    (WebCore::CoreAudioCaptureSource::endInterruption):
    * testing/Internals.cpp:
    (WebCore::Internals::setMediaStreamSourceInterrupted):
    * testing/Internals.h:
    * testing/Internals.idl:

    LayoutTests:

    https://bugs.webkit.org/show_bug.cgi?id=191283
     <rdar://problem/45773103>

    Patch by Eric Carlson <[email protected]> on 2018-11-05
    Reviewed by Jon Lee.

    * fast/mediastream/media-stream-track-interrupted-expected.txt: Added.
    * fast/mediastream/media-stream-track-interrupted.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237837 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-606-branch/LayoutTests/ChangeLog (238147 => 238148)


--- branches/safari-606-branch/LayoutTests/ChangeLog	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/LayoutTests/ChangeLog	2018-11-13 22:46:14 UTC (rev 238148)
@@ -1,3 +1,53 @@
+2018-11-13  Alan Coon  <[email protected]>
+
+        Cherry-pick r237837. rdar://problem/45996796
+
+    [MediaStream] An audio track should be muted when capture is interrupted by the OS.
+    Source/WebCore:
+    
+    https://bugs.webkit.org/show_bug.cgi?id= 191283
+     <rdar://problem/45773103>
+    
+    Patch by Eric Carlson <[email protected]> on 2018-11-05
+    Reviewed by Jon Lee.
+    
+    Test: fast/mediastream/media-stream-track-interrupted.html
+    
+    * platform/mediastream/RealtimeMediaSource.cpp:
+    (WebCore::RealtimeMediaSource::setInterruptedForTesting):
+    * platform/mediastream/RealtimeMediaSource.h:
+    * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+    (WebCore::CoreAudioCaptureSource::beginInterruption):
+    (WebCore::CoreAudioCaptureSource::endInterruption):
+    * testing/Internals.cpp:
+    (WebCore::Internals::setMediaStreamSourceInterrupted):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    https://bugs.webkit.org/show_bug.cgi?id=191283
+     <rdar://problem/45773103>
+    
+    Patch by Eric Carlson <[email protected]> on 2018-11-05
+    Reviewed by Jon Lee.
+    
+    * fast/mediastream/media-stream-track-interrupted-expected.txt: Added.
+    * fast/mediastream/media-stream-track-interrupted.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-11-05  Eric Carlson  <[email protected]>
+
+            [MediaStream] An audio track should be muted when capture is interrupted by the OS.
+            https://bugs.webkit.org/show_bug.cgi?id=191283
+             <rdar://problem/45773103>
+
+            Reviewed by Jon Lee.
+
+            * fast/mediastream/media-stream-track-interrupted-expected.txt: Added.
+            * fast/mediastream/media-stream-track-interrupted.html: Added.
+
 2018-11-07  Ryan Haddad  <[email protected]>
 
         Unreviewed test gardening for rdar://problem/44568702.

Added: branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted-expected.txt (0 => 238148)


--- branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted-expected.txt	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted-expected.txt	2018-11-13 22:46:14 UTC (rev 238148)
@@ -0,0 +1,6 @@
+
+
+PASS Create stream 
+PASS Interrupt video track 
+PASS Interrupt audio track 
+

Added: branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted.html (0 => 238148)


--- branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted.html	                        (rev 0)
+++ branches/safari-606-branch/LayoutTests/fast/mediastream/media-stream-track-interrupted.html	2018-11-13 22:46:14 UTC (rev 238148)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>Capture source interruption.</title>
+    <script src=""
+    <script src=""
+ </head>
+<body>
+    <video width=320 height=240></video>
+
+    <script>
+
+    let video;
+
+   if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    function waitForPageStateChange(numberOfTries, originalState, resolve, reject)
+    {
+        let newState = internals.pageMediaState();
+        if (newState != originalState) {
+            resolve(newState);
+            return;
+        }
+
+        if (numberOfTries <= 0) {
+            reject('Page state did not change in time.');
+            return;
+        }
+
+        setTimeout(() => { waitForPageStateChange(--numberOfTries, originalState, resolve, reject); }, 10);
+    }
+
+    function testTrack(track, title)
+    {
+        promise_test((test) => {
+            return new Promise((resolve, reject) => {
+                let isVideo = track.kind == "video";
+                if (window.internals) {
+                    assert_false(internals.pageMediaState().includes('HasMutedVideoCaptureDevice'));
+                    assert_false(internals.pageMediaState().includes('HasMutedAudioCaptureDevice'));
+                }
+
+                track._onunmute_ = () => reject("Got 'unmute' event unexpectedly!");
+                track._onmute_ = () => {
+                    new Promise((innerResolve, innerReject) => {
+                        waitForPageStateChange(10, internals.pageMediaState(), innerResolve, innerReject)
+                    }).then((pageMediaState) => {
+
+                        track._onunmute_ = (evt) => {
+                            waitForPageStateChange(10, internals.pageMediaState(), resolve, reject)
+                        }
+
+                        if (window.internals) {
+                            assert_true(pageMediaState.includes(isVideo ? 'HasMutedVideoCaptureDevice' : 'HasMutedAudioCaptureDevice'));
+                            assert_false(pageMediaState.includes(isVideo ? 'HasMutedAudioCaptureDevice' : 'HasMutedVideoCaptureDevice'));
+                            assert_true(pageMediaState.includes(isVideo ? 'HasActiveAudioCaptureDevice' : 'HasActiveVideoCaptureDevice'));
+                            assert_false(pageMediaState.includes(isVideo ? 'HasActiveVideoCaptureDevice' : 'HasActiveAudioCaptureDevice'));
+                            internals.setMediaStreamSourceInterrupted(track, false)
+                        }
+                    })
+                }
+
+                if (window.internals)
+                    internals.setMediaStreamSourceInterrupted(track, true);
+                setTimeout(() => reject("Muted state did not change in 1 second"), 1000);
+            });
+        }, title);
+    }
+
+    promise_test((test) => {
+        return navigator.mediaDevices.getUserMedia({ video: true, audio: true})
+            .then((stream) => {
+                testTrack(stream.getVideoTracks()[0], "Interrupt video track");
+                testTrack(stream.getAudioTracks()[0], "Interrupt audio track");
+            });
+    }, "Create stream");
+
+
+    </script>
+
+</body>
+</html>

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-11-13 22:46:14 UTC (rev 238148)
@@ -1,3 +1,63 @@
+2018-11-13  Alan Coon  <[email protected]>
+
+        Cherry-pick r237837. rdar://problem/45996796
+
+    [MediaStream] An audio track should be muted when capture is interrupted by the OS.
+    Source/WebCore:
+    
+    https://bugs.webkit.org/show_bug.cgi?id= 191283
+     <rdar://problem/45773103>
+    
+    Patch by Eric Carlson <[email protected]> on 2018-11-05
+    Reviewed by Jon Lee.
+    
+    Test: fast/mediastream/media-stream-track-interrupted.html
+    
+    * platform/mediastream/RealtimeMediaSource.cpp:
+    (WebCore::RealtimeMediaSource::setInterruptedForTesting):
+    * platform/mediastream/RealtimeMediaSource.h:
+    * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+    (WebCore::CoreAudioCaptureSource::beginInterruption):
+    (WebCore::CoreAudioCaptureSource::endInterruption):
+    * testing/Internals.cpp:
+    (WebCore::Internals::setMediaStreamSourceInterrupted):
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    https://bugs.webkit.org/show_bug.cgi?id=191283
+     <rdar://problem/45773103>
+    
+    Patch by Eric Carlson <[email protected]> on 2018-11-05
+    Reviewed by Jon Lee.
+    
+    * fast/mediastream/media-stream-track-interrupted-expected.txt: Added.
+    * fast/mediastream/media-stream-track-interrupted.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-11-05  Eric Carlson  <[email protected]>
+
+            [MediaStream] An audio track should be muted when capture is interrupted by the OS.
+            https://bugs.webkit.org/show_bug.cgi?id= 191283
+             <rdar://problem/45773103>
+
+            Reviewed by Jon Lee.
+
+            Test: fast/mediastream/media-stream-track-interrupted.html
+
+            * platform/mediastream/RealtimeMediaSource.cpp:
+            (WebCore::RealtimeMediaSource::setInterruptedForTesting):
+            * platform/mediastream/RealtimeMediaSource.h:
+            * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+            (WebCore::CoreAudioCaptureSource::beginInterruption):
+            (WebCore::CoreAudioCaptureSource::endInterruption):
+            * testing/Internals.cpp:
+            (WebCore::Internals::setMediaStreamSourceInterrupted):
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
 2018-10-29  Kocsen Chung  <[email protected]>
 
         Apply patch. rdar://problem/45363479

Modified: branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp	2018-11-13 22:46:14 UTC (rev 238148)
@@ -110,6 +110,11 @@
     notifyMutedObservers();
 }
 
+void RealtimeMediaSource::setInterruptedForTesting(bool interrupted)
+{
+    notifyMutedChange(interrupted);
+}
+
 void RealtimeMediaSource::notifyMutedObservers() const
 {
     for (Observer& observer : m_observers)

Modified: branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/platform/mediastream/RealtimeMediaSource.h	2018-11-13 22:46:14 UTC (rev 238148)
@@ -220,6 +220,7 @@
 
     // Testing only
     virtual void delaySamples(Seconds) { };
+    void setInterruptedForTesting(bool);
 
 protected:
     RealtimeMediaSource(const String& id, Type, const String& name);

Modified: branches/safari-606-branch/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2018-11-13 22:46:14 UTC (rev 238148)
@@ -941,6 +941,7 @@
     scheduleDeferredTask([this, &unit] {
         m_suspendType = unit.isProducingData() ? SuspensionType::WhilePlaying : SuspensionType::WhilePaused;
         unit.suspend();
+        notifyMutedChange(true);
         m_suspendPending = false;
     });
 }
@@ -961,8 +962,10 @@
     scheduleDeferredTask([this, type, &unit] {
         if (m_reconfigurationState == ReconfigurationState::Required)
             unit.reconfigureAudioUnit();
-        if (type == SuspensionType::WhilePlaying)
+        if (type == SuspensionType::WhilePlaying) {
             unit.resume();
+            notifyMutedChange(false);
+        }
         m_reconfigurationState = ReconfigurationState::None;
         m_resumePending = false;
     });

Modified: branches/safari-606-branch/Source/WebCore/testing/Internals.cpp (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/testing/Internals.cpp	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/testing/Internals.cpp	2018-11-13 22:46:14 UTC (rev 238148)
@@ -4444,6 +4444,12 @@
 {
     track.setIdForTesting(WTFMove(id));
 }
+
+void Internals::setMediaStreamSourceInterrupted(MediaStreamTrack& track, bool interrupted)
+{
+    track.source().setInterruptedForTesting(interrupted);
+}
+
 #endif
 
 String Internals::audioSessionCategory() const

Modified: branches/safari-606-branch/Source/WebCore/testing/Internals.h (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/testing/Internals.h	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/testing/Internals.h	2018-11-13 22:46:14 UTC (rev 238148)
@@ -657,6 +657,7 @@
     void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&);
     void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&);
     void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id);
+    void setMediaStreamSourceInterrupted(MediaStreamTrack&, bool);
 #endif
 
     String audioSessionCategory() const;

Modified: branches/safari-606-branch/Source/WebCore/testing/Internals.idl (238147 => 238148)


--- branches/safari-606-branch/Source/WebCore/testing/Internals.idl	2018-11-13 22:35:15 UTC (rev 238147)
+++ branches/safari-606-branch/Source/WebCore/testing/Internals.idl	2018-11-13 22:46:14 UTC (rev 238148)
@@ -617,6 +617,7 @@
     [Conditional=MEDIA_STREAM] void removeMediaStreamTrack(MediaStream stream, MediaStreamTrack track);
     [Conditional=MEDIA_STREAM] void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack track);
     [Conditional=MEDIA_STREAM] void setMediaStreamTrackIdentifier(MediaStreamTrack track, DOMString identifier);
+    [Conditional=MEDIA_STREAM] void setMediaStreamSourceInterrupted(MediaStreamTrack track, boolean interrupted);
 
     unsigned long long documentIdentifier(Document document);
     boolean isDocumentAlive(unsigned long long documentIdentifier);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to