Bug 1345756: [MSE] P4. Pre-roll AAC by 2112 audio frames. r=gerald a=gchang
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 09 Mar 2017 10:57:02 +0100
changeset 395375 e5d344d9779166a17334aabc5dd993e848310184
parent 395374 5949efc94129770b58066c6c319d610e1d5ede35
child 395376 8419d3c2e10097fcb623867200879754b40fd229
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, gchang
bugs1345756
milestone54.0a2
Bug 1345756: [MSE] P4. Pre-roll AAC by 2112 audio frames. r=gerald a=gchang MozReview-Commit-ID: K09DyZMzbY7
dom/media/mediasource/MediaSourceDemuxer.cpp
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -286,18 +286,25 @@ MediaSourceTrackDemuxer::MediaSourceTrac
                                                  TrackInfo::TrackType aType,
                                                  TrackBuffersManager* aManager)
   : mParent(aParent)
   , mManager(aManager)
   , mType(aType)
   , mMonitor("MediaSourceTrackDemuxer")
   , mReset(true)
   , mPreRoll(TimeUnit::FromMicroseconds(
-      OpusDataDecoder::IsOpus(mParent->GetTrackInfo(mType)->mMimeType) ? 80000
-                                                                       : 0))
+      OpusDataDecoder::IsOpus(mParent->GetTrackInfo(mType)->mMimeType)
+      ? 80000
+      : mParent->GetTrackInfo(mType)->mMimeType.EqualsLiteral("audio/mp4a-latm")
+        // AAC encoder delay is by default 2112 audio frames.
+        // See https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
+        // So we always seek 2112 frames
+        ? (2112 * 1000000ULL
+           / mParent->GetTrackInfo(mType)->GetAsAudioInfo()->mRate)
+        : 0))
 {
 }
 
 UniquePtr<TrackInfo>
 MediaSourceTrackDemuxer::GetInfo() const
 {
   return mParent->GetTrackInfo(mType)->Clone();
 }