Skip to content

Commit

Permalink
Bug 1863800 - part5 : set L1 path on the MFCDM process if it's alread…
Browse files Browse the repository at this point in the history
…y created before downloading L1. r=aosmond,gerard-majax

MFCDM process can be launched without setting L1 path, if the L1 hasn't
been installed at the moment. If L1 is installed later, we would update
the path to the MFCDM process and setup its sandbox permission.

Differential Revision: https://phabricator.services.mozilla.com/D195834
  • Loading branch information
alastor0325 committed Dec 19, 2023
1 parent 2489913 commit e2d6b4b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dom/media/gmp/GMPServiceParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
# include "mozilla/dom/MediaKeys.h" // MediaKeys::kMediaKeysRequestTopic
#endif

#ifdef MOZ_WMF_CDM
# include "mozilla/MFCDMParent.h"
#endif

namespace mozilla::gmp {

#ifdef __CLASS__
Expand Down Expand Up @@ -650,6 +654,12 @@ void GeckoMediaPluginServiceParent::UpdateContentProcessGMPCapabilities(
hasH264 = HAS_H264;
}
}
#ifdef MOZ_WMF_CDM
if (name.Equals("gmp-widevinecdm-l1")) {
nsCOMPtr<nsIFile> pluginFile = gmp->GetDirectory();
MFCDMService::UpdateWidevineL1Path(pluginFile);
}
#endif
caps.AppendElement(std::move(x));
}
}
Expand Down
41 changes: 41 additions & 0 deletions dom/media/ipc/MFCDMParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "SpecialSystemDirectory.h" // For temp dir
#include "WMFUtils.h"

#ifdef MOZ_WMF_CDM_LPAC_SANDBOX
# include "sandboxBroker.h"
#endif

using Microsoft::WRL::ComPtr;
using Microsoft::WRL::MakeAndInitialize;

Expand Down Expand Up @@ -1170,6 +1174,43 @@ RefPtr<GenericNonExclusivePromise> MFCDMService::LaunchMFCDMProcessIfNeeded(
});
}

/* static */
void MFCDMService::UpdateWidevineL1Path(nsIFile* aFile) {
RefPtr<ipc::UtilityProcessManager> utilityProc =
ipc::UtilityProcessManager::GetSingleton();
if (NS_WARN_IF(!utilityProc)) {
NS_WARNING("Failed to get UtilityProcessManager");
return;
}

// If the MFCDM process hasn't been created yet, then we will set the path
// when creating the process later.
const auto sandboxKind = ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM;
if (!utilityProc->Process(sandboxKind)) {
return;
}

// The MFCDM process has been started, we need to update its L1 path and set
// the permission for LPAC.
nsString widevineL1Path;
MOZ_ASSERT(aFile);
if (NS_WARN_IF(NS_FAILED(aFile->GetTarget(widevineL1Path)))) {
NS_WARNING("MFCDMService::UpdateWidevineL1Path, Failed to get L1 path!");
return;
}

RefPtr<ipc::UtilityAudioDecoderChild> uadc =
ipc::UtilityAudioDecoderChild::GetSingleton(sandboxKind);
if (NS_WARN_IF(!uadc)) {
NS_WARNING("Failed to get UtilityAudioDecoderChild");
return;
}
Unused << uadc->SendUpdateWidevineL1Path(widevineL1Path);
#ifdef MOZ_WMF_CDM_LPAC_SANDBOX
SandboxBroker::EnsureLpacPermsissionsOnDir(widevineL1Path);
#endif
}

#undef MFCDM_REJECT_IF_FAILED
#undef MFCDM_REJECT_IF
#undef MFCDM_RETURN_IF_FAILED
Expand Down
5 changes: 5 additions & 0 deletions dom/media/ipc/MFCDMParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ class MFCDMService {
// This is used to display CDM capabilites in `about:support`.
static void GetAllKeySystemsCapabilities(dom::Promise* aPromise);

// If Widevine L1 is downloaded after the MFCDM process is created, then we
// use this method to update the L1 path and setup L1 permission for the MFCDM
// process.
static void UpdateWidevineL1Path(nsIFile* aFile);

private:
static RefPtr<GenericNonExclusivePromise> LaunchMFCDMProcessIfNeeded(
ipc::SandboxingKind aSandbox);
Expand Down
2 changes: 2 additions & 0 deletions ipc/glue/PUtilityAudioDecoder.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ parent:

#ifdef MOZ_WMF_CDM
async GetKeySystemCapabilities() returns (MFCDMCapabilitiesIPDL[] result);

async UpdateWidevineL1Path(nsString path);
#endif

child:
Expand Down
6 changes: 6 additions & 0 deletions ipc/glue/UtilityAudioDecoderParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ IPCResult UtilityAudioDecoderParent::RecvGetKeySystemCapabilities(
});
return IPC_OK();
}

IPCResult UtilityAudioDecoderParent::RecvUpdateWidevineL1Path(
const nsString& aPath) {
MFCDMParent::SetWidevineL1Path(NS_ConvertUTF16toUTF8(aPath).get());
return IPC_OK();
}
#endif

} // namespace mozilla::ipc
2 changes: 2 additions & 0 deletions ipc/glue/UtilityAudioDecoderParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class UtilityAudioDecoderParent final : public PUtilityAudioDecoderParent {
#ifdef MOZ_WMF_CDM
IPCResult RecvGetKeySystemCapabilities(
GetKeySystemCapabilitiesResolver&& aResolver);

IPCResult RecvUpdateWidevineL1Path(const nsString& aPath);
#endif

private:
Expand Down

0 comments on commit e2d6b4b

Please sign in to comment.