VideoTrack.h (2172B)
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::dom { 13 14 class VideoTrackList; 15 class VideoStreamTrack; 16 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); 23 24 NS_DECL_ISUPPORTS_INHERITED 25 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VideoTrack, MediaTrack) 26 27 JSObject* WrapObject(JSContext* aCx, 28 JS::Handle<JSObject*> aGivenProto) override; 29 30 VideoTrack* AsVideoTrack() override { return this; } 31 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; 38 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; } 43 44 // WebIDL 45 bool Selected() const { return mSelected; } 46 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); 51 52 private: 53 virtual ~VideoTrack(); 54 55 bool mSelected; 56 RefPtr<VideoStreamTrack> mVideoStreamTrack; 57 }; 58 59 } // namespace mozilla::dom 60 61 #endif // mozilla_dom_VideoTrack_h