mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1561178 - Create a VideoBridge connection from the RDD process to the parent process. r=jya
Differential Revision: https://phabricator.services.mozilla.com/D35969 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cf1e91357b
commit
3e1eacd221
@ -8,6 +8,7 @@ include PrefsTypes;
|
||||
|
||||
include protocol PProfiler;
|
||||
include protocol PRemoteDecoderManager;
|
||||
include protocol PVideoBridge;
|
||||
|
||||
using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
|
||||
|
||||
@ -35,6 +36,8 @@ parent:
|
||||
|
||||
async PreferenceUpdate(Pref pref);
|
||||
|
||||
async CreateVideoBridgeToParentProcess(Endpoint<PVideoBridgeChild> endpoint);
|
||||
|
||||
child:
|
||||
// args TBD, sent when init complete. Occurs once, after Init().
|
||||
async InitComplete();
|
||||
|
@ -159,6 +159,15 @@ mozilla::ipc::IPCResult RDDParent::RecvNewContentRemoteDecoderManager(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RDDParent::RecvCreateVideoBridgeToParentProcess(
|
||||
Endpoint<PVideoBridgeChild>&& aEndpoint) {
|
||||
if (!RemoteDecoderManagerParent::CreateVideoBridgeToParentProcess(
|
||||
std::move(aEndpoint))) {
|
||||
return IPC_FAIL_NO_REASON(this);
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult RDDParent::RecvRequestMemoryReport(
|
||||
const uint32_t& aGeneration, const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage, const Maybe<FileDescriptor>& aDMDFile) {
|
||||
|
@ -31,6 +31,8 @@ class RDDParent final : public PRDDParent {
|
||||
|
||||
mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager(
|
||||
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
|
||||
mozilla::ipc::IPCResult RecvCreateVideoBridgeToParentProcess(
|
||||
Endpoint<PVideoBridgeChild>&& aEndpoint);
|
||||
mozilla::ipc::IPCResult RecvRequestMemoryReport(
|
||||
const uint32_t& generation, const bool& anonymize,
|
||||
const bool& minimizeMemoryUsage,
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/StaticPrefs.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/layers/VideoBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "nsAppRunner.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "RDDChild.h"
|
||||
@ -160,6 +162,26 @@ void RDDProcessManager::OnProcessLaunchComplete(RDDProcessHost* aHost) {
|
||||
}
|
||||
mQueuedPrefs.Clear();
|
||||
|
||||
ipc::Endpoint<PVideoBridgeParent> parentPipe;
|
||||
ipc::Endpoint<PVideoBridgeChild> childPipe;
|
||||
|
||||
// Currently hardcoded to use the current process as the parent side,
|
||||
// we need to add support for the GPU process.
|
||||
nsresult rv = PVideoBridge::CreateEndpoints(
|
||||
base::GetCurrentProcId(), mRDDChild->OtherPid(), &parentPipe, &childPipe);
|
||||
if (NS_FAILED(rv)) {
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("Could not create video bridge: %d", int(rv)));
|
||||
DestroyProcess();
|
||||
return;
|
||||
}
|
||||
|
||||
mRDDChild->SendCreateVideoBridgeToParentProcess(std::move(childPipe));
|
||||
|
||||
CompositorThreadHolder::Loop()->PostTask(
|
||||
NewRunnableFunction("gfx::VideoBridgeParent::Open",
|
||||
&VideoBridgeParent::Open, std::move(parentPipe)));
|
||||
|
||||
CrashReporter::AnnotateCrashReport(
|
||||
CrashReporter::Annotation::RDDProcessStatus,
|
||||
NS_LITERAL_CSTRING("Running"));
|
||||
|
@ -173,6 +173,25 @@ bool RemoteDecoderManagerParent::CreateForContent(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoteDecoderManagerParent::CreateVideoBridgeToParentProcess(
|
||||
Endpoint<PVideoBridgeChild>&& aEndpoint) {
|
||||
// We never want to decode in the GPU process, but output
|
||||
// frames to the parent process.
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_RDD);
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!StartupThreads()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<Runnable> task = NewRunnableFunction(
|
||||
"gfx::VideoBridgeChild::Open", &VideoBridgeChild::OpenToParentProcess,
|
||||
std::move(aEndpoint));
|
||||
sRemoteDecoderManagerParentThread->Dispatch(task.forget(),
|
||||
NS_DISPATCH_NORMAL);
|
||||
return true;
|
||||
}
|
||||
|
||||
RemoteDecoderManagerParent::RemoteDecoderManagerParent(
|
||||
RemoteDecoderManagerThreadHolder* aHolder)
|
||||
: mThreadHolder(aHolder) {
|
||||
|
@ -21,6 +21,9 @@ class RemoteDecoderManagerParent final : public PRemoteDecoderManagerParent {
|
||||
static bool CreateForContent(
|
||||
Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
|
||||
|
||||
static bool CreateVideoBridgeToParentProcess(
|
||||
Endpoint<layers::PVideoBridgeChild>&& aEndpoint);
|
||||
|
||||
// Can be called from any thread
|
||||
SurfaceDescriptorGPUVideo StoreImage(layers::Image* aImage,
|
||||
layers::TextureClient* aTexture);
|
||||
|
@ -30,6 +30,15 @@ void VideoBridgeChild::StartupForGPUProcess() {
|
||||
&VideoBridgeParent::Open, std::move(parentPipe)));
|
||||
}
|
||||
|
||||
void VideoBridgeChild::OpenToParentProcess(
|
||||
Endpoint<PVideoBridgeChild>&& aEndpoint) {
|
||||
sVideoBridgeToParentProcess = new VideoBridgeChild();
|
||||
|
||||
if (!aEndpoint.Bind(sVideoBridgeToParentProcess)) {
|
||||
// We can't recover from this.
|
||||
MOZ_CRASH("Failed to bind RemoteDecoderManagerParent to endpoint");
|
||||
}
|
||||
}
|
||||
|
||||
void VideoBridgeChild::OpenToGPUProcess(
|
||||
Endpoint<PVideoBridgeChild>&& aEndpoint) {
|
||||
|
@ -65,6 +65,7 @@ class VideoBridgeChild final : public PVideoBridgeChild,
|
||||
|
||||
bool CanSend() { return mCanSend; }
|
||||
|
||||
static void OpenToParentProcess(Endpoint<PVideoBridgeChild>&& aEndpoint);
|
||||
static void OpenToGPUProcess(Endpoint<PVideoBridgeChild>&& aEndpoint);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user