Title: [93054] trunk
Revision
93054
Author
[email protected]
Date
2011-08-15 12:37:22 -0700 (Mon, 15 Aug 2011)

Log Message

Add shell implementation for Web Audio API's MediaElementAudioSourceNode
https://bugs.webkit.org/show_bug.cgi?id=66175

Reviewed by Kenneth Russell.

Source/WebCore:

Test: webaudio/mediaelementaudiosourcenode.html

* DerivedSources.make:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLMediaElement.idl:
* webaudio/AudioContext.cpp:
(WebCore::AudioContext::createMediaElementSource):
* webaudio/AudioContext.h:
* webaudio/AudioContext.idl:
* webaudio/AudioNode.h:
* webaudio/MediaElementAudioSourceNode.cpp: Added.
(WebCore::MediaElementAudioSourceNode::create):
(WebCore::MediaElementAudioSourceNode::MediaElementAudioSourceNode):
(WebCore::MediaElementAudioSourceNode::process):
(WebCore::MediaElementAudioSourceNode::reset):
* webaudio/MediaElementAudioSourceNode.h: Added.
(WebCore::MediaElementAudioSourceNode::mediaElement):
* webaudio/MediaElementAudioSourceNode.idl: Added.

LayoutTests:

* webaudio/mediaelementaudiosourcenode-expected.txt: Added.
* webaudio/mediaelementaudiosourcenode.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93053 => 93054)


--- trunk/LayoutTests/ChangeLog	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/LayoutTests/ChangeLog	2011-08-15 19:37:22 UTC (rev 93054)
@@ -1,3 +1,13 @@
+2011-08-15  Chris Rogers  <[email protected]>
+
+        Add shell implementation for Web Audio API's MediaElementAudioSourceNode
+        https://bugs.webkit.org/show_bug.cgi?id=66175
+
+        Reviewed by Kenneth Russell.
+
+        * webaudio/mediaelementaudiosourcenode-expected.txt: Added.
+        * webaudio/mediaelementaudiosourcenode.html: Added.
+
 2011-08-15  Ryosuke Niwa  <[email protected]>
 
         webkit-indent-blockquote is unnecessary

Added: trunk/LayoutTests/webaudio/mediaelementaudiosourcenode-expected.txt (0 => 93054)


--- trunk/LayoutTests/webaudio/mediaelementaudiosourcenode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webaudio/mediaelementaudiosourcenode-expected.txt	2011-08-15 19:37:22 UTC (rev 93054)
@@ -0,0 +1,14 @@
+Basic tests for MediaElementAudioSourceNode API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS Source AudioNode has no inputs.
+PASS Source AudioNode has one output.
+PASS connect() exception thrown for illegal destination AudioNode.
+PASS connect() exception thrown for illegal output index.
+PASS connect() exception thrown for illegal input index.
+PASS audioNode.connect(context.destination) succeeded.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webaudio/mediaelementaudiosourcenode.html (0 => 93054)


--- trunk/LayoutTests/webaudio/mediaelementaudiosourcenode.html	                        (rev 0)
+++ trunk/LayoutTests/webaudio/mediaelementaudiosourcenode.html	2011-08-15 19:37:22 UTC (rev 93054)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Basic tests for MediaElementAudioSourceNode API.");
+
+var context = 0;
+
+function runTest() {
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    window.jsTestIsAsync = true;
+
+    context = new webkitAudioContext();
+
+    audioElement = new Audio();
+    mediaSource = context.createMediaElementSource(audioElement);
+    window.audioNode = mediaSource;
+
+    // Check number of inputs and outputs.
+    if (audioNode.numberOfInputs == 0)
+        testPassed("Source AudioNode has no inputs.");
+    else
+        testFailed("Source AudioNode should not have inputs.");
+    
+    if (audioNode.numberOfOutputs == 1)
+        testPassed("Source AudioNode has one output.");
+    else
+        testFailed("Source AudioNode should have one output.");
+
+    // Try calling connect() method with illegal values.
+
+    try {
+        audioNode.connect(0, 0, 0);
+        testFailed("connect() exception should be thrown for illegal destination AudioNode.");
+    } catch(e) {
+        testPassed("connect() exception thrown for illegal destination AudioNode.");
+    }
+
+    try {
+        audioNode.connect(context.destination, 5, 0);
+        testFailed("connect() exception should be thrown for illegal output index.");
+    } catch(e) {
+        testPassed("connect() exception thrown for illegal output index.");
+    }
+
+    try {
+        audioNode.connect(context.destination, 0, 5);
+        testFailed("connect() exception should be thrown for illegal input index.");
+    } catch(e) {
+        testPassed("connect() exception thrown for illegal input index.");
+    }
+
+    // Try calling connect() with proper values.
+    try {
+        audioNode.connect(context.destination, 0, 0);
+        testPassed("audioNode.connect(context.destination) succeeded.");
+    } catch(e) {
+        testFailed("audioNode.connect(context.destination) failed.");
+    }
+
+    finishJSTest();
+}
+
+runTest();
+successfullyParsed = true;
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (93053 => 93054)


--- trunk/Source/WebCore/ChangeLog	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/ChangeLog	2011-08-15 19:37:22 UTC (rev 93054)
@@ -1,3 +1,30 @@
+2011-08-15  Chris Rogers  <[email protected]>
+
+        Add shell implementation for Web Audio API's MediaElementAudioSourceNode
+        https://bugs.webkit.org/show_bug.cgi?id=66175
+
+        Reviewed by Kenneth Russell.
+
+        Test: webaudio/mediaelementaudiosourcenode.html
+
+        * DerivedSources.make:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLMediaElement.idl:
+        * webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::createMediaElementSource):
+        * webaudio/AudioContext.h:
+        * webaudio/AudioContext.idl:
+        * webaudio/AudioNode.h:
+        * webaudio/MediaElementAudioSourceNode.cpp: Added.
+        (WebCore::MediaElementAudioSourceNode::create):
+        (WebCore::MediaElementAudioSourceNode::MediaElementAudioSourceNode):
+        (WebCore::MediaElementAudioSourceNode::process):
+        (WebCore::MediaElementAudioSourceNode::reset):
+        * webaudio/MediaElementAudioSourceNode.h: Added.
+        (WebCore::MediaElementAudioSourceNode::mediaElement):
+        * webaudio/MediaElementAudioSourceNode.idl: Added.
+
 2011-08-15  Emil A Eklund  <[email protected]>
 
         Switch mouse events to to new layout types

Modified: trunk/Source/WebCore/DerivedSources.make (93053 => 93054)


--- trunk/Source/WebCore/DerivedSources.make	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/DerivedSources.make	2011-08-15 19:37:22 UTC (rev 93054)
@@ -77,6 +77,7 @@
     HighPass2FilterNode \
     _javascript_AudioNode \
     LowPass2FilterNode \
+    MediaElementAudioSourceNode \
     OfflineAudioCompletionEvent \
     RealtimeAnalyserNode \
     WaveShaperNode \

Modified: trunk/Source/WebCore/WebCore.gypi (93053 => 93054)


--- trunk/Source/WebCore/WebCore.gypi	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/WebCore.gypi	2011-08-15 19:37:22 UTC (rev 93054)
@@ -1455,6 +1455,7 @@
             'webaudio/HighPass2FilterNode.idl',
             'webaudio/_javascript_AudioNode.idl',
             'webaudio/LowPass2FilterNode.idl',
+            'webaudio/MediaElementAudioSourceNode.idl',
             'webaudio/OfflineAudioCompletionEvent.idl',
             'webaudio/RealtimeAnalyserNode.idl',
             'webaudio/WaveShaperNode.idl',
@@ -5067,6 +5068,8 @@
             'webaudio/_javascript_AudioNode.h',
             'webaudio/LowPass2FilterNode.cpp',
             'webaudio/LowPass2FilterNode.h',
+            'webaudio/MediaElementAudioSourceNode.cpp',
+            'webaudio/MediaElementAudioSourceNode.h',
             'webaudio/OfflineAudioCompletionEvent.cpp',
             'webaudio/OfflineAudioCompletionEvent.h',
             'webaudio/OfflineAudioDestinationNode.cpp',

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (93053 => 93054)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-08-15 19:37:22 UTC (rev 93054)
@@ -5789,6 +5789,8 @@
 		FD06DFA5134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */; };
 		FD06DFA6134A4DEF006F5D7D /* DefaultAudioDestinationNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD06DFA4134A4DEF006F5D7D /* DefaultAudioDestinationNode.h */; };
 		FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = FD1660A413787C6D001FFA7B /* DenormalDisabler.h */; };
+		FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */; };
+		FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */; };
 		FD2DBF1212B048A300ED98C6 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */; };
 		FD2DBF1312B048A300ED98C6 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2DBF0F12B048A300ED98C6 /* AudioToolbox.framework */; };
 		FD2DBF1412B048A300ED98C6 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD2DBF1012B048A300ED98C6 /* AudioUnit.framework */; };
@@ -5920,6 +5922,8 @@
 		FD6ED2C4136B8E42003CF072 /* DynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C2136B8E42003CF072 /* DynamicsCompressorNode.h */; };
 		FD6ED2C7136B8E66003CF072 /* DynamicsCompressor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD6ED2C5136B8E66003CF072 /* DynamicsCompressor.cpp */; };
 		FD6ED2C8136B8E66003CF072 /* DynamicsCompressor.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6ED2C6136B8E66003CF072 /* DynamicsCompressor.h */; };
+		FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD6F252913F5EF0E0065165F /* MediaElementAudioSourceNode.cpp */; };
+		FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */; };
 		FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */; };
 		FD7868BA136B999200D403DF /* JSDynamicsCompressorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */; };
 		FD7F299113D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */; };
@@ -12563,6 +12567,8 @@
 		FD06DFA3134A4DEF006F5D7D /* DefaultAudioDestinationNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DefaultAudioDestinationNode.cpp; sourceTree = "<group>"; };
 		FD06DFA4134A4DEF006F5D7D /* DefaultAudioDestinationNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DefaultAudioDestinationNode.h; sourceTree = "<group>"; };
 		FD1660A413787C6D001FFA7B /* DenormalDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DenormalDisabler.h; sourceTree = "<group>"; };
+		FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaElementAudioSourceNode.cpp; sourceTree = "<group>"; };
+		FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaElementAudioSourceNode.h; sourceTree = "<group>"; };
 		FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = /System/Library/Frameworks/Accelerate.framework; sourceTree = "<absolute>"; };
 		FD2DBF0F12B048A300ED98C6 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
 		FD2DBF1012B048A300ED98C6 /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = "<absolute>"; };
@@ -12716,6 +12722,9 @@
 		FD6ED2C5136B8E66003CF072 /* DynamicsCompressor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicsCompressor.cpp; sourceTree = "<group>"; };
 		FD6ED2C6136B8E66003CF072 /* DynamicsCompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicsCompressor.h; sourceTree = "<group>"; };
 		FD6ED2C9136B8E9D003CF072 /* DynamicsCompressorNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DynamicsCompressorNode.idl; sourceTree = "<group>"; };
+		FD6F252913F5EF0E0065165F /* MediaElementAudioSourceNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaElementAudioSourceNode.cpp; sourceTree = "<group>"; };
+		FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaElementAudioSourceNode.h; sourceTree = "<group>"; };
+		FD6F252B13F5EF0E0065165F /* MediaElementAudioSourceNode.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MediaElementAudioSourceNode.idl; sourceTree = "<group>"; };
 		FD7868B7136B999200D403DF /* JSDynamicsCompressorNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDynamicsCompressorNode.cpp; sourceTree = "<group>"; };
 		FD7868B8136B999200D403DF /* JSDynamicsCompressorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDynamicsCompressorNode.h; sourceTree = "<group>"; };
 		FD7F298A13D4C0CB00AD9535 /* WaveShaperDSPKernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaveShaperDSPKernel.cpp; sourceTree = "<group>"; };
@@ -20178,6 +20187,9 @@
 				FD315FEE12B0267600C1A359 /* LowPass2FilterNode.cpp */,
 				FD315FEF12B0267600C1A359 /* LowPass2FilterNode.h */,
 				FD315FF012B0267600C1A359 /* LowPass2FilterNode.idl */,
+				FD6F252913F5EF0E0065165F /* MediaElementAudioSourceNode.cpp */,
+				FD6F252A13F5EF0E0065165F /* MediaElementAudioSourceNode.h */,
+				FD6F252B13F5EF0E0065165F /* MediaElementAudioSourceNode.idl */,
 				FDA3E955134A49EF008D4B5A /* OfflineAudioCompletionEvent.cpp */,
 				FDA3E956134A49EF008D4B5A /* OfflineAudioCompletionEvent.h */,
 				FDA3E95D134A49FF008D4B5A /* OfflineAudioCompletionEvent.idl */,
