зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351574. P1 - let MediaDecoderReader::RequestVideoData() take TimeUnit instead of int64_t. r=jya
MozReview-Commit-ID: DOsYkcJ77Em --HG-- extra : rebase_source : 3a62ef115f29121ff8b3f10651e4085ee9b0a5f9 extra : intermediate-source : cad177b6c8fbdc3dee80cc8fdb553b2d9d60bd04 extra : source : d26b8549793add957cb4620418fa861a3b8c7aec
This commit is contained in:
Родитель
acf7c794ef
Коммит
8944536d62
|
@ -238,7 +238,7 @@ class ReRequestVideoWithSkipTask : public Runnable
|
|||
{
|
||||
public:
|
||||
ReRequestVideoWithSkipTask(MediaDecoderReader* aReader,
|
||||
int64_t aTimeThreshold)
|
||||
const media::TimeUnit& aTimeThreshold)
|
||||
: mReader(aReader)
|
||||
, mTimeThreshold(aTimeThreshold)
|
||||
{
|
||||
|
@ -258,7 +258,7 @@ public:
|
|||
|
||||
private:
|
||||
RefPtr<MediaDecoderReader> mReader;
|
||||
const int64_t mTimeThreshold;
|
||||
const media::TimeUnit mTimeThreshold;
|
||||
};
|
||||
|
||||
class ReRequestAudioTask : public Runnable
|
||||
|
@ -287,20 +287,21 @@ private:
|
|||
|
||||
RefPtr<MediaDecoderReader::VideoDataPromise>
|
||||
MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
|
||||
int64_t aTimeThreshold)
|
||||
const media::TimeUnit& aTimeThreshold)
|
||||
{
|
||||
RefPtr<VideoDataPromise> p = mBaseVideoPromise.Ensure(__func__);
|
||||
bool skip = aSkipToNextKeyframe;
|
||||
while (VideoQueue().GetSize() == 0 &&
|
||||
!VideoQueue().IsFinished()) {
|
||||
if (!DecodeVideoFrame(skip, aTimeThreshold)) {
|
||||
if (!DecodeVideoFrame(skip, aTimeThreshold.ToMicroseconds())) {
|
||||
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
|
||||
// would hog the decode task queue.
|
||||
RefPtr<nsIRunnable> task(new ReRequestVideoWithSkipTask(this, aTimeThreshold));
|
||||
RefPtr<nsIRunnable> task(
|
||||
new ReRequestVideoWithSkipTask(this, aTimeThreshold));
|
||||
mTaskQueue->Dispatch(task.forget());
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -149,9 +149,10 @@ public:
|
|||
// 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 microseconds.
|
||||
// the next keyframe at or after aTimeThreshold.
|
||||
virtual RefPtr<VideoDataPromise>
|
||||
RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold);
|
||||
RequestVideoData(bool aSkipToNextKeyframe,
|
||||
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
|
||||
|
|
|
@ -65,19 +65,20 @@ MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
|
||||
MOZ_ASSERT(!mShutdown);
|
||||
|
||||
if (aTimeThreshold.ToMicroseconds() > 0) {
|
||||
if (aTimeThreshold > media::TimeUnit::Zero()) {
|
||||
aTimeThreshold += StartTime();
|
||||
}
|
||||
|
||||
int64_t startTime = StartTime().ToMicroseconds();
|
||||
return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
|
||||
&MediaDecoderReader::RequestVideoData,
|
||||
aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds())
|
||||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (VideoData* aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
return InvokeAsync<bool, media::TimeUnit&&>(
|
||||
mReader->OwnerThread(), mReader.get(), __func__,
|
||||
&MediaDecoderReader::RequestVideoData,
|
||||
aSkipToNextKeyframe, aTimeThreshold)
|
||||
->Then(mOwnerThread, __func__,
|
||||
[startTime] (VideoData* aVideo) {
|
||||
aVideo->AdjustForStartTime(startTime);
|
||||
},
|
||||
[] (const MediaResult& aError) {});
|
||||
}
|
||||
|
||||
RefPtr<MediaDecoderReader::SeekPromise>
|
||||
|
|
|
@ -1536,7 +1536,7 @@ MediaFormatReader::ShouldSkip(bool aSkipToNextKeyframe,
|
|||
|
||||
RefPtr<MediaDecoderReader::VideoDataPromise>
|
||||
MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
||||
int64_t aTimeThreshold)
|
||||
const media::TimeUnit& aTimeThreshold)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
MOZ_DIAGNOSTIC_ASSERT(mSeekPromise.IsEmpty(),
|
||||
|
@ -1545,7 +1545,8 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
MOZ_DIAGNOSTIC_ASSERT(!mVideo.mSeekRequest.Exists()
|
||||
|| mVideo.mTimeThreshold.isSome());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsSeeking(), "called mid-seek");
|
||||
LOGV("RequestVideoData(%d, %" PRId64 ")", aSkipToNextKeyframe, aTimeThreshold);
|
||||
LOGV("RequestVideoData(%d, %" PRId64 ")",
|
||||
aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());
|
||||
|
||||
if (!HasVideo()) {
|
||||
LOG("called with no video track");
|
||||
|
@ -1565,14 +1566,12 @@ MediaFormatReader::RequestVideoData(bool aSkipToNextKeyframe,
|
|||
__func__);
|
||||
}
|
||||
|
||||
media::TimeUnit timeThreshold{ media::TimeUnit::FromMicroseconds(
|
||||
aTimeThreshold) };
|
||||
// Ensure we have no pending seek going as ShouldSkip could return out of date
|
||||
// information.
|
||||
if (!mVideo.HasInternalSeekPending()
|
||||
&& ShouldSkip(aSkipToNextKeyframe, timeThreshold)) {
|
||||
&& ShouldSkip(aSkipToNextKeyframe, aTimeThreshold)) {
|
||||
RefPtr<VideoDataPromise> p = mVideo.EnsurePromise(__func__);
|
||||
SkipVideoDemuxToNextKeyFrame(timeThreshold);
|
||||
SkipVideoDemuxToNextKeyFrame(aTimeThreshold);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ public:
|
|||
size_t SizeOfAudioQueueInFrames() override;
|
||||
|
||||
RefPtr<VideoDataPromise>
|
||||
RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override;
|
||||
RequestVideoData(bool aSkipToNextKeyframe,
|
||||
const media::TimeUnit& aTimeThreshold) override;
|
||||
|
||||
RefPtr<AudioDataPromise> RequestAudioData() override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче