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 340250 65ab7976703a2d769d5fd5e8862ebeb11832c197
parent 340249 7af8faeaf115123fa3774221d930fa80aed1fd49
child 340251 adadc9dbb64824d48696e956c37635dd70e2e454
push id6278
push usercbook@mozilla.com
push dateTue, 09 Aug 2016 13:34:48 +0000
treeherdermozilla-beta@65ab7976703a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, ritu
bugs1290371
milestone49.0
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
@@ -1595,25 +1595,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;
   }