Title: [262793] trunk
Revision
262793
Author
[email protected]
Date
2020-06-09 08:35:15 -0700 (Tue, 09 Jun 2020)

Log Message

Fix two MediaStream tests
https://bugs.webkit.org/show_bug.cgi?id=208926
<rdar://problem/60329008>

Reviewed by Eric Carlson.

Source/WebCore:

Previously, the mock capture sample rate was the one of the mock audio shared unit, which is the sample rate of the audio session by default.
This sample rate may change according the bots.
For that reason, explicitly set the mock shared unit sample rate to the default sample rate of the device, just before creating the source.
MediaConstraints may still apply after this step.

Fix an issue where we would use the real core audio unit in CoreAudioCaptureSource constructor.
We now pass the unit override if any in constructor.

Covered by unflaked tests.

* platform/mediastream/mac/BaseAudioSharedUnit.cpp:
(WebCore::BaseAudioSharedUnit::BaseAudioSharedUnit):
* platform/mediastream/mac/BaseAudioSharedUnit.h:
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::initializeCoreAudioCaptureSource):
(WebCore::CoreAudioSharedUnit::CoreAudioSharedUnit):
(WebCore::CoreAudioCaptureSource::create):
(WebCore::CoreAudioCaptureSource::createForTesting):
(WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource):
* platform/mediastream/mac/CoreAudioCaptureSource.h:
* platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockRealtimeAudioSource::create):
(WebCore::MockAudioSharedUnit::MockAudioSharedUnit):
Do not disable echo cancellation to mimick what the real unit is doing.

LayoutTests:

* fast/mediastream/MediaStreamTrack-getSettings-expected.txt:
* fast/mediastream/MediaStreamTrack-getSettings.html:
* platform/mac-wk2/TestExpectations:
Unskip tests.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (262792 => 262793)


--- trunk/LayoutTests/ChangeLog	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/LayoutTests/ChangeLog	2020-06-09 15:35:15 UTC (rev 262793)
@@ -1,3 +1,16 @@
+2020-06-09  Youenn Fablet  <[email protected]>
+
+        Fix two MediaStream tests
+        https://bugs.webkit.org/show_bug.cgi?id=208926
+        <rdar://problem/60329008>
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/MediaStreamTrack-getSettings-expected.txt:
+        * fast/mediastream/MediaStreamTrack-getSettings.html:
+        * platform/mac-wk2/TestExpectations:
+        Unskip tests.
+
 2020-06-09  Zalan Bujtas  <[email protected]>
 
         [LFC][Table][Floats] Multi-pass table layout needs clean floating state

Modified: trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings-expected.txt (262792 => 262793)


--- trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings-expected.txt	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings-expected.txt	2020-06-09 15:35:15 UTC (rev 262793)
@@ -27,6 +27,13 @@
 PASS "echoCancellation" in track.getCapabilities() is true
 PASS "sampleRate" in track.getCapabilities() is true
 PASS "volume" in track.getCapabilities() is true
+Validate sampleRate constraints appears correctly in track settings
+audio track settings:
+  settings.deviceId = <UUID>
+  settings.echoCancellation = true
+  settings.sampleRate = 48000
+  settings.volume = 1
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html (262792 => 262793)


--- trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html	2020-06-09 15:35:15 UTC (rev 262793)
@@ -54,6 +54,11 @@
                 debug('According to the spec: "[every setting] MUST be a member of the set defined for that property by getCapabilities()"<br>');
                 checkTrackSettings(stream.getVideoTracks()[0]);
                 checkTrackSettings(stream.getAudioTracks()[0]);
+
+                debug('Validate sampleRate constraints appears correctly in track settings');
+                stream = await navigator.mediaDevices.getUserMedia({audio: { sampleRate : 48000 } });
+                listTrackSettings(stream.getAudioTracks()[0]);
+
                 finishJSTest();
             }
 

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (262792 => 262793)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2020-06-09 15:35:15 UTC (rev 262793)
@@ -823,10 +823,6 @@
 
 webkit.org/b/194826 http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html [ Pass Timeout ]
 
