MediaElementAudioSourceNode.h (2269B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MediaElementAudioSourceNode_h_ 8 #define MediaElementAudioSourceNode_h_ 9 10 #include "MediaStreamAudioSourceNode.h" 11 12 namespace mozilla::dom { 13 14 class AudioContext; 15 struct MediaElementAudioSourceOptions; 16 17 class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode { 18 public: 19 NS_DECL_ISUPPORTS_INHERITED 20 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaElementAudioSourceNode, 21 MediaStreamAudioSourceNode) 22 static already_AddRefed<MediaElementAudioSourceNode> Create( 23 AudioContext& aAudioContext, 24 const MediaElementAudioSourceOptions& aOptions, ErrorResult& aRv); 25 26 static already_AddRefed<MediaElementAudioSourceNode> Constructor( 27 const GlobalObject& aGlobal, AudioContext& aAudioContext, 28 const MediaElementAudioSourceOptions& aOptions, ErrorResult& aRv) { 29 return Create(aAudioContext, aOptions, aRv); 30 } 31 32 JSObject* WrapObject(JSContext* aCx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 35 const char* NodeType() const override { 36 return "MediaElementAudioSourceNode"; 37 } 38 39 const char* CrossOriginErrorString() const override { 40 return "MediaElementAudioSourceNodeCrossOrigin"; 41 } 42 43 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override { 44 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); 45 } 46 47 HTMLMediaElement* MediaElement(); 48 49 private: 50 explicit MediaElementAudioSourceNode(AudioContext* aContext, 51 HTMLMediaElement* aElement); 52 ~MediaElementAudioSourceNode() = default; 53 54 void Destroy() override; 55 56 // If AudioContext was not allowed to start, we would try to start it when 57 // source starts. 58 void ListenForAllowedToPlay(const MediaElementAudioSourceOptions& aOptions); 59 60 MozPromiseRequestHolder<GenericNonExclusivePromise> mAllowedToPlayRequest; 61 62 RefPtr<HTMLMediaElement> mElement; 63 }; 64 65 } // namespace mozilla::dom 66 67 #endif