1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef _REMOTE_TRACK_SOURCE_H_ 6 #define _REMOTE_TRACK_SOURCE_H_ 7 8 #include "MediaStreamTrack.h" 9 #include "MediaStreamError.h" 10 11 namespace mozilla { 12 13 class RemoteTrackSource : public dom::MediaStreamTrackSource { 14 public: RemoteTrackSource(SourceMediaTrack * aStream,nsIPrincipal * aPrincipal,const nsString & aLabel)15 explicit RemoteTrackSource(SourceMediaTrack* aStream, 16 nsIPrincipal* aPrincipal, const nsString& aLabel) 17 : dom::MediaStreamTrackSource(aPrincipal, aLabel), mStream(aStream) {} 18 GetMediaSource()19 dom::MediaSourceEnum GetMediaSource() const override { 20 return dom::MediaSourceEnum::Other; 21 } 22 ApplyConstraints(const dom::MediaTrackConstraints & aConstraints,dom::CallerType aCallerType)23 RefPtr<ApplyConstraintsPromise> ApplyConstraints( 24 const dom::MediaTrackConstraints& aConstraints, 25 dom::CallerType aCallerType) override { 26 return ApplyConstraintsPromise::CreateAndReject( 27 MakeRefPtr<MediaMgrError>( 28 dom::MediaStreamError::Name::OverconstrainedError, 29 NS_LITERAL_STRING("")), 30 __func__); 31 } 32 Stop()33 void Stop() override { 34 // XXX (Bug 1314270): Implement rejection logic if necessary when we have 35 // clarity in the spec. 36 } 37 Disable()38 void Disable() override {} 39 Enable()40 void Enable() override {} 41 SetPrincipal(nsIPrincipal * aPrincipal)42 void SetPrincipal(nsIPrincipal* aPrincipal) { 43 mPrincipal = aPrincipal; 44 PrincipalChanged(); 45 } SetMuted(bool aMuted)46 void SetMuted(bool aMuted) { MutedChanged(aMuted); } ForceEnded()47 void ForceEnded() { OverrideEnded(); } 48 49 const RefPtr<SourceMediaTrack> mStream; 50 51 protected: ~RemoteTrackSource()52 virtual ~RemoteTrackSource() { 53 MOZ_ASSERT(NS_IsMainThread()); 54 MOZ_ASSERT(mStream->IsDestroyed()); 55 } 56 }; 57 58 } // namespace mozilla 59 60 #endif // _REMOTE_TRACK_SOURCE_H_ 61