Bug 1521964 - Don't suspend the video decoder when cloning a video visually. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D20674

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2019-03-01 22:36:53 +00:00
Родитель 59c1141de6
Коммит 44acc929a5
3 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -471,6 +471,7 @@ void HTMLVideoElement::MaybeBeginCloningVisually() {
mVisualCloneTarget->GetVideoFrameContainer();
if (mdsm && container) {
mdsm->SetSecondaryVideoContainer(container);
mDecoder->SetCloningVisually(true);
}
} else if (mSrcStream) {
VideoFrameContainer* container =
@ -488,6 +489,7 @@ void HTMLVideoElement::EndCloningVisually() {
MediaDecoderStateMachine* mdsm = mDecoder->GetStateMachine();
if (mdsm) {
mdsm->SetSecondaryVideoContainer(nullptr);
mDecoder->SetCloningVisually(false);
}
} else if (mSrcStream) {
VideoFrameContainer* container =

Просмотреть файл

@ -305,6 +305,7 @@ MediaDecoder::MediaDecoder(MediaDecoderInit& aInit)
mIsElementInTree(false),
mForcedHidden(false),
mHasSuspendTaint(aInit.mHasSuspendTaint),
mIsCloningVisually(false),
mPlaybackRate(aInit.mPlaybackRate),
mLogicallySeeking(false, "MediaDecoder::mLogicallySeeking"),
INIT_MIRROR(mBuffered, TimeIntervals()),
@ -988,6 +989,14 @@ void MediaDecoder::UpdateVideoDecodeMode() {
return;
}
// If mIsCloningVisually is set, never suspend the video decoder.
if (mIsCloningVisually) {
LOG("UpdateVideoDecodeMode(), set Normal because the element is cloning "
"itself visually to another video container.");
mDecoderStateMachine->SetVideoDecodeMode(VideoDecodeMode::Normal);
return;
}
// Don't suspend elements that is not in tree.
if (!mIsElementInTree) {
LOG("UpdateVideoDecodeMode(), set Normal because the element is not in "
@ -1046,6 +1055,13 @@ bool MediaDecoder::HasSuspendTaint() const {
return mHasSuspendTaint;
}
void MediaDecoder::SetCloningVisually(bool aIsCloningVisually) {
if (mIsCloningVisually != aIsCloningVisually) {
mIsCloningVisually = aIsCloningVisually;
UpdateVideoDecodeMode();
}
}
bool MediaDecoder::IsMediaSeekable() {
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE(GetStateMachine(), false);

Просмотреть файл

@ -308,6 +308,8 @@ class MediaDecoder : public DecoderDoctorLifeLogger<MediaDecoder> {
// Returns true if the decoder can't participate in suspend-video-decoder.
bool HasSuspendTaint() const;
void SetCloningVisually(bool aIsCloningVisually);
void UpdateVideoDecodeMode();
void SetIsBackgroundVideoDecodingAllowed(bool aAllowed);
@ -562,6 +564,10 @@ class MediaDecoder : public DecoderDoctorLifeLogger<MediaDecoder> {
// disabled.
bool mHasSuspendTaint;
// True if the decoder is sending video to a secondary container, and should
// not suspend the decoder.
bool mIsCloningVisually;
MediaDecoderOwner::NextFrameStatus mNextFrameStatus =
MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;