Bug 1356502. P2 - let VideoData::UpdateTimestamp() take a TimeUnit instead of ambiguous int64_t. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 14 Apr 2017 14:17:04 +0800
changeset 563926 fae57ed7885f9fe474542dca6b6f4ab20885c08b
parent 563925 2f18e3f376fc4f33d93d0d5d82292b8bb7d06b60
child 563970 96a32652413aa1c82f909ad722bdcc9ced9b4307
push id54473
push userjwwang@mozilla.com
push dateTue, 18 Apr 2017 04:37:54 +0000
bugs1356502
milestone55.0a1
Bug 1356502. P2 - let VideoData::UpdateTimestamp() take a TimeUnit instead of ambiguous int64_t. MozReview-Commit-ID: G17uLSrjBrR
dom/media/MediaData.cpp
dom/media/MediaData.h
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -225,25 +225,24 @@ VideoData::SizeOfIncludingThis(MallocSiz
 void
 VideoData::UpdateDuration(const TimeUnit& aDuration)
 {
   MOZ_ASSERT(!aDuration.IsNegative());
   mDuration = aDuration;
 }
 
 void
-VideoData::UpdateTimestamp(int64_t aTimestamp)
+VideoData::UpdateTimestamp(const TimeUnit& aTimestamp)
 {
-  MOZ_ASSERT(aTimestamp >= 0);
+  MOZ_ASSERT(!aTimestamp.IsNegative());
 
-  auto updatedDuration =
-    GetEndTime() - TimeUnit::FromMicroseconds(aTimestamp);
+  auto updatedDuration = GetEndTime() - aTimestamp;
   MOZ_ASSERT(!updatedDuration.IsNegative());
 
-  mTime = aTimestamp;
+  mTime = aTimestamp.ToMicroseconds();
   mDuration = updatedDuration;
 }
 
 /* static */
 bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage,
                                     const VideoInfo& aInfo,
                                     const YCbCrBuffer &aBuffer,
                                     const IntRect& aPicture,
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -557,17 +557,17 @@ public:
             IntSize aDisplay,
             uint32_t aFrameID);
 
   void SetListener(UniquePtr<Listener> aListener);
   void MarkSentToCompositor();
   bool IsSentToCompositor() { return mSentToCompositor; }
 
   void UpdateDuration(const media::TimeUnit& aDuration);
-  void UpdateTimestamp(int64_t aTimestamp);
+  void UpdateTimestamp(const media::TimeUnit& aTimestamp);
 
 protected:
   ~VideoData();
 
   bool mSentToCompositor;
   UniquePtr<Listener> mListener;
 };
 
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1415,17 +1415,17 @@ private:
            aVideo->mTime, aVideo->GetEndTime().ToMicroseconds(),
            target.ToMicroseconds());
       mFirstVideoFrameAfterSeek = aVideo;
     } else {
       if (target.ToMicroseconds() >= aVideo->mTime &&
           aVideo->GetEndTime() >= target) {
         // The seek target lies inside this frame's time slice. Adjust the
         // frame's start time to match the seek target.
-        aVideo->UpdateTimestamp(target.ToMicroseconds());
+        aVideo->UpdateTimestamp(target);
       }
       mFirstVideoFrameAfterSeek = nullptr;
 
       SLOG("DropVideoUpToSeekTarget() found video frame [%" PRId64 ", %" PRId64 "] "
            "containing target=%" PRId64,
            aVideo->mTime, aVideo->GetEndTime().ToMicroseconds(),
            target.ToMicroseconds());