tor-browser

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

UtilityMediaServiceChild.h (3455B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 sts=2 et sw=2 tw=80: */
      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 #ifndef _include_ipc_glue_UtilityMediaServiceChild_h__
      7 #define _include_ipc_glue_UtilityMediaServiceChild_h__
      8 
      9 #include "mozilla/ProcInfo.h"
     10 #include "mozilla/ProfilerMarkers.h"
     11 #include "mozilla/RefPtr.h"
     12 
     13 #include "mozilla/ipc/Endpoint.h"
     14 #include "mozilla/ipc/UtilityProcessParent.h"
     15 #include "mozilla/ipc/UtilityProcessSandboxing.h"
     16 #include "mozilla/ipc/UtilityMediaService.h"
     17 #include "mozilla/ipc/PUtilityMediaServiceChild.h"
     18 #include "mozilla/gfx/gfxVarReceiver.h"
     19 
     20 #ifdef MOZ_WMF_MEDIA_ENGINE
     21 #  include "mozilla/gfx/GPUProcessListener.h"
     22 #endif
     23 
     24 #include "PDMFactory.h"
     25 
     26 namespace mozilla::ipc {
     27 
     28 class UtilityMediaServiceChildShutdownObserver : public nsIObserver {
     29 public:
     30  explicit UtilityMediaServiceChildShutdownObserver(SandboxingKind aKind)
     31      : mSandbox(aKind) {};
     32 
     33  NS_DECL_ISUPPORTS
     34 
     35  NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
     36                     const char16_t* aData) override;
     37 
     38 private:
     39  virtual ~UtilityMediaServiceChildShutdownObserver() = default;
     40 
     41  const SandboxingKind mSandbox;
     42 };
     43 
     44 // This controls performing audio decoding on the utility process and it is
     45 // intended to live on the main process side
     46 class UtilityMediaServiceChild final : public PUtilityMediaServiceChild,
     47                                       public gfx::gfxVarReceiver
     48 #ifdef MOZ_WMF_MEDIA_ENGINE
     49    ,
     50                                       public gfx::GPUProcessListener
     51 #endif
     52 {
     53 public:
     54  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UtilityMediaServiceChild, override);
     55  mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
     56      const RemoteMediaIn& aLocation,
     57      const media::MediaCodecsSupported& aSupported);
     58 
     59  UtilityActorName GetActorName() { return GetAudioActorName(mSandbox); }
     60 
     61  nsresult BindToUtilityProcess(RefPtr<UtilityProcessParent> aUtilityParent);
     62 
     63  void ActorDestroy(ActorDestroyReason aReason) override;
     64 
     65  void Bind(Endpoint<PUtilityMediaServiceChild>&& aEndpoint);
     66 
     67  static void Shutdown(SandboxingKind aKind);
     68 
     69  static RefPtr<UtilityMediaServiceChild> GetSingleton(SandboxingKind aKind);
     70 
     71  void OnVarChanged(const nsTArray<gfx::GfxVarUpdate>& aVar) override;
     72 
     73 #ifdef MOZ_WMF_MEDIA_ENGINE
     74  mozilla::ipc::IPCResult RecvCompleteCreatedVideoBridge();
     75 
     76  void OnCompositorUnexpectedShutdown() override;
     77 
     78  // True if creating a video bridge sucessfully. Currently only used for media
     79  // engine cdm.
     80  bool CreateVideoBridge(mozilla::ipc::EndpointProcInfo aOtherProcess);
     81 #endif
     82 
     83 #ifdef MOZ_WMF_CDM
     84  void GetKeySystemCapabilities(dom::Promise* aPromise);
     85 
     86  mozilla::ipc::IPCResult RecvDisableHardwareDRM();
     87 #endif
     88 
     89 private:
     90  explicit UtilityMediaServiceChild(SandboxingKind aKind);
     91  ~UtilityMediaServiceChild() = default;
     92 
     93  const SandboxingKind mSandbox;
     94 
     95 #ifdef MOZ_WMF_MEDIA_ENGINE
     96  // True if the utility process has created a video bridge with the GPU prcess.
     97  // Currently only used for media egine cdm. Main thread only.
     98  enum class State { None, Creating, Created };
     99  State mHasCreatedVideoBridge = State::None;
    100 #endif
    101 
    102  TimeStamp mAudioDecoderChildStart;
    103 };
    104 
    105 }  // namespace mozilla::ipc
    106 
    107 #endif  // _include_ipc_glue_UtilityMediaServiceChild_h__