Bug 1846848 - part3 : add a way to get CDM capabilities from the chrome process. r=gerard-majax,jolin

Differential Revision: https://phabricator.services.mozilla.com/D194452
This commit is contained in:
alwu
2023-12-06 18:16:04 +00:00
parent e51b73b328
commit 3de0b2d419
8 changed files with 90 additions and 11 deletions

View File

@@ -7,6 +7,7 @@
#include "mozilla/EMEUtils.h" #include "mozilla/EMEUtils.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "MediaData.h"
#include "mozilla/StaticPrefs_media.h" #include "mozilla/StaticPrefs_media.h"
#include "mozilla/dom/KeySystemNames.h" #include "mozilla/dom/KeySystemNames.h"
#include "mozilla/dom/UnionTypes.h" #include "mozilla/dom/UnionTypes.h"
@@ -128,4 +129,17 @@ bool IsHardwareDecryptionSupported(
return supportHardwareDecryption; return supportHardwareDecryption;
} }
const char* EncryptionSchemeStr(const CryptoScheme& aScheme) {
switch (aScheme) {
case CryptoScheme::None:
return "none";
case CryptoScheme::Cenc:
return "cenc";
case CryptoScheme::Cbcs:
return "cbcs";
default:
return "not-defined!";
}
}
} // namespace mozilla } // namespace mozilla

View File

