Title: [265342] trunk
Revision
265342
Author
cdu...@apple.com
Date
2020-08-06 13:01:30 -0700 (Thu, 06 Aug 2020)

Log Message

MediaStreamAudioSourceNode should have a constructor
https://bugs.webkit.org/show_bug.cgi?id=215225

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/webaudio/idlharness.https.window-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor-expected.txt:

Source/WebCore:

MediaStreamAudioSourceNode should have a constructor:
- https://webaudio.github.io/web-audio-api/#mediastreamaudiosourcenode

No new tests, rebaselined existing tests.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::createMediaStreamSource):
* Modules/webaudio/MediaStreamAudioSourceNode.cpp:
(WebCore::MediaStreamAudioSourceNode::create):
* Modules/webaudio/MediaStreamAudioSourceNode.h:
* Modules/webaudio/MediaStreamAudioSourceNode.idl:
* Modules/webaudio/MediaStreamAudioSourceOptions.h: Copied from Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl.
* Modules/webaudio/MediaStreamAudioSourceOptions.idl: Copied from Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl.
* Modules/webaudio/WebKitAudioContext.cpp:
(WebCore::WebKitAudioContext::createMediaStreamSource):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265341 => 265342)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-06 20:01:30 UTC (rev 265342)
@@ -1,5 +1,17 @@
 2020-08-06  Chris Dumez  <cdu...@apple.com>
 
+        MediaStreamAudioSourceNode should have a constructor
+        https://bugs.webkit.org/show_bug.cgi?id=215225
+
+        Reviewed by Eric Carlson.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor-expected.txt:
+
+2020-08-06  Chris Dumez  <cdu...@apple.com>
+
         DynamicsCompressorNode.reduction attribute should be a float, not an AudioParam
         https://bugs.webkit.org/show_bug.cgi?id=215195
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt (265341 => 265342)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-06 20:01:30 UTC (rev 265342)
@@ -855,7 +855,7 @@
 FAIL AudioNode interface: new MediaStreamAudioDestinationNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new MediaStreamAudioDestinationNode(context)')"
 FAIL AudioNode interface: new MediaStreamAudioDestinationNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new MediaStreamAudioDestinationNode(context)')"
 PASS MediaStreamAudioSourceNode interface: existence and properties of interface object 
-FAIL MediaStreamAudioSourceNode interface object length assert_equals: wrong value for MediaStreamAudioSourceNode.length expected 2 but got 0
+PASS MediaStreamAudioSourceNode interface object length 
 PASS MediaStreamAudioSourceNode interface object name 
 PASS MediaStreamAudioSourceNode interface: existence and properties of interface prototype object 
 PASS MediaStreamAudioSourceNode interface: existence and properties of interface prototype object's "constructor" property 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor-expected.txt (265341 => 265342)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor-expected.txt	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor-expected.txt	2020-08-06 20:01:30 UTC (rev 265342)
@@ -1,16 +1,6 @@
 
 PASS MediaStreamAudioSourceNode created with factory method and MediaStream with no tracks 
-FAIL MediaStreamAudioSourceNode created with constructor and MediaStream with no tracks assert_throws_dom: A MediaStreamAudioSourceNode can only be constructed via the constructor
-          with a MediaStream that has at least one track of kind "audio" function "function () {
-              new MediaStreamAudioSourceNode(ac, { mediaStream: emptyStream });
-            }" threw object "TypeError: function is not a constructor (evaluating 'new MediaStreamAudioSourceNode(ac, { mediaStream: emptyStream })')" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
+PASS MediaStreamAudioSourceNode created with constructor and MediaStream with no tracks 
 PASS MediaStreamAudioSourceNode created with the factory method and MediaStream with only a video track 
-FAIL MediaStreamAudioSourceNode created with constructor and MediaStream with only a video track assert_throws_dom: A MediaStreamAudioSourceNode can only be constructed via the factory with a
-          MediaStream that has at least one track of kind "audio" function "function () {
-              new MediaStreamAudioSourceNode(ac, {
-                mediaStream: videoOnlyStream,
-              });
-            }" threw object "TypeError: function is not a constructor (evaluating 'new MediaStreamAudioSourceNode(ac, {
-                mediaStream: videoOnlyStream,
-              })')" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
+PASS MediaStreamAudioSourceNode created with constructor and MediaStream with only a video track 
 

Modified: trunk/Source/WebCore/CMakeLists.txt (265341 => 265342)


--- trunk/Source/WebCore/CMakeLists.txt	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-08-06 20:01:30 UTC (rev 265342)
@@ -486,6 +486,7 @@
     Modules/webaudio/MediaElementAudioSourceOptions.idl
     Modules/webaudio/MediaStreamAudioDestinationNode.idl
     Modules/webaudio/MediaStreamAudioSourceNode.idl
+    Modules/webaudio/MediaStreamAudioSourceOptions.idl
     Modules/webaudio/OfflineAudioCompletionEvent.idl
     Modules/webaudio/OfflineAudioCompletionEventInit.idl
     Modules/webaudio/OfflineAudioContext.idl

Modified: trunk/Source/WebCore/ChangeLog (265341 => 265342)


--- trunk/Source/WebCore/ChangeLog	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/ChangeLog	2020-08-06 20:01:30 UTC (rev 265342)
@@ -1,3 +1,32 @@
+2020-08-06  Chris Dumez  <cdu...@apple.com>
+
+        MediaStreamAudioSourceNode should have a constructor
+        https://bugs.webkit.org/show_bug.cgi?id=215225
+
+        Reviewed by Eric Carlson.
+
+        MediaStreamAudioSourceNode should have a constructor:
+        - https://webaudio.github.io/web-audio-api/#mediastreamaudiosourcenode
+
+        No new tests, rebaselined existing tests.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::createMediaStreamSource):
+        * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
+        (WebCore::MediaStreamAudioSourceNode::create):
+        * Modules/webaudio/MediaStreamAudioSourceNode.h:
+        * Modules/webaudio/MediaStreamAudioSourceNode.idl:
+        * Modules/webaudio/MediaStreamAudioSourceOptions.h: Copied from Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl.
+        * Modules/webaudio/MediaStreamAudioSourceOptions.idl: Copied from Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl.
+        * Modules/webaudio/WebKitAudioContext.cpp:
+        (WebCore::WebKitAudioContext::createMediaStreamSource):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2020-08-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Rename LeadingExpansion and TrailingExpansion to LeftExpansion and RightExpansion

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (265341 => 265342)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-06 20:01:30 UTC (rev 265342)
@@ -335,6 +335,7 @@
 $(PROJECT_DIR)/Modules/webaudio/MediaElementAudioSourceOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/MediaStreamAudioDestinationNode.idl
 $(PROJECT_DIR)/Modules/webaudio/MediaStreamAudioSourceNode.idl
+$(PROJECT_DIR)/Modules/webaudio/MediaStreamAudioSourceOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/OfflineAudioCompletionEvent.idl
 $(PROJECT_DIR)/Modules/webaudio/OfflineAudioCompletionEventInit.idl
 $(PROJECT_DIR)/Modules/webaudio/OfflineAudioContext.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (265341 => 265342)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-06 20:01:30 UTC (rev 265342)
@@ -1116,6 +1116,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamAudioDestinationNode.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamAudioSourceNode.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamAudioSourceNode.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamAudioSourceOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamAudioSourceOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamTrack.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamTrack.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSMediaStreamTrackEvent.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (265341 => 265342)


