Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / media / VideoTrack.h
blobaf632090eeab64ed518b3de2d669dab613d49eb6
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_VideoTrack_h
8 #define mozilla_dom_VideoTrack_h
10 #include "MediaTrack.h"
12 namespace mozilla::dom {
14 class VideoTrackList;
15 class VideoStreamTrack;
17 class VideoTrack : public MediaTrack {
18 public:
19 VideoTrack(nsIGlobalObject* aOwnerGlobal, const nsAString& aId,
20 const nsAString& aKind, const nsAString& aLabel,
21 const nsAString& aLanguage,
22 VideoStreamTrack* aStreamTrack = nullptr);
24 NS_DECL_ISUPPORTS_INHERITED
25 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VideoTrack, MediaTrack)
27 JSObject* WrapObject(JSContext* aCx,
28 JS::Handle<JSObject*> aGivenProto) override;
30 VideoTrack* AsVideoTrack() override { return this; }
32 // When fetching media resource, if no video track is selected by the media
33 // resource, then the first VideoTrack object in the list is set selected as
34 // default. If multiple video tracks are selected by its media resource at
35 // fetching phase, then the first enabled video track is set selected.
36 // aFlags contains FIRE_NO_EVENTS because no events are fired in such cases.
37 void SetEnabledInternal(bool aEnabled, int aFlags) override;
39 // Get associated video stream track when the video track comes from
40 // MediaStream. This might be nullptr when the src of owning HTMLMediaElement
41 // is not MediaStream.
42 VideoStreamTrack* GetVideoStreamTrack() { return mVideoStreamTrack; }
44 // WebIDL
45 bool Selected() const { return mSelected; }
47 // Either zero or one video track is selected in a list; If the selected track
48 // is in a VideoTrackList, then all the other VideoTrack objects in that list
49 // must be unselected.
50 void SetSelected(bool aSelected);
52 private:
53 virtual ~VideoTrack();
55 bool mSelected;
56 RefPtr<VideoStreamTrack> mVideoStreamTrack;
59 } // namespace mozilla::dom
61 #endif // mozilla_dom_VideoTrack_h