Bug 1290371 - handle files with audio and video tracks but no samples at all; r=jya. a=ritu
authorKaku Kuo <tkuo@mozilla.com>
Wed, 03 Aug 2016 16:51:29 +0800
changeset 347602 10d3f6d868e5451e0b030e7734c09d3de18bbfdf
parent 347601 81217ea8f4ffcb73a7cb62fb35d89615a3f6f324
child 347603 582822e22e479fc2c13b118d417979604985d3da
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, ritu
bugs1290371
milestone50.0a2
Bug 1290371 - handle files with audio and video tracks but no samples at all; r=jya. a=ritu So, we have 4 boolean variables and here is the truth table. Case 1, 2, 3, 4, 7, 8, 10 and 12 are not possible to happen. Then, the remaining cases could be clustered into three categories: (1) Case 5, 9 and 13: no sample is demuxed at all, return 0. (2) Case 6, 11, 14 and 15: either audio or video is able to be demuxed, return the known value. (3) Case 15: both audio and video are demuxed, return the minimum of the values. For simplifying the logic, I will initialize the audioStartTime and videoStartTime to be INFINITY if we don't have the first-demuxed sample, otherwise, initialize them to be the real first-demuxed sample's time. Then, the final calculation will be: (1) Case 5, 9 and 13: the minimum of two INFINITY values is still INFINITY, return 0. (2) Case 6, 11, 14 and 15: return the minimum of one real first-demuxed-time and the INFINITY. (3) Case 15: return the minimum of two real first-demuxed-time values. Case HasAudio HasVideo HasAudioSample HasVideoSample ExpectedResult --------------------------------------------------------------------------------------------------- 1 F F F F not possible 2 F F F T not possible 3 F F T F not possible 4 F F T T not possible --------------------------------------------------------------------------------------------------- 5 F T F F return 0 6 F T F T return video sample 7 F T T F not possible 8 F T T T not possible --------------------------------------------------------------------------------------------------- 9 T F F F return 0 10 T F F T not possible 11 T F T F return audio sample 12 T F T T not possible --------------------------------------------------------------------------------------------------- 13 T T F F return 0 14 T T F T return videoSample 15 T T T F return audioSample 16 T T T T return min(auidoSample, videoSample) MozReview-Commit-ID: ANsYDth7slJ
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1647,25 +1647,23 @@ MediaFormatReader::SetSeekTarget(const S
   mFallbackSeekTime = mPendingSeekTime = Some(target.GetTime());
 }
 
 TimeUnit
 MediaFormatReader::DemuxStartTime()
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(!ForceZeroStartTime());
-  MOZ_ASSERT((!HasAudio() || mAudio.mFirstDemuxedSampleTime.isSome()) &&
-             (!HasVideo() || mVideo.mFirstDemuxedSampleTime.isSome()));
+  MOZ_ASSERT(HasAudio() || HasVideo());
 
-  return std::min(HasAudio()
-                  ? mAudio.mFirstDemuxedSampleTime.ref()
-                  : TimeUnit::FromInfinity(),
-                  HasVideo()
-                  ? mVideo.mFirstDemuxedSampleTime.ref()
-                  : TimeUnit::FromInfinity());
+  const TimeUnit startTime =
+    std::min(mAudio.mFirstDemuxedSampleTime.refOr(TimeUnit::FromInfinity()),
+             mVideo.mFirstDemuxedSampleTime.refOr(TimeUnit::FromInfinity()));
+
+  return startTime.IsInfinite() ? TimeUnit::FromMicroseconds(0) : startTime;
 }
 
 void
 MediaFormatReader::ScheduleSeek()
 {
   if (mSeekScheduled) {
     return;
   }