зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1458446 - Add AudioWorkletNode interface definitions. r=baku,karlt
MozReview-Commit-ID: BLumJG4BDke --HG-- extra : rebase_source : 1a507149cefb76cedbcc336d9b9ae6e0eebed59c
This commit is contained in:
Родитель
b3c473218f
Коммит
5fdd4661b7
|
@ -0,0 +1,103 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AudioWorkletNode.h"
|
||||
|
||||
#include "AudioParamMap.h"
|
||||
#include "mozilla/dom/AudioWorkletNodeBinding.h"
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(AudioWorkletNode, AudioNode)
|
||||
|
||||
AudioWorkletNode::AudioWorkletNode(AudioContext* aAudioContext,
|
||||
const nsAString& aName)
|
||||
: AudioNode(aAudioContext,
|
||||
2,
|
||||
ChannelCountMode::Max,
|
||||
ChannelInterpretation::Speakers)
|
||||
, mNodeName(aName)
|
||||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AudioWorkletNode>
|
||||
AudioWorkletNode::Constructor(const GlobalObject& aGlobal,
|
||||
AudioContext& aAudioContext,
|
||||
const nsAString& aName,
|
||||
const AudioWorkletNodeOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (aAudioContext.CheckClosed(aRv)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aOptions.mNumberOfInputs == 0 && aOptions.mNumberOfOutputs == 0) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aOptions.mOutputChannelCount.WasPassed()) {
|
||||
if (aOptions.mOutputChannelCount.Value().Length() !=
|
||||
aOptions.mNumberOfOutputs) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (uint32_t channelCount : aOptions.mOutputChannelCount.Value()) {
|
||||
if (channelCount == 0 ||
|
||||
channelCount > WebAudioUtils::MaxChannelCount) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<AudioWorkletNode> audioWorkletNode =
|
||||
new AudioWorkletNode(&aAudioContext, aName);
|
||||
|
||||
audioWorkletNode->Initialize(aOptions, aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return audioWorkletNode.forget();
|
||||
}
|
||||
|
||||
AudioParamMap* AudioWorkletNode::GetParameters(ErrorResult& aRv) const
|
||||
{
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MessagePort* AudioWorkletNode::GetPort(ErrorResult& aRv) const
|
||||
{
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
AudioWorkletNode::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AudioWorkletNodeBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
size_t
|
||||
AudioWorkletNode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t amount = AudioNode::SizeOfExcludingThis(aMallocSizeOf);
|
||||
return amount;
|
||||
}
|
||||
|
||||
size_t
|
||||
AudioWorkletNode::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef AudioWorkletNode_h_
|
||||
#define AudioWorkletNode_h_
|
||||
|
||||
#include "AudioNode.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AudioParamMap;
|
||||
struct AudioWorkletNodeOptions;
|
||||
class MessagePort;
|
||||
|
||||
class AudioWorkletNode : public AudioNode
|
||||
{
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
IMPL_EVENT_HANDLER(processorerror)
|
||||
|
||||
static already_AddRefed<AudioWorkletNode>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
AudioContext& aAudioContext,
|
||||
const nsAString& aName,
|
||||
const AudioWorkletNodeOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
AudioParamMap* GetParameters(ErrorResult& aRv) const;
|
||||
|
||||
MessagePort* GetPort(ErrorResult& aRv) const;
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
const char* NodeType() const override
|
||||
{
|
||||
return "AudioWorkletNode";
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
|
||||
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
|
||||
|
||||
private:
|
||||
AudioWorkletNode(AudioContext* aAudioContext, const nsAString& aName);
|
||||
~AudioWorkletNode() = default;
|
||||
|
||||
nsString mNodeName;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // AudioWorkletNode_h_
|
|
@ -52,6 +52,7 @@ EXPORTS.mozilla.dom += [
|
|||
'AudioParamMap.h',
|
||||
'AudioProcessingEvent.h',
|
||||
'AudioScheduledSourceNode.h',
|
||||
'AudioWorkletNode.h',
|
||||
'BiquadFilterNode.h',
|
||||
'ChannelMergerNode.h',
|
||||
'ChannelSplitterNode.h',
|
||||
|
@ -89,6 +90,7 @@ UNIFIED_SOURCES += [
|
|||
'AudioParamMap.cpp',
|
||||
'AudioProcessingEvent.cpp',
|
||||
'AudioScheduledSourceNode.cpp',
|
||||
'AudioWorkletNode.cpp',
|
||||
'BiquadFilterNode.cpp',
|
||||
'ChannelMergerNode.cpp',
|
||||
'ChannelSplitterNode.cpp',
|
||||
|
|
|
@ -158,6 +158,8 @@ var interfaceNamesInGlobalScope =
|
|||
{name: "AudioScheduledSourceNode", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "AudioStreamTrack", insecureContext: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "AudioWorkletNode", insecureContext: false, disabled: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "AuthenticatorAssertionResponse"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://webaudio.github.io/web-audio-api/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
dictionary AudioWorkletNodeOptions : AudioNodeOptions {
|
||||
unsigned long numberOfInputs = 1;
|
||||
unsigned long numberOfOutputs = 1;
|
||||
sequence<unsigned long> outputChannelCount;
|
||||
record<DOMString, double> parameterData;
|
||||
object? processorOptions = null;
|
||||
};
|
||||
|
||||
[SecureContext, Pref="dom.audioworklet.enabled",
|
||||
Constructor (BaseAudioContext context, DOMString name, optional AudioWorkletNodeOptions options)]
|
||||
interface AudioWorkletNode : AudioNode {
|
||||
[Throws]
|
||||
readonly attribute AudioParamMap parameters;
|
||||
[Throws]
|
||||
readonly attribute MessagePort port;
|
||||
attribute EventHandler onprocessorerror;
|
||||
};
|
|
@ -385,6 +385,7 @@ WEBIDL_FILES = [
|
|||
'AudioTrack.webidl',
|
||||
'AudioTrackList.webidl',
|
||||
'AudioWorkletGlobalScope.webidl',
|
||||
'AudioWorkletNode.webidl',
|
||||
'AutocompleteInfo.webidl',
|
||||
'BarProp.webidl',
|
||||
'BaseAudioContext.webidl',
|
||||
|
|
|
@ -808,6 +808,7 @@ GK_ATOM(onpopuphiding, "onpopuphiding")
|
|||
GK_ATOM(onpopuppositioned, "onpopuppositioned")
|
||||
GK_ATOM(onpopupshowing, "onpopupshowing")
|
||||
GK_ATOM(onpopupshown, "onpopupshown")
|
||||
GK_ATOM(onprocessorerror, "onprocessorerror")
|
||||
GK_ATOM(onpush, "onpush")
|
||||
GK_ATOM(onpushsubscriptionchange, "onpushsubscriptionchange")
|
||||
GK_ATOM(onRadioStateChange, "onRadioStateChange")
|
||||
|
|
Загрузка…
Ссылка в новой задаче