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 13:18:51 +00:00
Родитель 358d1707a7
Коммит 03e7bf883c
6 изменённых файлов: 22 добавлений и 16 удалений

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

@ -13,9 +13,12 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* aContext) MediaElementAudioSourceNode::MediaElementAudioSourceNode(
: MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges) { AudioContext* aContext, HTMLMediaElement* aElement)
} : MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges),
mElement(aElement) {
MOZ_ASSERT(aElement);
}
/* static */ /* static */
already_AddRefed<MediaElementAudioSourceNode> already_AddRefed<MediaElementAudioSourceNode>
@ -28,7 +31,7 @@ MediaElementAudioSourceNode::Create(
} }
RefPtr<MediaElementAudioSourceNode> node = RefPtr<MediaElementAudioSourceNode> node =
new MediaElementAudioSourceNode(&aAudioContext); new MediaElementAudioSourceNode(&aAudioContext, aOptions.mMediaElement);
RefPtr<DOMMediaStream> stream = aOptions.mMediaElement->CaptureAudio( RefPtr<DOMMediaStream> stream = aOptions.mMediaElement->CaptureAudio(
aRv, aAudioContext.Destination()->Stream()->Graph()); aRv, aAudioContext.Destination()->Stream()->Graph());
@ -71,5 +74,9 @@ void MediaElementAudioSourceNode::Destroy() {
MediaStreamAudioSourceNode::Destroy(); MediaStreamAudioSourceNode::Destroy();
} }
HTMLMediaElement* MediaElementAudioSourceNode::MediaElement() {
return mElement;
}
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

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

@ -42,8 +42,11 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
} }
HTMLMediaElement* MediaElement();
private: private:
explicit MediaElementAudioSourceNode(AudioContext* aContext); explicit MediaElementAudioSourceNode(AudioContext* aContext,
HTMLMediaElement* aElement);
void Destroy() override; void Destroy() override;
@ -52,6 +55,8 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode {
void ListenForAllowedToPlay(const MediaElementAudioSourceOptions& aOptions); void ListenForAllowedToPlay(const MediaElementAudioSourceOptions& aOptions);
MozPromiseRequestHolder<GenericNonExclusivePromise> mAllowedToPlayRequest; MozPromiseRequestHolder<GenericNonExclusivePromise> mAllowedToPlayRequest;
RefPtr<HTMLMediaElement> mElement;
}; };
} // namespace dom } // namespace dom

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

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

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

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

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

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

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

@ -14,9 +14,6 @@
[AudioListener interface: attribute forwardX] [AudioListener interface: attribute forwardX]
expected: FAIL 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] [AudioParam interface: calling cancelAndHoldAtTime(double) on new AudioBufferSourceNode(context).playbackRate with too few arguments must throw TypeError]
expected: FAIL expected: FAIL
@ -41,9 +38,6 @@
[AudioListener interface: context.listener must inherit property "positionY" with the proper type] [AudioListener interface: context.listener must inherit property "positionY" with the proper type]
expected: FAIL expected: FAIL
[MediaElementAudioSourceNode interface: new MediaElementAudioSourceNode(context, {mediaElement: new Audio}) must inherit property "mediaElement" with the proper type]
expected: FAIL
[AudioContext interface: operation getOutputTimestamp()] [AudioContext interface: operation getOutputTimestamp()]
expected: FAIL expected: FAIL
@ -77,9 +71,6 @@
[AudioContext interface: context must inherit property "baseLatency" with the proper type] [AudioContext interface: context must inherit property "baseLatency" with the proper type]
expected: FAIL expected: FAIL
[MediaElementAudioSourceNode interface: attribute mediaElement]
expected: FAIL
[AudioListener interface: context.listener must inherit property "positionX" with the proper type] [AudioListener interface: context.listener must inherit property "positionX" with the proper type]
expected: FAIL expected: FAIL