tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MediaDataEncoderProxy.h (1841B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #if !defined(MediaDataEncoderProxy_h_)
      8 #  define MediaDataEncoderProxy_h_
      9 
     10 #  include "PlatformEncoderModule.h"
     11 #  include "mozilla/Atomics.h"
     12 #  include "mozilla/RefPtr.h"
     13 #  include "nsThreadUtils.h"
     14 #  include "nscore.h"
     15 
     16 namespace mozilla {
     17 
     18 class MediaDataEncoderProxy final : public MediaDataEncoder {
     19 public:
     20  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataEncoderProxy, final);
     21 
     22  explicit MediaDataEncoderProxy(
     23      already_AddRefed<MediaDataEncoder> aProxyEncoder,
     24      already_AddRefed<nsISerialEventTarget> aProxyThread);
     25 
     26  RefPtr<InitPromise> Init() override;
     27  RefPtr<EncodePromise> Encode(const MediaData* aSample) override;
     28  RefPtr<EncodePromise> Encode(nsTArray<RefPtr<MediaData>>&& aSamples) override;
     29  RefPtr<ReconfigurationPromise> Reconfigure(
     30      const RefPtr<const EncoderConfigurationChangeList>& aConfigurationChanges)
     31      override;
     32  RefPtr<EncodePromise> Drain() override;
     33  RefPtr<ShutdownPromise> Shutdown() override;
     34  RefPtr<GenericPromise> SetBitrate(uint32_t aBitsPerSec) override;
     35  bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
     36  nsCString GetDescriptionName() const override;
     37 
     38 protected:
     39  virtual ~MediaDataEncoderProxy();
     40 
     41 private:
     42  // Set on construction and clear on the proxy thread if set.
     43  RefPtr<MediaDataEncoder> mProxyEncoder;
     44  const nsCOMPtr<nsISerialEventTarget> mProxyThread;
     45 
     46 #  if defined(DEBUG)
     47  Atomic<bool> mIsShutdown = Atomic<bool>(false);
     48 #  endif
     49 };
     50 
     51 }  // namespace mozilla
     52 
     53 #endif  // MediaDataEncoderProxy_h_