MediaStreamWindowCapturer.h (1729B)
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 MediaStreamWindowCapturer_h 7 #define MediaStreamWindowCapturer_h 8 9 #include "DOMMediaStream.h" 10 11 namespace mozilla { 12 namespace dom { 13 class AudioStreamTrack; 14 class MediaStreamTrack; 15 } // namespace dom 16 17 class MediaInputPort; 18 19 /** 20 * Given a DOMMediaStream and a window id, this class will pipe the audio from 21 * all live audio tracks in the stream to the MediaTrackGraph's window capture 22 * mechanism. 23 */ 24 class MediaStreamWindowCapturer : public DOMMediaStream::TrackListener { 25 public: 26 MediaStreamWindowCapturer(DOMMediaStream* aStream, uint64_t aWindowId); 27 NS_DECL_ISUPPORTS_INHERITED 28 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaStreamWindowCapturer, 29 DOMMediaStream::TrackListener) 30 31 void NotifyTrackAdded(const RefPtr<dom::MediaStreamTrack>& aTrack) override; 32 void NotifyTrackRemoved(const RefPtr<dom::MediaStreamTrack>& aTrack) override; 33 34 struct CapturedTrack { 35 CapturedTrack(dom::MediaStreamTrack* aTrack, uint64_t aWindowID); 36 ~CapturedTrack(); 37 38 const WeakPtr<dom::MediaStreamTrack> mTrack; 39 const RefPtr<MediaInputPort> mPort; 40 }; 41 42 const WeakPtr<DOMMediaStream> mStream; 43 const uint64_t mWindowId; 44 45 protected: 46 ~MediaStreamWindowCapturer(); 47 void AddTrack(dom::AudioStreamTrack* aTrack); 48 void RemoveTrack(dom::AudioStreamTrack* aTrack); 49 50 nsTArray<UniquePtr<CapturedTrack>> mTracks; 51 }; 52 } // namespace mozilla 53 54 #endif /* MediaStreamWindowCapturer_h */