Line data Source code
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_VideoTrack_h
8 : #define mozilla_dom_VideoTrack_h
9 :
10 : #include "MediaTrack.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 : class VideoTrackList;
16 : class VideoStreamTrack;
17 :
18 : class VideoTrack : public MediaTrack
19 : {
20 : public:
21 : VideoTrack(const nsAString& aId,
22 : const nsAString& aKind,
23 : const nsAString& aLabel,
24 : const nsAString& aLanguage,
25 : VideoStreamTrack* aStreamTarck = nullptr);
26 :
27 : NS_DECL_ISUPPORTS_INHERITED
28 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VideoTrack, MediaTrack)
29 :
30 : JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
31 :
32 0 : VideoTrack* AsVideoTrack() override
33 : {
34 0 : return this;
35 : }
36 :
37 : // When fetching media resource, if no video track is selected by the media
38 : // resource, then the first VideoTrack object in the list is set selected as
39 : // default. If multiple video tracks are selected by its media resource at
40 : // fetching phase, then the first enabled video track is set selected.
41 : // aFlags contains FIRE_NO_EVENTS because no events are fired in such cases.
42 : void SetEnabledInternal(bool aEnabled, int aFlags) override;
43 :
44 : // Get associated video stream track when the video track comes from
45 : // MediaStream. This might be nullptr when the src of owning HTMLMediaElement
46 : // is not MediaStream.
47 0 : VideoStreamTrack* GetVideoStreamTrack() { return mVideoStreamTrack; }
48 :
49 : // WebIDL
50 0 : bool Selected() const
51 : {
52 0 : return mSelected;
53 : }
54 :
55 : // Either zero or one video track is selected in a list; If the selected track
56 : // is in a VideoTrackList, then all the other VideoTrack objects in that list
57 : // must be unselected.
58 : void SetSelected(bool aSelected);
59 :
60 : private:
61 : virtual ~VideoTrack();
62 :
63 : bool mSelected;
64 : RefPtr<VideoStreamTrack> mVideoStreamTrack;
65 : };
66 :
67 : } // namespace dom
68 : } // namespace mozilla
69 :
70 : #endif // mozilla_dom_VideoTrack_h
|