Line data Source code
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 VideoDecoderManagerThreadHolder;
15 :
16 : class VideoDecoderManagerParent final : public PVideoDecoderManagerParent
17 : {
18 : public:
19 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerParent)
20 :
21 : static bool CreateForContent(Endpoint<PVideoDecoderManagerParent>&& aEndpoint);
22 :
23 : // Can be called from any thread
24 : SurfaceDescriptorGPUVideo StoreImage(layers::Image* aImage, layers::TextureClient* aTexture);
25 :
26 : static void StartupThreads();
27 : static void ShutdownThreads();
28 :
29 : static void ShutdownVideoBridge();
30 :
31 : bool OnManagerThread();
32 :
33 : protected:
34 : PVideoDecoderParent* AllocPVideoDecoderParent(const VideoInfo& aVideoInfo, const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess) override;
35 : bool DeallocPVideoDecoderParent(PVideoDecoderParent* actor) override;
36 :
37 : mozilla::ipc::IPCResult RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override;
38 : mozilla::ipc::IPCResult RecvDeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD) override;
39 :
40 : void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;
41 :
42 : void DeallocPVideoDecoderManagerParent() override;
43 :
44 : private:
45 : explicit VideoDecoderManagerParent(VideoDecoderManagerThreadHolder* aThreadHolder);
46 : ~VideoDecoderManagerParent();
47 :
48 : void Open(Endpoint<PVideoDecoderManagerParent>&& aEndpoint);
49 :
50 : std::map<uint64_t, RefPtr<layers::Image>> mImageMap;
51 : std::map<uint64_t, RefPtr<layers::TextureClient>> mTextureMap;
52 :
53 : RefPtr<VideoDecoderManagerThreadHolder> mThreadHolder;
54 : };
55 :
56 : } // namespace dom
57 : } // namespace mozilla
58 :
59 : #endif // include_dom_ipc_VideoDecoderManagerParent_h
|