@@ -20326,6 +20338,8 @@
 				FDA15EC012B03F2D003A583A /* JSHighPass2FilterNode.h */,
 				FDA15ECB12B03F61003A583A /* JSJavaScriptAudioNode.cpp */,
 				FDA15ECC12B03F61003A583A /* JSJavaScriptAudioNode.h */,
+				FD23A12313F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp */,
+				FD23A12413F5FA5900F67001 /* JSMediaElementAudioSourceNode.h */,
 				FDA15EC312B03F3B003A583A /* JSLowPass2FilterNode.cpp */,
 				FDA15EC412B03F3B003A583A /* JSLowPass2FilterNode.h */,
 				FDF6BAF6134A4C9800822920 /* JSOfflineAudioCompletionEvent.cpp */,
@@ -23370,6 +23384,8 @@
 				BCBB8AB913F1AFB000734DF0 /* PODInterval.h in Headers */,
 				BCBB8ABA13F1AFB000734DF0 /* PODIntervalTree.h in Headers */,
 				BCBB8ABB13F1AFB000734DF0 /* PODRedBlackTree.h in Headers */,
+				FD6F252D13F5EF0E0065165F /* MediaElementAudioSourceNode.h in Headers */,
+				FD23A12613F5FA5900F67001 /* JSMediaElementAudioSourceNode.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -26172,6 +26188,8 @@
 				977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
 				FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
 				59DE790413F16C7F0007FCDF /* JavaMethodJSC.cpp in Sources */,
