зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1360123 P2 - move ConstructMediaTracks/RemoveMediaTracks to HTMLMediaElemnt; r=jwwang
MozReview-Commit-ID: 3S63JeXAX2w --HG-- extra : rebase_source : ef807247a5042fa23ba6b6f5c907035bd8d64199
This commit is contained in:
Родитель
bb1078e81f
Коммит
dab014bd99
|
@ -3713,6 +3713,7 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
|
|||
mDefaultPlaybackStartPosition(0.0),
|
||||
mIsAudioTrackAudible(false),
|
||||
mHasSuspendTaint(false),
|
||||
mMediaTracksConstructed(false),
|
||||
mVisibilityState(Visibility::UNTRACKED),
|
||||
mErrorSink(new ErrorSink(this)),
|
||||
mAudioChannelWrapper(new AudioChannelAgentCallback(this, mAudioChannel))
|
||||
|
@ -7341,7 +7342,11 @@ HTMLMediaElement::GetDocument() const
|
|||
void
|
||||
HTMLMediaElement::ConstructMediaTracks(const MediaInfo* aInfo)
|
||||
{
|
||||
MOZ_ASSERT(aInfo);
|
||||
if (mMediaTracksConstructed || !aInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMediaTracksConstructed = true;
|
||||
|
||||
AudioTrackList* audioList = AudioTracks();
|
||||
if (audioList && aInfo->HasAudio()) {
|
||||
|
@ -7373,6 +7378,8 @@ HTMLMediaElement::RemoveMediaTracks()
|
|||
if (mVideoTrackList) {
|
||||
mVideoTrackList->RemoveTracks();
|
||||
}
|
||||
|
||||
mMediaTracksConstructed = false;
|
||||
}
|
||||
|
||||
class MediaElementGMPCrashHelper : public GMPCrashHelper
|
||||
|
|
|
@ -1747,6 +1747,10 @@ private:
|
|||
// participate in video decoder suspending.
|
||||
bool mHasSuspendTaint;
|
||||
|
||||
// True if audio tracks and video tracks are constructed and added into the
|
||||
// track list, false if all tracks are removed from the track list.
|
||||
bool mMediaTracksConstructed;
|
||||
|
||||
Visibility mVisibilityState;
|
||||
|
||||
UniquePtr<ErrorSink> mErrorSink;
|
||||
|
|
|
@ -385,7 +385,6 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
|
|||
, mPlaybackStatistics(new MediaChannelStatistics())
|
||||
, mPinnedForSeek(false)
|
||||
, mMinimizePreroll(false)
|
||||
, mMediaTracksConstructed(false)
|
||||
, mFiredMetadataLoaded(false)
|
||||
, mIsDocumentVisible(false)
|
||||
, mElementVisibility(Visibility::UNTRACKED)
|
||||
|
@ -774,7 +773,7 @@ void
|
|||
MediaDecoder::OnMetadataUpdate(TimedMetadata&& aMetadata)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
RemoveMediaTracks();
|
||||
GetOwner()->RemoveMediaTracks();
|
||||
MetadataLoaded(nsAutoPtr<MediaInfo>(new MediaInfo(*aMetadata.mInfo)),
|
||||
Move(aMetadata.mTags),
|
||||
MediaDecoderEventVisibility::Observable);
|
||||
|
@ -797,7 +796,7 @@ MediaDecoder::MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
|
|||
mMediaSeekable = aInfo->mMediaSeekable;
|
||||
mMediaSeekableOnlyInBufferedRanges = aInfo->mMediaSeekableOnlyInBufferedRanges;
|
||||
mInfo = aInfo.forget();
|
||||
ConstructMediaTracks();
|
||||
GetOwner()->ConstructMediaTracks(mInfo);
|
||||
|
||||
// Make sure the element and the frame (if any) are told about
|
||||
// our new size.
|
||||
|
@ -1164,9 +1163,9 @@ MediaDecoder::ChangeState(PlayState aState)
|
|||
mPlayState = aState;
|
||||
|
||||
if (mPlayState == PLAY_STATE_PLAYING) {
|
||||
ConstructMediaTracks();
|
||||
GetOwner()->ConstructMediaTracks(mInfo);
|
||||
} else if (IsEnded()) {
|
||||
RemoveMediaTracks();
|
||||
GetOwner()->RemoveMediaTracks();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1709,32 +1708,6 @@ MediaDecoder::GetOwner() const
|
|||
return mOwner;
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoder::ConstructMediaTracks()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
||||
|
||||
if (mMediaTracksConstructed || !mInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
GetOwner()->ConstructMediaTracks(mInfo);
|
||||
|
||||
mMediaTracksConstructed = true;
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoder::RemoveMediaTracks()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
||||
|
||||
GetOwner()->RemoveMediaTracks();
|
||||
|
||||
mMediaTracksConstructed = false;
|
||||
}
|
||||
|
||||
MediaDecoderOwner::NextFrameStatus
|
||||
MediaDecoder::NextFrameBufferedStatus()
|
||||
{
|
||||
|
|
|
@ -387,17 +387,6 @@ private:
|
|||
// change. Call on the main thread only.
|
||||
virtual void ChangeState(PlayState aState);
|
||||
|
||||
// Called from MetadataLoaded(). Ask its owner to create audio/video tracks
|
||||
// and adds them to its owner's audio/video track list.
|
||||
// Call on the main thread only.
|
||||
void ConstructMediaTracks();
|
||||
|
||||
// Ask its owner to remove all audio tracks and video tracks that are
|
||||
// previously added into the track list.
|
||||
// Call on the main thread only.
|
||||
void RemoveMediaTracks();
|
||||
|
||||
|
||||
// Called when the video has completed playing.
|
||||
// Call on the main thread only.
|
||||
void PlaybackEnded();
|
||||
|
@ -685,11 +674,6 @@ protected:
|
|||
// or play the media again.
|
||||
bool mMinimizePreroll;
|
||||
|
||||
// True if audio tracks and video tracks are constructed and added into the
|
||||
// owenr's track list, false if all tracks are removed from the owner's track
|
||||
// list.
|
||||
bool mMediaTracksConstructed;
|
||||
|
||||
// True if we've already fired metadataloaded.
|
||||
bool mFiredMetadataLoaded;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче