Bug 1366362: P2. Change access restrictions of members. r?jwwang
We try to make the definition in the same order as the base class and with the same access.
We make DoSeek protected as we'll need it in the next change.
MozReview-Commit-ID: KAn1Jj3mAB7
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1013,21 +1013,18 @@ public:
{
// We set mVideoDecodeSuspended to false in Enter().
MOZ_ASSERT(false, "Shouldn't have suspended video decoding.");
}
protected:
SeekJob mSeekJob;
+ virtual void DoSeek() = 0;
void SeekCompleted();
-
-private:
- virtual void DoSeek() = 0;
-
virtual TimeUnit CalculateNewCurrentTime() const = 0;
};
class MediaDecoderStateMachine::AccurateSeekingState
: public MediaDecoderStateMachine::SeekingState
{
public:
explicit AccurateSeekingState(Master* aPtr) : SeekingState(aPtr) { }
@@ -1189,31 +1186,16 @@ public:
void HandleVideoWaited(MediaData::Type aType) override
{
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking,
"Seek shouldn't be finished");
RequestVideoData();
}
-private:
- void DemuxerSeek()
- {
- // Request the demuxer to perform seek.
- Reader()->Seek(mSeekJob.mTarget.ref())
- ->Then(OwnerThread(), __func__,
- [this] (const media::TimeUnit& aUnit) {
- OnSeekResolved(aUnit);
- },
- [this] (const SeekRejectValue& aReject) {
- OnSeekRejected(aReject);
- })
- ->Track(mSeekRequest);
- }
-
void DoSeek() override
{
mDoneAudioSeeking = !Info().HasAudio() || mSeekJob.mTarget->IsVideoOnly();
mDoneVideoSeeking = !Info().HasVideo();
if (mSeekJob.mTarget->IsVideoOnly()) {
mMaster->ResetDecode(TrackInfo::kVideoTrack);
} else {
@@ -1256,16 +1238,31 @@ private:
return TimeUnit::FromMicroseconds(
audioGap <= videoGap ? audioStart : videoStart);
}
MOZ_ASSERT(false, "AccurateSeekTask doesn't handle other seek types.");
return TimeUnit::Zero();
}
+private:
+ void DemuxerSeek()
+ {
+ // Request the demuxer to perform seek.
+ Reader()->Seek(mSeekJob.mTarget.ref())
+ ->Then(OwnerThread(), __func__,
+ [this] (const media::TimeUnit& aUnit) {
+ OnSeekResolved(aUnit);
+ },
+ [this] (const SeekRejectValue& aReject) {
+ OnSeekRejected(aReject);
+ })
+ ->Track(mSeekRequest);
+ }
+
void OnSeekResolved(media::TimeUnit)
{
mSeekRequest.Complete();
// We must decode the first samples of active streams, so we can determine
// the new stream time. So dispatch tasks to do that.
if (!mDoneVideoSeeking) {
RequestVideoData();
@@ -1517,71 +1514,16 @@ public:
{
// Disconnect my async seek operation.
mAsyncSeekTask->Cancel();
// Disconnect MediaDecoder.
mSeekJob.RejectIfExists(__func__);
}
-private:
- void DoSeekInternal()
- {
- auto currentTime = mCurrentTime;
- DiscardFrames(VideoQueue(), [currentTime] (int64_t aSampleTime) {
- return aSampleTime <= currentTime.ToMicroseconds();
- });
-
- if (!NeedMoreVideo()) {
- FinishSeek();
- } else if (!mMaster->IsRequestingVideoData()
- && !mMaster->IsWaitingVideoData()) {
- RequestVideoData();
- }
- }
-
- class AysncNextFrameSeekTask : public Runnable
- {
- public:
- explicit AysncNextFrameSeekTask(NextFrameSeekingState* aStateObject)
- : mStateObj(aStateObject)
- {
- }
-
- void Cancel() { mStateObj = nullptr; }
-
- NS_IMETHOD Run() override
- {
- if (mStateObj) {
- mStateObj->DoSeekInternal();
- }
- return NS_OK;
- }
-
- private:
- NextFrameSeekingState* mStateObj;
- };
-
- void DoSeek() override
- {
- // We need to do the seek operation asynchronously. Because for a special
- // case (bug504613.ogv) which has no data at all, the 1st seekToNextFrame()
- // operation reaches to the end of the media. If we did the seek operation
- // synchronously, we immediately resolve the SeekPromise in mSeekJob and
- // then switch to the CompletedState which dispatches an "ended" event.
- // However, the ThenValue of the SeekPromise has not yet been set, so the
- // promise resolving is postponed and then the JS developer receives the
- // "ended" event before the seek promise is resolved.
- // An asynchronous seek operation helps to solve this issue since while the
- // seek is actually performed, the ThenValue of SeekPromise has already
- // been set so that it won't be postponed.
- RefPtr<Runnable> r = mAsyncSeekTask = new AysncNextFrameSeekTask(this);
- OwnerThread()->Dispatch(r.forget());
- }
-
void HandleAudioDecoded(AudioData* aAudio) override
{
mMaster->PushAudio(aAudio);
}
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override
{
MOZ_ASSERT(aVideo);
@@ -1656,16 +1598,71 @@ private:
TimeUnit CalculateNewCurrentTime() const override
{
// The HTMLMediaElement.currentTime should be updated to the seek target
// which has been updated to the next frame's time.
return mSeekJob.mTarget->GetTime();
}
+ void DoSeek() override
+ {
+ // We need to do the seek operation asynchronously. Because for a special
+ // case (bug504613.ogv) which has no data at all, the 1st seekToNextFrame()
+ // operation reaches the end of the media. If we did the seek operation
+ // synchronously, we immediately resolve the SeekPromise in mSeekJob and
+ // then switch to the CompletedState which dispatches an "ended" event.
+ // However, the ThenValue of the SeekPromise has not yet been set, so the
+ // promise resolving is postponed and then the JS developer receives the
+ // "ended" event before the seek promise is resolved.
+ // An asynchronous seek operation helps to solve this issue since while the
+ // seek is actually performed, the ThenValue of SeekPromise has already
+ // been set so that it won't be postponed.
+ RefPtr<Runnable> r = mAsyncSeekTask = new AysncNextFrameSeekTask(this);
+ OwnerThread()->Dispatch(r.forget());
+ }
+
+private:
+ void DoSeekInternal()
+ {
+ auto currentTime = mCurrentTime;
+ DiscardFrames(VideoQueue(), [currentTime] (int64_t aSampleTime) {
+ return aSampleTime <= currentTime.ToMicroseconds();
+ });
+
+ if (!NeedMoreVideo()) {
+ FinishSeek();
+ } else if (!mMaster->IsRequestingVideoData()
+ && !mMaster->IsWaitingVideoData()) {
+ RequestVideoData();
+ }
+ }
+
+ class AysncNextFrameSeekTask : public Runnable
+ {
+ public:
+ explicit AysncNextFrameSeekTask(NextFrameSeekingState* aStateObject)
+ : mStateObj(aStateObject)
+ {
+ }
+
+ void Cancel() { mStateObj = nullptr; }
+
+ NS_IMETHOD Run() override
+ {
+ if (mStateObj) {
+ mStateObj->DoSeekInternal();
+ }
+ return NS_OK;
+ }
+
+ private:
+ NextFrameSeekingState* mStateObj;
+ };
+
void RequestVideoData()
{
mMaster->RequestVideoData(false, media::TimeUnit());
}
bool NeedMoreVideo() const
{
// Need to request video when we have none and video queue is not finished.