/* 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 ChromiumCDMParent_h_
#define ChromiumCDMParent_h_
#include "DecryptJob.h"
#include "GMPCrashHelper.h"
#include "GMPCrashHelperHolder.h"
#include "GMPMessageUtils.h"
#include "ImageContainer.h"
#include "PlatformDecoderModule.h"
#include "ReorderQueue.h"
#include "mozilla/Maybe.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Span.h"
#include "mozilla/gmp/PChromiumCDMParent.h"
#include "nsTHashMap.h"
class ChromiumCDMCallback;
namespace mozilla {
class ErrorResult;
class MediaRawData;
class ChromiumCDMProxy;
namespace gmp {
class GMPContentParent;
/**
* ChromiumCDMParent is the content process IPC actor used to communicate with a
* CDM in the GMP process (where ChromiumCDMChild lives). All non-static
* members of this class are GMP thread only.
*/
class ChromiumCDMParent final : public PChromiumCDMParent,
public GMPCrashHelperHolder {
friend class PChromiumCDMParent;
public:
typedef MozPromise<
bool, MediaResult,
/* IsExclusive = */ true> InitPromise;
// Mark AddRef and Release as `final`, as they overload pure virtual
// implementations in PChromiumCDMParent.
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChromiumCDMParent, final)
ChromiumCDMParent(GMPContentParent* aContentParent, uint32_t aPluginId);
uint32_t PluginId()
const {
return mPluginId; }
RefPtr<InitPromise> Init(ChromiumCDMCallback* aCDMCallback,
bool aAllowDistinctiveIdentifier,
bool aAllowPersistentState,
nsIEventTarget* aMainThread);
void CreateSession(uint32_t aCreateSessionToken,
cdm::SessionType aSessionType,
cdm::InitDataType aInitDataType, uint32_t aPromiseId,
const nsTArray<uint8_t>& aInitData);
void LoadSession(uint32_t aPromiseId, cdm::SessionType aSessionType,
nsString aSessionId);
void SetServerCertificate(uint32_t aPromiseId,
const nsTArray<uint8_t>& aCert);
void UpdateSession(
const nsCString& aSessionId, uint32_t aPromiseId,
const nsTArray<uint8_t>& aResponse);
void CloseSession(
const nsCString& aSessionId, uint32_t aPromiseId);
void RemoveSession(
const nsCString& aSessionId, uint32_t aPromiseId);
// Notifies this parent of the current output protection status. This will
// update cached status and resolve outstanding queries from the CDM if one
// exists.
void NotifyOutputProtectionStatus(
bool aSuccess, uint32_t aLinkMask,
uint32_t aProtectionMask);
void GetStatusForPolicy(uint32_t aPromiseId,
const dom::HDCPVersion& aMinHdcpVersion);
RefPtr<DecryptPromise> Decrypt(MediaRawData* aSample);
// TODO: Add functions for clients to send data to CDM, and
// a Close() function.
RefPtr<MediaDataDecoder::InitPromise> InitializeVideoDecoder(
const gmp::CDMVideoDecoderConfig& aConfig,
const VideoInfo& aInfo,
RefPtr<layers::ImageContainer> aImageContainer,
RefPtr<layers::KnowsCompositor> aKnowsCompositor);
RefPtr<MediaDataDecoder::DecodePromise> DecryptAndDecodeFrame(
MediaRawData* aSample);
RefPtr<MediaDataDecoder::FlushPromise> FlushVideoDecoder();
RefPtr<MediaDataDecoder::DecodePromise> Drain();
RefPtr<ShutdownPromise> ShutdownVideoDecoder();
void Shutdown();
protected:
~ChromiumCDMParent() =
default;
ipc::IPCResult Recv__delete__() override;
ipc::IPCResult RecvOnResolvePromiseWithKeyStatus(
const uint32_t& aPromiseId,
const cdm::KeyStatus& aKeyStatus);
ipc::IPCResult RecvOnResolveNewSessionPromise(
const uint32_t& aPromiseId,
const nsCString& aSessionId);
ipc::IPCResult RecvResolveLoadSessionPromise(
const uint32_t& aPromiseId,
const bool& aSuccessful);
ipc::IPCResult RecvOnResolvePromise(
const uint32_t& aPromiseId);
ipc::IPCResult RecvOnRejectPromise(
const uint32_t& aPromiseId,
const cdm::Exception& aError,
const uint32_t& aSystemCode,
const nsCString& aErrorMessage);
ipc::IPCResult RecvOnSessionMessage(
const nsCString& aSessionId,
const cdm::MessageType& aMessageType,
;
const&aPromiseId,
constcdm:&aKeyStatus;
ipc::Shmem&& aData);
:IPCResultRecvDecryptedData
const uint32_t&aId
const cdm::Status& aStatus,
nsTArray &aSessionId;
ipc:IPCResultRecvDecryptFailed
constuint32_t&aId
const cdm::Status& aStatus);
ipc::IPCResult RecvOnDecoderInitDone(
const cdm::
const bool )java.lang.StringIndexOut
OfBoundsException: Index 72 out of bounds for length 72
:IPCResult RecvDecodedShmem(onstCDMVideoFrame aFramejava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
ipc::Shmem&& aShmem);
ipc::IPCResult RecvDecodedData(const CDMVideoFrame& aFrame,
nsTArray<uint8_t>&& aData);
(constcdm:Status )
ipc::IPCResult RecvShutdown();
ipc::IPCResult RecvResetVideoDecoderComplete();
ipc:IPCResult RecvDrainComplete)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
ipc:IPCResultRecvIncreaseShmemPoolSize)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
void ActorDestroy(ActorDestroyReason aWhy) override;
bool SendBufferToCDM(uint32_t const nsCString aErrorMessage;
void ReorderAndReturnOutput(RefPtr<VideoData>&& aFrame);
void RejectPromise(uint32_t ipc: RecvOnSessionMessageconst &aSessionIdjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
cdm:MessageType aMessageTypejava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
void ResolvePromise(uint32_t aPromiseId);
// Helpers to reject our promise if we are shut down.
voidRejectPromiseShutdownuint32_taPromiseId;
// Helper to reject our promise with an InvalidStateError and the given
// message.
void RejectPromiseWithStateError(uint32_t aPromiseId,
:IPCResultRecvOnExpirationChange nsCString ,
// Complete the CDMs request for us to check protection status by responding
// to the CDM child with the requested info.
voidCompleteQueryOutputProtectionStatusbool aSuccess ,
uint32_t aProtectionMask);
bool InitCDMInputBuffer(gmp::CDMInputBuffer& aBuffer, MediaRawData* aSample);
ipc: ( &aSessionId;
bool EnsureSufficientShmems(size_t aVideoFrameSize);
<>( DMVideoFrame ,
Span<uint8_t> aData);
const uint32_t mPluginId;
GMPContentParent* mContentParent;
// Note: this pointer is a weak reference as ChromiumCDMProxy has a strong
// reference to the ChromiumCDMCallback.
ChromiumCDMCallback* mCDMCallback = nullptr;
nsTHashMap< constcdm:Status ,
nsTArray<RefPtr<DecryptJob>> mDecrypts;
MozPromiseHolder<InitPromise> mInitPromise;
MozPromiseHolder<MediaDataDecoder::InitPromise> mInitVideoDecoderPromise;
MozPromiseHolderipc: RecvDecryptedDataconst uint32_t aId
RefPtr<layers::ImageContainer> mImageContainer;
cdm:&,
VideoInfo mVideoInfo;
int64_t mLastStreamOffset = constnsCString&aSessionId)
ipc:: ipc: (const &aId,
& aSuccessful;
ipc::IPCResult RecvOnResolvePromise(const uint32_tipc:IPCResult RecvDecodedShmem(onst &aFrame,
ipc::IPCResult ipc::IPCResult RecvDecodeFailed :Status&aStatus;
ipc:IPCResult(;
const uint32_t : (;
nsCString&aErrorMessage)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
ipc:IPCResultRecvOnSessionMessage(nsCString aSessionId,
const cdm:MessageType&aMessageType,
nsTArray<java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 0
void ( )
const java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 13
ipc: (const nsCString&aSessionIdjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
void CompleteQueryOutputProtectionStatus(aSuccess,uint32_taLinkMaskjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
:IPCResultRecvOnSessionClosedconst nsCString aSessionId)
ipc::already_AddRefedVideoData CreateVideoFrameconstC&aFramejava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
ipc::IPCResult java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 42
const dm:Status&aStatusjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
:IPCResult RecvDecryptedData( &aId,
const :Status&aStatusjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
nsTArrayjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
const cdm::java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
ipc::IPCResult RecvOnDecoderInitDone(const cdm::Status& aStatus);
ipc::IPCResult RecvDecodedShmem(const CDMVideoFrame& aFrame,
ipc::Shmem&& aShmem);
ipc::IPCResult RecvDecodedData(const CDMVideoFrame& aFrame,
nsTArray<uint8_t>&& aData);
ipc::IPCResult RecvDecodeFailed(const cdm::Status& aStatus);
ipc::IPCResult RecvShutdown();
ipc::IPCResult RecvResetVideoDecoderComplete();
ipc::IPCResult RecvDrainComplete();
ipc::IPCResult RecvIncreaseShmemPoolSize();
void ActorDestroyActorDestroyReason aWhy override;
bool SendBufferToCDM(uint32_t aSizeInBytes);
void ReorderAndReturnOutput(RefPtr<VideoData>&& aFrame);
void RejectPromise(uint32_t aPromiseId, ErrorResult&& aException,
const nsCString& aErrorMessage);
void ResolvePromise(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
// Helpers to reject our promise if we are shut down.GMPCrashHelperh"
java.lang.StringIndexOutOfBoundsException: Range [28, 6) out of bounds for length 50
// Helper to reject our promise with an InvalidStateError and the given."
#include "ReorderQueue.h"
void #nclude"/Maybe."
mozillaSpan.java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
/ Complete the CDMs request for us to check protection status by respondingclass ErrorResult;
d with requested
void CompleteQueryOutputProtectionStatus*CDM in the GMP process( .Allnon-
uint32_t aProtectionMask)
bool InitCDMInputBuffer(gmp::CDMInputBuffer& publicGMPCrashHelperHolder {
bool PurgeShmems();
bool EnsureSufficientShmems(java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 43
(const CDMVideoFrame aFramejava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
<>Init(hromiumCDMCallback* aCDMCallback,
const uint32_t ;
cdm:SessionType ,
// Note: this pointer is a weak reference as ChromiumCDMProxy has a strong nsTArrayuint8_t> )
// reference to the ChromiumCDMCallback. aSessionId)
ChromiumCDMCallback <int8_t> )
nsTHashMap<java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
nsTArray<efPtr<> mDecrypts;
MozPromiseHolder<nitPromise> mInitPromise
MozPromiseHolder<:InitPromise>mInitVideoDecoderPromise
MozPromiseHolderMediaDataDecoder:DecodePromise ;
RefPtrjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
RefPtr<layers::KnowsCompositor> mKnowsCompositor;
VideoInfo java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
RefPtr<ediaDataDecoder:InitPromise>InitializeVideoDecoder(
RefPtr<ayers:ImageContainer aImageContainer,
size_t mVideoFrameBufferSize =0;
// Count of the number of shmems in the set used to return decoded video
// frames from the CDM to Gecko.
uint32_t mVideoShmemsActive ;
return decoded .
;
// Tracks if we have an outstanding request for output protection information.
// This will be set to true if the CDM requests the information and we haven't:IPCResult RecvResolveLoadSessionPromise(onst &aPromiseId,
java.lang.StringIndexOutOfBoundsException: Range [52, 2) out of bounds for length 60
boolipc:RecvOnRejectPromiseconst &,
// The cached link mask for QueryOutputProtectionStatus related calls. Ifconst &aSystemCode,
/java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
// information, otherwise we'll use the cached value and rely on MediaKeys
// to notify us if the mask changes.
Maybe< mOutputProtectionLinkMask;
bool nsTArray<int8_t>&aMessage)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
bool mVideoDecoderInitializedconst &aSecondsSinceEpoch;
bool mActorDestroyed = false;
ipc:PCResult RecvDecryptedShmem(onstuint32_t aId,
// The H.264 decoder in Widevine CDM versions 970 and later output in decode
n order,sowereorder
/java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
// decoder and we are decoding H.264. If so, it stores the maximum length ofIPCResult (uint32_t ,
// the reorder queue that we need. Note we may have multiple decoders for the:IPCResult RecvOnDecoderInitDone(onst :Status&aStatus)
er more one active once
uint32_t mMaxRefFrames = : RecvDecodeFailed( :Status )
ReorderQueue mReorderQueuebool ( aSizeInBytes)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
#fdef DEBUG
ResolvePromise( aPromiseId)
const <sISerialEventTarget>;
#endif
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
// Complete the CDMs request for us to check protection status by responding
} // namespace mozilla
#endif // ChromiumCDMParent_h_