--- trunk/Source/WebCore/DerivedSources.make	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/DerivedSources.make	2020-08-06 20:01:30 UTC (rev 265342)
@@ -418,6 +418,7 @@
     $(WebCore)/Modules/webaudio/MediaElementAudioSourceOptions.idl \
     $(WebCore)/Modules/webaudio/MediaStreamAudioDestinationNode.idl \
     $(WebCore)/Modules/webaudio/MediaStreamAudioSourceNode.idl \
+    $(WebCore)/Modules/webaudio/MediaStreamAudioSourceOptions.idl \
     $(WebCore)/Modules/webaudio/OfflineAudioCompletionEvent.idl \
     $(WebCore)/Modules/webaudio/OfflineAudioCompletionEventInit.idl \
     $(WebCore)/Modules/webaudio/OfflineAudioContext.idl \

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (265341 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-08-06 20:01:30 UTC (rev 265342)
@@ -36,6 +36,7 @@
 #include "MediaStreamAudioDestinationNode.h"
 #include "MediaStreamAudioSource.h"
 #include "MediaStreamAudioSourceNode.h"
+#include "MediaStreamAudioSourceOptions.h"
 #endif
 
 #if ENABLE(VIDEO)
@@ -128,30 +129,7 @@
 
     ASSERT(isMainThread());
 
-    if (isStopped())
-        return Exception { InvalidStateError };
-
-    auto audioTracks = mediaStream.getAudioTracks();
-    if (audioTracks.isEmpty())
-        return Exception { InvalidStateError };
-
-    MediaStreamTrack* providerTrack = nullptr;
-    for (auto& track : audioTracks) {
-        if (track->audioSourceProvider()) {
-            providerTrack = track.get();
-            break;
-        }
-    }
-    if (!providerTrack)
-        return Exception { InvalidStateError };
-
-    lazyInitialize();
-
-    auto node = MediaStreamAudioSourceNode::create(*this, mediaStream, *providerTrack);
-    node->setFormat(2, sampleRate());
-
-    refNode(node); // context keeps reference until node is disconnected
-    return node;
+    return MediaStreamAudioSourceNode::create(*this, { &mediaStream });
 }
 
 ExceptionOr<Ref<MediaStreamAudioDestinationNode>> AudioContext::createMediaStreamDestination()

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp (265341 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp	2020-08-06 20:01:30 UTC (rev 265342)
@@ -31,6 +31,7 @@
 #include "AudioContext.h"
 #include "AudioNodeOutput.h"
 #include "Logging.h"
+#include "MediaStreamAudioSourceOptions.h"
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/Locker.h>
 
@@ -38,9 +39,35 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(MediaStreamAudioSourceNode);
 
-Ref<MediaStreamAudioSourceNode> MediaStreamAudioSourceNode::create(BaseAudioContext& context, MediaStream& mediaStream, MediaStreamTrack& audioTrack)
+ExceptionOr<Ref<MediaStreamAudioSourceNode>> MediaStreamAudioSourceNode::create(BaseAudioContext& context, MediaStreamAudioSourceOptions&& options)
 {
-    return adoptRef(*new MediaStreamAudioSourceNode(context, mediaStream, audioTrack));
+    RELEASE_ASSERT(options.mediaStream);
+
+    if (context.isStopped())
+        return Exception { InvalidStateError };
+
+    auto audioTracks = options.mediaStream->getAudioTracks();
+    if (audioTracks.isEmpty())
+        return Exception { InvalidStateError, "Media stream has no audio tracks"_s };
+
+    MediaStreamTrack* providerTrack = nullptr;
+    for (auto& track : audioTracks) {
+        if (track->audioSourceProvider()) {
+            providerTrack = track.get();
+            break;
+        }
+    }
+    if (!providerTrack)
+        return Exception { InvalidStateError, "Could not find an audio track with an audio source provider"_s };
+
+    context.lazyInitialize();
+
+    auto node = adoptRef(*new MediaStreamAudioSourceNode(context, *options.mediaStream, *providerTrack));
+    node->setFormat(2, context.sampleRate());
+
+    context.refNode(node); // context keeps reference until node is disconnected
+
+    return node;
 }
 
 MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(BaseAudioContext& context, MediaStream& mediaStream, MediaStreamTrack& audioTrack)

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h (265341 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h	2020-08-06 20:01:30 UTC (rev 265342)
@@ -35,12 +35,13 @@
 namespace WebCore {
 
 class AudioContext;
+struct MediaStreamAudioSourceOptions;
 class MultiChannelResampler;
 
 class MediaStreamAudioSourceNode final : public AudioNode, public AudioSourceProviderClient {
     WTF_MAKE_ISO_ALLOCATED(MediaStreamAudioSourceNode);
 public:
-    static Ref<MediaStreamAudioSourceNode> create(BaseAudioContext&, MediaStream&, MediaStreamTrack&);
+    static ExceptionOr<Ref<MediaStreamAudioSourceNode>> create(BaseAudioContext&, MediaStreamAudioSourceOptions&&);
 
     virtual ~MediaStreamAudioSourceNode();
 

Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl (265341 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl	2020-08-06 20:01:30 UTC (rev 265342)
@@ -26,5 +26,7 @@
     Conditional=WEB_AUDIO&MEDIA_STREAM,
     JSGenerateToJSObject
 ] interface MediaStreamAudioSourceNode : AudioNode {
+    [MayThrowException, EnabledBySetting=ModernUnprefixedWebAudio] constructor (AudioContext context, MediaStreamAudioSourceOptions options);
+
     readonly attribute MediaStream mediaStream;
 };

Copied: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.h (from rev 265341, trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl) (0 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.h	2020-08-06 20:01:30 UTC (rev 265342)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#include "MediaStream.h"
+
+namespace WebCore {
+
+struct MediaStreamAudioSourceOptions {
+    RefPtr<MediaStream> mediaStream;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)

Copied: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.idl (from rev 265341, trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.idl) (0 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceOptions.idl	2020-08-06 20:01:30 UTC (rev 265342)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2020, Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=WEB_AUDIO&MEDIA_STREAM
+] dictionary MediaStreamAudioSourceOptions {
+    required MediaStream mediaStream;
+};

Modified: trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.cpp (265341 => 265342)


--- trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.cpp	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.cpp	2020-08-06 20:01:30 UTC (rev 265342)
@@ -42,6 +42,7 @@
 #include "MediaStreamAudioDestinationNode.h"
 #include "MediaStreamAudioSource.h"
 #include "MediaStreamAudioSourceNode.h"
+#include "MediaStreamAudioSourceOptions.h"
 #endif
 
 #if ENABLE(VIDEO)
@@ -112,31 +113,7 @@
     ALWAYS_LOG(LOGIDENTIFIER);
 
     ASSERT(isMainThread());
-
-    if (isStopped())
-        return Exception { InvalidStateError };
-
-    auto audioTracks = mediaStream.getAudioTracks();
-    if (audioTracks.isEmpty())
-        return Exception { InvalidStateError };
-
-    MediaStreamTrack* providerTrack = nullptr;
-    for (auto& track : audioTracks) {
-        if (track->audioSourceProvider()) {
-            providerTrack = track.get();
-            break;
-        }
-    }
-    if (!providerTrack)
-        return Exception { InvalidStateError };
-
-    lazyInitialize();
-
-    auto node = MediaStreamAudioSourceNode::create(*this, mediaStream, *providerTrack);
-    node->setFormat(2, sampleRate());
-
-    refNode(node); // context keeps reference until node is disconnected
-    return node;
+    return MediaStreamAudioSourceNode::create(*this, { &mediaStream });
 }
 
 ExceptionOr<Ref<MediaStreamAudioDestinationNode>> WebKitAudioContext::createMediaStreamDestination()

Modified: trunk/Source/WebCore/Sources.txt (265341 => 265342)


--- trunk/Source/WebCore/Sources.txt	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/Sources.txt	2020-08-06 20:01:30 UTC (rev 265342)
@@ -3087,6 +3087,7 @@
 JSMediaStream.cpp
 JSMediaStreamAudioDestinationNode.cpp
 JSMediaStreamAudioSourceNode.cpp
+JSMediaStreamAudioSourceOptions.cpp
 JSMediaStreamTrack.cpp
 JSMediaStreamTrackEvent.cpp
 JSMediaTrackConstraints.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (265341 => 265342)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-06 18:38:07 UTC (rev 265341)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-06 20:01:30 UTC (rev 265342)
@@ -2455,6 +2455,7 @@
 		834476EF1DA5BC5E002B6EC1 /* JSScrollOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8E5 /* JSScrollOptions.h */; };
 		834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */; };
 		8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; };
+		834CBFC224DC786700C2A3D8 /* MediaStreamAudioSourceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 834CBFBF24DC785500C2A3D8 /* MediaStreamAudioSourceOptions.h */; };
 		834DFAD01F7DAE5D00C2725B /* SharedStringHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 834DFACC1F7DAE5600C2725B /* SharedStringHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		8356F97F24D9F818006C3E41 /* WebKitAudioListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 8356F97E24D9F809006C3E41 /* WebKitAudioListener.h */; };
