Changeset 250774 in webkit


Ignore:
Timestamp:
Oct 7, 2019 7:36:18 AM (5 years ago)
Author:
youenn@apple.com
Message:

[iOS] Unmuting capture of a page is not working
https://bugs.webkit.org/show_bug.cgi?id=202627

Reviewed by Eric Carlson.

Source/WebCore:

Before the patch, we were muting the capture tracks but never unmuting them.
The patch updates the code to make sure we unmute capture tracks based on the document state.
In addition, the iOS code wass process-wide while capture might happen between two documents in the same process.
The patch updates the capturestate computation and muting logic to be Document based.
A follow-up refactoring will merge back iOS and MacOS code paths.
Covered by API test.

  • Modules/mediastream/MediaStreamTrack.cpp:

(WebCore::MediaStreamTrack::captureState):
(WebCore::MediaStreamTrack::updateCaptureAccordingMutedState):
(WebCore::MediaStreamTrack::muteCapture): Deleted.

  • Modules/mediastream/MediaStreamTrack.h:
  • dom/Document.cpp:

(WebCore::Document::updateIsPlayingMedia):
(WebCore::Document::pageMutedStateDidChange):

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: Added.

(-[GetUserMediaCaptureUIDelegate _webView:requestMediaCaptureAuthorization:decisionHandler:]):
(-[GetUserMediaCaptureUIDelegate _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):
(-[GetUserMediaTestView haveStream:]):
(TestWebKitAPI::waitUntilCaptureState):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKit/getUserMedia.html:
Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r250770 r250774  
     12019-10-07  youenn fablet  <youenn@apple.com>
     2
     3        [iOS] Unmuting capture of a page is not working
     4        https://bugs.webkit.org/show_bug.cgi?id=202627
     5
     6        Reviewed by Eric Carlson.
     7
     8        Before the patch, we were muting the capture tracks but never unmuting them.
     9        The patch updates the code to make sure we unmute capture tracks based on the document state.
     10        In addition, the iOS code wass process-wide while capture might happen between two documents in the same process.
     11        The patch updates the capturestate computation and muting logic to be Document based.
     12        A follow-up refactoring will merge back iOS and MacOS code paths.
     13        Covered by API test.
     14
     15        * Modules/mediastream/MediaStreamTrack.cpp:
     16        (WebCore::MediaStreamTrack::captureState):
     17        (WebCore::MediaStreamTrack::updateCaptureAccordingMutedState):
     18        (WebCore::MediaStreamTrack::muteCapture): Deleted.
     19        * Modules/mediastream/MediaStreamTrack.h:
     20        * dom/Document.cpp:
     21        (WebCore::Document::updateIsPlayingMedia):
     22        (WebCore::Document::pageMutedStateDidChange):
     23
    1242019-10-06  Ryosuke Niwa  <rniwa@webkit.org>
    225
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp

    r250735 r250774  
    466466
    467467#if PLATFORM(IOS_FAMILY)
    468 MediaProducer::MediaStateFlags MediaStreamTrack::captureState()
     468MediaProducer::MediaStateFlags MediaStreamTrack::captureState(Document& document)
    469469{
    470470    MediaProducer::MediaStateFlags state = MediaProducer::IsNotPlaying;
    471     if (auto* source = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource())
    472         state |= sourceCaptureState(*source);
    473     if (auto* source = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource())
    474         state |= sourceCaptureState(*source);
     471    for (auto* captureTrack : allCaptureTracks()) {
     472        if (captureTrack->document() != &document || captureTrack->ended())
     473            continue;
     474        state |= sourceCaptureState(captureTrack->source());
     475    }
    475476    return state;
    476477}
    477478
    478 void MediaStreamTrack::muteCapture()
    479 {
    480     if (auto* source = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource())
    481         source->setMuted(true);
    482     if (auto* source = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource())
    483         source->setMuted(true);
     479void MediaStreamTrack::updateCaptureAccordingToMutedState(Document& document)
     480{
     481    for (auto* captureTrack : allCaptureTracks()) {
     482        if (captureTrack->document() != &document || captureTrack->ended())
     483            continue;
     484        captureTrack->setMuted(document.page()->mutedState());
     485    }
    484486}
    485487#endif
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h

    r250735 r250774  
    7373
    7474#if PLATFORM(IOS_FAMILY)
    75     static MediaProducer::MediaStateFlags captureState();
    76     static void muteCapture();
     75    static MediaProducer::MediaStateFlags captureState(Document&);
     76    static void updateCaptureAccordingToMutedState(Document&);
    7777#endif
    7878
  • trunk/Source/WebCore/dom/Document.cpp

    r250747 r250774  
    39883988
    39893989#if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
    3990     state |= MediaStreamTrack::captureState();
     3990    state |= MediaStreamTrack::captureState(*this);
    39913991#endif
    39923992
     
    40344034
    40354035#if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
    4036     MediaStreamTrack::muteCapture();
     4036    MediaStreamTrack::updateCaptureAccordingToMutedState(*this);
    40374037#endif
    40384038}
  • trunk/Tools/ChangeLog

    r250771 r250774  
     12019-10-07  youenn fablet  <youenn@apple.com>
     2
     3        [iOS] Unmuting capture of a page is not working
     4        https://bugs.webkit.org/show_bug.cgi?id=202627
     5
     6        Reviewed by Eric Carlson.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit/GetUserMedia.mm: Added.
     10        (-[GetUserMediaCaptureUIDelegate _webView:requestMediaCaptureAuthorization:decisionHandler:]):
     11        (-[GetUserMediaCaptureUIDelegate _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):
     12        (-[GetUserMediaTestView haveStream:]):
     13        (TestWebKitAPI::waitUntilCaptureState):
     14        (TestWebKitAPI::TEST):
     15        * TestWebKitAPI/Tests/WebKit/getUserMedia.html:
     16
    1172019-10-07  Philippe Normand  <pnormand@igalia.com>
    218
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r250729 r250774  
    214214                3FCC4FE51EC4E8520076E37C /* PictureInPictureDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3FCC4FE41EC4E8520076E37C /* PictureInPictureDelegate.mm */; };
    215215                3FCC4FE81EC4E8CA0076E37C /* PictureInPictureDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 3FCC4FE61EC4E87E0076E37C /* PictureInPictureDelegate.html */; };
     216                41157237234B240C0050A1D1 /* GetUserMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41157236234B24040050A1D1 /* GetUserMedia.mm */; };
    216217                4135FB842011FAA700332139 /* InjectInternals_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4135FB832011FAA300332139 /* InjectInternals_Bundle.cpp */; };
    217218                4135FB852011FABF00332139 /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */; };
     
    17031704                3FCC4FE41EC4E8520076E37C /* PictureInPictureDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureDelegate.mm; sourceTree = "<group>"; };
    17041705                3FCC4FE61EC4E87E0076E37C /* PictureInPictureDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = PictureInPictureDelegate.html; sourceTree = "<group>"; };
     1706                41157236234B24040050A1D1 /* GetUserMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetUserMedia.mm; sourceTree = "<group>"; };
    17051707                4135FB832011FAA300332139 /* InjectInternals_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InjectInternals_Bundle.cpp; path = Tests/InjectInternals_Bundle.cpp; sourceTree = SOURCE_ROOT; };
    17061708                4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
     
    35153517                                F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */,
    35163518                                F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */,
     3519                                41157236234B24040050A1D1 /* GetUserMedia.mm */,
    35173520                                07CE1CF21F06A7E000BF89F5 /* GetUserMediaNavigation.mm */,
    35183521                                07E499901F9E56A1002F1EF3 /* GetUserMediaReprompt.mm */,
     
    45544557                                7CCE7EE21A411A9A00447C4C /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
    45554558                                2DADF26321CB8F32003D3E3A /* GetResourceData.mm in Sources */,
     4559                                41157237234B240C0050A1D1 /* GetUserMedia.mm in Sources */,
    45564560                                07CE1CF31F06A7E000BF89F5 /* GetUserMediaNavigation.mm in Sources */,
    45574561                                07E499911F9E56DF002F1EF3 /* GetUserMediaReprompt.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/getUserMedia.html

    r246093 r250774  
    5151                navigator.mediaDevices.getUserMedia({audio: true, video: true});
    5252            }
     53
     54            function captureAudio()
     55            {
     56                navigator.mediaDevices.getUserMedia({audio: true}).then(s => stream = s);
     57            }
     58
     59            function captureAudioAndVideo()
     60            {
     61                navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(s => stream = s);
     62            }
    5363        </script>
    5464    <head>
Note: See TracChangeset for help on using the changeset viewer.