Bug 1454998 - Move TrackInfo::mTrackId away from TrackID as they're independent. r=karlt
☠☠ backed out by 5f5e153eb14b ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Wed, 02 Oct 2019 08:12:09 +0000
changeset 495872 6105a4176729d7f05462aa6a32eaf0c1617752ce
parent 495871 b2feeb41df2be2c2b5b923af53aa3ccb5fdc2a8a
child 495873 3ce4dc7e9ae24adc463c4106cc5d3ab6c13dedb6
push id36639
push userrgurzau@mozilla.com
push dateWed, 02 Oct 2019 16:35:54 +0000
treeherdermozilla-central@314a0fee08fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1454998
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1454998 - Move TrackInfo::mTrackId away from TrackID as they're independent. r=karlt TrackID has been used to denote tracks that are part of MediaStreams in the MediaStreamGraph. The TrackInfo::mTrackId IDs are no longer used in the MediaStream APIs and as such it's not necessary that they have the type TrackID. This patch changes TrackInfo::mTrackId to be of type uint32_t instead, as that is the type of Mp4parseTrackInfo::track_id, which is assigned to TrackInfo::mTrackId as the sole remaining non-static user. Other users set a static trackId of `1` or `2`, and as such remain supported by this change. Differential Revision: https://phabricator.services.mozilla.com/D46763
dom/media/MediaDecoderOwner.h
dom/media/MediaInfo.h
dom/media/mp4/MP4Metadata.cpp
dom/media/mp4/MP4Metadata.h
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef MediaDecoderOwner_h_
 #define MediaDecoderOwner_h_
 
 #include "mozilla/UniquePtr.h"
 #include "MediaInfo.h"
 #include "MediaSegment.h"
 #include "nsSize.h"
