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/. */
13 const char* TrackTypeToStr(TrackInfo::TrackType aTrack
) {
15 case TrackInfo::kUndefinedTrack
:
17 case TrackInfo::kAudioTrack
:
19 case TrackInfo::kVideoTrack
:
21 case TrackInfo::kTextTrack
:
28 bool TrackInfo::IsEqualTo(const TrackInfo
& rhs
) const {
30 mId
== rhs
.mId
&& mKind
== rhs
.mKind
&& mLabel
== rhs
.mLabel
&&
31 mLanguage
== rhs
.mLanguage
&& mEnabled
== rhs
.mEnabled
&&
32 mTrackId
== rhs
.mTrackId
&& mMimeType
== rhs
.mMimeType
&&
33 mDuration
== rhs
.mDuration
&& mMediaTime
== rhs
.mMediaTime
&&
34 mCrypto
.mCryptoScheme
== rhs
.mCrypto
.mCryptoScheme
&&
35 mCrypto
.mIVSize
== rhs
.mCrypto
.mIVSize
&&
36 mCrypto
.mKeyId
== rhs
.mCrypto
.mKeyId
&&
37 mCrypto
.mCryptByteBlock
== rhs
.mCrypto
.mCryptByteBlock
&&
38 mCrypto
.mSkipByteBlock
== rhs
.mCrypto
.mSkipByteBlock
&&
39 mCrypto
.mConstantIV
== rhs
.mCrypto
.mConstantIV
&& mTags
== rhs
.mTags
&&
40 mIsRenderedExternally
== rhs
.mIsRenderedExternally
&& mType
== rhs
.mType
);
43 nsCString
TrackInfo::ToString() const {
47 "TrackInfo: id:%s kind:%s label:%s language:%s enabled:%s trackid: %d "
48 "mimetype:%s duration:%s media time:%s crypto:%s rendered externaly: %s "
50 NS_ConvertUTF16toUTF8(mId
).get(), NS_ConvertUTF16toUTF8(mKind
).get(),
51 NS_ConvertUTF16toUTF8(mLabel
).get(),
52 NS_ConvertUTF16toUTF8(mLanguage
).get(), mEnabled
? "true" : "false",
53 mTrackId
, mMimeType
.get(), mDuration
.ToString().get(),
54 mMediaTime
.ToString().get(), EnumValueToString(mCrypto
.mCryptoScheme
),
55 mIsRenderedExternally
? "true" : "false", TrackTypeToStr(mType
));
57 if (!mTags
.IsEmpty()) {
58 rv
.AppendPrintf("\n");
59 for (const auto& tag
: mTags
) {
60 rv
.AppendPrintf("%s:%s", tag
.mKey
.get(), tag
.mValue
.get());
67 bool VideoInfo::operator==(const VideoInfo
& rhs
) const {
68 return (TrackInfo::IsEqualTo(rhs
) && mDisplay
== rhs
.mDisplay
&&
69 mStereoMode
== rhs
.mStereoMode
&& mImage
== rhs
.mImage
&&
70 *mCodecSpecificConfig
== *rhs
.mCodecSpecificConfig
&&
71 *mExtraData
== *rhs
.mExtraData
&& mRotation
== rhs
.mRotation
&&
72 mColorDepth
== rhs
.mColorDepth
&& mImageRect
== rhs
.mImageRect
&&
73 mAlphaPresent
== rhs
.mAlphaPresent
);
76 bool AudioInfo::operator==(const AudioInfo
& rhs
) const {
77 return (TrackInfo::IsEqualTo(rhs
) && mRate
== rhs
.mRate
&&
78 mChannels
== rhs
.mChannels
&& mChannelMap
== rhs
.mChannelMap
&&
79 mBitDepth
== rhs
.mBitDepth
&& mProfile
== rhs
.mProfile
&&
80 mExtendedProfile
== rhs
.mExtendedProfile
&&
81 mCodecSpecificConfig
== rhs
.mCodecSpecificConfig
);
84 nsCString
AudioInfo::ToString() const {
88 "AudioInfo: %s, %" PRIu32
"Hz, %" PRIu32
"ch (%s) %" PRIu32
89 "-bits, profile: %" PRIu8
", extended profile: %" PRIu8
", %s extradata",
90 mMimeType
.get(), mRate
, mChannels
,
91 AudioConfig::ChannelLayout::ChannelMapToString(mChannelMap
).get(),
92 mBitDepth
, mProfile
, mExtendedProfile
,
93 mCodecSpecificConfig
.is
<NoCodecSpecificData
>() ? "no" : "with");
98 } // namespace mozilla