1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/MediaStreamTrack.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef MEDIASTREAMTRACK_H_ 1.10 +#define MEDIASTREAMTRACK_H_ 1.11 + 1.12 +#include "mozilla/DOMEventTargetHelper.h" 1.13 +#include "nsID.h" 1.14 +#include "StreamBuffer.h" 1.15 + 1.16 +namespace mozilla { 1.17 + 1.18 +class DOMMediaStream; 1.19 + 1.20 +namespace dom { 1.21 + 1.22 +class AudioStreamTrack; 1.23 +class VideoStreamTrack; 1.24 + 1.25 +/** 1.26 + * Class representing a track in a DOMMediaStream. 1.27 + */ 1.28 +class MediaStreamTrack : public DOMEventTargetHelper { 1.29 +public: 1.30 + /** 1.31 + * aTrackID is the MediaStreamGraph track ID for the track in the 1.32 + * MediaStream owned by aStream. 1.33 + */ 1.34 + MediaStreamTrack(DOMMediaStream* aStream, TrackID aTrackID); 1.35 + virtual ~MediaStreamTrack(); 1.36 + 1.37 + NS_DECL_ISUPPORTS_INHERITED 1.38 + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamTrack, 1.39 + DOMEventTargetHelper) 1.40 + 1.41 + DOMMediaStream* GetParentObject() const { return mStream; } 1.42 + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE = 0; 1.43 + 1.44 + DOMMediaStream* GetStream() const { return mStream; } 1.45 + TrackID GetTrackID() const { return mTrackID; } 1.46 + virtual AudioStreamTrack* AsAudioStreamTrack() { return nullptr; } 1.47 + virtual VideoStreamTrack* AsVideoStreamTrack() { return nullptr; } 1.48 + 1.49 + // WebIDL 1.50 + virtual void GetKind(nsAString& aKind) = 0; 1.51 + void GetId(nsAString& aID); 1.52 + void GetLabel(nsAString& aLabel) { aLabel.Truncate(); } 1.53 + bool Enabled() { return mEnabled; } 1.54 + void SetEnabled(bool aEnabled); 1.55 + 1.56 + // Notifications from the MediaStreamGraph 1.57 + void NotifyEnded() { mEnded = true; } 1.58 + 1.59 +protected: 1.60 + nsRefPtr<DOMMediaStream> mStream; 1.61 + TrackID mTrackID; 1.62 + nsID mID; 1.63 + bool mEnded; 1.64 + bool mEnabled; 1.65 +}; 1.66 + 1.67 +} 1.68 +} 1.69 + 1.70 +#endif /* MEDIASTREAMTRACK_H_ */