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"
13 class AudioStreamTrack
;
14 class MediaStreamTrack
;
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
24 class MediaStreamWindowCapturer
: public DOMMediaStream::TrackListener
{
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
);
38 const WeakPtr
<dom::MediaStreamTrack
> mTrack
;
39 const RefPtr
<MediaInputPort
> mPort
;
42 const WeakPtr
<DOMMediaStream
> mStream
;
43 const uint64_t mWindowId
;
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 */