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/. */
7 #ifndef mozilla_dom_MediaTrack_h
8 #define mozilla_dom_MediaTrack_h
10 #include "mozilla/DOMEventTargetHelper.h"
20 * Base class of AudioTrack and VideoTrack. The AudioTrack and VideoTrack
21 * objects represent specific tracks of a media resource. Each track has aspects
22 * of an identifier, category, label, and language, even if a track is removed
23 * from its corresponding track list, those aspects do not change.
25 * When fetching the media resource, an audio/video track is created if the
26 * media resource is found to have an audio/video track. When the UA has learned
27 * that an audio/video track has ended, this audio/video track will be removed
28 * from its corresponding track list.
30 * Although AudioTrack and VideoTrack are not EventTargets, TextTrack is, and
31 * TextTrack inherits from MediaTrack as well (or is going to).
33 class MediaTrack
: public DOMEventTargetHelper
36 MediaTrack(nsIGlobalObject
* aOwnerGlobal
,
38 const nsAString
& aKind
,
39 const nsAString
& aLabel
,
40 const nsAString
& aLanguage
);
42 NS_DECL_ISUPPORTS_INHERITED
43 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaTrack
, DOMEventTargetHelper
)
47 FIRE_NO_EVENTS
= 1 << 0,
49 // The default behavior of enabling an audio track or selecting a video track
50 // fires a change event and notifies its media resource about the changes.
51 // It should not fire any events when fetching media resource.
52 virtual void SetEnabledInternal(bool aEnabled
, int aFlags
) = 0;
54 virtual AudioTrack
* AsAudioTrack()
59 virtual VideoTrack
* AsVideoTrack()
64 const nsString
& GetId() const
70 void GetId(nsAString
& aId
) const
74 void GetKind(nsAString
& aKind
) const
78 void GetLabel(nsAString
& aLabel
) const
82 void GetLanguage(nsAString
& aLanguage
) const
84 aLanguage
= mLanguage
;
87 friend class MediaTrackList
;
90 virtual ~MediaTrack();
92 void SetTrackList(MediaTrackList
* aList
);
94 RefPtr
<MediaTrackList
> mList
;
102 } // namespace mozilla
104 #endif // mozilla_dom_MediaTrack_h