@@ -15,6 +15,8 @@
namespace mozilla { namespace mozilla {
enum class CryptoScheme : uint8_t;
namespace dom { namespace dom {
class ArrayBufferViewOrArrayBuffer; class ArrayBufferViewOrArrayBuffer;
} }
@@ -78,6 +80,8 @@ const char* ToMediaKeyStatusStr(dom::MediaKeyStatus aStatus);
bool IsHardwareDecryptionSupported( bool IsHardwareDecryptionSupported(
const dom::MediaKeySystemConfiguration& aConfig); const dom::MediaKeySystemConfiguration& aConfig);
const char* EncryptionSchemeStr(const CryptoScheme& aScheme);
} // namespace mozilla } // namespace mozilla
#endif // EME_LOG_H_ #endif // EME_LOG_H_

View File

@@ -64,17 +64,6 @@ static void MFCDMCapabilitiesIPDLToKeySystemConfig(
NS_ConvertUTF16toUTF8(aKeySystemConfig.GetDebugInfo()).get()); NS_ConvertUTF16toUTF8(aKeySystemConfig.GetDebugInfo()).get());
} }
static const char* EncryptionSchemeStr(const CryptoScheme aScheme) {
switch (aScheme) {
case CryptoScheme::None:
return "none";
case CryptoScheme::Cenc:
return "cenc";
case CryptoScheme::Cbcs:
return "cbcs";
}
}
bool WMFCDMImpl::GetCapabilities(nsTArray<KeySystemConfig>& aOutConfigs) { bool WMFCDMImpl::GetCapabilities(nsTArray<KeySystemConfig>& aOutConfigs) {
nsCOMPtr<nsISerialEventTarget> backgroundTaskQueue; nsCOMPtr<nsISerialEventTarget> backgroundTaskQueue;
NS_CreateBackgroundTaskQueue(__func__, getter_AddRefs(backgroundTaskQueue)); NS_CreateBackgroundTaskQueue(__func__, getter_AddRefs(backgroundTaskQueue));

View File

@@ -11,6 +11,10 @@ using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
using mozilla::media::MediaCodecsSupported from "MediaCodecsSupport.h"; using mozilla::media::MediaCodecsSupported from "MediaCodecsSupport.h";
using mozilla::RemoteDecodeIn from "mozilla/RemoteDecoderManagerChild.h"; using mozilla::RemoteDecodeIn from "mozilla/RemoteDecoderManagerChild.h";
#ifdef MOZ_WMF_CDM
using mozilla::MFCDMCapabilitiesIPDL from "mozilla/PMFCDM.h";
#endif
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
@@ -31,6 +35,10 @@ parent:
async UpdateVar(GfxVarUpdate var); async UpdateVar(GfxVarUpdate var);
#endif #endif
#ifdef MOZ_WMF_CDM
async GetKeySystemCapabilities() returns (MFCDMCapabilitiesIPDL[] result);
#endif
child: child:
async UpdateMediaCodecsSupported(RemoteDecodeIn aLocation, async UpdateMediaCodecsSupported(RemoteDecodeIn aLocation,
MediaCodecsSupported aSupported); MediaCodecsSupported aSupported);

View File

@@ -19,6 +19,11 @@
# include "mozilla/layers/VideoBridgeUtils.h" # include "mozilla/layers/VideoBridgeUtils.h"
#endif #endif
#ifdef MOZ_WMF_CDM
# include "mozilla/EMEUtils.h"
# include "mozilla/PMFCDM.h"
#endif
namespace mozilla::ipc { namespace mozilla::ipc {
NS_IMETHODIMP UtilityAudioDecoderChildShutdownObserver::Observe( NS_IMETHODIMP UtilityAudioDecoderChildShutdownObserver::Observe(
@@ -173,4 +178,33 @@ bool UtilityAudioDecoderChild::CreateVideoBridge() {
} }
#endif #endif
#ifdef MOZ_WMF_CDM
void UtilityAudioDecoderChild::GetKeySystemCapabilities() {
EME_LOG("Ask capabilities for all supported CDMs");
SendGetKeySystemCapabilities()->Then(
NS_GetCurrentThread(), __func__,
[](CopyableTArray<MFCDMCapabilitiesIPDL>&& result) {
for (const auto& capabilities : result) {
EME_LOG("Received capabilities for %s",
NS_ConvertUTF16toUTF8(capabilities.keySystem()).get());
for (const auto& v : capabilities.videoCapabilities()) {
EME_LOG(" capabilities: video=%s",
NS_ConvertUTF16toUTF8(v.contentType()).get());
}
for (const auto& a : capabilities.audioCapabilities()) {
EME_LOG(" capabilities: audio=%s",
NS_ConvertUTF16toUTF8(a.contentType()).get());
}
for (const auto& e : capabilities.encryptionSchemes()) {
EME_LOG(" capabilities: encryptionScheme=%s",
EncryptionSchemeStr(e));
}
}
},
[](const mozilla::ipc::ResponseRejectReason& aReason) {
EME_LOG("IPC failure for GetKeySystemCapabilities!");
});
}
#endif
} // namespace mozilla::ipc } // namespace mozilla::ipc

View File

@@ -107,6 +107,10 @@ class UtilityAudioDecoderChild final : public PUtilityAudioDecoderChild
bool CreateVideoBridge(); bool CreateVideoBridge();
#endif #endif
#ifdef MOZ_WMF_CDM
void GetKeySystemCapabilities();
#endif
private: private:
explicit UtilityAudioDecoderChild(SandboxingKind aKind); explicit UtilityAudioDecoderChild(SandboxingKind aKind);
~UtilityAudioDecoderChild() = default; ~UtilityAudioDecoderChild() = default;

View File

@@ -35,6 +35,11 @@
# include "gfxConfig.h" # include "gfxConfig.h"
#endif #endif
#ifdef MOZ_WMF_CDM
# include "mozilla/MFCDMParent.h"
# include "mozilla/PMFCDM.h"
#endif
namespace mozilla::ipc { namespace mozilla::ipc {
UtilityAudioDecoderParent::UtilityAudioDecoderParent() UtilityAudioDecoderParent::UtilityAudioDecoderParent()
@@ -170,4 +175,20 @@ IPCResult UtilityAudioDecoderParent::RecvUpdateVar(
} }
#endif #endif
#ifdef MOZ_WMF_CDM
IPCResult UtilityAudioDecoderParent::RecvGetKeySystemCapabilities(
GetKeySystemCapabilitiesResolver&& aResolver) {
MOZ_ASSERT(mKind == SandboxingKind::MF_MEDIA_ENGINE_CDM);
MFCDMParent::GetAllKeySystemsCapabilities()->Then(
GetCurrentSerialEventTarget(), __func__,
[aResolver](CopyableTArray<MFCDMCapabilitiesIPDL>&& aCapabilities) {
aResolver(std::move(aCapabilities));
},
[aResolver](nsresult) {
aResolver(CopyableTArray<MFCDMCapabilitiesIPDL>());
});
return IPC_OK();
}
#endif
} // namespace mozilla::ipc } // namespace mozilla::ipc

View File

@@ -45,6 +45,11 @@ class UtilityAudioDecoderParent final : public PUtilityAudioDecoderParent {
IPCResult RecvUpdateVar(const mozilla::gfx::GfxVarUpdate& aUpdate); IPCResult RecvUpdateVar(const mozilla::gfx::GfxVarUpdate& aUpdate);
#endif #endif
#ifdef MOZ_WMF_CDM
IPCResult RecvGetKeySystemCapabilities(
GetKeySystemCapabilitiesResolver&& aResolver);
#endif
private: private:
~UtilityAudioDecoderParent(); ~UtilityAudioDecoderParent();