2016-09-23 00:44:26 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "VideoBridgeChild.h"
|
|
|
|
#include "VideoBridgeParent.h"
|
|
|
|
#include "CompositorThread.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
StaticRefPtr<VideoBridgeChild> sVideoBridgeChildSingleton;
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
VideoBridgeChild::Startup()
|
|
|
|
{
|
|
|
|
sVideoBridgeChildSingleton = new VideoBridgeChild();
|
|
|
|
RefPtr<VideoBridgeParent> parent = new VideoBridgeParent();
|
|
|
|
|
|
|
|
MessageLoop* loop = CompositorThreadHolder::Loop();
|
|
|
|
|
|
|
|
sVideoBridgeChildSingleton->Open(parent->GetIPCChannel(),
|
|
|
|
loop,
|
|
|
|
ipc::ChildSide);
|
2016-11-11 05:01:36 +03:00
|
|
|
sVideoBridgeChildSingleton->mIPDLSelfRef = sVideoBridgeChildSingleton;
|
2016-10-07 11:13:33 +03:00
|
|
|
parent->SetOtherProcessId(base::GetCurrentProcId());
|
2016-09-23 00:44:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
VideoBridgeChild::Shutdown()
|
|
|
|
{
|
2016-11-11 05:02:32 +03:00
|
|
|
if (sVideoBridgeChildSingleton) {
|
|
|
|
sVideoBridgeChildSingleton->Close();
|
|
|
|
sVideoBridgeChildSingleton = nullptr;
|
|
|
|
}
|
2016-09-23 00:44:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
VideoBridgeChild::VideoBridgeChild()
|
|
|
|
: mMessageLoop(MessageLoop::current())
|
2016-11-11 05:01:36 +03:00
|
|
|
, mCanSend(true)
|
2016-09-23 00:44:26 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoBridgeChild::~VideoBridgeChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoBridgeChild*
|
|
|
|
VideoBridgeChild::GetSingleton()
|
|
|
|
{
|
|
|
|
return sVideoBridgeChildSingleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VideoBridgeChild::AllocUnsafeShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem)
|
|
|
|
{
|
|
|
|
return PVideoBridgeChild::AllocUnsafeShmem(aSize, aType, aShmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VideoBridgeChild::AllocShmem(size_t aSize,
|
|
|
|
ipc::SharedMemory::SharedMemoryType aType,
|
|
|
|
ipc::Shmem* aShmem)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(CanSend());
|
|
|
|
return PVideoBridgeChild::AllocShmem(aSize, aType, aShmem);
|
|
|
|
}
|
|
|
|
|
2016-11-04 03:28:28 +03:00
|
|
|
bool
|
2016-09-23 00:44:26 +03:00
|
|
|
VideoBridgeChild::DeallocShmem(ipc::Shmem& aShmem)
|
|
|
|
{
|
2016-11-04 03:28:28 +03:00
|
|
|
return PVideoBridgeChild::DeallocShmem(aShmem);
|
2016-09-23 00:44:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PTextureChild*
|
|
|
|
VideoBridgeChild::AllocPTextureChild(const SurfaceDescriptor&,
|
|
|
|
const LayersBackend&,
|
|
|
|
const TextureFlags&,
|
|
|
|
const uint64_t& aSerial)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(CanSend());
|
|
|
|
return TextureClient::CreateIPDLActor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
VideoBridgeChild::DeallocPTextureChild(PTextureChild* actor)
|
|
|
|
{
|
|
|
|
return TextureClient::DestroyIPDLActor(actor);
|
|
|
|
}
|
|
|
|
|
2016-11-11 05:01:36 +03:00
|
|
|
void
|
|
|
|
VideoBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
|
|
|
|
{
|
|
|
|
mCanSend = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VideoBridgeChild::DeallocPVideoBridgeChild()
|
|
|
|
{
|
|
|
|
mIPDLSelfRef = nullptr;
|
|
|
|
}
|
|
|
|
|
2016-09-23 00:44:26 +03:00
|
|
|
PTextureChild*
|
|
|
|
VideoBridgeChild::CreateTexture(const SurfaceDescriptor& aSharedData,
|
|
|
|
LayersBackend aLayersBackend,
|
|
|
|
TextureFlags aFlags,
|
2017-04-20 04:24:13 +03:00
|
|
|
uint64_t aSerial,
|
2017-03-21 06:57:56 +03:00
|
|
|
wr::MaybeExternalImageId& aExternalImageId,
|
|
|
|
nsIEventTarget* aTarget)
|
2016-09-23 00:44:26 +03:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(CanSend());
|
|
|
|
return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, aSerial);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VideoBridgeChild::IsSameProcess() const
|
|
|
|
{
|
|
|
|
return OtherPid() == base::GetCurrentProcId();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|