-webkit.org/b/194916 fast/mediastream/MediaStream-video-element.html [ Pass Failure ]
-
-webkit.org/b/196400 fast/mediastream/MediaStreamTrack-getSettings.html [ Pass Failure ]
-
 webkit.org/b/196403 imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html [ Pass Failure ]
 
 webkit.org/b/187391 accessibility/mac/async-increment-decrement-action.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (262792 => 262793)


--- trunk/Source/WebCore/ChangeLog	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/ChangeLog	2020-06-09 15:35:15 UTC (rev 262793)
@@ -1,3 +1,36 @@
+2020-06-09  Youenn Fablet  <[email protected]>
+
+        Fix two MediaStream tests
+        https://bugs.webkit.org/show_bug.cgi?id=208926
+        <rdar://problem/60329008>
+
+        Reviewed by Eric Carlson.
+
+        Previously, the mock capture sample rate was the one of the mock audio shared unit, which is the sample rate of the audio session by default.
+        This sample rate may change according the bots.
+        For that reason, explicitly set the mock shared unit sample rate to the default sample rate of the device, just before creating the source.
+        MediaConstraints may still apply after this step.
+
+        Fix an issue where we would use the real core audio unit in CoreAudioCaptureSource constructor.
+        We now pass the unit override if any in constructor.
+
+        Covered by unflaked tests.
+
+        * platform/mediastream/mac/BaseAudioSharedUnit.cpp:
+        (WebCore::BaseAudioSharedUnit::BaseAudioSharedUnit):
+        * platform/mediastream/mac/BaseAudioSharedUnit.h:
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::initializeCoreAudioCaptureSource):
+        (WebCore::CoreAudioSharedUnit::CoreAudioSharedUnit):
+        (WebCore::CoreAudioCaptureSource::create):
+        (WebCore::CoreAudioCaptureSource::createForTesting):
+        (WebCore::CoreAudioCaptureSource::CoreAudioCaptureSource):
+        * platform/mediastream/mac/CoreAudioCaptureSource.h:
+        * platform/mediastream/mac/MockAudioSharedUnit.mm:
+        (WebCore::MockRealtimeAudioSource::create):
+        (WebCore::MockAudioSharedUnit::MockAudioSharedUnit):
+        Do not disable echo cancellation to mimick what the real unit is doing.
+
 2020-06-09  Zalan Bujtas  <[email protected]>
 
         [LFC][Table][Floats] Multi-pass table layout needs clean floating state

Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp (262792 => 262793)


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2020-06-09 15:35:15 UTC (rev 262793)
@@ -36,6 +36,11 @@
 
 namespace WebCore {
 
+BaseAudioSharedUnit::BaseAudioSharedUnit()
+    : m_sampleRate(AudioSession::sharedSession().sampleRate())
+{
+}
+
 void BaseAudioSharedUnit::addClient(CoreAudioCaptureSource& client)
 {
     auto locker = holdLock(m_clientsLock);

Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h (262792 => 262793)


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2020-06-09 15:35:15 UTC (rev 262793)
@@ -43,6 +43,7 @@
 
 class BaseAudioSharedUnit {
 public:
+    BaseAudioSharedUnit();
     virtual ~BaseAudioSharedUnit() = default;
 
     void startProducingData();

Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (262792 => 262793)


--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2020-06-09 15:35:15 UTC (rev 262793)
@@ -158,7 +158,6 @@
 CoreAudioSharedUnit::CoreAudioSharedUnit()
     : m_verifyCapturingTimer(*this, &CoreAudioSharedUnit::verifyIsCapturing)
 {
-    setSampleRate(AudioSession::sharedSession().sampleRate());
 }
 
 void CoreAudioSharedUnit::setCaptureDevice(String&& persistentID, uint32_t captureDeviceID)
@@ -591,12 +590,6 @@
 
 static CaptureSourceOrError initializeCoreAudioCaptureSource(Ref<CoreAudioCaptureSource>&& source, const MediaConstraints* constraints)
 {
-#if PLATFORM(IOS_FAMILY)
-    // We ensure that we unsuspend ourselves on the constructor as a capture source
-    // is created when getUserMedia grants access which only happens when the process is foregrounded.
-    CoreAudioSharedUnit::singleton().prepareForNewCapture();
-#endif
-
     if (constraints) {
         if (auto result = source->applyConstraints(*constraints))
             return WTFMove(result->badConstraint);
@@ -618,6 +611,10 @@
         return { };
 
     auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), String { device->label() }, WTFMove(hashSalt), 0));
+
+    // We ensure that we unsuspend ourselves on the constructor as a capture source
+    // is created when getUserMedia grants access which only happens when the process is foregrounded.
+    source->unit().prepareForNewCapture();
 #endif
     return initializeCoreAudioCaptureSource(WTFMove(source), constraints);
 }
@@ -624,9 +621,7 @@
 
 CaptureSourceOrError CoreAudioCaptureSource::createForTesting(String&& deviceID, String&& label, String&& hashSalt, const MediaConstraints* constraints, BaseAudioSharedUnit& overrideUnit)
 {
-    auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), WTFMove(label), WTFMove(hashSalt), 0));
-
-    source->m_overrideUnit = &overrideUnit;
+    auto source = adoptRef(*new CoreAudioCaptureSource(WTFMove(deviceID), WTFMove(label), WTFMove(hashSalt), 0, &overrideUnit));
     return initializeCoreAudioCaptureSource(WTFMove(source), constraints);
 }
 
