Bug 1350973 - Implement new attributes MediaStreamAudioSourceNode.mediaStream and MediaElementAudioSourceNode.mediaElement. r=baku

Differential Revision: https://phabricator.services.mozilla.com/D37283

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Paul Adenot 2019-07-11 20:09:58 +00:00
Родитель 6d8671ebb8
Коммит c74b95c375
6 изменённых файлов: 45 добавлений и 15 удалений

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

@ -13,8 +13,31 @@
namespace mozilla {
namespace dom {
MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* aContext)
: MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges) {
NS_IMPL_CYCLE_COLLECTION_CLASS(MediaElementAudioSourceNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaElementAudioSourceNode)
tmp->Destroy();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(AudioNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaElementAudioSourceNode,
MediaStreamAudioSourceNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaElementAudioSourceNode)
NS_INTERFACE_MAP_END_INHERITING(MediaStreamAudioSourceNode)
NS_IMPL_ADDREF_INHERITED(MediaElementAudioSourceNode,
MediaStreamAudioSourceNode)
NS_IMPL_RELEASE_INHERITED(MediaElementAudioSourceNode,
MediaStreamAudioSourceNode)
MediaElementAudioSourceNode::MediaElementAudioSourceNode(
AudioContext* aContext, HTMLMediaElement* aElement)
: MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges),
mElement(aElement) {
MOZ_ASSERT(aElement);
}
/* static */
@ -28,7 +51,7 @@ MediaElementAudioSourceNode::Create(
}
RefPtr<MediaElementAudioSourceNode> node =
new MediaElementAudioSourceNode(&aAudioContext);
new MediaElementAudioSourceNode(&aAudioContext, aOptions.mMediaElement);
RefPtr<DOMMediaStream> stream = aOptions.mMediaElement->CaptureAudio(
aRv, aAudioContext.Destination()->Stream()->Graph());
@ -71,5 +94,9 @@ void MediaElementAudioSourceNode::Destroy() {
MediaStreamAudioSourceNode::Destroy();
}
HTMLMediaElement* MediaElementAudioSourceNode::MediaElement() {
return mElement;
}
} // namespace dom
} // namespace mozilla

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

@ -17,6 +17,9 @@ struct MediaElementAudioSourceOptions;
class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaElementAudioSourceNode,
MediaStreamAudioSourceNode)
static already_AddRefed<MediaElementAudioSourceNode> Create(
AudioContext& aAudioContext,
const MediaElementAudioSourceOptions& aOptions, ErrorResult& aRv);
@ -42,8 +45,12 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
HTMLMediaElement* MediaElement();
private:
explicit MediaElementAudioSourceNode(AudioContext* aContext);
explicit MediaElementAudioSourceNode(AudioContext* aContext,
HTMLMediaElement* aElement);
~MediaElementAudioSourceNode() = default;
void Destroy() override;
@ -52,6 +59,8 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode {
void ListenForAllowedToPlay(const MediaElementAudioSourceOptions& aOptions);
MozPromiseRequestHolder<GenericNonExclusivePromise> mAllowedToPlayRequest;
RefPtr<HTMLMediaElement> mElement;
};
} // namespace dom

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

@ -65,6 +65,8 @@ class MediaStreamAudioSourceNode
uint16_t NumberOfInputs() const override { return 0; }
DOMMediaStream* GetMediaStream() { return mInputStream; }
const char* NodeType() const override { return "MediaStreamAudioSourceNode"; }
virtual const char* CrossOriginErrorString() const {

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

@ -17,7 +17,7 @@ dictionary MediaElementAudioSourceOptions {
[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, MediaElementAudioSourceOptions options)]
interface MediaElementAudioSourceNode : AudioNode {
readonly attribute HTMLMediaElement mediaElement;
};
// Mozilla extensions

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

@ -17,7 +17,8 @@ dictionary MediaStreamAudioSourceOptions {
[Pref="dom.webaudio.enabled",
Constructor(AudioContext context, MediaStreamAudioSourceOptions options)]
interface MediaStreamAudioSourceNode : AudioNode {
[BinaryName="GetMediaStream"]
readonly attribute MediaStream mediaStream;
};
// Mozilla extensions

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

@ -14,9 +14,6 @@
[AudioListener interface: attribute forwardX]
expected: FAIL
[MediaStreamAudioSourceNode interface: attribute mediaStream]
expected: FAIL
[AudioParam interface: calling cancelAndHoldAtTime(double) on new AudioBufferSourceNode(context).playbackRate with too few arguments must throw TypeError]
expected: FAIL
@ -38,9 +35,6 @@
[AudioListener interface: context.listener must inherit property "positionY" with the proper type]
expected: FAIL
[MediaElementAudioSourceNode interface: new MediaElementAudioSourceNode(context, {mediaElement: new Audio}) must inherit property "mediaElement" with the proper type]
expected: FAIL
[Stringification of new AudioProcessingEvent('', {\n playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer\n })]
expected: FAIL
@ -68,9 +62,6 @@
[AudioListener interface: context.listener must inherit property "forwardY" with the proper type]
expected: FAIL
[MediaElementAudioSourceNode interface: attribute mediaElement]
expected: FAIL
[AudioListener interface: context.listener must inherit property "positionX" with the proper type]
expected: FAIL