michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MEDIASTREAMTRACK_H_ michael@0: #define MEDIASTREAMTRACK_H_ michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "nsID.h" michael@0: #include "StreamBuffer.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class DOMMediaStream; michael@0: michael@0: namespace dom { michael@0: michael@0: class AudioStreamTrack; michael@0: class VideoStreamTrack; michael@0: michael@0: /** michael@0: * Class representing a track in a DOMMediaStream. michael@0: */ michael@0: class MediaStreamTrack : public DOMEventTargetHelper { michael@0: public: michael@0: /** michael@0: * aTrackID is the MediaStreamGraph track ID for the track in the michael@0: * MediaStream owned by aStream. michael@0: */ michael@0: MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID); michael@0: virtual ~MediaStreamTrack(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack, michael@0: DOMEventTargetHelper) michael@0: michael@0: DOMMediaStream* GetParentObject() const { return mStream; } michael@0: virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE = 0; michael@0: michael@0: DOMMediaStream* GetStream() const { return mStream; } michael@0: TrackID GetTrackID() const { return mTrackID; } michael@0: virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; } michael@0: virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; } michael@0: michael@0: // WebIDL michael@0: virtual void GetKind(nsAString& aKind) = 0; michael@0: void GetId(nsAString& aID); michael@0: void GetLabel(nsAString& aLabel) { aLabel.Truncate(); } michael@0: bool Enabled() { return mEnabled; } michael@0: void SetEnabled(bool aEnabled); michael@0: michael@0: // Notifications from the MediaStreamGraph michael@0: void NotifyEnded() { mEnded = true; } michael@0: michael@0: protected: michael@0: nsRefPtr mStream; michael@0: TrackID mTrackID; michael@0: nsID mID; michael@0: bool mEnded; michael@0: bool mEnabled; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* MEDIASTREAMTRACK_H_ */