Backed out 6 changesets (bug 1886057) for causing build bustages in MFCDMSession.cpp CLOSED TREE

Backed out changeset 4e4e5d843fc3 (bug 1886057)
Backed out changeset eee295a109f8 (bug 1886057)
Backed out changeset deeb4d41a8ed (bug 1886057)
Backed out changeset 93dcd5c56c14 (bug 1886057)
Backed out changeset 3daba4b63121 (bug 1886057)
Backed out changeset ce3a6cf698ec (bug 1886057)
This commit is contained in:
Cristian Tuns 2024-03-20 15:16:54 -04:00
parent 039620a213
commit 12b00c05ed
13 changed files with 157 additions and 28 deletions

View File

@ -454,7 +454,7 @@ class HTMLMediaElement::MediaControlKeyListener final
void HandleMediaKey(MediaControlKey aKey) override {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(IsStarted());
MEDIACONTROL_LOG("HandleEvent '%s'", GetEnumString(aKey).get());
MEDIACONTROL_LOG("HandleEvent '%s'", ToMediaControlKeyStr(aKey));
if (aKey == MediaControlKey::Play) {
Owner()->Play();
} else if (aKey == MediaControlKey::Pause) {

View File

@ -117,6 +117,26 @@ nsString KeySystemToProxyName(const nsAString& aKeySystem) {
return u""_ns;
}
#define ENUM_TO_STR(enumVal) \
case enumVal: \
return #enumVal
const char* ToMediaKeyStatusStr(dom::MediaKeyStatus aStatus) {
switch (aStatus) {
ENUM_TO_STR(dom::MediaKeyStatus::Usable);
ENUM_TO_STR(dom::MediaKeyStatus::Expired);
ENUM_TO_STR(dom::MediaKeyStatus::Released);
ENUM_TO_STR(dom::MediaKeyStatus::Output_restricted);
ENUM_TO_STR(dom::MediaKeyStatus::Output_downscaled);
ENUM_TO_STR(dom::MediaKeyStatus::Status_pending);
ENUM_TO_STR(dom::MediaKeyStatus::Internal_error);
default:
return "Undefined MediaKeyStatus!";
}
}
#undef ENUM_TO_STR
bool IsHardwareDecryptionSupported(
const dom::MediaKeySystemConfiguration& aConfig) {
for (const auto& capabilities : aConfig.mAudioCapabilities) {

View File

@ -158,7 +158,7 @@ void WMFCDMProxy::ResolvePromiseWithKeyStatus(
RETURN_IF_SHUTDOWN();
EME_LOG("WMFCDMProxy::ResolvePromiseWithKeyStatus(this=%p, pid=%" PRIu32
", status=%s)",
this, aId, dom::GetEnumString(aStatus).get());
this, aId, ToMediaKeyStatusStr(aStatus));
if (!mKeys.IsNull()) {
mKeys->ResolvePromiseWithKeyStatus(aId, aStatus);
} else {

View File

@ -229,7 +229,7 @@ void ContentMediaAgent::EnableAction(uint64_t aBrowsingContextId,
}
LOG("Notify to enable action '%s' in BC %" PRId64,
GetEnumString(aAction).get(), bc->Id());
ToMediaSessionActionStr(aAction), bc->Id());
if (XRE_IsContentProcess()) {
ContentChild* contentChild = ContentChild::GetSingleton();
Unused << contentChild->SendNotifyMediaSessionSupportedActionChanged(
@ -251,7 +251,7 @@ void ContentMediaAgent::DisableAction(uint64_t aBrowsingContextId,
}
LOG("Notify to disable action '%s' in BC %" PRId64,
GetEnumString(aAction).get(), bc->Id());
ToMediaSessionActionStr(aAction), bc->Id());
if (XRE_IsContentProcess()) {
ContentChild* contentChild = ContentChild::GetSingleton();
Unused << contentChild->SendNotifyMediaSessionSupportedActionChanged(
@ -325,7 +325,7 @@ void ContentMediaController::HandleMediaKey(MediaControlKey aKey) {
if (mReceivers.IsEmpty()) {
return;
}
LOG("Handle '%s' event, receiver num=%zu", GetEnumString(aKey).get(),
LOG("Handle '%s' event, receiver num=%zu", ToMediaControlKeyStr(aKey),
mReceivers.Length());
// We have default handlers for play, pause and stop.
// https://w3c.github.io/mediasession/#ref-for-dom-mediasessionaction-play%E2%91%A3

View File

@ -46,7 +46,7 @@ void ContentPlaybackController::NotifyContentMediaControlKeyReceiver(
if (RefPtr<ContentMediaControlKeyReceiver> receiver =
ContentMediaControlKeyReceiver::Get(mBC)) {
LOG("Handle '%s' in default behavior for BC %" PRIu64,
GetEnumString(aKey).get(), mBC->Id());
ToMediaControlKeyStr(aKey), mBC->Id());
receiver->HandleMediaKey(aKey);
}
}
@ -61,7 +61,7 @@ void ContentPlaybackController::NotifyMediaSession(
const MediaSessionActionDetails& aDetails) {
if (RefPtr<MediaSession> session = GetMediaSession()) {
LOG("Handle '%s' in media session behavior for BC %" PRIu64,
GetEnumString(aDetails.mAction).get(), mBC->Id());
ToMediaSessionActionStr(aDetails.mAction), mBC->Id());
MOZ_ASSERT(session->IsActive(), "Notify inactive media session!");
session->NotifyHandler(aDetails);
}

View File

@ -161,7 +161,7 @@ void MediaControlKeyManager::SetSupportedMediaKeys(
const MediaKeysArray& aSupportedKeys) {
mSupportedKeys.Clear();
for (const auto& key : aSupportedKeys) {
LOG_INFO("Supported keys=%s", GetEnumString(key).get());
LOG_INFO("Supported keys=%s", ToMediaControlKeyStr(key));
mSupportedKeys.AppendElement(key);
}
if (mEventSource && mEventSource->IsOpened()) {

View File

@ -20,12 +20,66 @@ extern mozilla::LazyLogModule gMediaControlLog;
namespace mozilla::dom {
inline const char* ToMediaControlKeyStr(MediaControlKey aKey) {
switch (aKey) {
case MediaControlKey::Focus:
return "Focus";
case MediaControlKey::Pause:
return "Pause";
case MediaControlKey::Play:
return "Play";
case MediaControlKey::Playpause:
return "Play & pause";
case MediaControlKey::Previoustrack:
return "Previous track";
case MediaControlKey::Nexttrack:
return "Next track";
case MediaControlKey::Seekbackward:
return "Seek backward";
case MediaControlKey::Seekforward:
return "Seek forward";
case MediaControlKey::Skipad:
return "Skip Ad";
case MediaControlKey::Seekto:
return "Seek to";
case MediaControlKey::Stop:
return "Stop";
default:
MOZ_ASSERT_UNREACHABLE("Invalid action.");
return "Unknown";
}
}
inline const char* ToMediaControlKeyStr(const Maybe<MediaControlKey>& aKey) {
if (aKey.isNothing()) {
MOZ_ASSERT_UNREACHABLE("Invalid action.");
return "Unknown";
}
return GetEnumString(aKey.value()).get();
return ToMediaControlKeyStr(aKey.value());
}
inline const char* ToMediaSessionActionStr(MediaSessionAction aAction) {
switch (aAction) {
case MediaSessionAction::Play:
return "play";
case MediaSessionAction::Pause:
return "pause";
case MediaSessionAction::Seekbackward:
return "seek backward";
case MediaSessionAction::Seekforward:
return "seek forward";
case MediaSessionAction::Previoustrack:
return "previous track";
case MediaSessionAction::Nexttrack:
return "next track";
case MediaSessionAction::Skipad:
return "skip ad";
case MediaSessionAction::Seekto:
return "Seek to";
default:
MOZ_ASSERT(aAction == MediaSessionAction::Stop);
return "stop";
}
}
inline MediaControlKey ConvertMediaSessionActionToControlKey(

View File

@ -338,10 +338,10 @@ void MediaStatusManager::EnableAction(uint64_t aBrowsingContextId,
}
if (info->IsActionSupported(aAction)) {
LOG("Action '%s' has already been enabled for context %" PRIu64,
GetEnumString(aAction).get(), aBrowsingContextId);
ToMediaSessionActionStr(aAction), aBrowsingContextId);
return;
}
LOG("Enable action %s for context %" PRIu64, GetEnumString(aAction).get(),
LOG("Enable action %s for context %" PRIu64, ToMediaSessionActionStr(aAction),
aBrowsingContextId);
info->EnableAction(aAction);
NotifySupportedKeysChangedIfNeeded(aBrowsingContextId);
@ -355,11 +355,11 @@ void MediaStatusManager::DisableAction(uint64_t aBrowsingContextId,
}
if (!info->IsActionSupported(aAction)) {
LOG("Action '%s' hasn't been enabled yet for context %" PRIu64,
GetEnumString(aAction).get(), aBrowsingContextId);
ToMediaSessionActionStr(aAction), aBrowsingContextId);
return;
}
LOG("Disable action %s for context %" PRIu64, GetEnumString(aAction).get(),
aBrowsingContextId);
LOG("Disable action %s for context %" PRIu64,
ToMediaSessionActionStr(aAction), aBrowsingContextId);
info->DisableAction(aAction);
NotifySupportedKeysChangedIfNeeded(aBrowsingContextId);
}

View File

@ -244,7 +244,7 @@ void MFCDMSession::OnSessionKeysChange() {
nsAutoCString keyIdString(ToHexString(keyId));
LOG("Append keyid-sz=%u, keyid=%s, status=%s", keyStatus.cbKeyId,
keyIdString.get(),
dom::GetEnumString(ToMediaKeyStatus(keyStatus.eMediaKeyStatus)).get());
ToMediaKeyStatusStr(ToMediaKeyStatus(keyStatus.eMediaKeyStatus)));
keyInfos.AppendElement(MFCDMKeyInformation{
std::move(keyId), ToMediaKeyStatus(keyStatus.eMediaKeyStatus)});
}

View File

@ -205,13 +205,37 @@ Result<Ok, nsCString> IsValidAudioDataInit(const AudioDataInit& aInit) {
return Ok();
}
const char* FormatToString(AudioSampleFormat aFormat) {
switch (aFormat) {
case AudioSampleFormat::U8:
return "u8";
case AudioSampleFormat::S16:
return "s16";
case AudioSampleFormat::S32:
return "s32";
case AudioSampleFormat::F32:
return "f32";
case AudioSampleFormat::U8_planar:
return "u8-planar";
case AudioSampleFormat::S16_planar:
return "s16-planar";
case AudioSampleFormat::S32_planar:
return "s32-planar";
case AudioSampleFormat::F32_planar:
return "f32-planar";
default:
MOZ_ASSERT_UNREACHABLE("wrong enum value");
}
return "unsupported";
}
/* static */
already_AddRefed<AudioData> AudioData::Constructor(const GlobalObject& aGlobal,
const AudioDataInit& aInit,
ErrorResult& aRv) {
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
LOGD("[%p] AudioData(fmt: %s, rate: %f, ch: %" PRIu32 ", ts: %" PRId64 ")",
global.get(), GetEnumString(aInit.mFormat).get(), aInit.mSampleRate,
global.get(), FormatToString(aInit.mFormat), aInit.mSampleRate,
aInit.mNumberOfChannels, aInit.mTimestamp);
if (!global) {
LOGE("Global unavailable");
@ -481,7 +505,7 @@ nsCString AudioData::ToString() const {
return nsPrintfCString("AudioData[%zu bytes %s %fHz %" PRIu32 "x%" PRIu32
"ch]",
mResource->Data().LengthBytes(),
GetEnumString(mAudioSampleFormat.value()).get(),
FormatToString(mAudioSampleFormat.value()),
mSampleRate, mNumberOfFrames, mNumberOfChannels);
}
@ -491,9 +515,8 @@ nsCString CopyToToString(size_t aDestBufSize,
"AudioDataCopyToOptions[data: %zu bytes %s frame count:%" PRIu32
" frame offset: %" PRIu32 " plane: %" PRIu32 "]",
aDestBufSize,
aOptions.mFormat.WasPassed()
? GetEnumString(aOptions.mFormat.Value()).get()
: "null",
aOptions.mFormat.WasPassed() ? FormatToString(aOptions.mFormat.Value())
: "null",
aOptions.mFrameCount.WasPassed() ? aOptions.mFrameCount.Value() : 0,
aOptions.mFrameOffset, aOptions.mPlaneIndex);
}

View File

@ -23,6 +23,20 @@ extern mozilla::LazyLogModule gTextTrackLog;
namespace mozilla::dom {
static const char* ToStateStr(const TextTrackMode aMode) {
switch (aMode) {
case TextTrackMode::Disabled:
return "DISABLED";
case TextTrackMode::Hidden:
return "HIDDEN";
case TextTrackMode::Showing:
return "SHOWING";
default:
MOZ_ASSERT_UNREACHABLE("Invalid state.");
}
return "Unknown";
}
static const char* ToReadyStateStr(const TextTrackReadyState aState) {
switch (aState) {
case TextTrackReadyState::NotLoaded:
@ -39,6 +53,24 @@ static const char* ToReadyStateStr(const TextTrackReadyState aState) {
return "Unknown";
}
static const char* ToTextTrackKindStr(const TextTrackKind aKind) {
switch (aKind) {
case TextTrackKind::Subtitles:
return "Subtitles";
case TextTrackKind::Captions:
return "Captions";
case TextTrackKind::Descriptions:
return "Descriptions";
case TextTrackKind::Chapters:
return "Chapters";
case TextTrackKind::Metadata:
return "Metadata";
default:
MOZ_ASSERT_UNREACHABLE("Invalid kind.");
}
return "Unknown";
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(TextTrack, DOMEventTargetHelper, mCueList,
mActiveCueList, mTextTrackList,
mTrackElement)
@ -97,8 +129,8 @@ void TextTrack::SetMode(TextTrackMode aValue) {
if (mMode == aValue) {
return;
}
WEBVTT_LOG("Set mode=%s for track kind %s", GetEnumString(aValue).get(),
GetEnumString(mKind).get());
WEBVTT_LOG("Set mode=%s for track kind %s", ToStateStr(aValue),
ToTextTrackKindStr(mKind));
mMode = aValue;
HTMLMediaElement* mediaElement = GetMediaElement();

View File

@ -439,10 +439,10 @@ const char* MPRISServiceHandler::DesktopEntry() const {
bool MPRISServiceHandler::PressKey(dom::MediaControlKey aKey) const {
MOZ_ASSERT(mInitialized);
if (!IsMediaKeySupported(aKey)) {
LOGMPRIS("%s is not supported", dom::GetEnumString(aKey).get());
LOGMPRIS("%s is not supported", ToMediaControlKeyStr(aKey));
return false;
}
LOGMPRIS("Press %s", dom::GetEnumString(aKey).get());
LOGMPRIS("Press %s", ToMediaControlKeyStr(aKey));
EmitEvent(aKey);
return true;
}
@ -861,7 +861,7 @@ bool MPRISServiceHandler::EmitSupportedKeyChanged(dom::MediaControlKey aKey,
bool aSupported) const {
auto it = gKeyProperty.find(aKey);
if (it == gKeyProperty.end()) {
LOGMPRIS("No property for %s", dom::GetEnumString(aKey).get());
LOGMPRIS("No property for %s", ToMediaControlKeyStr(aKey));
return false;
}

View File

@ -356,7 +356,7 @@ bool WindowsSMTCProvider::RegisterEvents() {
void WindowsSMTCProvider::OnButtonPressed(
mozilla::dom::MediaControlKey aKey) const {
if (!IsKeySupported(aKey)) {
LOG("key: %s is not supported", dom::GetEnumString(aKey).get());
LOG("key: %s is not supported", ToMediaControlKeyStr(aKey));
return;
}
@ -383,7 +383,7 @@ bool WindowsSMTCProvider::UpdateButtons() {
for (const mozilla::dom::MediaControlKey& key : kKeys) {
if (!EnableKey(key, IsKeySupported(key))) {
success = false;
LOG("Failed to set %s=%s", dom::GetEnumString(key).get(),
LOG("Failed to set %s=%s", ToMediaControlKeyStr(key),
IsKeySupported(key) ? "true" : "false");
}
}
@ -414,7 +414,7 @@ bool WindowsSMTCProvider::EnableKey(mozilla::dom::MediaControlKey aKey,
// The callback for the event checks if the key is supported
return mSeekRegistrationToken.value != 0;
default:
LOG("No button for %s", dom::GetEnumString(aKey).get());
LOG("No button for %s", ToMediaControlKeyStr(aKey));
return false;
}
}