Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / media / MediaStreamWindowCapturer.h
blobdfd6062c3cb29db84ed0f8ad82e4b742daa2d724
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/. */
6 #ifndef MediaStreamWindowCapturer_h
7 #define MediaStreamWindowCapturer_h
9 #include "DOMMediaStream.h"
11 namespace mozilla {
12 namespace dom {
13 class AudioStreamTrack;
14 class MediaStreamTrack;
15 } // namespace dom
17 class MediaInputPort;
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.
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)
31 void NotifyTrackAdded(const RefPtr<dom::MediaStreamTrack>& aTrack) override;
32 void NotifyTrackRemoved(const RefPtr<dom::MediaStreamTrack>& aTrack) override;
34 struct CapturedTrack {
35 CapturedTrack(dom::MediaStreamTrack* aTrack, uint64_t aWindowID);
36 ~CapturedTrack();
38 const WeakPtr<dom::MediaStreamTrack> mTrack;
39 const RefPtr<MediaInputPort> mPort;
42 const WeakPtr<DOMMediaStream> mStream;
43 const uint64_t mWindowId;
45 protected:
46 ~MediaStreamWindowCapturer();
47 void AddTrack(dom::AudioStreamTrack* aTrack);
48 void RemoveTrack(dom::AudioStreamTrack* aTrack);
50 nsTArray<UniquePtr<CapturedTrack>> mTracks;
52 } // namespace mozilla
54 #endif /* MediaStreamWindowCapturer_h */