AudioTrack.h (1588B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 et tw=78: */ 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 mozilla_dom_AudioTrack_h 8 #define mozilla_dom_AudioTrack_h 9 10 #include "MediaTrack.h" 11 12 namespace mozilla::dom { 13 14 class AudioStreamTrack; 15 16 class AudioTrack : public MediaTrack { 17 public: 18 AudioTrack(nsIGlobalObject* aOwnerGlobal, const nsAString& aId, 19 const nsAString& aKind, const nsAString& aLabel, 20 const nsAString& aLanguage, bool aEnabled, 21 AudioStreamTrack* aStreamTrack = nullptr); 22 23 NS_DECL_ISUPPORTS_INHERITED 24 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioTrack, MediaTrack) 25 26 JSObject* WrapObject(JSContext* aCx, 27 JS::Handle<JSObject*> aGivenProto) override; 28 29 AudioTrack* AsAudioTrack() override { return this; } 30 31 void SetEnabledInternal(bool aEnabled, int aFlags) override; 32 33 // Get associated audio stream track when the audio track comes from 34 // MediaStream. This might be nullptr when the src of owning HTMLMediaElement 35 // is not MediaStream. 36 AudioStreamTrack* GetAudioStreamTrack() { return mAudioStreamTrack; } 37 38 // WebIDL 39 bool Enabled() const { return mEnabled; } 40 41 void SetEnabled(bool aEnabled); 42 43 private: 44 virtual ~AudioTrack(); 45 46 bool mEnabled; 47 RefPtr<AudioStreamTrack> mAudioStreamTrack; 48 }; 49 50 } // namespace mozilla::dom 51 52 #endif // mozilla_dom_AudioTrack_h