Bug 1397307 - P9. Pass video frame rate to RemoteVideoDecoder and GPU process. r?mattwoodrow
MozReview-Commit-ID: BDSO332f3B6
--- a/dom/media/ipc/PVideoDecoderManager.ipdl
+++ b/dom/media/ipc/PVideoDecoderManager.ipdl
@@ -18,20 +18,21 @@ sync protocol PVideoDecoderManager
manages PVideoDecoder;
parent:
// aBlacklistedD3D11Driver and aBlacklistedD3D9Driver are used to read back the blacklisted driver information
// from GPU process to content process.
// We should have added a new sync method to read back this information but, in that way, we also introduce one
// more sync IPC call.
// Considering that this information is only used for telemetry usage in bug 1393392 and should be removed once
// we have collected enough data, we add these two return values here for convenience.
- sync PVideoDecoder(VideoInfo info, TextureFactoryIdentifier identifier) returns (bool success,
- nsCString aBlacklistedD3D11Driver,
- nsCString aBlacklistedD3D9Driver,
- nsCString aErrorDescription);
+ sync PVideoDecoder(VideoInfo info, float framerate, TextureFactoryIdentifier identifier)
+ returns (bool success,
+ nsCString aBlacklistedD3D11Driver,
+ nsCString aBlacklistedD3D9Driver,
+ nsCString aErrorDescription);
sync Readback(SurfaceDescriptorGPUVideo sd) returns (SurfaceDescriptor aResult);
async DeallocateSurfaceDescriptorGPUVideo(SurfaceDescriptorGPUVideo sd);
};
} // namespace dom
} // namespace mozilla
--- a/dom/media/ipc/RemoteVideoDecoder.cpp
+++ b/dom/media/ipc/RemoteVideoDecoder.cpp
@@ -183,16 +183,17 @@ RemoteDecoderModule::CreateVideoDecoder(
MediaResult result(NS_OK);
VideoDecoderManagerChild::GetManagerThread()->Dispatch(
NS_NewRunnableFunction(
"dom::RemoteDecoderModule::CreateVideoDecoder",
[&]() {
AutoCompleteTask complete(&task);
result = object->mActor->InitIPDL(
aParams.VideoConfig(),
+ aParams.mRate.mValue,
aParams.mKnowsCompositor->GetTextureFactoryIdentifier());
}),
NS_DISPATCH_NORMAL);
task.Wait();
if (NS_FAILED(result)) {
if (aParams.mError) {
*aParams.mError = result;
--- a/dom/media/ipc/VideoDecoderChild.cpp
+++ b/dom/media/ipc/VideoDecoderChild.cpp
@@ -171,16 +171,17 @@ VideoDecoderChild::ActorDestroy(ActorDes
ReportUnblacklistingTelemetry(aWhy == AbnormalShutdown,
mBlacklistedD3D11Driver,
mBlacklistedD3D9Driver);
#endif // XP_WIN
}
MediaResult
VideoDecoderChild::InitIPDL(const VideoInfo& aVideoInfo,
+ float aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier)
{
RefPtr<VideoDecoderManagerChild> manager =
VideoDecoderManagerChild::GetSingleton();
// The manager isn't available because VideoDecoderManagerChild has been
// initialized with null end points and we don't want to decode video on GPU
// process anymore. Return false here so that we can fallback to other PDMs.
@@ -197,17 +198,20 @@ VideoDecoderChild::InitIPDL(const VideoI
// available. If not, then the cycle repeats until we're ready.
if (!manager->CanSend()) {
return NS_OK;
}
mIPDLSelfRef = this;
bool success = false;
nsCString errorDescription;
- if (manager->SendPVideoDecoderConstructor(this, aVideoInfo, aIdentifier,
+ if (manager->SendPVideoDecoderConstructor(this,
+ aVideoInfo,
+ aFramerate,
+ aIdentifier,
&success,
&mBlacklistedD3D11Driver,
&mBlacklistedD3D9Driver,
&errorDescription)) {
mCanSend = true;
}
return success ? MediaResult(NS_OK) :
--- a/dom/media/ipc/VideoDecoderChild.h
+++ b/dom/media/ipc/VideoDecoderChild.h
@@ -45,16 +45,17 @@ public:
void Shutdown();
bool IsHardwareAccelerated(nsACString& aFailureReason) const;
nsCString GetDescriptionName() const;
void SetSeekThreshold(const media::TimeUnit& aTime);
MediaDataDecoder::ConversionRequired NeedsConversion() const;
MOZ_IS_CLASS_INIT
MediaResult InitIPDL(const VideoInfo& aVideoInfo,
+ float aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier);
void DestroyIPDL();
// Called from IPDL when our actor has been destroyed
void IPDLActorDestroyed();
VideoDecoderManagerChild* GetManager();
--- a/dom/media/ipc/VideoDecoderManagerChild.cpp
+++ b/dom/media/ipc/VideoDecoderManagerChild.cpp
@@ -111,16 +111,17 @@ VideoDecoderManagerChild::GetManagerThre
/* static */ AbstractThread*
VideoDecoderManagerChild::GetManagerAbstractThread()
{
return sVideoDecoderChildAbstractThread;
}
PVideoDecoderChild*
VideoDecoderManagerChild::AllocPVideoDecoderChild(const VideoInfo& aVideoInfo,
+ const float& aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
bool* aSuccess,
nsCString* /* not used */,
nsCString* /* not used */,
nsCString* /* not used */)
{
return new VideoDecoderChild();
}
--- a/dom/media/ipc/VideoDecoderManagerChild.h
+++ b/dom/media/ipc/VideoDecoderManagerChild.h
@@ -66,16 +66,17 @@ protected:
void InitIPDL();
void ActorDestroy(ActorDestroyReason aWhy) override;
void DeallocPVideoDecoderManagerChild() override;
void HandleFatalError(const char* aName, const char* aMsg) const override;
PVideoDecoderChild* AllocPVideoDecoderChild(const VideoInfo& aVideoInfo,
+ const float& aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
bool* aSuccess,
nsCString* aBlacklistedD3D11Driver,
nsCString* aBlacklistedD3D9Driver,
nsCString* aErrorDescription) override;
bool DeallocPVideoDecoderChild(PVideoDecoderChild* actor) override;
private:
--- a/dom/media/ipc/VideoDecoderManagerParent.cpp
+++ b/dom/media/ipc/VideoDecoderManagerParent.cpp
@@ -50,35 +50,36 @@ VideoDecoderManagerParent::StoreImage(Im
StaticRefPtr<nsIThread> sVideoDecoderManagerThread;
StaticRefPtr<TaskQueue> sManagerTaskQueue;
class VideoDecoderManagerThreadHolder
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderManagerThreadHolder)
public:
- VideoDecoderManagerThreadHolder() {}
+ VideoDecoderManagerThreadHolder() { }
private:
- ~VideoDecoderManagerThreadHolder() {
+ ~VideoDecoderManagerThreadHolder()
+ {
NS_DispatchToMainThread(NS_NewRunnableFunction(
"dom::VideoDecoderManagerThreadHolder::~VideoDecoderManagerThreadHolder",
[]() -> void {
sVideoDecoderManagerThread->Shutdown();
sVideoDecoderManagerThread = nullptr;
}));
}
};
StaticRefPtr<VideoDecoderManagerThreadHolder> sVideoDecoderManagerThreadHolder;
class ManagerThreadShutdownObserver : public nsIObserver
{
virtual ~ManagerThreadShutdownObserver() = default;
public:
- ManagerThreadShutdownObserver() {}
+ ManagerThreadShutdownObserver() { }
NS_DECL_ISUPPORTS
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override
{
MOZ_ASSERT(strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
@@ -196,28 +197,29 @@ VideoDecoderManagerParent::~VideoDecoder
void
VideoDecoderManagerParent::ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason)
{
mThreadHolder = nullptr;
}
PVideoDecoderParent*
VideoDecoderManagerParent::AllocPVideoDecoderParent(const VideoInfo& aVideoInfo,
+ const float& aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
bool* aSuccess,
nsCString* aBlacklistedD3D11Driver,
nsCString* aBlacklistedD3D9Driver,
nsCString* aErrorDescription)
{
RefPtr<TaskQueue> decodeTaskQueue = new TaskQueue(
SharedThreadPool::Get(NS_LITERAL_CSTRING("VideoDecoderParent"), 4),
"VideoDecoderParent::mDecodeTaskQueue");
auto* parent = new VideoDecoderParent(
- this, aVideoInfo, aIdentifier,
+ this, aVideoInfo, aFramerate, aIdentifier,
sManagerTaskQueue, decodeTaskQueue, aSuccess, aErrorDescription);
#ifdef XP_WIN
*aBlacklistedD3D11Driver = GetFoundD3D11BlacklistedDLL();
*aBlacklistedD3D9Driver = GetFoundD3D9BlacklistedDLL();
#endif // XP_WIN
return parent;
--- a/dom/media/ipc/VideoDecoderManagerParent.h
+++ b/dom/media/ipc/VideoDecoderManagerParent.h
@@ -27,16 +27,17 @@ public:
static void ShutdownThreads();
static void ShutdownVideoBridge();
bool OnManagerThread();
protected:
PVideoDecoderParent* AllocPVideoDecoderParent(const VideoInfo& aVideoInfo,
+ const float& aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
bool* aSuccess,
nsCString* aBlacklistedD3D11Driver,
nsCString* aBlacklistedD3D9Driver,
nsCString* aErrorDescription) override;
bool DeallocPVideoDecoderParent(PVideoDecoderParent* actor) override;
mozilla::ipc::IPCResult RecvReadback(const SurfaceDescriptorGPUVideo& aSD, SurfaceDescriptor* aResult) override;
--- a/dom/media/ipc/VideoDecoderParent.cpp
+++ b/dom/media/ipc/VideoDecoderParent.cpp
@@ -39,16 +39,17 @@ public:
return VideoBridgeChild::GetSingleton();
}
private:
virtual ~KnowsCompositorVideo() = default;
};
VideoDecoderParent::VideoDecoderParent(VideoDecoderManagerParent* aParent,
const VideoInfo& aVideoInfo,
+ float aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
TaskQueue* aManagerTaskQueue,
TaskQueue* aDecodeTaskQueue,
bool* aSuccess,
nsCString* aErrorDescription)
: mParent(aParent)
, mManagerTaskQueue(aManagerTaskQueue)
, mDecodeTaskQueue(aDecodeTaskQueue)
@@ -71,16 +72,17 @@ VideoDecoderParent::VideoDecoderParent(V
WMFDecoderModule::Init();
RefPtr<WMFDecoderModule> pdm(new WMFDecoderModule());
pdm->Startup();
CreateDecoderParams params(aVideoInfo);
params.mTaskQueue = mDecodeTaskQueue;
params.mKnowsCompositor = mKnowsCompositor;
params.mImageContainer = new layers::ImageContainer();
+ params.mRate = CreateDecoderParams::VideoFrameRate(aFramerate);
MediaResult error(NS_OK);
params.mError = &error;
mDecoder = pdm->CreateVideoDecoder(params);
if (NS_FAILED(error)) {
MOZ_ASSERT(aErrorDescription);
*aErrorDescription = error.Description();
--- a/dom/media/ipc/VideoDecoderParent.h
+++ b/dom/media/ipc/VideoDecoderParent.h
@@ -23,16 +23,17 @@ class VideoDecoderParent final : public
{
public:
// We refcount this class since the task queue can have runnables
// that reference us.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderParent)
VideoDecoderParent(VideoDecoderManagerParent* aParent,
const VideoInfo& aVideoInfo,
+ float aFramerate,
const layers::TextureFactoryIdentifier& aIdentifier,
TaskQueue* aManagerTaskQueue,
TaskQueue* aDecodeTaskQueue,
bool* aSuccess,
nsCString* aErrorDescription);
void Destroy();