Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "VideoBridgeChild.h"
7 : #include "VideoBridgeParent.h"
8 : #include "CompositorThread.h"
9 :
10 : namespace mozilla {
11 : namespace layers {
12 :
13 3 : StaticRefPtr<VideoBridgeChild> sVideoBridgeChildSingleton;
14 :
15 : /* static */ void
16 0 : VideoBridgeChild::Startup()
17 : {
18 0 : sVideoBridgeChildSingleton = new VideoBridgeChild();
19 0 : RefPtr<VideoBridgeParent> parent = new VideoBridgeParent();
20 :
21 0 : MessageLoop* loop = CompositorThreadHolder::Loop();
22 :
23 0 : sVideoBridgeChildSingleton->Open(parent->GetIPCChannel(),
24 : loop,
25 0 : ipc::ChildSide);
26 0 : sVideoBridgeChildSingleton->mIPDLSelfRef = sVideoBridgeChildSingleton;
27 0 : parent->SetOtherProcessId(base::GetCurrentProcId());
28 0 : }
29 :
30 : /* static */ void
31 0 : VideoBridgeChild::Shutdown()
32 : {
33 0 : if (sVideoBridgeChildSingleton) {
34 0 : sVideoBridgeChildSingleton->Close();
35 0 : sVideoBridgeChildSingleton = nullptr;
36 : }
37 0 : }
38 :
39 0 : VideoBridgeChild::VideoBridgeChild()
40 0 : : mMessageLoop(MessageLoop::current())
41 0 : , mCanSend(true)
42 : {
43 0 : }
44 :
45 0 : VideoBridgeChild::~VideoBridgeChild()
46 : {
47 0 : }
48 :
49 : VideoBridgeChild*
50 0 : VideoBridgeChild::GetSingleton()
51 : {
52 0 : return sVideoBridgeChildSingleton;
53 : }
54 :
55 : bool
56 0 : VideoBridgeChild::AllocUnsafeShmem(size_t aSize,
57 : ipc::SharedMemory::SharedMemoryType aType,
58 : ipc::Shmem* aShmem)
59 : {
60 0 : return PVideoBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
61 : }
62 :
63 : bool
64 0 : VideoBridgeChild::AllocShmem(size_t aSize,
65 : ipc::SharedMemory::SharedMemoryType aType,
66 : ipc::Shmem* aShmem)
67 : {
68 0 : MOZ_ASSERT(CanSend());
69 0 : return PVideoBridgeChild::AllocShmem(aSize, aType, aShmem);
70 : }
71 :
72 : bool
73 0 : VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
74 : {
75 0 : return PVideoBridgeChild::DeallocShmem(aShmem);
76 : }
77 :
78 : PTextureChild*
79 0 : VideoBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
80 : const LayersBackend&,
81 : const TextureFlags&,
82 : const uint64_t& aSerial)
83 : {
84 0 : MOZ_ASSERT(CanSend());
85 0 : return TextureClient::CreateIPDLActor();
86 : }
87 :
88 : bool
89 0 : VideoBridgeChild::DeallocPTextureChild(PTextureChild* actor)
90 : {
91 0 : return TextureClient::DestroyIPDLActor(actor);
92 : }
93 :
94 : void
95 0 : VideoBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
96 : {
97 0 : mCanSend = false;
98 0 : }
99 :
100 : void
101 0 : VideoBridgeChild::DeallocPVideoBridgeChild()
102 : {
103 0 : mIPDLSelfRef = nullptr;
104 0 : }
105 :
106 : PTextureChild*
107 0 : VideoBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
108 : LayersBackend aLayersBackend,
109 : TextureFlags aFlags,
110 : uint64_t aSerial,
111 : wr::MaybeExternalImageId& aExternalImageId,
112 : nsIEventTarget* aTarget)
113 : {
114 0 : MOZ_ASSERT(CanSend());
115 0 : return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, aSerial);
116 : }
117 :
118 0 : bool VideoBridgeChild::IsSameProcess() const
119 : {
120 0 : return OtherPid() == base::GetCurrentProcId();
121 : }
122 :
123 : } // namespace layers
124 : } // namespace mozilla
|