Bug 1322883 - AudioNode constructors - part 17 - MediaStreamAudioSourceNode, r=padenot

This commit is contained in:
Andrea Marchesini 2016-12-15 19:24:43 +01:00
Родитель ef0b4a0ce6
Коммит 040ca23f4e
6 изменённых файлов: 38 добавлений и 19 удалений

Просмотреть файл

@ -25,6 +25,7 @@
#include "mozilla/dom/IIRFilterNodeBinding.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/MediaElementAudioSourceNodeBinding.h"
#include "mozilla/dom/MediaStreamAudioSourceNodeBinding.h"
#include "mozilla/dom/OfflineAudioContextBinding.h"
#include "mozilla/dom/OscillatorNodeBinding.h"
#include "mozilla/dom/PannerNodeBinding.h"
@ -374,16 +375,10 @@ already_AddRefed<MediaStreamAudioSourceNode>
AudioContext::CreateMediaStreamSource(DOMMediaStream& aMediaStream,
ErrorResult& aRv)
{
if (mIsOffline) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
MediaStreamAudioSourceOptions options;
options.mMediaStream = aMediaStream;
if (CheckClosed(aRv)) {
return nullptr;
}
return MediaStreamAudioSourceNode::Create(this, &aMediaStream, aRv);
return MediaStreamAudioSourceNode::Create(*this, options, aRv);
}
already_AddRefed<GainNode>

Просмотреть файл

@ -43,13 +43,23 @@ MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(AudioContext* aContext)
}
/* static */ already_AddRefed<MediaStreamAudioSourceNode>
MediaStreamAudioSourceNode::Create(AudioContext* aContext,
DOMMediaStream* aStream, ErrorResult& aRv)
MediaStreamAudioSourceNode::Create(AudioContext& aAudioContext,
const MediaStreamAudioSourceOptions& aOptions,
ErrorResult& aRv)
{
RefPtr<MediaStreamAudioSourceNode> node =
new MediaStreamAudioSourceNode(aContext);
if (aAudioContext.IsOffline()) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
node->Init(aStream, aRv);
if (aAudioContext.CheckClosed(aRv)) {
return nullptr;
}
RefPtr<MediaStreamAudioSourceNode> node =
new MediaStreamAudioSourceNode(&aAudioContext);
node->Init(aOptions.mMediaStream, aRv);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -15,6 +15,9 @@ namespace mozilla {
namespace dom {
class AudioContext;
struct MediaStreamAudioSourceOptions;
class MediaStreamAudioSourceNodeEngine final : public AudioNodeEngine
{
public:
@ -46,11 +49,19 @@ class MediaStreamAudioSourceNode : public AudioNode,
{
public:
static already_AddRefed<MediaStreamAudioSourceNode>
Create(AudioContext* aContext, DOMMediaStream* aStream, ErrorResult& aRv);
Create(AudioContext& aContext, const MediaStreamAudioSourceOptions& aOptions,
ErrorResult& aRv);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamAudioSourceNode, AudioNode)
static already_AddRefed<MediaStreamAudioSourceNode>
Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
const MediaStreamAudioSourceOptions& aOptions, ErrorResult& aRv)
{
return Create(aAudioContext, aOptions, aRv);
}
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
void DestroyMediaStream() override;

Просмотреть файл

@ -31,7 +31,7 @@ var gTest = {
source.connect(dest);
source.start(0);
var mediaStreamSource = context.createMediaStreamSource(dest.stream);
var mediaStreamSource = new MediaStreamAudioSourceNode(context, { mediaStream: dest.stream });
// channelCount and channelCountMode should have no effect
mediaStreamSource.channelCount = 1;
mediaStreamSource.channelCountMode = "explicit";

Просмотреть файл

@ -12,7 +12,5 @@
[Pref="dom.webaudio.enabled"]
interface MediaStreamAudioDestinationNode : AudioNode {
readonly attribute MediaStream stream;
};

Просмотреть файл

@ -10,7 +10,12 @@
* liability, trademark and document use rules apply.
*/
[Pref="dom.webaudio.enabled"]
dictionary MediaStreamAudioSourceOptions {
required MediaStream mediaStream;
};
[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, MediaStreamAudioSourceOptions options)]
interface MediaStreamAudioSourceNode : AudioNode {
};