|
| 1 | +/* |
| 2 | + * Copyright (C) 2021 Apple Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions |
| 6 | + * are met: |
| 7 | + * 1. Redistributions of source code must retain the above copyright |
| 8 | + * notice, this list of conditions and the following disclaimer. |
| 9 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer in the |
| 11 | + * documentation and/or other materials provided with the distribution. |
| 12 | + * |
| 13 | + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | + */ |
| 25 | + |
| 26 | +#include "config.h" |
| 27 | + |
| 28 | +#if ENABLE(WEB_AUDIO) |
| 29 | +#include "JSAudioNode.h" |
| 30 | + |
| 31 | +#include "AnalyserNode.h" |
| 32 | +#include "AudioBufferSourceNode.h" |
| 33 | +#include "AudioDestinationNode.h" |
| 34 | +#include "AudioNode.h" |
| 35 | +#include "AudioWorkletNode.h" |
| 36 | +#include "BiquadFilterNode.h" |
| 37 | +#include "ChannelMergerNode.h" |
| 38 | +#include "ChannelSplitterNode.h" |
| 39 | +#include "ConstantSourceNode.h" |
| 40 | +#include "ConvolverNode.h" |
| 41 | +#include "DelayNode.h" |
| 42 | +#include "DynamicsCompressorNode.h" |
| 43 | +#include "GainNode.h" |
| 44 | +#include "IIRFilterNode.h" |
| 45 | +#include "JSAnalyserNode.h" |
| 46 | +#include "JSAudioBufferSourceNode.h" |
| 47 | +#include "JSAudioDestinationNode.h" |
| 48 | +#include "JSAudioWorkletNode.h" |
| 49 | +#include "JSBiquadFilterNode.h" |
| 50 | +#include "JSChannelMergerNode.h" |
| 51 | +#include "JSChannelSplitterNode.h" |
| 52 | +#include "JSConstantSourceNode.h" |
| 53 | +#include "JSConvolverNode.h" |
| 54 | +#include "JSDelayNode.h" |
| 55 | +#include "JSDynamicsCompressorNode.h" |
| 56 | +#include "JSGainNode.h" |
| 57 | +#include "JSIIRFilterNode.h" |
| 58 | +#include "JSMediaElementAudioSourceNode.h" |
| 59 | +#include "JSMediaStreamAudioDestinationNode.h" |
| 60 | +#include "JSMediaStreamAudioSourceNode.h" |
| 61 | +#include "JSOscillatorNode.h" |
| 62 | +#include "JSPannerNode.h" |
| 63 | +#include "JSScriptProcessorNode.h" |
| 64 | +#include "JSStereoPannerNode.h" |
| 65 | +#include "JSWaveShaperNode.h" |
| 66 | +#include "MediaElementAudioSourceNode.h" |
| 67 | +#include "MediaStreamAudioDestinationNode.h" |
| 68 | +#include "MediaStreamAudioSourceNode.h" |
| 69 | +#include "OscillatorNode.h" |
| 70 | +#include "PannerNode.h" |
| 71 | +#include "ScriptProcessorNode.h" |
| 72 | +#include "StereoPannerNode.h" |
| 73 | +#include "WaveShaperNode.h" |
| 74 | + |
| 75 | +namespace WebCore { |
| 76 | +using namespace JSC; |
| 77 | + |
| 78 | +JSValue toJSNewlyCreated(JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<AudioNode>&& node) |
| 79 | +{ |
| 80 | + switch (node->nodeType()) { |
| 81 | + case AudioNode::NodeTypeDestination: |
| 82 | + return createWrapper<AudioDestinationNode>(globalObject, WTFMove(node)); |
| 83 | + case AudioNode::NodeTypeOscillator: |
| 84 | + return createWrapper<OscillatorNode>(globalObject, WTFMove(node)); |
| 85 | + case AudioNode::NodeTypeAudioBufferSource: |
| 86 | + return createWrapper<AudioBufferSourceNode>(globalObject, WTFMove(node)); |
| 87 | + case AudioNode::NodeTypeMediaElementAudioSource: |
| 88 | +#if ENABLE(VIDEO) |
| 89 | + return createWrapper<MediaElementAudioSourceNode>(globalObject, WTFMove(node)); |
| 90 | +#else |
| 91 | + return createWrapper<AudioNode>(globalObject, WTFMove(node)); |
| 92 | +#endif |
| 93 | +#if ENABLE(MEDIA_STREAM) |
| 94 | + case AudioNode::NodeTypeMediaStreamAudioDestination: |
| 95 | + return createWrapper<MediaStreamAudioDestinationNode>(globalObject, WTFMove(node)); |
| 96 | + case AudioNode::NodeTypeMediaStreamAudioSource: |
| 97 | + return createWrapper<MediaStreamAudioSourceNode>(globalObject, WTFMove(node)); |
| 98 | +#else |
| 99 | + case AudioNode::NodeTypeMediaStreamAudioDestination: |
| 100 | + case AudioNode::NodeTypeMediaStreamAudioSource: |
| 101 | + return createWrapper<AudioNode>(globalObject, WTFMove(node)); |
| 102 | +#endif |
| 103 | + case AudioNode::NodeTypeJavaScript: |
| 104 | + return createWrapper<ScriptProcessorNode>(globalObject, WTFMove(node)); |
| 105 | + case AudioNode::NodeTypeBiquadFilter: |
| 106 | + return createWrapper<BiquadFilterNode>(globalObject, WTFMove(node)); |
| 107 | + case AudioNode::NodeTypePanner: |
| 108 | + return createWrapper<PannerNode>(globalObject, WTFMove(node)); |
| 109 | + case AudioNode::NodeTypeConvolver: |
| 110 | + return createWrapper<ConvolverNode>(globalObject, WTFMove(node)); |
| 111 | + case AudioNode::NodeTypeDelay: |
| 112 | + return createWrapper<DelayNode>(globalObject, WTFMove(node)); |
| 113 | + case AudioNode::NodeTypeGain: |
| 114 | + return createWrapper<GainNode>(globalObject, WTFMove(node)); |
| 115 | + case AudioNode::NodeTypeChannelSplitter: |
| 116 | + return createWrapper<ChannelSplitterNode>(globalObject, WTFMove(node)); |
| 117 | + case AudioNode::NodeTypeChannelMerger: |
| 118 | + return createWrapper<ChannelMergerNode>(globalObject, WTFMove(node)); |
| 119 | + case AudioNode::NodeTypeAnalyser: |
| 120 | + return createWrapper<AnalyserNode>(globalObject, WTFMove(node)); |
| 121 | + case AudioNode::NodeTypeDynamicsCompressor: |
| 122 | + return createWrapper<DynamicsCompressorNode>(globalObject, WTFMove(node)); |
| 123 | + case AudioNode::NodeTypeWaveShaper: |
| 124 | + return createWrapper<WaveShaperNode>(globalObject, WTFMove(node)); |
| 125 | + case AudioNode::NodeTypeConstant: |
| 126 | + return createWrapper<ConstantSourceNode>(globalObject, WTFMove(node)); |
| 127 | + case AudioNode::NodeTypeStereoPanner: |
| 128 | + return createWrapper<StereoPannerNode>(globalObject, WTFMove(node)); |
| 129 | + case AudioNode::NodeTypeIIRFilter: |
| 130 | + return createWrapper<IIRFilterNode>(globalObject, WTFMove(node)); |
| 131 | + case AudioNode::NodeTypeWorklet: |
| 132 | + return createWrapper<AudioWorkletNode>(globalObject, WTFMove(node)); |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +JSValue toJS(JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, AudioNode& node) |
| 137 | +{ |
| 138 | + return wrap(lexicalGlobalObject, globalObject, node); |
| 139 | +} |
| 140 | + |
| 141 | +} // namespace WebCore |
| 142 | + |
| 143 | +#endif // ENABLE(WEB_AUDIO) |
0 commit comments