1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #include "MediaInfo.h"
8 
9 namespace mozilla {
10 
TrackTypeToStr(TrackInfo::TrackType aTrack)11 const char* TrackTypeToStr(TrackInfo::TrackType aTrack) {
12   switch (aTrack) {
13     case TrackInfo::kUndefinedTrack:
14       return "Undefined";
15     case TrackInfo::kAudioTrack:
16       return "Audio";
17     case TrackInfo::kVideoTrack:
18       return "Video";
19     case TrackInfo::kTextTrack:
20       return "Text";
21     default:
22       return "Unknown";
23   }
24 }
25 
IsEqualTo(const TrackInfo & rhs) const26 bool TrackInfo::IsEqualTo(const TrackInfo& rhs) const {
27   return (
28       mId == rhs.mId && mKind == rhs.mKind && mLabel == rhs.mLabel &&
29       mLanguage == rhs.mLanguage && mEnabled == rhs.mEnabled &&
30       mTrackId == rhs.mTrackId && mMimeType == rhs.mMimeType &&
31       mDuration == rhs.mDuration && mMediaTime == rhs.mMediaTime &&
32       mCrypto.mCryptoScheme == rhs.mCrypto.mCryptoScheme &&
33       mCrypto.mIVSize == rhs.mCrypto.mIVSize &&
34       mCrypto.mKeyId == rhs.mCrypto.mKeyId &&
35       mCrypto.mCryptByteBlock == rhs.mCrypto.mCryptByteBlock &&
36       mCrypto.mSkipByteBlock == rhs.mCrypto.mSkipByteBlock &&
37       mCrypto.mConstantIV == rhs.mCrypto.mConstantIV && mTags == rhs.mTags &&
38       mIsRenderedExternally == rhs.mIsRenderedExternally && mType == rhs.mType);
39 }
40 
operator ==(const VideoInfo & rhs) const41 bool VideoInfo::operator==(const VideoInfo& rhs) const {
42   return (TrackInfo::IsEqualTo(rhs) && mDisplay == rhs.mDisplay &&
43           mStereoMode == rhs.mStereoMode && mImage == rhs.mImage &&
44           *mCodecSpecificConfig == *rhs.mCodecSpecificConfig &&
45           *mExtraData == *rhs.mExtraData && mRotation == rhs.mRotation &&
46           mColorDepth == rhs.mColorDepth && mImageRect == rhs.mImageRect &&
47           mAlphaPresent == rhs.mAlphaPresent);
48 }
49 
operator ==(const AudioInfo & rhs) const50 bool AudioInfo::operator==(const AudioInfo& rhs) const {
51   return (TrackInfo::IsEqualTo(rhs) && mRate == rhs.mRate &&
52           mChannels == rhs.mChannels && mChannelMap == rhs.mChannelMap &&
53           mBitDepth == rhs.mBitDepth && mProfile == rhs.mProfile &&
54           mExtendedProfile == rhs.mExtendedProfile &&
55           *mCodecSpecificConfig == *rhs.mCodecSpecificConfig &&
56           *mExtraData == *rhs.mExtraData);
57 }
58 
59 }  // namespace mozilla
60