Bug 1500596 - pt2 - Add operator== for AudioInfo and VideoInfo. r=jya
authorMichael Froman <mfroman@mozilla.com>
Thu, 14 Feb 2019 19:08:19 +0000
changeset 459567 c1648a2a4d081c351cbf05af0876ffdb22dc6acf
parent 459566 cce258ac041bd88e0414a836de77eb86abe9753a
child 459568 3699bea870c48d4d18bddb5ff40f2b192f83c479
push id35563
push userccoroiu@mozilla.com
push dateSat, 16 Feb 2019 09:36:04 +0000
treeherdermozilla-central@1cfd69d05aa1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1500596
milestone67.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 1500596 - pt2 - Add operator== for AudioInfo and VideoInfo. r=jya These are needed for upcoming addition to an IPDL union. Depends on D18639 Differential Revision: https://phabricator.services.mozilla.com/D18640
dom/media/MediaInfo.cpp
dom/media/MediaInfo.h
--- a/dom/media/MediaInfo.cpp
+++ b/dom/media/MediaInfo.cpp
@@ -18,9 +18,55 @@ const char* TrackTypeToStr(TrackInfo::Tr
       return "Video";
     case TrackInfo::kTextTrack:
       return "Text";
     default:
       return "Unknown";
   }
 }
 
+bool TrackInfo::IsEqualTo(const TrackInfo& rhs) const {
+  return (mId == rhs.mId &&
+          mKind == rhs.mKind &&
+          mLabel == rhs.mLabel &&
+          mLanguage == rhs.mLanguage &&
+          mEnabled == rhs.mEnabled &&
+          mTrackId == rhs.mTrackId &&
+          mMimeType == rhs.mMimeType &&
+          mDuration == rhs.mDuration &&
+          mMediaTime == rhs.mMediaTime &&
+          mCrypto.mCryptoScheme == rhs.mCrypto.mCryptoScheme &&
+          mCrypto.mIVSize == rhs.mCrypto.mIVSize &&
+          mCrypto.mKeyId == rhs.mCrypto.mKeyId &&
+          mCrypto.mCryptByteBlock == rhs.mCrypto.mCryptByteBlock &&
+          mCrypto.mSkipByteBlock == rhs.mCrypto.mSkipByteBlock &&
+          mCrypto.mConstantIV == rhs.mCrypto.mConstantIV &&
+          mTags == rhs.mTags &&
+          mIsRenderedExternally == rhs.mIsRenderedExternally &&
+          mType == rhs.mType);
+}
+
+bool VideoInfo::operator==(const VideoInfo& rhs) const {
+  return (TrackInfo::IsEqualTo(rhs) &&
+          mDisplay == rhs.mDisplay &&
+          mStereoMode == rhs.mStereoMode &&
+          mImage == rhs.mImage &&
+          *mCodecSpecificConfig == *rhs.mCodecSpecificConfig &&
+          *mExtraData == *rhs.mExtraData &&
+          mRotation == rhs.mRotation &&
+          mColorDepth == rhs.mColorDepth &&
+          mImageRect == rhs.mImageRect &&
+          mAlphaPresent == rhs.mAlphaPresent);
+}
+
+bool AudioInfo::operator==(const AudioInfo& rhs) const {
+  return (TrackInfo::IsEqualTo(rhs) &&
+          mRate == rhs.mRate &&
+          mChannels == rhs.mChannels &&
+          mChannelMap == rhs.mChannelMap &&
+          mBitDepth == rhs.mBitDepth &&
+          mProfile == rhs.mProfile &&
+          mExtendedProfile == rhs.mExtendedProfile &&
+          *mCodecSpecificConfig == *rhs.mCodecSpecificConfig &&
+          *mExtraData == *rhs.mExtraData);
+}
+
 }  // namespace mozilla
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -27,16 +27,19 @@ class VideoInfo;
 class TextInfo;
 
 class MetadataTag {
  public:
   MetadataTag(const nsACString& aKey, const nsACString& aValue)
       : mKey(aKey), mValue(aValue) {}
   nsCString mKey;
   nsCString mValue;
+  bool operator==(const MetadataTag& rhs) const {
+    return mKey == rhs.mKey && mValue == rhs.mValue;
+  }
 };
 
 typedef nsDataHashtable<nsCStringHashKey, nsCString> MetadataTags;
 
 class TrackInfo {
  public:
   enum TrackType { kUndefinedTrack, kAudioTrack, kVideoTrack, kTextTrack };
   TrackInfo(TrackType aType, const nsAString& aId, const nsAString& aKind,
@@ -114,16 +117,17 @@ class TrackInfo {
     mDuration = aOther.mDuration;
     mMediaTime = aOther.mMediaTime;
     mCrypto = aOther.mCrypto;
     mIsRenderedExternally = aOther.mIsRenderedExternally;
     mType = aOther.mType;
     mTags = aOther.mTags;
     MOZ_COUNT_CTOR(TrackInfo);
   }
+  bool IsEqualTo(const TrackInfo& rhs) const;
 
  private:
   TrackType mType;
 };
 
 // String version of track type.
 const char* TrackTypeToStr(TrackInfo::TrackType aTrack);
 
@@ -160,16 +164,18 @@ class VideoInfo : public TrackInfo {
         mImage(aOther.mImage),
         mCodecSpecificConfig(aOther.mCodecSpecificConfig),
         mExtraData(aOther.mExtraData),
         mRotation(aOther.mRotation),
         mColorDepth(aOther.mColorDepth),
         mImageRect(aOther.mImageRect),
         mAlphaPresent(aOther.mAlphaPresent) {}
 
+  bool operator==(const VideoInfo& rhs) const;
+
   bool IsValid() const override {
     return mDisplay.width > 0 && mDisplay.height > 0;
   }
 
   VideoInfo* GetAsVideoInfo() override { return this; }
 
   const VideoInfo* GetAsVideoInfo() const override { return this; }
 
@@ -281,16 +287,18 @@ class AudioInfo : public TrackInfo {
         mChannels(aOther.mChannels),
         mChannelMap(aOther.mChannelMap),
         mBitDepth(aOther.mBitDepth),
         mProfile(aOther.mProfile),
         mExtendedProfile(aOther.mExtendedProfile),
         mCodecSpecificConfig(aOther.mCodecSpecificConfig),
         mExtraData(aOther.mExtraData) {}
 
+  bool operator==(const AudioInfo& rhs) const;
+
   static const uint32_t MAX_RATE = 640000;
 
   bool IsValid() const override {
     return mChannels > 0 && mRate > 0 && mRate <= MAX_RATE;
   }
 
   AudioInfo* GetAsAudioInfo() override { return this; }