зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1821803 - part4 : prevent setting CDM before the engine initialization. r=jolin
Differential Revision: https://phabricator.services.mozilla.com/D172489
This commit is contained in:
Родитель
7e7b0ded7c
Коммит
b37f11ef4d
|
@ -448,6 +448,9 @@ RefPtr<ShutdownPromise> ExternalEngineStateMachine::Shutdown() {
|
||||||
|
|
||||||
mMetadataManager.Disconnect();
|
mMetadataManager.Disconnect();
|
||||||
|
|
||||||
|
mSetCDMProxyPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_ABORT_ERR, __func__);
|
||||||
|
mSetCDMProxyRequest.DisconnectIfExists();
|
||||||
|
|
||||||
mEngine->Shutdown();
|
mEngine->Shutdown();
|
||||||
|
|
||||||
auto* state = mState.AsShutdownEngine();
|
auto* state = mState.AsShutdownEngine();
|
||||||
|
@ -1030,10 +1033,38 @@ void ExternalEngineStateMachine::UpdateSecondaryVideoContainer() {
|
||||||
|
|
||||||
RefPtr<SetCDMPromise> ExternalEngineStateMachine::SetCDMProxy(
|
RefPtr<SetCDMPromise> ExternalEngineStateMachine::SetCDMProxy(
|
||||||
CDMProxy* aProxy) {
|
CDMProxy* aProxy) {
|
||||||
|
if (mState.IsShutdownEngine()) {
|
||||||
|
return SetCDMPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mState.IsInitEngine() && mState.AsInitEngine()->mInitPromise) {
|
||||||
|
LOG("SetCDMProxy is called before init");
|
||||||
|
mState.AsInitEngine()->mInitPromise->Then(
|
||||||
|
OwnerThread(), __func__,
|
||||||
|
[self = RefPtr{this}, proxy = RefPtr{aProxy},
|
||||||
|
this](const GenericNonExclusivePromise::ResolveOrRejectValue& aVal) {
|
||||||
|
SetCDMProxy(proxy)
|
||||||
|
->Then(OwnerThread(), __func__,
|
||||||
|
[self = RefPtr{this},
|
||||||
|
this](const SetCDMPromise::ResolveOrRejectValue& aVal) {
|
||||||
|
mSetCDMProxyRequest.Complete();
|
||||||
|
if (aVal.IsResolve()) {
|
||||||
|
mSetCDMProxyPromise.Resolve(true, __func__);
|
||||||
|
} else {
|
||||||
|
mSetCDMProxyPromise.Reject(NS_ERROR_DOM_MEDIA_CDM_ERR,
|
||||||
|
__func__);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->Track(mSetCDMProxyRequest);
|
||||||
|
});
|
||||||
|
return mSetCDMProxyPromise.Ensure(__func__);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO : set CDM proxy again if we recreate the media engine after crash.
|
// TODO : set CDM proxy again if we recreate the media engine after crash.
|
||||||
LOG("SetCDMProxy=%p", aProxy);
|
LOG("SetCDMProxy=%p", aProxy);
|
||||||
MOZ_DIAGNOSTIC_ASSERT(mEngine);
|
MOZ_DIAGNOSTIC_ASSERT(mEngine);
|
||||||
if (!mEngine->SetCDMProxy(aProxy)) {
|
if (!mEngine->SetCDMProxy(aProxy)) {
|
||||||
|
LOG("Failed to set CDM proxy on the engine");
|
||||||
return SetCDMPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CDM_ERR, __func__);
|
return SetCDMPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_CDM_ERR, __func__);
|
||||||
}
|
}
|
||||||
return MediaDecoderStateMachineBase::SetCDMProxy(aProxy);
|
return MediaDecoderStateMachineBase::SetCDMProxy(aProxy);
|
||||||
|
|
|
@ -286,6 +286,10 @@ class ExternalEngineStateMachine final
|
||||||
bool mHasEnoughVideo = false;
|
bool mHasEnoughVideo = false;
|
||||||
bool mSentPlaybackEndedEvent = false;
|
bool mSentPlaybackEndedEvent = false;
|
||||||
bool mHasReceivedFirstDecodedVideoFrame = false;
|
bool mHasReceivedFirstDecodedVideoFrame = false;
|
||||||
|
|
||||||
|
// Only used if setting CDM happens before the engine finishes initialization.
|
||||||
|
MozPromiseHolder<SetCDMPromise> mSetCDMProxyPromise;
|
||||||
|
MozPromiseRequestHolder<SetCDMPromise> mSetCDMProxyRequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExternalPlaybackEngine {
|
class ExternalPlaybackEngine {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче