Diff
Modified: trunk/LayoutTests/ChangeLog (135984 => 135985)
--- trunk/LayoutTests/ChangeLog 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/LayoutTests/ChangeLog 2012-11-28 09:04:25 UTC (rev 135985)
@@ -1,3 +1,13 @@
+2012-11-28 Tommy Widenflycht <[email protected]>
+
+ Add basic implementation for MediaStreamAudioDestinationNode
+ https://bugs.webkit.org/show_bug.cgi?id=101815
+
+ Reviewed by Chris Rogers.
+
+ * webaudio/mediastreamaudiodestinationnode-expected.txt: Added.
+ * webaudio/mediastreamaudiodestinationnode.html: Added.
+
2012-11-28 Jaehun Lim <[email protected]>
[EFL][WK1] Gardening AC testcases in efl-wk1
Added: trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode-expected.txt (0 => 135985)
--- trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode-expected.txt (rev 0)
+++ trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode-expected.txt 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,9 @@
+Basic tests for MediaStreamAudioDestinationNode API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS Destination AudioNode has one input.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode.html (0 => 135985)
--- trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode.html (rev 0)
+++ trunk/LayoutTests/webaudio/mediastreamaudiodestinationnode.html 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Basic tests for MediaStreamAudioDestinationNode API.");
+
+var context = 0;
+
+function runTest() {
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ }
+
+ context = new webkitAudioContext();
+
+ var mediaStreamDestination = context.createMediaStreamDestination();
+
+ // Check number of inputs and outputs.
+ if (mediaStreamDestination.numberOfInputs == 1)
+ testPassed("Destination AudioNode has one input.");
+ else
+ testFailed("Destination AudioNode should have one input.");
+
+ // FIXME: We should have no outputs, but since we're implemented using AudioBasicInspectorNode
+ // we have one.
+ // if (mediaStreamDestination.numberOfOutputs == 0)
+ // testPassed("Destination AudioNode has no outputs.");
+ // else
+ // testFailed("Destination AudioNode should not have outputs.");
+
+ // FIXME: add a test where we create a PeerConnection and call addStream(mediaStreamDestination.stream).
+
+ finishJSTest();
+}
+
+runTest();
+window.successfullyParsed = true;
+
+</script>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/Platform/ChangeLog (135984 => 135985)
--- trunk/Source/Platform/ChangeLog 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/Platform/ChangeLog 2012-11-28 09:04:25 UTC (rev 135985)
@@ -1,3 +1,20 @@
+2012-11-28 Tommy Widenflycht <[email protected]>
+
+ Add basic implementation for MediaStreamAudioDestinationNode
+ https://bugs.webkit.org/show_bug.cgi?id=101815
+
+ Reviewed by Chris Rogers.
+
+ Adds the consumer interface and related functionality to WebMediaStreamSource.
+
+ * chromium/public/WebAudioDestinationConsumer.h: Added.
+ (WebKit):
+ (WebAudioDestinationConsumer):
+ (WebKit::WebAudioDestinationConsumer::~WebAudioDestinationConsumer):
+ * chromium/public/WebMediaStreamSource.h:
+ (WebKit):
+ (WebMediaStreamSource):
+
2012-11-27 Eberhard Graether <[email protected]>
[chromium] Add WebLayerTreeViewClient API to request font atlas
Added: trunk/Source/Platform/chromium/public/WebAudioDestinationConsumer.h (0 => 135985)
--- trunk/Source/Platform/chromium/public/WebAudioDestinationConsumer.h (rev 0)
+++ trunk/Source/Platform/chromium/public/WebAudioDestinationConsumer.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ */
+
+#ifndef WebAudioDestinationConsumer_h
+#define WebAudioDestinationConsumer_h
+
+#include "WebVector.h"
+
+namespace WebKit {
+
+class WebAudioDestinationConsumer {
+public:
+ virtual ~WebAudioDestinationConsumer() { }
+
+ // The size of the vector is the number of audio channels, and numberOfFrames is the
+ // number of audio frames in the (possibly multi-channel) buffer in a planar format.
+ virtual void consumeAudio(const WebVector<const float*>&, size_t numberOfFrames) = 0;
+};
+
+} // namespace WebKit
+
+#endif // WebAudioDestinationConsumer_h
Modified: trunk/Source/Platform/chromium/public/WebMediaStreamSource.h (135984 => 135985)
--- trunk/Source/Platform/chromium/public/WebMediaStreamSource.h 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/Platform/chromium/public/WebMediaStreamSource.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -34,13 +34,14 @@
#include "WebCommon.h"
#include "WebNonCopyable.h"
#include "WebPrivatePtr.h"
+#include "WebVector.h"
namespace WebCore {
class MediaStreamSource;
}
namespace WebKit {
-
+class WebAudioDestinationConsumer;
class WebString;
class WebMediaStreamSource {
@@ -91,6 +92,13 @@
WEBKIT_EXPORT ExtraData* extraData() const;
WEBKIT_EXPORT void setExtraData(ExtraData*);
+ // Only used if if this is a WebAudio source.
+ // The WebAudioDestinationConsumer is not owned, and has to be disposed of separately
+ // after calling removeAudioConsumer.
+ WEBKIT_EXPORT bool requiresAudioConsumer() const;
+ WEBKIT_EXPORT void addAudioConsumer(WebAudioDestinationConsumer*);
+ WEBKIT_EXPORT bool removeAudioConsumer(WebAudioDestinationConsumer*);
+
#if WEBKIT_IMPLEMENTATION
WebMediaStreamSource(const WTF::PassRefPtr<WebCore::MediaStreamSource>&);
WebMediaStreamSource& operator=(WebCore::MediaStreamSource*);
Modified: trunk/Source/WebCore/ChangeLog (135984 => 135985)
--- trunk/Source/WebCore/ChangeLog 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/ChangeLog 2012-11-28 09:04:25 UTC (rev 135985)
@@ -1,3 +1,68 @@
+2012-11-28 Tommy Widenflycht <[email protected]>
+
+ Add basic implementation for MediaStreamAudioDestinationNode
+ https://bugs.webkit.org/show_bug.cgi?id=101815
+
+ Reviewed by Chris Rogers.
+
+ Implements an audio destination node which has a MediaStream.
+ This can be added to a PeerConnection with peerConnection.addStream().
+ Please see use case (3):
+ https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/webrtc-integration.html
+
+ Test: webaudio/mediastreamaudiodestinationnode.html
+
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore):
+ (WebCore::AudioContext::createMediaStreamDestination):
+ * Modules/webaudio/AudioContext.h:
+ (WebCore):
+ (AudioContext):
+ * Modules/webaudio/AudioContext.idl:
+ * Modules/webaudio/AudioNode.h:
+ * Modules/webaudio/MediaStreamAudioDestinationNode.cpp: Added.
+ (WebCore):
+ (WebCore::MediaStreamAudioDestinationNode::create):
+ (WebCore::MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode):
+ (WebCore::MediaStreamAudioDestinationNode::mediaStreamSource):
+ (WebCore::MediaStreamAudioDestinationNode::~MediaStreamAudioDestinationNode):
+ (WebCore::MediaStreamAudioDestinationNode::process):
+ (WebCore::MediaStreamAudioDestinationNode::reset):
+ * Modules/webaudio/MediaStreamAudioDestinationNode.h: Added.
+ (WebCore):
+ (MediaStreamAudioDestinationNode):
+ (WebCore::MediaStreamAudioDestinationNode::stream):
+ * Modules/webaudio/MediaStreamAudioDestinationNode.idl: Added.
+ * WebCore.gypi:
+ * platform/audio/AudioDestinationConsumer.h: Copied from Source/WebCore/platform/mediastream/MediaStreamSource.cpp.
+ (WebCore):
+ (AudioDestinationConsumer):
+ (WebCore::AudioDestinationConsumer::~AudioDestinationConsumer):
+ * platform/chromium/support/WebMediaStreamSource.cpp:
+ (WebKit::WebMediaStreamSource::extraData):
+ (WebKit::WebMediaStreamSource::setExtraData):
+ (WebKit::WebMediaStreamSource::requiresAudioConsumer):
+ (WebKit):
+ (ConsumerWrapper):
+ (WebKit::ConsumerWrapper::create):
+ (WebKit::ConsumerWrapper::consumer):
+ (WebKit::ConsumerWrapper::ConsumerWrapper):
+ (WebKit::ConsumerWrapper::consumeAudio):
+ (WebKit::WebMediaStreamSource::addAudioConsumer):
+ (WebKit::WebMediaStreamSource::removeAudioConsumer):
+ * platform/mediastream/MediaStreamSource.cpp:
+ (WebCore::MediaStreamSource::create):
+ (WebCore::MediaStreamSource::MediaStreamSource):
+ (WebCore::MediaStreamSource::addAudioConsumer):
+ (WebCore):
+ (WebCore::MediaStreamSource::removeAudioConsumer):
+ (WebCore::MediaStreamSource::consumeAudio):
+ * platform/mediastream/MediaStreamSource.h:
+ (WebCore):
+ (MediaStreamSource):
+ (WebCore::MediaStreamSource::requiresAudioConsumer):
+ (WebCore::MediaStreamSource::audioConsumers):
+
2012-11-27 Mike West <[email protected]>
Improve WebSocketChannel connection failure console messages.
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (135984 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp 2012-11-28 09:04:25 UTC (rev 135985)
@@ -63,6 +63,7 @@
#if ENABLE(MEDIA_STREAM)
#include "MediaStream.h"
+#include "MediaStreamAudioDestinationNode.h"
#include "MediaStreamAudioSourceNode.h"
#endif
@@ -430,6 +431,14 @@
refNode(node.get()); // context keeps reference until node is disconnected
return node;
}
+
+PassRefPtr<MediaStreamAudioDestinationNode> AudioContext::createMediaStreamDestination()
+{
+ // FIXME: Add support for an optional argument which specifies the number of channels.
+ // FIXME: The default should probably be stereo instead of mono.
+ return MediaStreamAudioDestinationNode::create(this, 1);
+}
+
#endif
PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t bufferSize, ExceptionCode& ec)
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (135984 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -49,6 +49,7 @@
class AudioBufferCallback;
class AudioBufferSourceNode;
class MediaElementAudioSourceNode;
+class MediaStreamAudioDestinationNode;
class MediaStreamAudioSourceNode;
class HTMLMediaElement;
class ChannelMergerNode;
@@ -118,6 +119,7 @@
#endif
#if ENABLE(MEDIA_STREAM)
PassRefPtr<MediaStreamAudioSourceNode> createMediaStreamSource(MediaStream*, ExceptionCode&);
+ PassRefPtr<MediaStreamAudioDestinationNode> createMediaStreamDestination();
#endif
PassRefPtr<GainNode> createGain();
PassRefPtr<BiquadFilterNode> createBiquadFilter();
Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.idl (135984 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/AudioContext.idl 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.idl 2012-11-28 09:04:25 UTC (rev 135985)
@@ -66,6 +66,7 @@
#if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
MediaStreamAudioSourceNode createMediaStreamSource(in MediaStream mediaStream)
raises(DOMException);
+ MediaStreamAudioDestinationNode createMediaStreamDestination();
#endif
// Processing nodes
Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.h (135984 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/AudioNode.h 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -64,6 +64,7 @@
NodeTypeOscillator,
NodeTypeAudioBufferSource,
NodeTypeMediaElementAudioSource,
+ NodeTypeMediaStreamAudioDestination,
NodeTypeMediaStreamAudioSource,
NodeTypeJavaScript,
NodeTypeBiquadFilter,
Added: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp (0 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.cpp 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2012, Google 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#include "MediaStreamAudioDestinationNode.h"
+
+#include "AudioContext.h"
+#include "AudioNodeInput.h"
+#include "LocalMediaStream.h"
+#include "MediaStreamCenter.h"
+#include "RTCPeerConnectionHandler.h"
+#include "UUID.h"
+#include <wtf/Locker.h>
+
+namespace WebCore {
+
+PassRefPtr<MediaStreamAudioDestinationNode> MediaStreamAudioDestinationNode::create(AudioContext* context, size_t numberOfChannels)
+{
+ return adoptRef(new MediaStreamAudioDestinationNode(context, numberOfChannels));
+}
+
+MediaStreamAudioDestinationNode::MediaStreamAudioDestinationNode(AudioContext* context, size_t numberOfChannels)
+ : AudioBasicInspectorNode(context, context->sampleRate())
+ , m_mixBus(numberOfChannels, ProcessingSizeInFrames)
+{
+ setNodeType(NodeTypeMediaStreamAudioDestination);
+
+ m_source = MediaStreamSource::create(ASCIILiteral("WebAudio-") + createCanonicalUUIDString(), MediaStreamSource::TypeAudio, "MediaStreamAudioDestinationNode", MediaStreamSource::ReadyStateLive, true);
+ MediaStreamSourceVector audioSources;
+ audioSources.append(m_source);
+ MediaStreamSourceVector videoSources;
+ m_stream = LocalMediaStream::create(context->scriptExecutionContext(), audioSources, videoSources);
+ MediaStreamCenter::instance().didCreateMediaStream(m_stream->descriptor());
+
+ initialize();
+}
+
+MediaStreamSource* MediaStreamAudioDestinationNode::mediaStreamSource()
+{
+ return m_source.get();
+}
+
+MediaStreamAudioDestinationNode::~MediaStreamAudioDestinationNode()
+{
+ uninitialize();
+}
+
+void MediaStreamAudioDestinationNode::process(size_t numberOfFrames)
+{
+ m_mixBus.copyFrom(*input(0)->bus());
+ m_source->consumeAudio(&m_mixBus, numberOfFrames);
+}
+
+void MediaStreamAudioDestinationNode::reset()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
Added: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.h (0 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.h (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012, Google 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.
+ */
+
+#ifndef MediaStreamAudioDestinationNode_h
+#define MediaStreamAudioDestinationNode_h
+
+#if ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#include "AudioBasicInspectorNode.h"
+#include "AudioBus.h"
+#include "MediaStream.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class AudioContext;
+
+class MediaStreamAudioDestinationNode : public AudioBasicInspectorNode {
+public:
+ static PassRefPtr<MediaStreamAudioDestinationNode> create(AudioContext*, size_t numberOfChannels);
+
+ virtual ~MediaStreamAudioDestinationNode();
+
+ MediaStream* stream() { return m_stream.get(); }
+
+ // AudioNode.
+ virtual void process(size_t framesToProcess);
+ virtual void reset();
+
+ MediaStreamSource* mediaStreamSource();
+
+private:
+ MediaStreamAudioDestinationNode(AudioContext*, size_t numberOfChannels);
+
+ virtual double tailTime() const OVERRIDE { return 0; }
+ virtual double latencyTime() const OVERRIDE { return 0; }
+
+ // As an audio source, we will never propagate silence.
+ virtual bool propagatesSilence() const OVERRIDE { return false; }
+
+ RefPtr<MediaStream> m_stream;
+ RefPtr<MediaStreamSource> m_source;
+ AudioBus m_mixBus;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO) && ENABLE(MEDIA_STREAM)
+
+#endif // MediaStreamAudioDestinationNode_h
Added: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.idl (0 => 135985)
--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.idl (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioDestinationNode.idl 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012, Google 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,
+ JSGenerateToJSObject
+] interface MediaStreamAudioDestinationNode : AudioSourceNode {
+ readonly attribute MediaStream stream;
+};
Modified: trunk/Source/WebCore/WebCore.gypi (135984 => 135985)
--- trunk/Source/WebCore/WebCore.gypi 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/WebCore.gypi 2012-11-28 09:04:25 UTC (rev 135985)
@@ -920,6 +920,7 @@
'Modules/webaudio/DynamicsCompressorNode.idl',
'Modules/webaudio/ScriptProcessorNode.idl',
'Modules/webaudio/MediaElementAudioSourceNode.idl',
+ 'Modules/webaudio/MediaStreamAudioDestinationNode.idl',
'Modules/webaudio/MediaStreamAudioSourceNode.idl',
'Modules/webaudio/OfflineAudioCompletionEvent.idl',
'Modules/webaudio/OscillatorNode.idl',
@@ -1746,6 +1747,8 @@
'Modules/webaudio/ScriptProcessorNode.h',
'Modules/webaudio/MediaElementAudioSourceNode.cpp',
'Modules/webaudio/MediaElementAudioSourceNode.h',
+ 'Modules/webaudio/MediaStreamAudioDestinationNode.cpp',
+ 'Modules/webaudio/MediaStreamAudioDestinationNode.h',
'Modules/webaudio/MediaStreamAudioSourceNode.cpp',
'Modules/webaudio/MediaStreamAudioSourceNode.h',
'Modules/webaudio/OfflineAudioCompletionEvent.cpp',
Copied: trunk/Source/WebCore/platform/audio/AudioDestinationConsumer.h (from rev 135984, trunk/Source/WebCore/platform/mediastream/MediaStreamSource.cpp) (0 => 135985)
--- trunk/Source/WebCore/platform/audio/AudioDestinationConsumer.h (rev 0)
+++ trunk/Source/WebCore/platform/audio/AudioDestinationConsumer.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google 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.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef AudioDestinationConsumer_h
+#define AudioDestinationConsumer_h
+
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class AudioBus;
+
+class AudioDestinationConsumer : public RefCounted<AudioDestinationConsumer> {
+public:
+ virtual ~AudioDestinationConsumer() { }
+
+ virtual void consumeAudio(AudioBus*, size_t numberOfFrames) = 0;
+};
+
+} // WebCore
+
+#endif // AudioDestinationConsumer_h
Modified: trunk/Source/WebCore/platform/chromium/support/WebMediaStreamSource.cpp (135984 => 135985)
--- trunk/Source/WebCore/platform/chromium/support/WebMediaStreamSource.cpp 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/platform/chromium/support/WebMediaStreamSource.cpp 2012-11-28 09:04:25 UTC (rev 135985)
@@ -34,8 +34,11 @@
#include <public/WebMediaStreamSource.h>
+#include "AudioBus.h"
#include "MediaStreamSource.h"
+#include <public/WebAudioDestinationConsumer.h>
#include <public/WebString.h>
+#include <wtf/MainThread.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
@@ -121,6 +124,7 @@
WebMediaStreamSource::ExtraData* WebMediaStreamSource::extraData() const
{
+ ASSERT(!m_private.isNull());
RefPtr<MediaStreamSource::ExtraData> data = ""
if (!data)
return 0;
@@ -129,9 +133,72 @@
void WebMediaStreamSource::setExtraData(ExtraData* extraData)
{
+ ASSERT(!m_private.isNull());
m_private->setExtraData(adoptRef(new ExtraDataContainer(extraData)));
}
+bool WebMediaStreamSource::requiresAudioConsumer() const
+{
+ ASSERT(!m_private.isNull());
+ return m_private->requiresAudioConsumer();
+}
+
+class ConsumerWrapper : public WebCore::AudioDestinationConsumer {
+public:
+ static PassRefPtr<ConsumerWrapper> create(WebAudioDestinationConsumer* consumer)
+ {
+ return adoptRef(new ConsumerWrapper(consumer));
+ }
+
+ virtual void consumeAudio(AudioBus*, size_t numberOfFrames) OVERRIDE;
+
+ WebAudioDestinationConsumer* consumer() { return m_consumer; }
+
+private:
+ explicit ConsumerWrapper(WebAudioDestinationConsumer* consumer) : m_consumer(consumer) { }
+
+ // m_consumer is not owned by this class.
+ WebAudioDestinationConsumer* m_consumer;
+};
+
+void ConsumerWrapper::consumeAudio(AudioBus* bus, size_t numberOfFrames)
+{
+ if (!bus)
+ return;
+
+ // Wrap AudioBus.
+ size_t numberOfChannels = bus->numberOfChannels();
+ WebKit::WebVector<const float*> busVector(numberOfChannels);
+ for (size_t i = 0; i < numberOfChannels; ++i)
+ busVector[i] = bus->channel(i)->data();
+
+ m_consumer->consumeAudio(busVector, numberOfFrames);
+}
+
+void WebMediaStreamSource::addAudioConsumer(WebAudioDestinationConsumer* consumer)
+{
+ ASSERT(isMainThread());
+ ASSERT(!m_private.isNull() && consumer);
+
+ m_private->addAudioConsumer(ConsumerWrapper::create(consumer));
+}
+
+bool WebMediaStreamSource::removeAudioConsumer(WebAudioDestinationConsumer* consumer)
+{
+ ASSERT(isMainThread());
+ ASSERT(!m_private.isNull() && consumer);
+
+ const Vector<RefPtr<AudioDestinationConsumer> >& consumers = m_private->audioConsumers();
+ for (Vector<RefPtr<AudioDestinationConsumer> >::const_iterator it = consumers.begin(); it != consumers.end(); ++it) {
+ ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>((*it).get());
+ if (wrapper->consumer() == consumer) {
+ m_private->removeAudioConsumer(wrapper);
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace WebKit
#endif // ENABLE(MEDIA_STREAM)
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamSource.cpp (135984 => 135985)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamSource.cpp 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamSource.cpp 2012-11-28 09:04:25 UTC (rev 135985)
@@ -33,19 +33,21 @@
#if ENABLE(MEDIA_STREAM)
#include "MediaStreamSource.h"
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
-PassRefPtr<MediaStreamSource> MediaStreamSource::create(const String& id, Type type, const String& name, ReadyState readyState)
+PassRefPtr<MediaStreamSource> MediaStreamSource::create(const String& id, Type type, const String& name, ReadyState readyState, bool requiresConsumer)
{
- return adoptRef(new MediaStreamSource(id, type, name, readyState));
+ return adoptRef(new MediaStreamSource(id, type, name, readyState, requiresConsumer));
}
-MediaStreamSource::MediaStreamSource(const String& id, Type type, const String& name, ReadyState readyState)
+MediaStreamSource::MediaStreamSource(const String& id, Type type, const String& name, ReadyState readyState, bool requiresConsumer)
: m_id(id)
, m_type(type)
, m_name(name)
, m_readyState(readyState)
+ , m_requiresConsumer(requiresConsumer)
{
}
@@ -71,6 +73,33 @@
m_observers.remove(pos);
}
+void MediaStreamSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> consumer)
+{
+ ASSERT(m_requiresConsumer);
+ MutexLocker locker(m_audioConsumersLock);
+ m_audioConsumers.append(consumer);
+}
+
+bool MediaStreamSource::removeAudioConsumer(AudioDestinationConsumer* consumer)
+{
+ ASSERT(m_requiresConsumer);
+ MutexLocker locker(m_audioConsumersLock);
+ size_t pos = m_audioConsumers.find(consumer);
+ if (pos != notFound) {
+ m_audioConsumers.remove(pos);
+ return true;
+ }
+ return false;
+}
+
+void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames)
+{
+ ASSERT(m_requiresConsumer);
+ MutexLocker locker(m_audioConsumersLock);
+ for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsumers.begin(); it != m_audioConsumers.end(); ++it)
+ (*it)->consumeAudio(bus, numberOfFrames);
+}
+
} // namespace WebCore
#endif // ENABLE(MEDIA_STREAM)
Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamSource.h (135984 => 135985)
--- trunk/Source/WebCore/platform/mediastream/MediaStreamSource.h 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamSource.h 2012-11-28 09:04:25 UTC (rev 135985)
@@ -34,6 +34,7 @@
#if ENABLE(MEDIA_STREAM)
+#include "AudioDestinationConsumer.h"
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -64,7 +65,7 @@
ReadyStateEnded = 2
};
- static PassRefPtr<MediaStreamSource> create(const String& id, Type, const String& name, ReadyState = ReadyStateLive);
+ static PassRefPtr<MediaStreamSource> create(const String& id, Type, const String& name, ReadyState = ReadyStateLive, bool requiresConsumer = false);
const String& id() const { return m_id; }
Type type() const { return m_type; }
@@ -79,14 +80,24 @@
PassRefPtr<ExtraData> extraData() const { return m_extraData; }
void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; }
+ void consumeAudio(AudioBus*, size_t numberOfFrames);
+
+ bool requiresAudioConsumer() const { return m_requiresConsumer; }
+ void addAudioConsumer(PassRefPtr<AudioDestinationConsumer>);
+ bool removeAudioConsumer(AudioDestinationConsumer*);
+ const Vector<RefPtr<AudioDestinationConsumer> >& audioConsumers() { return m_audioConsumers; }
+
private:
- MediaStreamSource(const String& id, Type, const String& name, ReadyState);
+ MediaStreamSource(const String& id, Type, const String& name, ReadyState, bool requiresConsumer);
String m_id;
Type m_type;
String m_name;
ReadyState m_readyState;
+ bool m_requiresConsumer;
Vector<Observer*> m_observers;
+ Mutex m_audioConsumersLock;
+ Vector<RefPtr<AudioDestinationConsumer> > m_audioConsumers;
RefPtr<ExtraData> m_extraData;
};
Modified: trunk/Tools/ChangeLog (135984 => 135985)
--- trunk/Tools/ChangeLog 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Tools/ChangeLog 2012-11-28 09:04:25 UTC (rev 135985)
@@ -1,3 +1,17 @@
+2012-11-28 Tommy Widenflycht <[email protected]>
+
+ Add basic implementation for MediaStreamAudioDestinationNode
+ https://bugs.webkit.org/show_bug.cgi?id=101815
+
+ Reviewed by Chris Rogers.
+
+ Adds a bit of code that exercises the WebKit API.
+
+ * DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp:
+ (MockWebMediaStreamSourceConsumer):
+ (MockWebMediaStreamSourceConsumer::~MockWebMediaStreamSourceConsumer):
+ (MockWebMediaStreamCenter::didCreateMediaStream):
+
2012-11-28 Matt Falkenhagen <[email protected]>
Unreviewed. Adding myself to committers list.
Modified: trunk/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp (135984 => 135985)
--- trunk/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp 2012-11-28 09:00:52 UTC (rev 135984)
+++ trunk/Tools/DumpRenderTree/chromium/MockWebMediaStreamCenter.cpp 2012-11-28 09:04:25 UTC (rev 135985)
@@ -33,6 +33,7 @@
#include "MockWebMediaStreamCenter.h"
+#include <public/WebAudioDestinationConsumer.h>
#include <public/WebMediaStreamCenterClient.h>
#include <public/WebMediaStreamComponent.h>
#include <public/WebMediaStreamDescriptor.h>
@@ -85,8 +86,25 @@
videoComponents[i].source().setReadyState(WebMediaStreamSource::ReadyStateEnded);
}
-void MockWebMediaStreamCenter::didCreateMediaStream(WebMediaStreamDescriptor&)
+class MockWebAudioDestinationConsumer : public WebAudioDestinationConsumer {
+public:
+ virtual ~MockWebAudioDestinationConsumer() { }
+ virtual void consumeAudio(const WebVector<const float*>&, size_t number_of_frames) OVERRIDE { }
+};
+
+void MockWebMediaStreamCenter::didCreateMediaStream(WebMediaStreamDescriptor& stream)
{
+ WebVector<WebMediaStreamComponent> audioComponents;
+ stream.audioSources(audioComponents);
+ for (size_t i = 0; i < audioComponents.size(); ++i) {
+ WebMediaStreamSource source = audioComponents[i].source();
+ if (source.requiresAudioConsumer()) {
+ MockWebAudioDestinationConsumer* consumer = new MockWebAudioDestinationConsumer();
+ source.addAudioConsumer(consumer);
+ source.removeAudioConsumer(consumer);
+ delete consumer;
+ }
+ }
}
#endif // ENABLE(MEDIA_STREAM)