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