Bug 1355756. P2 - let VideoData::UpdateDuration() take TimeUnit.
MozReview-Commit-ID: BSydHhJwgup
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -218,21 +218,20 @@ VideoData::SizeOfIncludingThis(MallocSiz
static_cast<const mozilla::layers::PlanarYCbCrImage*>(mImage.get());
size += img->SizeOfIncludingThis(aMallocSizeOf);
}
return size;
}
void
-VideoData::UpdateDuration(int64_t aDuration)
+VideoData::UpdateDuration(const TimeUnit& aDuration)
{
- MOZ_ASSERT(aDuration >= 0);
-
- mDuration = TimeUnit::FromMicroseconds(aDuration);
+ MOZ_ASSERT(!aDuration.IsNegative());
+ mDuration = aDuration;
}
void
VideoData::UpdateTimestamp(int64_t aTimestamp)
{
MOZ_ASSERT(aTimestamp >= 0);
int64_t updatedDuration = GetEndTime() - aTimestamp;
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -553,17 +553,17 @@ public:
int64_t aTimecode,
IntSize aDisplay,
uint32_t aFrameID);
void SetListener(UniquePtr<Listener> aListener);
void MarkSentToCompositor();
bool IsSentToCompositor() { return mSentToCompositor; }
- void UpdateDuration(int64_t aDuration);
+ void UpdateDuration(const media::TimeUnit& aDuration);
void UpdateTimestamp(int64_t aTimestamp);
protected:
~VideoData();
bool mSentToCompositor;
UniquePtr<Listener> mListener;
};
--- a/dom/media/android/AndroidMediaReader.cpp
+++ b/dom/media/android/AndroidMediaReader.cpp
@@ -137,17 +137,17 @@ bool AndroidMediaReader::DecodeVideoFram
if (!mPlugin->ReadVideo(mPlugin, &frame, mVideoSeekTimeUs, &bufferCallback)) {
// We reached the end of the video stream. If we have a buffered
// video frame, push it the video queue using the total duration
// of the video as the end time.
if (mLastVideoFrame) {
int64_t durationUs;
mPlugin->GetDuration(mPlugin, &durationUs);
durationUs = std::max<int64_t>(durationUs - mLastVideoFrame->mTime, 0);
- mLastVideoFrame->UpdateDuration(durationUs);
+ mLastVideoFrame->UpdateDuration(TimeUnit::FromMicroseconds(durationUs));
mVideoQueue.Push(mLastVideoFrame);
mLastVideoFrame = nullptr;
}
return false;
}
mVideoSeekTimeUs = -1;
if (aKeyframeSkip) {
@@ -243,17 +243,17 @@ bool AndroidMediaReader::DecodeVideoFram
mLastVideoFrame = v;
continue;
}
// Calculate the duration as the timestamp of the current frame minus the
// 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);
+ mLastVideoFrame->UpdateDuration(TimeUnit::FromMicroseconds(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.ToMicroseconds()) {
mLastVideoFrame = nullptr;
continue;
}