|
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/. */ |
|
5 |
|
6 #ifndef MEDIASTREAMTRACK_H_ |
|
7 #define MEDIASTREAMTRACK_H_ |
|
8 |
|
9 #include "mozilla/DOMEventTargetHelper.h" |
|
10 #include "nsID.h" |
|
11 #include "StreamBuffer.h" |
|
12 |
|
13 namespace mozilla { |
|
14 |
|
15 class DOMMediaStream; |
|
16 |
|
17 namespace dom { |
|
18 |
|
19 class AudioStreamTrack; |
|
20 class VideoStreamTrack; |
|
21 |
|
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(); |
|
33 |
|
34 NS_DECL_ISUPPORTS_INHERITED |
|
35 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack, |
|
36 DOMEventTargetHelper) |
|
37 |
|
38 DOMMediaStream* GetParentObject() const { return mStream; } |
|
39 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE = 0; |
|
40 |
|
41 DOMMediaStream* GetStream() const { return mStream; } |
|
42 TrackID GetTrackID() const { return mTrackID; } |
|
43 virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; } |
|
44 virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; } |
|
45 |
|
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); |
|
52 |
|
53 // Notifications from the MediaStreamGraph |
|
54 void NotifyEnded() { mEnded = true; } |
|
55 |
|
56 protected: |
|
57 nsRefPtr<DOMMediaStream> mStream; |
|
58 TrackID mTrackID; |
|
59 nsID mID; |
|
60 bool mEnded; |
|
61 bool mEnabled; |
|
62 }; |
|
63 |
|
64 } |
|
65 } |
|
66 |
|
67 #endif /* MEDIASTREAMTRACK_H_ */ |