tor-browser

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

RemoteDecoderParent.h (2890B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 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_dom_media_ipc_RemoteDecoderParent_h
      7 #define include_dom_media_ipc_RemoteDecoderParent_h
      8 
      9 #include "mozilla/PRemoteDecoderParent.h"
     10 #include "mozilla/ShmemRecycleAllocator.h"
     11 
     12 namespace mozilla {
     13 
     14 class RemoteCDMParent;
     15 class RemoteMediaManagerParent;
     16 using mozilla::ipc::IPCResult;
     17 
     18 class RemoteDecoderParent : public ShmemRecycleAllocator<RemoteDecoderParent>,
     19                            public PRemoteDecoderParent {
     20  friend class PRemoteDecoderParent;
     21 
     22 public:
     23  // We refcount this class since the task queue can have runnables
     24  // that reference us.
     25  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteDecoderParent)
     26 
     27  RemoteDecoderParent(RemoteMediaManagerParent* aParent,
     28                      const CreateDecoderParams::OptionSet& aOptions,
     29                      nsISerialEventTarget* aManagerThread,
     30                      TaskQueue* aDecodeTaskQueue,
     31                      const Maybe<uint64_t>& aMediaEngineId,
     32                      Maybe<TrackingId> aTrackingId, RemoteCDMParent* aCDM);
     33 
     34  void Destroy();
     35 
     36  // PRemoteDecoderParent
     37  virtual IPCResult RecvConstruct(ConstructResolver&& aResolver) = 0;
     38  IPCResult RecvInit(InitResolver&& aResolver);
     39  IPCResult RecvDecode(ArrayOfRemoteMediaRawData* aData,
     40                       DecodeResolver&& aResolver);
     41  IPCResult RecvFlush(FlushResolver&& aResolver);
     42  IPCResult RecvDrain(DrainResolver&& aResolver);
     43  IPCResult RecvShutdown(ShutdownResolver&& aResolver);
     44  IPCResult RecvSetSeekThreshold(const media::TimeUnit& aTime);
     45 
     46  void ActorDestroy(ActorDestroyReason aWhy) override;
     47 
     48 protected:
     49  virtual ~RemoteDecoderParent();
     50 
     51  bool OnManagerThread();
     52 
     53  virtual MediaResult ProcessDecodedData(MediaDataDecoder::DecodedData&& aData,
     54                                         DecodedOutputIPDL& aDecodedData) = 0;
     55 
     56  const RefPtr<RemoteMediaManagerParent> mParent;
     57  const CreateDecoderParams::OptionSet mOptions;
     58  const RefPtr<TaskQueue> mDecodeTaskQueue;
     59  RefPtr<MediaDataDecoder> mDecoder;
     60  const RefPtr<RemoteCDMParent> mCDM;
     61  const Maybe<TrackingId> mTrackingId;
     62 
     63  // Only be used on Windows when the media engine playback is enabled.
     64  const Maybe<uint64_t> mMediaEngineId;
     65 
     66 private:
     67  void DecodeNextSample(const RefPtr<ArrayOfRemoteMediaRawData>& aData,
     68                        size_t aIndex, MediaDataDecoder::DecodedData&& aOutput,
     69                        DecodeResolver&& aResolver);
     70  RefPtr<RemoteDecoderParent> mIPDLSelfRef;
     71  const RefPtr<nsISerialEventTarget> mManagerThread;
     72 };
     73 
     74 }  // namespace mozilla
     75 
     76 #endif  // include_dom_media_ipc_RemoteDecoderParent_h