зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1863226 - Allow logging TrackInfo, AudioInfo. r=azebrowski
Differential Revision: https://phabricator.services.mozilla.com/D192847
This commit is contained in:
Родитель
ae71eea535
Коммит
47d6b83ac3
|
@ -5,6 +5,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AudioConfig.h"
|
||||
#include "nsString.h"
|
||||
#include <array>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -224,6 +226,46 @@ ChannelLayout AudioConfig::ChannelLayout::SMPTEDefault(ChannelMap aMap) {
|
|||
return ChannelLayout(channels, layout.Elements());
|
||||
}
|
||||
|
||||
nsCString AudioConfig::ChannelLayout::ChannelMapToString(
|
||||
const ChannelMap aChannelMap) {
|
||||
nsCString rv;
|
||||
|
||||
constexpr const std::array CHANNEL_NAME = {"Front left",
|
||||
"Front right",
|
||||
"Front center",
|
||||
"Low frequency",
|
||||
"Back left",
|
||||
"Back right",
|
||||
"Front left of center",
|
||||
"Front right of center",
|
||||
"Back center",
|
||||
"Side left",
|
||||
"Side right",
|
||||
"Top center",
|
||||
"Top front left",
|
||||
"Top front center",
|
||||
"Top front right",
|
||||
"Top back left",
|
||||
"Top back center",
|
||||
"Top back right"};
|
||||
|
||||
rv.AppendPrintf("0x%08x", aChannelMap);
|
||||
rv.Append("[");
|
||||
bool empty = true;
|
||||
for (size_t i = 0; i < CHANNEL_NAME.size(); i++) {
|
||||
if (aChannelMap & (1 << i)) {
|
||||
if (!empty) {
|
||||
rv.Append("|");
|
||||
}
|
||||
empty = false;
|
||||
rv.Append(CHANNEL_NAME[i]);
|
||||
}
|
||||
}
|
||||
rv.Append("]");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool AudioConfig::ChannelLayout::MappingTable(const ChannelLayout& aOther,
|
||||
nsTArray<uint8_t>* aMap) const {
|
||||
if (!IsValid() || !aOther.IsValid() || Map() != aOther.Map()) {
|
||||
|
|
|
@ -97,6 +97,8 @@ class AudioConfig {
|
|||
|
||||
static ChannelLayout SMPTEDefault(const ChannelLayout& aChannelLayout);
|
||||
static ChannelLayout SMPTEDefault(ChannelMap aMap);
|
||||
// Convert a channel map to a human readable string for debugging purposes.
|
||||
static nsCString ChannelMapToString(const ChannelMap aChannelMap);
|
||||
|
||||
static constexpr ChannelMap UNKNOWN_MAP = 0;
|
||||
|
||||
|
|
|
@ -544,4 +544,18 @@ void MediaRawDataWriter::PopFront(size_t aSize) {
|
|||
mTarget->mBuffer.PopFront(aSize);
|
||||
}
|
||||
|
||||
const char* CryptoSchemeToString(const CryptoScheme& aScheme) {
|
||||
switch (aScheme) {
|
||||
case CryptoScheme::None:
|
||||
return "None";
|
||||
case CryptoScheme::Cenc:
|
||||
return "Cenc";
|
||||
case CryptoScheme::Cbcs:
|
||||
return "Cbcs";
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -571,6 +571,8 @@ enum class CryptoScheme : uint8_t {
|
|||
Cbcs,
|
||||
};
|
||||
|
||||
const char* CryptoSchemeToString(const CryptoScheme& aScheme);
|
||||
|
||||
class CryptoTrack {
|
||||
public:
|
||||
CryptoTrack()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaInfo.h"
|
||||
#include "MediaData.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -38,6 +39,30 @@ bool TrackInfo::IsEqualTo(const TrackInfo& rhs) const {
|
|||
mIsRenderedExternally == rhs.mIsRenderedExternally && mType == rhs.mType);
|
||||
}
|
||||
|
||||
nsCString TrackInfo::ToString() const {
|
||||
nsCString rv;
|
||||
|
||||
rv.AppendPrintf(
|
||||
"TrackInfo: id:%s kind:%s label:%s language:%s enabled:%s trackid: %d "
|
||||
"mimetype:%s duration:%s media time:%s crypto:%s rendered externaly: %s "
|
||||
"type:%s",
|
||||
NS_ConvertUTF16toUTF8(mId).get(), NS_ConvertUTF16toUTF8(mKind).get(),
|
||||
NS_ConvertUTF16toUTF8(mLabel).get(),
|
||||
NS_ConvertUTF16toUTF8(mLanguage).get(), mEnabled ? "true" : "false",
|
||||
mTrackId, mMimeType.get(), mDuration.ToString().get(),
|
||||
mMediaTime.ToString().get(), CryptoSchemeToString(mCrypto.mCryptoScheme),
|
||||
mIsRenderedExternally ? "true" : "false", TrackTypeToStr(mType));
|
||||
|
||||
if (!mTags.IsEmpty()) {
|
||||
rv.AppendPrintf("\n");
|
||||
for (const auto& tag : mTags) {
|
||||
rv.AppendPrintf("%s:%s", tag.mKey.get(), tag.mValue.get());
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool VideoInfo::operator==(const VideoInfo& rhs) const {
|
||||
return (TrackInfo::IsEqualTo(rhs) && mDisplay == rhs.mDisplay &&
|
||||
mStereoMode == rhs.mStereoMode && mImage == rhs.mImage &&
|
||||
|
@ -55,4 +80,18 @@ bool AudioInfo::operator==(const AudioInfo& rhs) const {
|
|||
mCodecSpecificConfig == rhs.mCodecSpecificConfig);
|
||||
}
|
||||
|
||||
nsCString AudioInfo::ToString() const {
|
||||
nsCString rv;
|
||||
|
||||
rv.AppendPrintf(
|
||||
"AudioInfo: %" PRIu32 "Hz, %" PRIu32 "ch (%s) %" PRIu32
|
||||
"-bits profile: %" PRIu8 " extended profile: %" PRIu8 ", %s extradata",
|
||||
mRate, mChannels,
|
||||
AudioConfig::ChannelLayout::ChannelMapToString(mChannelMap).get(),
|
||||
mBitDepth, mProfile, mExtendedProfile,
|
||||
mCodecSpecificConfig.is<NoCodecSpecificData>() ? "no" : "with");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -295,6 +295,8 @@ class TrackInfo {
|
|||
bool IsText() const { return !!GetAsTextInfo(); }
|
||||
TrackType GetType() const { return mType; }
|
||||
|
||||
nsCString ToString() const;
|
||||
|
||||
bool virtual IsValid() const = 0;
|
||||
|
||||
virtual UniquePtr<TrackInfo> Clone() const = 0;
|
||||
|
@ -498,6 +500,8 @@ class AudioInfo : public TrackInfo {
|
|||
|
||||
const AudioInfo* GetAsAudioInfo() const override { return this; }
|
||||
|
||||
nsCString ToString() const;
|
||||
|
||||
UniquePtr<TrackInfo> Clone() const override {
|
||||
return MakeUnique<AudioInfo>(*this);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче