Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / media / MediaInfo.cpp
blobea9eebcb5892cc77381349eb2b4bcf8b7c39b133
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/. */
7 #include "MediaInfo.h"
8 #include "MediaData.h"
10 namespace mozilla {
12 const char* TrackTypeToStr(TrackInfo::TrackType aTrack) {
13 switch (aTrack) {
14 case TrackInfo::kUndefinedTrack:
15 return "Undefined";
16 case TrackInfo::kAudioTrack:
17 return "Audio";
18 case TrackInfo::kVideoTrack:
19 return "Video";
20 case TrackInfo::kTextTrack:
21 return "Text";
22 default:
23 return "Unknown";
27 bool TrackInfo::IsEqualTo(const TrackInfo& rhs) const {
28 return (
29 mId == rhs.mId && mKind == rhs.mKind && mLabel == rhs.mLabel &&
30 mLanguage == rhs.mLanguage && mEnabled == rhs.mEnabled &&
31 mTrackId == rhs.mTrackId && mMimeType == rhs.mMimeType &&
32 mDuration == rhs.mDuration && mMediaTime == rhs.mMediaTime &&
33 mCrypto.mCryptoScheme == rhs.mCrypto.mCryptoScheme &&
34 mCrypto.mIVSize == rhs.mCrypto.mIVSize &&
35 mCrypto.mKeyId == rhs.mCrypto.mKeyId &&
36 mCrypto.mCryptByteBlock == rhs.mCrypto.mCryptByteBlock &&
37 mCrypto.mSkipByteBlock == rhs.mCrypto.mSkipByteBlock &&
38 mCrypto.mConstantIV == rhs.mCrypto.mConstantIV && mTags == rhs.mTags &&
39 mIsRenderedExternally == rhs.mIsRenderedExternally && mType == rhs.mType);
42 nsCString TrackInfo::ToString() const {
43 nsCString rv;
45 rv.AppendPrintf(
46 "TrackInfo: id:%s kind:%s label:%s language:%s enabled:%s trackid: %d "
47 "mimetype:%s duration:%s media time:%s crypto:%s rendered externaly: %s "
48 "type:%s",
49 NS_ConvertUTF16toUTF8(mId).get(), NS_ConvertUTF16toUTF8(mKind).get(),
50 NS_ConvertUTF16toUTF8(mLabel).get(),
51 NS_ConvertUTF16toUTF8(mLanguage).get(), mEnabled ? "true" : "false",
52 mTrackId, mMimeType.get(), mDuration.ToString().get(),
53 mMediaTime.ToString().get(), CryptoSchemeToString(mCrypto.mCryptoScheme),
54 mIsRenderedExternally ? "true" : "false", TrackTypeToStr(mType));
56 if (!mTags.IsEmpty()) {
57 rv.AppendPrintf("\n");
58 for (const auto& tag : mTags) {
59 rv.AppendPrintf("%s:%s", tag.mKey.get(), tag.mValue.get());
63 return rv;
66 bool VideoInfo::operator==(const VideoInfo& rhs) const {
67 return (TrackInfo::IsEqualTo(rhs) && mDisplay == rhs.mDisplay &&
68 mStereoMode == rhs.mStereoMode && mImage == rhs.mImage &&
69 *mCodecSpecificConfig == *rhs.mCodecSpecificConfig &&
70 *mExtraData == *rhs.mExtraData && mRotation == rhs.mRotation &&
71 mColorDepth == rhs.mColorDepth && mImageRect == rhs.mImageRect &&
72 mAlphaPresent == rhs.mAlphaPresent);
75 bool AudioInfo::operator==(const AudioInfo& rhs) const {
76 return (TrackInfo::IsEqualTo(rhs) && mRate == rhs.mRate &&
77 mChannels == rhs.mChannels && mChannelMap == rhs.mChannelMap &&
78 mBitDepth == rhs.mBitDepth && mProfile == rhs.mProfile &&
79 mExtendedProfile == rhs.mExtendedProfile &&
80 mCodecSpecificConfig == rhs.mCodecSpecificConfig);
83 nsCString AudioInfo::ToString() const {
84 nsCString rv;
86 rv.AppendPrintf(
87 "AudioInfo: %" PRIu32 "Hz, %" PRIu32 "ch (%s) %" PRIu32
88 "-bits profile: %" PRIu8 " extended profile: %" PRIu8 ", %s extradata",
89 mRate, mChannels,
90 AudioConfig::ChannelLayout::ChannelMapToString(mChannelMap).get(),
91 mBitDepth, mProfile, mExtendedProfile,
92 mCodecSpecificConfig.is<NoCodecSpecificData>() ? "no" : "with");
94 return rv;
97 } // namespace mozilla