Bug 1351574. P2 - let MediaDecoderReader::DecodeVideoFrame() take TimeUnit instead of int64_t.
MozReview-Commit-ID: 84z2yir8sfX
--- a/dom/media/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -159,17 +159,17 @@ MediaDecoderReader::DecodeToFirstVideoDa
MOZ_ASSERT(OnTaskQueue());
typedef VideoDataPromise PromiseType;
RefPtr<PromiseType::Private> p = new PromiseType::Private(__func__);
RefPtr<MediaDecoderReader> self = this;
InvokeUntil([self] () -> bool {
MOZ_ASSERT(self->OnTaskQueue());
NS_ENSURE_TRUE(!self->mShutdown, false);
bool skip = false;
- if (!self->DecodeVideoFrame(skip, 0)) {
+ if (!self->DecodeVideoFrame(skip, media::TimeUnit::Zero())) {
self->VideoQueue().Finish();
return !!self->VideoQueue().PeekFront();
}
return true;
}, [self] () -> bool {
MOZ_ASSERT(self->OnTaskQueue());
return self->VideoQueue().GetSize();
})->Then(OwnerThread(), __func__, [self, p] () {
@@ -288,17 +288,17 @@ private:
RefPtr<MediaDecoderReader::VideoDataPromise>
MediaDecoderReader::RequestVideoData(bool aSkipToNextKeyframe,
const media::TimeUnit& aTimeThreshold)
{
RefPtr<VideoDataPromise> p = mBaseVideoPromise.Ensure(__func__);
bool skip = aSkipToNextKeyframe;
while (VideoQueue().GetSize() == 0 &&
!VideoQueue().IsFinished()) {
- if (!DecodeVideoFrame(skip, aTimeThreshold.ToMicroseconds())) {
+ 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
// would hog the decode task queue.
RefPtr<nsIRunnable> task(
new ReRequestVideoWithSkipTask(this, aTimeThreshold));
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -361,17 +361,18 @@ private:
return false;
}
// Overrides of this function should read and decodes one video frame.
// Packets with a timestamp less than aTimeThreshold will be decoded
// (unless they're not keyframes and aKeyframeSkip is true), but will
// not be added to the queue. This function blocks until the decode
// is complete.
- virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold)
+ virtual bool DecodeVideoFrame(bool& aKeyframeSkip,
+ const media::TimeUnit& aTimeThreshold)
{
return false;
}
// GetBuffered estimates the time ranges buffered by interpolating the cached
// byte ranges with the duration of the media. Reader subclasses should
// override this method if they can quickly calculate the buffered ranges more
// accurately.
--- a/dom/media/android/AndroidMediaReader.cpp
+++ b/dom/media/android/AndroidMediaReader.cpp
@@ -111,18 +111,18 @@ nsresult AndroidMediaReader::ResetDecode
if (mLastVideoFrame) {
mLastVideoFrame = nullptr;
}
mSeekRequest.DisconnectIfExists();
mSeekPromise.RejectIfExists(NS_OK, __func__);
return MediaDecoderReader::ResetDecode(aTracks);
}
-bool AndroidMediaReader::DecodeVideoFrame(bool &aKeyframeSkip,
- int64_t aTimeThreshold)
+bool AndroidMediaReader::DecodeVideoFrame(bool& aKeyframeSkip,
+ const media::TimeUnit& aTimeThreshold)
{
// Record number of frames decoded and parsed. Automatically update the
// stats counters using the AutoNotifyDecoded stack-based class.
AbstractMediaDecoder::AutoNotifyDecoded a(mDecoder);
// Throw away the currently buffered frame if we are seeking.
if (mLastVideoFrame && mVideoSeekTimeUs != -1) {
mLastVideoFrame = nullptr;
@@ -248,17 +248,17 @@ bool AndroidMediaReader::DecodeVideoFram
// timestamp of the previous frame. We can then return the previously
// decoded frame, and it will have a valid timestamp.
int64_t duration = v->mTime - mLastVideoFrame->mTime;
mLastVideoFrame->UpdateDuration(duration);
// We have the start time of the next frame, so we can push the previous
// frame into the queue, except if the end time is below the threshold,
// in which case it wouldn't be displayed anyway.
- if (mLastVideoFrame->GetEndTime() < aTimeThreshold) {
+ if (mLastVideoFrame->GetEndTime() < aTimeThreshold.ToMicroseconds()) {
mLastVideoFrame = nullptr;
continue;
}
// Buffer the current frame we just decoded.
mVideoQueue.Push(mLastVideoFrame);
mLastVideoFrame = v;
--- a/dom/media/android/AndroidMediaReader.h
+++ b/dom/media/android/AndroidMediaReader.h
@@ -39,17 +39,18 @@ class AndroidMediaReader : public MediaD
public:
AndroidMediaReader(AbstractMediaDecoder* aDecoder,
const MediaContainerType& aContainerType);
nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
TrackInfo::kVideoTrack)) override;
bool DecodeAudioData() override;
- bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) override;
+ bool DecodeVideoFrame(bool& aKeyframeSkip,
+ const media::TimeUnit& aTimeThreshold) override;
nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
RefPtr<SeekPromise> Seek(const SeekTarget& aTarget) override;
RefPtr<ShutdownPromise> Shutdown() override;
class ImageBufferCallback : public MPAPI::BufferCallback {
typedef mozilla::layers::Image Image;
--- a/dom/media/directshow/DirectShowReader.cpp
+++ b/dom/media/directshow/DirectShowReader.cpp
@@ -307,18 +307,18 @@ DirectShowReader::DecodeAudioData()
DirectShowCopy(reinterpret_cast<uint8_t *>(data),
mBytesPerSample,
numSamples,
mNumChannels));
return true;
}
bool
-DirectShowReader::DecodeVideoFrame(bool &aKeyframeSkip,
- int64_t aTimeThreshold)
+DirectShowReader::DecodeVideoFrame(bool& aKeyframeSkip,
+ const media::TimeUnit& aTimeThreshold)
{
MOZ_ASSERT(OnTaskQueue());
return false;
}
RefPtr<MediaDecoderReader::SeekPromise>
DirectShowReader::Seek(const SeekTarget& aTarget)
{
--- a/dom/media/directshow/DirectShowReader.h
+++ b/dom/media/directshow/DirectShowReader.h
@@ -46,18 +46,18 @@ class SourceFilter;
class DirectShowReader : public MediaDecoderReader
{
public:
explicit DirectShowReader(AbstractMediaDecoder* aDecoder);
virtual ~DirectShowReader();
bool DecodeAudioData() override;
- bool DecodeVideoFrame(bool &aKeyframeSkip,
- int64_t aTimeThreshold) override;
+ bool DecodeVideoFrame(bool& aKeyframeSkip,
+ const media::TimeUnit& aTimeThreshold) override;
nsresult ReadMetadata(MediaInfo* aInfo,
MetadataTags** aTags) override;
RefPtr<SeekPromise> Seek(const SeekTarget& aTarget) override;
static const GUID CLSID_MPEG_LAYER_3_DECODER_FILTER;