Title: [98512] trunk/Source/WebCore
Revision
98512
Author
crog...@google.com
Date
2011-10-26 12:57:36 -0700 (Wed, 26 Oct 2011)

Log Message

Add AudioSourceProviderClient and setFormat() method so we can know audio stream format
https://bugs.webkit.org/show_bug.cgi?id=70155

Reviewed by Eric Carlson.

No new tests.  There isn't yet an implementation to test.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::createMediaPlayer):
(WebCore::HTMLMediaElement::setAudioSourceNode):
Let MediaPlayer know about the MediaElementAudioSourceNode so it can callback with audio stream format information.
* platform/audio/AudioSourceProvider.h:
(WebCore::AudioSourceProvider::setClient):
Add abstract setClient() method so a client may know about stream format information when it becomes available.
* platform/audio/AudioSourceProviderClient.h: Copied from Source/WebCore/webaudio/MediaElementAudioSourceNode.h.
(WebCore::AudioSourceProviderClient::~AudioSourceProviderClient):
Add abstract class AudioSourceProviderClient which implements setFormat() to receive audio stream format information.
* webaudio/MediaElementAudioSourceNode.cpp:
(WebCore::MediaElementAudioSourceNode::setFormat):
Concrete implementation of setFormat() so MediaElementAudioSourceNode can create necessary audio converters.
* webaudio/MediaElementAudioSourceNode.h:
Make MediaElementAudioSourceNode implement AudioSourceProviderClient so it can get audio stream format information
when its setFormat() method is called.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (98511 => 98512)


--- trunk/Source/WebCore/ChangeLog	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/ChangeLog	2011-10-26 19:57:36 UTC (rev 98512)
@@ -1,3 +1,29 @@
+2011-10-26  Chris Rogers  <crog...@google.com>
+
+        Add AudioSourceProviderClient and setFormat() method so we can know audio stream format
+        https://bugs.webkit.org/show_bug.cgi?id=70155
+
+        Reviewed by Eric Carlson.
+
+        No new tests.  There isn't yet an implementation to test.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::createMediaPlayer):
+        (WebCore::HTMLMediaElement::setAudioSourceNode):
+        Let MediaPlayer know about the MediaElementAudioSourceNode so it can callback with audio stream format information.
+        * platform/audio/AudioSourceProvider.h:
+        (WebCore::AudioSourceProvider::setClient):
+        Add abstract setClient() method so a client may know about stream format information when it becomes available.
+        * platform/audio/AudioSourceProviderClient.h: Copied from Source/WebCore/webaudio/MediaElementAudioSourceNode.h.
+        (WebCore::AudioSourceProviderClient::~AudioSourceProviderClient):
+        Add abstract class AudioSourceProviderClient which implements setFormat() to receive audio stream format information.
+        * webaudio/MediaElementAudioSourceNode.cpp:
+        (WebCore::MediaElementAudioSourceNode::setFormat):
+        Concrete implementation of setFormat() so MediaElementAudioSourceNode can create necessary audio converters.
+        * webaudio/MediaElementAudioSourceNode.h:
+        Make MediaElementAudioSourceNode implement AudioSourceProviderClient so it can get audio stream format information
+        when its setFormat() method is called.
+
 2011-10-26  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Unreviewed, rolling out r98483.

Modified: trunk/Source/WebCore/WebCore.gypi (98511 => 98512)


--- trunk/Source/WebCore/WebCore.gypi	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/WebCore.gypi	2011-10-26 19:57:36 UTC (rev 98512)
@@ -3122,6 +3122,7 @@
             'platform/audio/AudioResamplerKernel.cpp',
             'platform/audio/AudioResamplerKernel.h',
             'platform/audio/AudioSourceProvider.h',
+            'platform/audio/AudioSourceProviderClient.h',
             'platform/audio/AudioUtilities.cpp',
             'platform/audio/AudioUtilities.h',
             'platform/audio/Biquad.cpp',

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (98511 => 98512)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-26 19:57:36 UTC (rev 98512)
@@ -6193,6 +6193,7 @@
 		FD5686C913AC180200B69C68 /* AsyncAudioDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD5686C713AC180200B69C68 /* AsyncAudioDecoder.cpp */; };
 		FD5686CA13AC180200B69C68 /* AsyncAudioDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FD5686C813AC180200B69C68 /* AsyncAudioDecoder.h */; };
 		FD5686CC13AC181400B69C68 /* AudioBufferCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = FD5686CB13AC181400B69C68 /* AudioBufferCallback.h */; };
+		FD62F52E145898D80094B0ED /* AudioSourceProviderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */; };
 		FD6ED2C3136B8E42003CF072 /* DynamicsCompressorNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD6ED2C1136B8E42003CF072 /* DynamicsCompressorNode.cpp */; };
 		FD6ED2C4136B8E42003CF072 /* DynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C2136B8E42003CF072 /* DynamicsCompressorNode.h */; };
 		FD6ED2C7136B8E66003CF072 /* DynamicsCompressor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD6ED2C5136B8E66003CF072 /* DynamicsCompressor.cpp */; };