+				FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */,
+				FD23A12513F5FA5900F67001 /* JSMediaElementAudioSourceNode.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/html/HTMLMediaElement.idl (93053 => 93054)


--- trunk/Source/WebCore/html/HTMLMediaElement.idl	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/html/HTMLMediaElement.idl	2011-08-15 19:37:22 UTC (rev 93054)
@@ -26,6 +26,7 @@
 module html {
     interface [
         Conditional=VIDEO,
+        GenerateNativeConverter
     ] HTMLMediaElement : HTMLElement {
 
     // error state

Modified: trunk/Source/WebCore/webaudio/AudioContext.cpp (93053 => 93054)


--- trunk/Source/WebCore/webaudio/AudioContext.cpp	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/webaudio/AudioContext.cpp	2011-08-15 19:37:22 UTC (rev 93054)
@@ -49,9 +49,11 @@
 #include "FFTFrame.h"
 #include "HRTFDatabaseLoader.h"
 #include "HRTFPanner.h"
+#include "HTMLMediaElement.h"
 #include "HighPass2FilterNode.h"
 #include "_javascript_AudioNode.h"
 #include "LowPass2FilterNode.h"
+#include "MediaElementAudioSourceNode.h"
 #include "OfflineAudioCompletionEvent.h"
 #include "OfflineAudioDestinationNode.h"
 #include "PlatformString.h"
@@ -310,6 +312,16 @@
     return node;
 }
 
+PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(HTMLMediaElement* mediaElement)
+{
+    ASSERT(isMainThread());
+    lazyInitialize();
+    RefPtr<MediaElementAudioSourceNode> node = MediaElementAudioSourceNode::create(this, mediaElement);
+
+    refNode(node.get()); // context keeps reference until node is disconnected
+    return node;
+}
+
 PassRefPtr<_javascript_AudioNode> AudioContext::createJavaScriptNode(size_t bufferSize)
 {
     ASSERT(isMainThread());

Modified: trunk/Source/WebCore/webaudio/AudioContext.h (93053 => 93054)


--- trunk/Source/WebCore/webaudio/AudioContext.h	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/webaudio/AudioContext.h	2011-08-15 19:37:22 UTC (rev 93054)
@@ -49,6 +49,8 @@
 class AudioBuffer;
 class AudioBufferCallback;
 class AudioBufferSourceNode;
+class MediaElementAudioSourceNode;
+class HTMLMediaElement;
 class AudioChannelMerger;
 class AudioChannelSplitter;
 class AudioGainNode;
@@ -108,6 +110,7 @@
 
     // The AudioNode create methods are called on the main thread (from _javascript_).
     PassRefPtr<AudioBufferSourceNode> createBufferSource();
+    PassRefPtr<MediaElementAudioSourceNode> createMediaElementSource(HTMLMediaElement*);
     PassRefPtr<AudioGainNode> createGainNode();
     PassRefPtr<BiquadFilterNode> createBiquadFilter();
     PassRefPtr<WaveShaperNode> createWaveShaper();

Modified: trunk/Source/WebCore/webaudio/AudioContext.idl (93053 => 93054)


--- trunk/Source/WebCore/webaudio/AudioContext.idl	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/webaudio/AudioContext.idl	2011-08-15 19:37:22 UTC (rev 93054)
@@ -57,8 +57,9 @@
         void decodeAudioData(in ArrayBuffer audioData, in [Callback] AudioBufferCallback successCallback, in [Optional, Callback] AudioBufferCallback errorCallback)
             raises(DOMException);
 
-        // Source
+        // Sources
         AudioBufferSourceNode createBufferSource();
+        MediaElementAudioSourceNode createMediaElementSource(in HTMLMediaElement mediaElement);
 
         // Processing nodes
         AudioGainNode createGainNode();

Modified: trunk/Source/WebCore/webaudio/AudioNode.h (93053 => 93054)


--- trunk/Source/WebCore/webaudio/AudioNode.h	2011-08-15 19:31:06 UTC (rev 93053)
+++ trunk/Source/WebCore/webaudio/AudioNode.h	2011-08-15 19:37:22 UTC (rev 93054)
@@ -57,6 +57,7 @@
         NodeTypeUnknown,
         NodeTypeDestination,
         NodeTypeAudioBufferSource,
+        NodeTypeMediaElementAudioSource,
         NodeTypeJavaScript,
         NodeTypeBiquadFilter,
         NodeTypeLowPass2Filter,

Added: trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp (0 => 93054)


--- trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp	                        (rev 0)
+++ trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.cpp	2011-08-15 19:37:22 UTC (rev 93054)
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEB_AUDIO)
+
+#include "MediaElementAudioSourceNode.h"
+
+#include "AudioContext.h"
+#include "AudioNodeOutput.h"
+
+namespace WebCore {
+
+PassRefPtr<MediaElementAudioSourceNode> MediaElementAudioSourceNode::create(AudioContext* context, HTMLMediaElement* mediaElement)
+{
+    return adoptRef(new MediaElementAudioSourceNode(context, mediaElement));      
+}
+
+MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* context, HTMLMediaElement* mediaElement)
+    : AudioSourceNode(context, context->sampleRate())
+    , m_mediaElement(mediaElement)
+{
+    // Default to stereo. This could change depending on what the media element .src is set to.
+    addOutput(adoptPtr(new AudioNodeOutput(this, 2)));
+    
+    setType(NodeTypeMediaElementAudioSource);
+}
+
+void MediaElementAudioSourceNode::process(size_t)
+{
+    AudioBus* outputBus = output(0)->bus();
+
+    // FIXME: implement MediaPlayer abstraction to get audio stream from <audio> and <video>
+    outputBus->zero();
+}
+
+void MediaElementAudioSourceNode::reset()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Added: trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h (0 => 93054)


--- trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h	                        (rev 0)
+++ trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.h	2011-08-15 19:37:22 UTC (rev 93054)
@@ -0,0 +1,54 @@
+/*
+ * 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 MediaElementAudioSourceNode_h
+#define MediaElementAudioSourceNode_h
+
+#include "AudioSourceNode.h"
+#include "HTMLMediaElement.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class AudioContext;
+    
+class MediaElementAudioSourceNode : public AudioSourceNode {
+public:
+    static PassRefPtr<MediaElementAudioSourceNode> create(AudioContext*, HTMLMediaElement*);
+
+    HTMLMediaElement* mediaElement() { return m_mediaElement.get(); }                                        
+
+    // AudioNode
+    virtual void process(size_t framesToProcess);
+    virtual void reset();
+
+private:
+    MediaElementAudioSourceNode(AudioContext*, HTMLMediaElement*);
+
+    RefPtr<HTMLMediaElement> m_mediaElement;
+};
+
+} // namespace WebCore
+
+#endif // MediaElementAudioSourceNode_h

Added: trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.idl (0 => 93054)


--- trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.idl	                        (rev 0)
+++ trunk/Source/WebCore/webaudio/MediaElementAudioSourceNode.idl	2011-08-15 19:37:22 UTC (rev 93054)
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+module audio {
+    interface [
+        Conditional=WEB_AUDIO,
+        GenerateToJS
+    ] MediaElementAudioSourceNode : AudioSourceNode {
+        readonly attribute HTMLMediaElement mediaElement;
+    };
+}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to