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 {
13 namespace dom {
14 
15 class AudioStreamTrack;
16 
17 class AudioTrack : public MediaTrack {
18  public:
19   AudioTrack(nsIGlobalObject* aOwnerGlobal, const nsAString& aId,
20              const nsAString& aKind, const nsAString& aLabel,
21              const nsAString& aLanguage, bool aEnabled,
22              AudioStreamTrack* aStreamTrack = nullptr);
23 
24   NS_DECL_ISUPPORTS_INHERITED
25   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioTrack, MediaTrack)
26 
27   JSObject* WrapObject(JSContext* aCx,
28                        JS::Handle<JSObject*> aGivenProto) override;
29 
AsAudioTrack()30   AudioTrack* AsAudioTrack() override { return this; }
31 
32   void SetEnabledInternal(bool aEnabled, int aFlags) override;
33 
34   // Get associated audio stream track when the audio track comes from
35   // MediaStream. This might be nullptr when the src of owning HTMLMediaElement
36   // is not MediaStream.
GetAudioStreamTrack()37   AudioStreamTrack* GetAudioStreamTrack() { return mAudioStreamTrack; }
38 
39   // WebIDL
Enabled()40   bool Enabled() const { return mEnabled; }
41 
42   void SetEnabled(bool aEnabled);
43 
44  private:
45   virtual ~AudioTrack();
46 
47   bool mEnabled;
48   RefPtr<AudioStreamTrack> mAudioStreamTrack;
49 };
50 
51 }  // namespace dom
52 }  // namespace mozilla
53 
54 #endif  // mozilla_dom_AudioTrack_h
55