Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef MEDIASTREAMTRACK_H_ |
michael@0 | 7 | #define MEDIASTREAMTRACK_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 10 | #include "nsID.h" |
michael@0 | 11 | #include "StreamBuffer.h" |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | |
michael@0 | 15 | class DOMMediaStream; |
michael@0 | 16 | |
michael@0 | 17 | namespace dom { |
michael@0 | 18 | |
michael@0 | 19 | class AudioStreamTrack; |
michael@0 | 20 | class VideoStreamTrack; |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * Class representing a track in a DOMMediaStream. |
michael@0 | 24 | */ |
michael@0 | 25 | class MediaStreamTrack : public DOMEventTargetHelper { |
michael@0 | 26 | public: |
michael@0 | 27 | /** |
michael@0 | 28 | * aTrackID is the MediaStreamGraph track ID for the track in the |
michael@0 | 29 | * MediaStream owned by aStream. |
michael@0 | 30 | */ |
michael@0 | 31 | MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID); |
michael@0 | 32 | virtual ~MediaStreamTrack(); |
michael@0 | 33 | |
michael@0 | 34 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 35 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack, |
michael@0 | 36 | DOMEventTargetHelper) |
michael@0 | 37 | |
michael@0 | 38 | DOMMediaStream* GetParentObject() const { return mStream; } |
michael@0 | 39 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE = 0; |
michael@0 | 40 | |
michael@0 | 41 | DOMMediaStream* GetStream() const { return mStream; } |
michael@0 | 42 | TrackID GetTrackID() const { return mTrackID; } |
michael@0 | 43 | virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; } |
michael@0 | 44 | virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; } |
michael@0 | 45 | |
michael@0 | 46 | // WebIDL |
michael@0 | 47 | virtual void GetKind(nsAString& aKind) = 0; |
michael@0 | 48 | void GetId(nsAString& aID); |
michael@0 | 49 | void GetLabel(nsAString& aLabel) { aLabel.Truncate(); } |
michael@0 | 50 | bool Enabled() { return mEnabled; } |
michael@0 | 51 | void SetEnabled(bool aEnabled); |
michael@0 | 52 | |
michael@0 | 53 | // Notifications from the MediaStreamGraph |
michael@0 | 54 | void NotifyEnded() { mEnded = true; } |
michael@0 | 55 | |
michael@0 | 56 | protected: |
michael@0 | 57 | nsRefPtr<DOMMediaStream> mStream; |
michael@0 | 58 | TrackID mTrackID; |
michael@0 | 59 | nsID mID; |
michael@0 | 60 | bool mEnded; |
michael@0 | 61 | bool mEnabled; |
michael@0 | 62 | }; |
michael@0 | 63 | |
michael@0 | 64 | } |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | #endif /* MEDIASTREAMTRACK_H_ */ |