-#include "TrackID.h"
 
 namespace mozilla {
 
 class AbstractThread;
 class GMPCrashHelper;
 class VideoFrameContainer;
 class MediaInfo;
 class MediaResult;
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -9,17 +9,16 @@
 #  include "mozilla/UniquePtr.h"
 #  include "mozilla/RefPtr.h"
 #  include "nsDataHashtable.h"
 #  include "nsString.h"
 #  include "nsTArray.h"
 #  include "AudioConfig.h"
 #  include "ImageTypes.h"
 #  include "MediaData.h"
-#  include "TrackID.h"  // for TrackID
 #  include "TimeUnits.h"
 #  include "mozilla/gfx/Point.h"  // for gfx::IntSize
 #  include "mozilla/gfx/Rect.h"   // for gfx::IntRect
 #  include "mozilla/gfx/Types.h"  // for gfx::ColorDepth
 
 namespace mozilla {
 
 class AudioInfo;
@@ -39,17 +38,17 @@ class MetadataTag {
 
 typedef nsDataHashtable<nsCStringHashKey, nsCString> MetadataTags;
 
 class TrackInfo {
  public:
   enum TrackType { kUndefinedTrack, kAudioTrack, kVideoTrack, kTextTrack };
   TrackInfo(TrackType aType, const nsAString& aId, const nsAString& aKind,
             const nsAString& aLabel, const nsAString& aLanguage, bool aEnabled,
-            TrackID aTrackId)
+            uint32_t aTrackId)
       : mId(aId),
         mKind(aKind),
         mLabel(aLabel),
         mLanguage(aLanguage),
         mEnabled(aEnabled),
         mTrackId(aTrackId),
         mIsRenderedExternally(false),
         mType(aType) {
@@ -69,17 +68,17 @@ class TrackInfo {
 
   // Fields common with MediaTrack object.
   nsString mId;
   nsString mKind;
   nsString mLabel;
   nsString mLanguage;
   bool mEnabled;
 
-  TrackID mTrackId;
+  uint32_t mTrackId;
 
   nsCString mMimeType;
   media::TimeUnit mDuration;
   media::TimeUnit mMediaTime;
   CryptoTrack mCrypto;
 
   nsTArray<MetadataTag> mTags;
 
@@ -395,26 +394,16 @@ class MediaInfo {
 
   bool IsEncrypted() const {
     return (HasAudio() && mAudio.mCrypto.IsEncrypted()) ||
            (HasVideo() && mVideo.mCrypto.IsEncrypted());
   }
 
   bool HasValidMedia() const { return HasVideo() || HasAudio(); }
 
-  void AssertValid() const {
-    NS_ASSERTION(!HasAudio() || mAudio.mTrackId != TRACK_INVALID,
-                 "Audio track ID must be valid");
-    NS_ASSERTION(!HasVideo() || mVideo.mTrackId != TRACK_INVALID,
-                 "Audio track ID must be valid");
-    NS_ASSERTION(
-        !HasAudio() || !HasVideo() || mAudio.mTrackId != mVideo.mTrackId,
-        "Duplicate track IDs");
-  }
-
   // TODO: Store VideoInfo and AudioIndo in arrays to support multi-tracks.
   VideoInfo mVideo;
   AudioInfo mAudio;
 
   // If the metadata includes a duration, we store it here.
   media::NullableTimeUnit mMetadataDuration;
 
   // The Ogg reader tries to kinda-sorta compute the duration by seeking to the
--- a/dom/media/mp4/MP4Metadata.cpp
+++ b/dom/media/mp4/MP4Metadata.cpp
@@ -421,38 +421,37 @@ MP4Metadata::ResultAndTrackInfo MP4Metad
 }
 
 bool MP4Metadata::CanSeek() const { return true; }
 
 MP4Metadata::ResultAndCryptoFile MP4Metadata::Crypto() const {
   return {NS_OK, &mCrypto};
 }
 
-MP4Metadata::ResultAndIndice MP4Metadata::GetTrackIndice(
-    mozilla::TrackID aTrackID) {
+MP4Metadata::ResultAndIndice MP4Metadata::GetTrackIndice(uint32_t aTrackId) {
   Mp4parseByteData indiceRawData = {};
 
   uint8_t fragmented = false;
-  auto rv = mp4parse_is_fragmented(mParser.get(), aTrackID, &fragmented);
+  auto rv = mp4parse_is_fragmented(mParser.get(), aTrackId, &fragmented);
   if (rv != MP4PARSE_STATUS_OK) {
     return {MediaResult(NS_ERROR_DOM_MEDIA_METADATA_ERR,
-                        RESULT_DETAIL("Cannot parse whether track id %d is "
+                        RESULT_DETAIL("Cannot parse whether track id %u is "
                                       "fragmented, mp4parse_error=%d",
-                                      int(aTrackID), int(rv))),
+                                      aTrackId, int(rv))),
             nullptr};
   }
 
   if (!fragmented) {
-    rv = mp4parse_get_indice_table(mParser.get(), aTrackID, &indiceRawData);
+    rv = mp4parse_get_indice_table(mParser.get(), aTrackId, &indiceRawData);
     if (rv != MP4PARSE_STATUS_OK) {
       return {
           MediaResult(NS_ERROR_DOM_MEDIA_METADATA_ERR,
-                      RESULT_DETAIL("Cannot parse index table in track id %d, "
+                      RESULT_DETAIL("Cannot parse index table in track id %u, "
                                     "mp4parse_error=%d",
-                                    int(aTrackID), int(rv))),
+                                    aTrackId, int(rv))),
           nullptr};
     }
   }
 
   UniquePtr<IndiceWrapper> indice;
   indice = mozilla::MakeUnique<IndiceWrapper>(indiceRawData);
 
   return {NS_OK, std::move(indice)};
--- a/dom/media/mp4/MP4Metadata.h
+++ b/dom/media/mp4/MP4Metadata.h
@@ -90,17 +90,17 @@ class MP4Metadata : public DecoderDoctor
                                   size_t aTrackNumber) const;
 
   bool CanSeek() const;
 
   using ResultAndCryptoFile = ResultAndType<const CryptoFile*>;
   ResultAndCryptoFile Crypto() const;
 
   using ResultAndIndice = ResultAndType<mozilla::UniquePtr<IndiceWrapper>>;
-  ResultAndIndice GetTrackIndice(mozilla::TrackID aTrackID);
+  ResultAndIndice GetTrackIndice(uint32_t aTrackId);
 
   nsresult Parse();
 
  private:
   void UpdateCrypto();
   Maybe<uint32_t> TrackTypeToGlobalTrackIndex(
       mozilla::TrackInfo::TrackType aType, size_t aTrackNumber) const;