@@ -692,9 +687,10 @@
     CoreAudioSharedUnit::unit().devicesChanged(devices);
 }
 
-CoreAudioCaptureSource::CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t captureDeviceID)
+CoreAudioCaptureSource::CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t captureDeviceID, BaseAudioSharedUnit* overrideUnit)
     : RealtimeMediaSource(RealtimeMediaSource::Type::Audio, WTFMove(label), WTFMove(deviceID), WTFMove(hashSalt))
     , m_captureDeviceID(captureDeviceID)
+    , m_overrideUnit(overrideUnit)
 {
     auto& unit = this->unit();
     initializeEchoCancellation(unit.enableEchoCancellation());

Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h (262792 => 262793)


--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.h	2020-06-09 15:35:15 UTC (rev 262793)
@@ -63,7 +63,7 @@
     CMClockRef timebaseClock();
 
 protected:
-    CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID);
+    CoreAudioCaptureSource(String&& deviceID, String&& label, String&& hashSalt, uint32_t persistentID, BaseAudioSharedUnit* = nullptr);
     virtual ~CoreAudioCaptureSource();
     BaseAudioSharedUnit& unit();
     const BaseAudioSharedUnit& unit() const;

Modified: trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm (262792 => 262793)


--- trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2020-06-09 15:17:01 UTC (rev 262792)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2020-06-09 15:35:15 UTC (rev 262793)
@@ -89,12 +89,12 @@
 
 CaptureSourceOrError MockRealtimeAudioSource::create(String&& deviceID, String&& name, String&& hashSalt, const MediaConstraints* constraints)
 {
-#ifndef NDEBUG
     auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(deviceID);
     ASSERT(device);
     if (!device)
         return { "No mock microphone device"_s };
-#endif
+
+    MockAudioSharedUnit::singleton().setSampleRate(WTF::get<MockMicrophoneProperties>(device->properties).defaultSampleRate);
     return CoreAudioCaptureSource::createForTesting(WTFMove(deviceID),  WTFMove(name), WTFMove(hashSalt), constraints, MockAudioSharedUnit::singleton());
 }
 
@@ -108,8 +108,6 @@
     : m_timer(RunLoop::current(), this, &MockAudioSharedUnit::tick)
     , m_workQueue(WorkQueue::create("MockAudioSharedUnit Capture Queue"))
 {
-    setSampleRate(AudioSession::sharedSession().sampleRate());
-    setEnableEchoCancellation(false);
 }
 
 bool MockAudioSharedUnit::hasAudioUnit() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to