2016-09-21 09:25:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=99: */
|
|
|
|
/* 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/. */
|
|
|
|
#ifndef include_dom_ipc_VideoDecoderManagerChild_h
|
|
|
|
#define include_dom_ipc_VideoDecoderManagerChild_h
|
|
|
|
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/dom/PVideoDecoderManagerChild.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2016-11-04 00:28:28 +00:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
}
|
2016-09-21 09:25:33 +00:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class VideoDecoderManagerChild final : public PVideoDecoderManagerChild,
|
2016-11-04 00:28:28 +00:00
|
|
|
public mozilla::ipc::IShmemAllocator {
|
2016-09-21 09:25:33 +00:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerChild)
|
|
|
|
|
2016-11-02 20:55:07 +00:00
|
|
|
// Can only be called from the manager thread
|
2016-09-21 09:25:33 +00:00
|
|
|
static VideoDecoderManagerChild* GetSingleton();
|
2016-11-02 20:55:07 +00:00
|
|
|
|
|
|
|
// Can be called from any thread.
|
2016-09-21 09:25:41 +00:00
|
|
|
static nsIThread* GetManagerThread();
|
2016-09-21 09:25:41 +00:00
|
|
|
static AbstractThread* GetManagerAbstractThread();
|
2016-09-21 09:25:33 +00:00
|
|
|
|
2016-11-02 20:55:07 +00:00
|
|
|
// Can be called from any thread, dispatches the request to the IPDL thread
|
|
|
|
// internally and will be ignored if the IPDL actor has been destroyed.
|
2016-11-04 00:28:28 +00:00
|
|
|
already_AddRefed<gfx::SourceSurface> Readback(
|
|
|
|
const SurfaceDescriptorGPUVideo& aSD);
|
2016-09-21 09:25:33 +00:00
|
|
|
void DeallocateSurfaceDescriptorGPUVideo(
|
|
|
|
const SurfaceDescriptorGPUVideo& aSD);
|
|
|
|
|
2016-11-04 00:28:28 +00:00
|
|
|
bool AllocShmem(size_t aSize,
|
|
|
|
mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
|
|
|
|
mozilla::ipc::Shmem* aShmem) override {
|
|
|
|
return PVideoDecoderManagerChild::AllocShmem(aSize, aShmType, aShmem);
|
|
|
|
}
|
|
|
|
bool AllocUnsafeShmem(size_t aSize,
|
|
|
|
mozilla::ipc::SharedMemory::SharedMemoryType aShmType,
|
|
|
|
mozilla::ipc::Shmem* aShmem) override {
|
|
|
|
return PVideoDecoderManagerChild::AllocUnsafeShmem(aSize, aShmType, aShmem);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Can be called from any thread, dispatches the request to the IPDL thread
|
|
|
|
// internally and will be ignored if the IPDL actor has been destroyed.
|
|
|
|
bool DeallocShmem(mozilla::ipc::Shmem& aShmem) override;
|
|
|
|
|
2016-09-21 09:25:33 +00:00
|
|
|
// Main thread only
|
2016-11-08 02:21:35 +00:00
|
|
|
static void InitForContent(
|
|
|
|
Endpoint<PVideoDecoderManagerChild>&& aVideoManager);
|
2016-09-21 09:25:33 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
2016-11-08 02:21:35 +00:00
|
|
|
// Run aTask (on the manager thread) when we next attempt to create a new
|
|
|
|
// manager (even if creation fails). Intended to be called from ActorDestroy
|
|
|
|
// when we get notified that the old manager is being destroyed. Can only be
|
|
|
|
// called from the manager thread.
|
|
|
|
void RunWhenRecreated(already_AddRefed<Runnable> aTask);
|
|
|
|
|
|
|
|
bool CanSend();
|
|
|
|
|
2016-09-21 09:25:41 +00:00
|
|
|
protected:
|
2016-11-08 02:21:35 +00:00
|
|
|
void InitIPDL();
|
|
|
|
|
2016-11-02 20:55:07 +00:00
|
|
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
|
|
void DeallocPVideoDecoderManagerChild() override;
|
|
|
|
|
2018-04-23 18:13:36 +00:00
|
|
|
void HandleFatalError(const char* aMsg) const override;
|
2016-11-02 20:55:07 +00:00
|
|
|
|
2018-10-09 16:59:24 +00:00
|
|
|
PVideoDecoderChild* AllocPVideoDecoderChild(
|
|
|
|
const VideoInfo& aVideoInfo, const float& aFramerate,
|
|
|
|
const CreateDecoderParams::OptionSet& aOptions,
|
|
|
|
const layers::TextureFactoryIdentifier& aIdentifier, bool* aSuccess,
|
|
|
|
nsCString* aBlacklistedD3D11Driver, nsCString* aBlacklistedD3D9Driver,
|
|
|
|
nsCString* aErrorDescription) override;
|
2016-09-21 09:25:41 +00:00
|
|
|
bool DeallocPVideoDecoderChild(PVideoDecoderChild* actor) override;
|
|
|
|
|
2016-09-21 09:25:33 +00:00
|
|
|
private:
|
2016-11-08 02:21:35 +00:00
|
|
|
// Main thread only
|
|
|
|
static void InitializeThread();
|
|
|
|
|
2016-09-21 09:25:33 +00:00
|
|
|
VideoDecoderManagerChild() : mCanSend(false) {}
|
|
|
|
~VideoDecoderManagerChild() {}
|
|
|
|
|
2016-11-08 02:21:35 +00:00
|
|
|
static void Open(Endpoint<PVideoDecoderManagerChild>&& aEndpoint);
|
|
|
|
|
|
|
|
RefPtr<VideoDecoderManagerChild> mIPDLSelfRef;
|
2016-11-02 20:55:07 +00:00
|
|
|
|
|
|
|
// Should only ever be accessed on the manager thread.
|
|
|
|
bool mCanSend;
|
2016-09-21 09:25:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // include_dom_ipc_VideoDecoderManagerChild_h
|