Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 78a2a01. rdar://problem/100335624
[iOS] Fire configurationchange event in case of switching automatically to another microphone while capturing https://bugs.webkit.org/show_bug.cgi?id=244535 rdar://problem/99331061 Reviewed by Eric Carlson. On iOS, the user may change of audio device through control center, while capturing. In that case, the microphone automatically switches to the new device. To expose this to the WebPage, we can use configurationchange event. The flow is: - AVAudioSessionCaptureDeviceManager detects microphone change - CoreAudioSharedUnit notifies CoreAudioCaptureSource in GPUProcess. - UserMediaCaptureManagerProxy is notified by CoreAudioCaptureSource and notifies UserMediaCaptureManager through IPC. - UserMediaCaptureManager in WebProcess notifies its source which notifies its MediaStreamTrack(s). - At the same time, settings and capabilities are updated. We add a mock API to test this code path. Covered by LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html. * LayoutTests/fast/mediastream/mediastreamtrack-configurationchange-expected.txt: Added. * LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html: Added. * Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp: (WebCore::MediaStreamTrack::trackConfigurationChanged): * Source/WebCore/Modules/mediastream/MediaStreamTrack.h: * Source/WebCore/Modules/mediastream/MediaStreamTrack.idl: * Source/WebCore/dom/EventNames.h: * Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.cpp: (WebCore::MediaStreamTrackPrivate::sourceConfigurationChanged): * Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h: * Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp: (WebCore::RealtimeMediaSource::RealtimeMediaSource): (WebCore::RealtimeMediaSource::setPersistentId): (WebCore::RealtimeMediaSource::initializePersistentId): * Source/WebCore/platform/mediastream/RealtimeMediaSource.h: * Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: * Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm: (WebCore::AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices const): * Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp: (WebCore::BaseAudioSharedUnit::handleNewCurrentMicrophoneDevice): * Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h: * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSource::handleNewCurrentMicrophoneDevice): * Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h: * Source/WebCore/platform/mediastream/mac/RealtimeMediaSourceCenterMac.mm: (WebCore::RealtimeMediaSourceCenter::shouldInterruptAudioOnPageVisibilityChange): * Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::triggerMockMicrophoneConfigurationChange): * Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.h: * Source/WebKit/GPUProcess/GPUProcess.cpp: (WebKit::GPUProcess::triggerMockMicrophoneConfigurationChange): * Source/WebKit/GPUProcess/GPUProcess.h: * Source/WebKit/GPUProcess/GPUProcess.messages.in: * Source/WebKit/UIProcess/API/C/WKPage.cpp: (WKPageTriggerMockMicrophoneConfigurationChange): * Source/WebKit/UIProcess/API/C/WKPagePrivate.h: * Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: * Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp: (WebKit::GPUProcessProxy::triggerMockMicrophoneConfigurationChange): * Source/WebKit/UIProcess/GPU/GPUProcessProxy.h: * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSource.cpp: (WebKit::RemoteRealtimeMediaSource::configurationChanged): * Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSource.h: * Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::sourceConfigurationChanged): * Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.h: * Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.messages.in: * Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::triggerMockMicrophoneConfigurationChange): * Tools/WebKitTestRunner/InjectedBundle/TestRunner.h: * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::triggerMockMicrophoneConfigurationChange): * Tools/WebKitTestRunner/TestController.h: * Tools/WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): Canonical link: https://commits.webkit.org/254035@main Canonical link: https://commits.webkit.org/252432.808@safari-7614.3.7.1-branch
- Loading branch information
Showing
39 changed files
with
219 additions
and
4 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
LayoutTests/fast/mediastream/mediastreamtrack-configurationchange-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
PASS Trigger configurationchange event in case OS changes microphone on its own | ||
|
35 changes: 35 additions & 0 deletions
35
LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>configurationchange event.</title> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id=video playsInline autoplay></video> | ||
<script> | ||
promise_test(async (t) => { | ||
if (!window.testRunner) | ||
return; | ||
|
||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); | ||
const track = stream.getAudioTracks()[0]; | ||
|
||
video.srcObject = stream; | ||
await video.play(); | ||
|
||
assert_equals(track.label, "Mock audio device 1"); | ||
|
||
testRunner.triggerMockMicrophoneConfigurationChange(); | ||
|
||
await new Promise((resolve, reject) => { | ||
track.onconfigurationchange = resolve; | ||
setTimeout(()=> reject("waited too long for configurationchange"), 5000); | ||
}); | ||
|
||
assert_equals(track.label, "Mock audio device 2"); | ||
}, "Trigger configurationchange event in case OS changes microphone on its own"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.