/src/mozilla-central/dom/media/ipc/VideoDecoderManagerChild.h
Line | Count | Source (jump to first uncovered line) |
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_VideoDecoderManagerChild_h |
7 | | #define include_dom_ipc_VideoDecoderManagerChild_h |
8 | | |
9 | | #include "mozilla/RefPtr.h" |
10 | | #include "mozilla/dom/PVideoDecoderManagerChild.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace gfx { |
14 | | class SourceSurface; |
15 | | } |
16 | | namespace dom { |
17 | | |
18 | | class VideoDecoderManagerChild final : public PVideoDecoderManagerChild |
19 | | , public mozilla::ipc::IShmemAllocator |
20 | | { |
21 | | public: |
22 | | NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerChild) |
23 | | |
24 | | // Can only be called from the manager thread |
25 | | static VideoDecoderManagerChild* GetSingleton(); |
26 | | |
27 | | // Can be called from any thread. |
28 | | static nsIThread* GetManagerThread(); |
29 | | static AbstractThread* GetManagerAbstractThread(); |
30 | | |
31 | | // Can be called from any thread, dispatches the request to the IPDL thread internally |
32 | | // and will be ignored if the IPDL actor has been destroyed. |
33 | | already_AddRefed<gfx::SourceSurface> Readback(const SurfaceDescriptorGPUVideo& aSD); |
34 | | void DeallocateSurfaceDescriptorGPUVideo(const SurfaceDescriptorGPUVideo& aSD); |
35 | | |
36 | | bool AllocShmem(size_t aSize, |
37 | | mozilla::ipc::SharedMemory::SharedMemoryType aShmType, |
38 | | mozilla::ipc::Shmem* aShmem) override |
39 | 0 | { |
40 | 0 | return PVideoDecoderManagerChild::AllocShmem(aSize, aShmType, aShmem); |
41 | 0 | } |
42 | | bool AllocUnsafeShmem(size_t aSize, |
43 | | mozilla::ipc::SharedMemory::SharedMemoryType aShmType, |
44 | | mozilla::ipc::Shmem* aShmem) override |
45 | 0 | { |
46 | 0 | return PVideoDecoderManagerChild::AllocUnsafeShmem(aSize, aShmType, aShmem); |
47 | 0 | } |
48 | | |
49 | | // Can be called from any thread, dispatches the request to the IPDL thread internally |
50 | | // and will be ignored if the IPDL actor has been destroyed. |
51 | | bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override; |
52 | | |
53 | | // Main thread only |
54 | | static void InitForContent(Endpoint<PVideoDecoderManagerChild>&& aVideoManager); |
55 | | static void Shutdown(); |
56 | | |
57 | | // Run aTask (on the manager thread) when we next attempt to create a new manager |
58 | | // (even if creation fails). Intended to be called from ActorDestroy when we get |
59 | | // notified that the old manager is being destroyed. |
60 | | // Can only be called from the manager thread. |
61 | | void RunWhenRecreated(already_AddRefed<Runnable> aTask); |
62 | | |
63 | | bool CanSend(); |
64 | | |
65 | | protected: |
66 | | void InitIPDL(); |
67 | | |
68 | | void ActorDestroy(ActorDestroyReason aWhy) override; |
69 | | void DeallocPVideoDecoderManagerChild() override; |
70 | | |
71 | | void HandleFatalError(const char* aMsg) const override; |
72 | | |
73 | | PVideoDecoderChild* AllocPVideoDecoderChild(const VideoInfo& aVideoInfo, |
74 | | const float& aFramerate, |
75 | | const layers::TextureFactoryIdentifier& aIdentifier, |
76 | | bool* aSuccess, |
77 | | nsCString* aBlacklistedD3D11Driver, |
78 | | nsCString* aBlacklistedD3D9Driver, |
79 | | nsCString* aErrorDescription) override; |
80 | | bool DeallocPVideoDecoderChild(PVideoDecoderChild* actor) override; |
81 | | |
82 | | private: |
83 | | // Main thread only |
84 | | static void InitializeThread(); |
85 | | |
86 | | VideoDecoderManagerChild() |
87 | | : mCanSend(false) |
88 | 0 | {} |
89 | 0 | ~VideoDecoderManagerChild() {} |
90 | | |
91 | | static void Open(Endpoint<PVideoDecoderManagerChild>&& aEndpoint); |
92 | | |
93 | | RefPtr<VideoDecoderManagerChild> mIPDLSelfRef; |
94 | | |
95 | | // Should only ever be accessed on the manager thread. |
96 | | bool mCanSend; |
97 | | }; |
98 | | |
99 | | } // namespace dom |
100 | | } // namespace mozilla |
101 | | |
102 | | #endif // include_dom_ipc_VideoDecoderManagerChild_h |