Bug 1355745 - Change the type of TrackInfo::mMediaTime to TimeUnit. r?jya draft
authorJW Wang <jwwang@mozilla.com>
Wed, 12 Apr 2017 16:53:09 +0800
changeset 561716 59b54419549d8d1e1fc50ae29aca80173cdee475
parent 561715 d8e14bf52d635a6a6969c8032a850965fdc66ff7
child 624055 c7a3c9952b4705affb620320d1b9a3214b4d6fcd
push id53822
push userjwwang@mozilla.com
push dateThu, 13 Apr 2017 03:38:46 +0000
reviewersjya
bugs1355745
milestone55.0a1
Bug 1355745 - Change the type of TrackInfo::mMediaTime to TimeUnit. r?jya MozReview-Commit-ID: 3vuPhLQBnFb
dom/media/MediaInfo.h
dom/media/fmp4/MP4Decoder.cpp
media/libstagefright/binding/DecoderData.cpp
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -57,17 +57,16 @@ public:
             bool aEnabled,
             TrackID aTrackId)
     : mId(aId)
     , mKind(aKind)
     , mLabel(aLabel)
     , mLanguage(aLanguage)
     , mEnabled(aEnabled)
     , mTrackId(aTrackId)
-    , mMediaTime(0)
     , mIsRenderedExternally(false)
     , mType(aType)
   {
     MOZ_COUNT_CTOR(TrackInfo);
   }
 
   // Only used for backward compatibility. Do not use in new code.
   void Init(const nsAString& aId,
@@ -89,17 +88,17 @@ public:
   nsString mLabel;
   nsString mLanguage;
   bool mEnabled;
 
   TrackID mTrackId;
 
   nsCString mMimeType;
   media::TimeUnit mDuration;
-  int64_t mMediaTime;
+  media::TimeUnit mMediaTime;
   CryptoTrack mCrypto;
 
   nsTArray<MetadataTag> mTags;
 
   // True if the track is gonna be (decrypted)/decoded and
   // rendered directly by non-gecko components.
   bool mIsRenderedExternally;
 
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -216,17 +216,16 @@ static const uint8_t sTestH264ExtraData[
 static already_AddRefed<MediaDataDecoder>
 CreateTestH264Decoder(layers::KnowsCompositor* aKnowsCompositor,
                       VideoInfo& aConfig,
                       TaskQueue* aTaskQueue)
 {
   aConfig.mMimeType = "video/avc";
   aConfig.mId = 1;
   aConfig.mDuration = media::TimeUnit::FromMicroseconds(40000);
-  aConfig.mMediaTime = 0;
   aConfig.mImage = aConfig.mDisplay = nsIntSize(640, 360);
   aConfig.mExtraData = new MediaByteBuffer();
   aConfig.mExtraData->AppendElements(sTestH264ExtraData,
                                      MOZ_ARRAY_LENGTH(sTestH264ExtraData));
 
   RefPtr<PDMFactory> platform = new PDMFactory();
   RefPtr<MediaDataDecoder> decoder(platform->CreateDecoder({ aConfig, aTaskQueue, aKnowsCompositor }));
 
--- a/media/libstagefright/binding/DecoderData.cpp
+++ b/media/libstagefright/binding/DecoderData.cpp
@@ -112,17 +112,18 @@ static void
 UpdateTrackInfo(mozilla::TrackInfo& aConfig,
                 const MetaData* aMetaData,
                 const char* aMimeType)
 {
   mozilla::CryptoTrack& crypto = aConfig.mCrypto;
   aConfig.mMimeType = aMimeType;
   aConfig.mDuration = TimeUnit::FromMicroseconds(
     FindInt64(aMetaData, kKeyDuration));
-  aConfig.mMediaTime = FindInt64(aMetaData, kKeyMediaTime);
+  aConfig.mMediaTime = TimeUnit::FromMicroseconds(
+    FindInt64(aMetaData, kKeyMediaTime));
   aConfig.mTrackId = FindInt32(aMetaData, kKeyTrackID);
   aConfig.mCrypto.mValid = aMetaData->findInt32(kKeyCryptoMode, &crypto.mMode) &&
     aMetaData->findInt32(kKeyCryptoDefaultIVSize, &crypto.mIVSize) &&
     FindData(aMetaData, kKeyCryptoKey, &crypto.mKeyId);
 }
 
 void
 MP4AudioInfo::Update(const MetaData* aMetaData,
@@ -226,17 +227,17 @@ MP4AudioInfo::Update(const mp4parse_trac
     mMimeType = MEDIA_MIMETYPE_AUDIO_MPEG;
   }
 
   mRate = audio->sample_rate;
   mChannels = audio->channels;
   mBitDepth = audio->bit_depth;
   mExtendedProfile = audio->profile;
   mDuration = TimeUnit::FromMicroseconds(track->duration);
-  mMediaTime = track->media_time;
+  mMediaTime = TimeUnit::FromMicroseconds(track->media_time);
   mTrackId = track->track_id;
 
   // In stagefright, mProfile is kKeyAACProfile, mExtendedProfile is kKeyAACAOT.
   // Both are from audioObjectType in AudioSpecificConfig.
   if (audio->profile <= 4) {
     mProfile = audio->profile;
   }
 
@@ -258,17 +259,17 @@ MP4VideoInfo::Update(const mp4parse_trac
   UpdateTrackProtectedInfo(*this, video->protected_data);
   if (track->codec == mp4parse_codec_AVC) {
     mMimeType = MEDIA_MIMETYPE_VIDEO_AVC;
   } else if (track->codec == mp4parse_codec_VP9) {
     mMimeType = NS_LITERAL_CSTRING("video/vp9");
   }
   mTrackId = track->track_id;
   mDuration = TimeUnit::FromMicroseconds(track->duration);
-  mMediaTime = track->media_time;
+  mMediaTime = TimeUnit::FromMicroseconds(track->media_time);
   mDisplay.width = video->display_width;
   mDisplay.height = video->display_height;
   mImage.width = video->image_width;
   mImage.height = video->image_height;
   mRotation = ToSupportedRotation(video->rotation);
   if (video->extra_data.data) {
     mExtraData->AppendElements(video->extra_data.data, video->extra_data.length);
   }