dom/media/MediaStreamWindowCapturer.h
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Wed, 25 May 2022 18:56:29 +0000
changeset 618847 fb0c469ac2fb9ed647bb174a047ea396f472adaf
parent 495897 9ea7aabf10fbf326e43daaa88b30f477b4ee3c32
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD cy -> 18a3618fb08f9f3d0e6f5e3b4204193f154d6c98 es-AR -> d5f750233cd6e462d5170d396d5cd51f0ee64e81 eu -> 89eb1d19cbc2092da7c92305075e65b32cd4512d fi -> a4cac829965a4562b98df47ac5a5f3fe31a35fbf fr -> 906fdc5ffdd0eba897ab0796422a61e2d325640a fy-NL -> 5b22201eded974b72789b1974623023c84286948 it -> ed918e4ee4ab3b3f6f421c816eb4fcf32f76330f nl -> 52db668d98e87cff8c22b4448a50230aa05029b1 rm -> 12e718da5d7b059ba9dc4a18f56990a5adfc8658 ru -> 233a1c00ee183d01ca8592ddd3df434159ba1b8b

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MediaStreamWindowCapturer_h
#define MediaStreamWindowCapturer_h

#include "DOMMediaStream.h"

namespace mozilla {
namespace dom {
class AudioStreamTrack;
class MediaStreamTrack;
}  // namespace dom

class MediaInputPort;

/**
 * Given a DOMMediaStream and a window id, this class will pipe the audio from
 * all live audio tracks in the stream to the MediaTrackGraph's window capture
 * mechanism.
 */
class MediaStreamWindowCapturer : public DOMMediaStream::TrackListener {
 public:
  MediaStreamWindowCapturer(DOMMediaStream* aStream, uint64_t aWindowId);
  ~MediaStreamWindowCapturer();

  void NotifyTrackAdded(const RefPtr<dom::MediaStreamTrack>& aTrack) override;
  void NotifyTrackRemoved(const RefPtr<dom::MediaStreamTrack>& aTrack) override;

  struct CapturedTrack {
    CapturedTrack(dom::MediaStreamTrack* aTrack, uint64_t aWindowID);
    ~CapturedTrack();

    const WeakPtr<dom::MediaStreamTrack> mTrack;
    const RefPtr<MediaInputPort> mPort;
  };

  const WeakPtr<DOMMediaStream> mStream;
  const uint64_t mWindowId;

 protected:
  void AddTrack(dom::AudioStreamTrack* aTrack);
  void RemoveTrack(dom::AudioStreamTrack* aTrack);

  nsTArray<UniquePtr<CapturedTrack>> mTracks;
};
}  // namespace mozilla

#endif /* MediaStreamWindowCapturer_h */