@@ -10475,6 +10476,8 @@
 		834B86A71C56E83A00F3F0E3 /* HTMLDataElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDataElement.h; sourceTree = "<group>"; };
 		834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLDataElement.h; sourceTree = "<group>"; };
 		834B86A91C56E93E00F3F0E3 /* JSHTMLDataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDataElement.cpp; sourceTree = "<group>"; };
+		834CBFBF24DC785500C2A3D8 /* MediaStreamAudioSourceOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaStreamAudioSourceOptions.h; sourceTree = "<group>"; };
+		834CBFC124DC785600C2A3D8 /* MediaStreamAudioSourceOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaStreamAudioSourceOptions.idl; sourceTree = "<group>"; };
 		834DD4F31BE08989002C9C3E /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; };
 		834DFACC1F7DAE5600C2725B /* SharedStringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedStringHash.h; sourceTree = "<group>"; };
 		834DFACE1F7DAE5700C2725B /* SharedStringHash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedStringHash.cpp; sourceTree = "<group>"; };
@@ -29637,6 +29640,8 @@
 				FD671A74159BB07000197559 /* MediaStreamAudioSourceNode.cpp */,
 				FD671A75159BB07000197559 /* MediaStreamAudioSourceNode.h */,
 				FD671A76159BB07000197559 /* MediaStreamAudioSourceNode.idl */,
+				834CBFBF24DC785500C2A3D8 /* MediaStreamAudioSourceOptions.h */,
+				834CBFC124DC785600C2A3D8 /* MediaStreamAudioSourceOptions.idl */,
 				FDA3E955134A49EF008D4B5A /* OfflineAudioCompletionEvent.cpp */,
 				FDA3E956134A49EF008D4B5A /* OfflineAudioCompletionEvent.h */,
 				FDA3E95D134A49FF008D4B5A /* OfflineAudioCompletionEvent.idl */,
@@ -32607,6 +32612,7 @@
 				078E094C17D1709600420AA1 /* MediaStreamAudioDestinationNode.h in Headers */,
 				0783228518013ED800999E0C /* MediaStreamAudioSource.h in Headers */,
 				FD671A78159BB07000197559 /* MediaStreamAudioSourceNode.h in Headers */,
+				834CBFC224DC786700C2A3D8 /* MediaStreamAudioSourceOptions.h in Headers */,
 				070F549817F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h in Headers */,
 				078E093717D16B2C00420AA1 /* MediaStreamPrivate.h in Headers */,
 				078E3CC01FE1C73C00483C1D /* MediaStreamRequest.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to