1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=99: */
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_ipc_VideoDecoderManagerParent_h
7 #define include_dom_ipc_VideoDecoderManagerParent_h
8 
9 #include "mozilla/dom/PVideoDecoderManagerParent.h"
10 
11 namespace mozilla {
12 namespace dom {
13 
14 class VideoDecoderManagerParent final : public PVideoDecoderManagerParent
15 {
16 public:
17   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerParent)
18 
19   static bool CreateForContent(Endpoint<PVideoDecoderManagerParent>&& aEndpoint);
20 
21   // Can be called from any thread
22   SurfaceDescriptorGPUVideo StoreImage(layers::Image* aImage, layers::TextureClient* aTexture);
23 
24   static void StartupThreads();
25   static void ShutdownThreads();
26 
27   static void ShutdownVideoBridge();
28 
29   bool OnManagerThread();
30 
31 protected:
32   PVideoDecoderParent* AllocPVideoDecoderParent() override;
33   bool DeallocPVideoDecoderParent(PVideoDecoderParent* actor) override;
34 
35   bool RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override;
36   bool RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override;
37 
ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason)38   void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override {}
39 
40   void DeallocPVideoDecoderManagerParent() override;
41 
42  private:
43   VideoDecoderManagerParent();
44   ~VideoDecoderManagerParent();
45 
46   void Open(Endpoint<PVideoDecoderManagerParent>&& aEndpoint);
47 
48   std::map<uint64_t, RefPtr<layers::Image>> mImageMap;
49   std::map<uint64_t, RefPtr<layers::TextureClient>> mTextureMap;
50 };
51 
52 } // namespace dom
53 } // namespace mozilla
54 
55 #endif // include_dom_ipc_VideoDecoderManagerParent_h
56