Bug 1371188 P2 - remove MediaDecoderReader::RequestVideoData()'s aSkipToNextKeyframe parameter; r?jya
It is not used.
MozReview-Commit-ID: EDPhN6RzKN0
--- a/dom/media/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -250,17 +250,17 @@ public:
}
NS_IMETHOD Run() override
{
MOZ_ASSERT(mReader->OnTaskQueue());
// Make sure ResetDecode hasn't been called in the mean time.
if (!mReader->mBaseVideoPromise.IsEmpty()) {
- mReader->RequestVideoData(/* aSkip = */ true, mTimeThreshold);
+ mReader->RequestVideoData(mTimeThreshold);
}
return NS_OK;
}
private:
RefPtr<MediaDecoderReader> mReader;
const media::TimeUnit mTimeThreshold;
@@ -286,21 +286,20 @@ public:
return NS_OK;
}
private:
RefPtr<MediaDecoderReader> mReader;
};
RefPtr<MediaDecoderReader::VideoDataPromise>
-MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
- const media::TimeUnit& aTimeThreshold)
+MediaDecoderReader::RequestVideoData(const media::TimeUnit& aTimeThreshold)
{
RefPtr<VideoDataPromise> p = mBaseVideoPromise.Ensure(__func__);
- bool skip = aSkipToNextKeyframe;
+ bool skip = false;
while (VideoQueue().GetSize() == 0 &&
!VideoQueue().IsFinished()) {
if (!DecodeVideoFrame(skip, aTimeThreshold)) {
VideoQueue().Finish();
} else if (skip) {
// We still need to decode more data in order to skip to the next
// keyframe. Post another task to the decode task queue to decode
// again. We don't just decode straight in a loop here, as that
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -136,22 +136,18 @@ public:
// Requests one audio sample from the reader.
//
// The decode should be performed asynchronously, and the promise should
// be resolved when it is complete.
virtual RefPtr<AudioDataPromise> RequestAudioData();
// Requests one video sample from the reader.
- //
- // If aSkipToKeyframe is true, the decode should skip ahead to the
- // the next keyframe at or after aTimeThreshold.
virtual RefPtr<VideoDataPromise>
- RequestVideoData(bool aSkipToNextKeyframe,
- const media::TimeUnit& aTimeThreshold);
+ RequestVideoData(const media::TimeUnit& aTimeThreshold);
// By default, the state machine polls the reader once per second when it's
// in buffering mode. Some readers support a promise-based mechanism by which
// they notify the state machine when the data arrives.
virtual bool IsWaitForDataSupported() const { return false; }
virtual RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType)
{
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -57,31 +57,29 @@ MediaDecoderReaderWrapper::RequestAudioD
return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__);
},
[] (const MediaResult& aError) {
return AudioDataPromise::CreateAndReject(aError, __func__);
});
}
RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
-MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
- media::TimeUnit aTimeThreshold)
+MediaDecoderReaderWrapper::RequestVideoData(media::TimeUnit aTimeThreshold)
{
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
MOZ_ASSERT(!mShutdown);
if (aTimeThreshold > media::TimeUnit::Zero()) {
aTimeThreshold += StartTime();
}
int64_t startTime = StartTime().ToMicroseconds();
return InvokeAsync(
mReader->OwnerThread(), mReader.get(), __func__,
- &MediaDecoderReader::RequestVideoData,
- aSkipToNextKeyframe, aTimeThreshold)
+ &MediaDecoderReader::RequestVideoData, aTimeThreshold)
->Then(mOwnerThread, __func__,
[startTime] (RefPtr<VideoData> aVideo) {
aVideo->AdjustForStartTime(startTime);
return VideoDataPromise::CreateAndResolve(aVideo.forget(), __func__);
},
[] (const MediaResult& aError) {
return VideoDataPromise::CreateAndReject(aError, __func__);
});
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/MediaDecoderReaderWrapper.h
@@ -37,17 +37,17 @@ public:
MediaDecoderReader* aReader);
media::TimeUnit StartTime() const;
RefPtr<MetadataPromise> ReadMetadata();
RefPtr<AudioDataPromise> RequestAudioData();
RefPtr<VideoDataPromise>
- RequestVideoData(bool aSkipToNextKeyframe, media::TimeUnit aTimeThreshold);
+ RequestVideoData(media::TimeUnit aTimeThreshold);
RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType);
RefPtr<SeekPromise> Seek(const SeekTarget& aTarget);
RefPtr<ShutdownPromise> Shutdown();
void ReleaseResources();
void ResetDecode(TrackSet aTracks);
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -598,33 +598,33 @@ public:
void HandleWaitingForVideo() override
{
mMaster->WaitForData(MediaData::VIDEO_DATA);
}
void HandleVideoCanceled() override
{
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
void HandleEndOfVideo() override
{
VideoQueue().Finish();
MaybeFinishDecodeFirstFrame();
}
void HandleAudioWaited(MediaData::Type aType) override
{
mMaster->RequestAudioData();
}
void HandleVideoWaited(MediaData::Type aType) override
{
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
void HandleVideoSuspendTimeout() override
{
// Do nothing for we need to decode the 1st video frame to get the
// dimensions.
}
@@ -732,18 +732,17 @@ public:
void HandleAudioCanceled() override
{
mMaster->RequestAudioData();
}
void HandleVideoCanceled() override
{
- mMaster->RequestVideoData(
- NeedToSkipToNextKeyframe(), mMaster->GetMediaTime());
+ mMaster->RequestVideoData(mMaster->GetMediaTime());
}
void HandleEndOfAudio() override;
void HandleEndOfVideo() override;
void HandleWaitingForAudio() override
{
mMaster->WaitForData(MediaData::AUDIO_DATA);
@@ -758,18 +757,17 @@ public:
void HandleAudioWaited(MediaData::Type aType) override
{
mMaster->RequestAudioData();
}
void HandleVideoWaited(MediaData::Type aType) override
{
- mMaster->RequestVideoData(
- NeedToSkipToNextKeyframe(), mMaster->GetMediaTime());
+ mMaster->RequestVideoData(mMaster->GetMediaTime());
}
void HandleAudioCaptured() override
{
MaybeStopPrerolling();
// MediaSink is changed. Schedule Step() to check if we can start playback.
mMaster->ScheduleStateMachine();
}
@@ -1327,17 +1325,17 @@ private:
{
MOZ_ASSERT(!mDoneAudioSeeking);
mMaster->RequestAudioData();
}
void RequestVideoData()
{
MOZ_ASSERT(!mDoneVideoSeeking);
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
void AdjustFastSeekIfNeeded(MediaData* aSample)
{
if (mSeekJob.mTarget->IsFast()
&& mSeekJob.mTarget->GetTime() > mCurrentTimeBeforeSeek
&& aSample->mTime < mCurrentTimeBeforeSeek) {
// We are doing a fastSeek, but we ended up *before* the previous
@@ -1681,17 +1679,17 @@ private:
}
private:
NextFrameSeekingState* mStateObj;
};
void RequestVideoData()
{
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
bool NeedMoreVideo() const
{
// Need to request video when we have none and video queue is not finished.
return VideoQueue().GetSize() == 0
&& !VideoQueue().IsFinished();
}
@@ -1840,17 +1838,17 @@ public:
mMaster->PushVideo(aVideo);
mMaster->ScheduleStateMachine();
}
void HandleAudioCanceled() override { mMaster->RequestAudioData(); }
void HandleVideoCanceled() override
{
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
void HandleWaitingForAudio() override
{
mMaster->WaitForData(MediaData::AUDIO_DATA);
}
void HandleWaitingForVideo() override
@@ -1860,17 +1858,17 @@ public:
void HandleAudioWaited(MediaData::Type aType) override
{
mMaster->RequestAudioData();
}
void HandleVideoWaited(MediaData::Type aType) override
{
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
void HandleEndOfAudio() override;
void HandleEndOfVideo() override;
void HandleVideoSuspendTimeout() override
{
// No video, so nothing to suspend.
@@ -2258,17 +2256,17 @@ DecodingFirstFrameState::Enter()
MOZ_ASSERT(!mMaster->mVideoDecodeSuspended);
// Dispatch tasks to decode first frames.
if (mMaster->HasAudio()) {
mMaster->RequestAudioData();
}
if (mMaster->HasVideo()) {
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
}
void
MediaDecoderStateMachine::
DecodingFirstFrameState::MaybeFinishDecodeFirstFrame()
{
MOZ_ASSERT(!mMaster->mSentFirstFrameLoadedEvent);
@@ -2393,18 +2391,17 @@ void
MediaDecoderStateMachine::
DecodingState::EnsureVideoDecodeTaskQueued()
{
if (!mMaster->IsVideoDecoding()
|| mMaster->IsRequestingVideoData()
|| mMaster->IsWaitingVideoData()) {
return;
}
- mMaster->RequestVideoData(
- NeedToSkipToNextKeyframe(), mMaster->GetMediaTime());
+ mMaster->RequestVideoData(mMaster->GetMediaTime());
}
bool
MediaDecoderStateMachine::
DecodingState::NeedToSkipToNextKeyframe()
{
// Since GetClock() can only be called after starting MediaSink, we return
// false quickly if it is not started because we won't fall behind playback
@@ -2558,17 +2555,17 @@ BufferingState::DispatchDecodeTasksIfNee
&& !mMaster->IsWaitingAudioData()) {
mMaster->RequestAudioData();
}
if (mMaster->IsVideoDecoding()
&& !mMaster->HaveEnoughDecodedVideo()
&& !mMaster->IsRequestingVideoData()
&& !mMaster->IsWaitingVideoData()) {
- mMaster->RequestVideoData(false, media::TimeUnit());
+ mMaster->RequestVideoData(media::TimeUnit());
}
}
void
MediaDecoderStateMachine::
BufferingState::Step()
{
TimeStamp now = TimeStamp::Now();
@@ -3300,31 +3297,30 @@ MediaDecoderStateMachine::RequestAudioDa
break;
default:
DecodeError(aError);
}
})->Track(mAudioDataRequest);
}
void
-MediaDecoderStateMachine::RequestVideoData(bool aSkipToNextKeyframe,
- const media::TimeUnit& aCurrentTime)
+MediaDecoderStateMachine::RequestVideoData(const media::TimeUnit& aCurrentTime)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(IsVideoDecoding());
MOZ_ASSERT(!IsRequestingVideoData());
MOZ_ASSERT(!IsWaitingVideoData());
LOGV("Queueing video task - queued=%" PRIuSIZE ", decoder-queued=%" PRIoSIZE
- ", skip=%i, time=%" PRId64,
+ ", stime=%" PRId64,
VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames(),
- aSkipToNextKeyframe, aCurrentTime.ToMicroseconds());
+ aCurrentTime.ToMicroseconds());
TimeStamp videoDecodeStartTime = TimeStamp::Now();
RefPtr<MediaDecoderStateMachine> self = this;
- mReader->RequestVideoData(aSkipToNextKeyframe, aCurrentTime)->Then(
+ mReader->RequestVideoData(aCurrentTime)->Then(
OwnerThread(), __func__,
[this, self, videoDecodeStartTime] (RefPtr<VideoData> aVideo) {
MOZ_ASSERT(aVideo);
mVideoDataRequest.Complete();
// Handle abnormal or negative timestamps.
mDecodedVideoEndTime = std::max(
mDecodedVideoEndTime, aVideo->GetEndTime());
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -422,18 +422,17 @@ protected:
void DecodeError(const MediaResult& aError);
void EnqueueFirstFrameLoadedEvent();
// Start a task to decode audio.
void RequestAudioData();
// Start a task to decode video.
- void RequestVideoData(bool aSkipToNextKeyframe,
- const media::TimeUnit& aCurrentTime);
+ void RequestVideoData(const media::TimeUnit& aCurrentTime);
void WaitForData(MediaData::Type aType);
bool IsRequestingAudioData() const { return mAudioDataRequest.Exists(); }
bool IsRequestingVideoData() const { return mVideoDataRequest.Exists(); }
bool IsWaitingAudioData() const { return mAudioWaitRequest.Exists(); }
bool IsWaitingVideoData() const { return mVideoWaitRequest.Exists(); }
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1552,28 +1552,26 @@ MediaFormatReader::ShouldSkip(TimeUnit a
return (nextKeyframe < aTimeThreshold
|| (mVideo.mTimeThreshold
&& mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold))
&& nextKeyframe.ToMicroseconds() >= 0
&& !nextKeyframe.IsInfinite();
}
RefPtr<MediaDecoderReader::VideoDataPromise>
-MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
- const TimeUnit& aTimeThreshold)
+MediaFormatReader::RequestVideoData(const TimeUnit& aTimeThreshold)
{
MOZ_ASSERT(OnTaskQueue());
MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(),
"No sample requests allowed while seeking");
MOZ_DIAGNOSTIC_ASSERT(!mVideo.HasPromise(), "No duplicate sample requests");
MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists()
|| mVideo.mTimeThreshold.isSome());
MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek");
- LOGV("RequestVideoData(%d, %" PRId64 ")",
- aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());
+ LOGV("RequestVideoData(%" PRId64 ")", aTimeThreshold.ToMicroseconds());
if (!HasVideo()) {
LOG("called with no video track");
return VideoDataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
}
if (IsSeeking()) {
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -34,18 +34,17 @@ public:
VideoFrameContainer* aVideoFrameContainer = nullptr);
virtual ~MediaFormatReader();
size_t SizeOfVideoQueueInFrames() override;
size_t SizeOfAudioQueueInFrames() override;
RefPtr<VideoDataPromise>
- RequestVideoData(bool aSkipToNextKeyframe,
- const media::TimeUnit& aTimeThreshold) override;
+ RequestVideoData(const media::TimeUnit& aTimeThreshold) override;
RefPtr<AudioDataPromise> RequestAudioData() override;
RefPtr<MetadataPromise> AsyncReadMetadata() override;
void ReadUpdatedMetadata(MediaInfo* aInfo) override;
RefPtr<SeekPromise> Seek(const SeekTarget& aTarget) override;