@@ -13519,6 +13520,7 @@
 		FD5686C813AC180200B69C68 /* AsyncAudioDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncAudioDecoder.h; sourceTree = "<group>"; };
 		FD5686CB13AC181400B69C68 /* AudioBufferCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioBufferCallback.h; sourceTree = "<group>"; };
 		FD5686CD13AC183E00B69C68 /* AudioBufferCallback.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AudioBufferCallback.idl; sourceTree = "<group>"; };
+		FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSourceProviderClient.h; sourceTree = "<group>"; };
 		FD6ED2C1136B8E42003CF072 /* DynamicsCompressorNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicsCompressorNode.cpp; sourceTree = "<group>"; };
 		FD6ED2C2136B8E42003CF072 /* DynamicsCompressorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicsCompressorNode.h; sourceTree = "<group>"; };
 		FD6ED2C5136B8E66003CF072 /* DynamicsCompressor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicsCompressor.cpp; sourceTree = "<group>"; };
@@ -21317,6 +21319,7 @@
 				FD31605112B026F700C1A359 /* AudioResamplerKernel.cpp */,
 				FD31605212B026F700C1A359 /* AudioResamplerKernel.h */,
 				FD31605312B026F700C1A359 /* AudioSourceProvider.h */,
+				FD62F52D145898D80094B0ED /* AudioSourceProviderClient.h */,
 				FD31605412B026F700C1A359 /* AudioUtilities.cpp */,
 				FD31605512B026F700C1A359 /* AudioUtilities.h */,
 				FD31605612B026F700C1A359 /* Biquad.cpp */,
@@ -24490,6 +24493,7 @@
 				970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
 				970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */,
 				9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
+				FD62F52E145898D80094B0ED /* AudioSourceProviderClient.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (98511 => 98512)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-10-26 19:57:36 UTC (rev 98512)
@@ -31,6 +31,7 @@
 #include "ApplicationCacheHost.h"
 #include "ApplicationCacheResource.h"
 #include "Attribute.h"
+#include "AudioSourceProvider.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
 #include "ClientRect.h"
@@ -3046,8 +3047,13 @@
     m_player = MediaPlayer::create(this);
 
 #if ENABLE(WEB_AUDIO)
-    if (m_audioSourceNode)
+    if (m_audioSourceNode) {
+        // When creating the player, make sure its AudioSourceProvider knows about the MediaElementAudioSourceNode.
+        if (audioSourceProvider())
+            audioSourceProvider()->setClient(m_audioSourceNode);
+
         m_audioSourceNode->unlock();
+    }
 #endif
 }
 
@@ -3055,6 +3061,9 @@
 void HTMLMediaElement::setAudioSourceNode(MediaElementAudioSourceNode* sourceNode)
 {
     m_audioSourceNode = sourceNode;
+
+    if (audioSourceProvider())
+        audioSourceProvider()->setClient(m_audioSourceNode);
 }
 
 AudioSourceProvider* HTMLMediaElement::audioSourceProvider()

Modified: trunk/Source/WebCore/platform/audio/AudioSourceProvider.h (98511 => 98512)


--- trunk/Source/WebCore/platform/audio/AudioSourceProvider.h	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/platform/audio/AudioSourceProvider.h	2011-10-26 19:57:36 UTC (rev 98512)
@@ -32,12 +32,17 @@
 namespace WebCore {
 
 class AudioBus;
+class AudioSourceProviderClient;
     
 // Abstract base-class for a pull-model client.
-// provideInput() gets called repeatedly to render time-slices of a continuous audio stream.
 class AudioSourceProvider {
 public:
+    // provideInput() gets called repeatedly to render time-slices of a continuous audio stream.
     virtual void provideInput(AudioBus* bus, size_t framesToProcess) = 0;
+
+    // If a client is set, we call it back when the audio format is available or changes.
+    virtual void setClient(AudioSourceProviderClient*) { };
+
     virtual ~AudioSourceProvider() { }
 };
 

Copied: trunk/Source/WebCore/platform/audio/AudioSourceProviderClient.h (from rev 98510, trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h) (0 => 98512)


--- trunk/Source/WebCore/platform/audio/AudioSourceProviderClient.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/audio/AudioSourceProviderClient.h	2011-10-26 19:57:36 UTC (rev 98512)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011, 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 AudioSourceProviderClient_h
+#define AudioSourceProviderClient_h
+
+namespace WebCore {
+
+class AudioSourceProviderClient {
+public:
+    virtual void setFormat(size_t numberOfChannels, float sampleRate) = 0;
+protected:
+    virtual ~AudioSourceProviderClient() { }
+};
+
+} // WebCore
+
+#endif // AudioSourceProviderClient_h

Modified: trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp (98511 => 98512)


--- trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp	2011-10-26 19:57:36 UTC (rev 98512)
@@ -57,6 +57,12 @@
     uninitialize();
 }
 
+void MediaElementAudioSourceNode::setFormat(size_t, float)
+{
+    // FIXME: setup a sample-rate converter if necessary to convert to the AudioContext sample-rate.
+    ASSERT_NOT_REACHED();
+}
+
 void MediaElementAudioSourceNode::process(size_t numberOfFrames)
 {
     AudioBus* outputBus = output(0)->bus();

Modified: trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h (98511 => 98512)


--- trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h	2011-10-26 19:55:26 UTC (rev 98511)
+++ trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h	2011-10-26 19:57:36 UTC (rev 98512)
@@ -28,6 +28,7 @@
 #if ENABLE(VIDEO)
 
 #include "AudioSourceNode.h"
+#include "AudioSourceProviderClient.h"
 #include "HTMLMediaElement.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/Threading.h>
@@ -36,7 +37,7 @@
 
 class AudioContext;
     
-class MediaElementAudioSourceNode : public AudioSourceNode {
+class MediaElementAudioSourceNode : public AudioSourceNode, public AudioSourceProviderClient {
 public:
     static PassRefPtr<MediaElementAudioSourceNode> create(AudioContext*, HTMLMediaElement*);
 
@@ -48,6 +49,9 @@
     virtual void process(size_t framesToProcess);
     virtual void reset();
     
+    // AudioSourceProviderClient
+    virtual void setFormat(size_t numberOfChannels, float sampleRate);
+    
     void lock();
     void unlock();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to