#include "content/browser/media/media_internals_audio_focus_helper.h"
#include <string>
#include <string_view>
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/values.h"
#include "content/browser/media/media_internals.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/media_session_service.h"
#include "content/public/browser/web_ui.h"
namespace content {
namespace {
const char kAudioFocusFunction[] = …;
const char kAudioFocusIdKey[] = …;
const char kAudioFocusSessionsKey[] = …;
const char kAudioFocusForceDuck[] = …;
const char kAudioFocusPreferStop[] = …;
const char kAudioFocusTypeGain[] = …;
const char kAudioFocusTypeGainTransient[] = …;
const char kAudioFocusTypeGainTransientMayDuck[] = …;
const char kAudioFocusTypeAmbient[] = …;
const char kMediaSessionStateActive[] = …;
const char kMediaSessionStateDucking[] = …;
const char kMediaSessionStateSuspended[] = …;
const char kMediaSessionStateInactive[] = …;
const char kMediaSessionPlaybackStatePaused[] = …;
const char kMediaSessionPlaybackStatePlaying[] = …;
const char kMediaSessionIsControllable[] = …;
const char kMediaSessionIsSensitive[] = …;
const char kMediaSessionHasAudio[] = …;
const char kMediaSessionHasVideo[] = …;
const char kMediaSessionHasAudioVideo[] = …;
}
MediaInternalsAudioFocusHelper::MediaInternalsAudioFocusHelper() = default;
MediaInternalsAudioFocusHelper::~MediaInternalsAudioFocusHelper() = default;
void MediaInternalsAudioFocusHelper::SendAudioFocusState() { … }
void MediaInternalsAudioFocusHelper::OnFocusGained(
media_session::mojom::AudioFocusRequestStatePtr session) { … }
void MediaInternalsAudioFocusHelper::OnFocusLost(
media_session::mojom::AudioFocusRequestStatePtr session) { … }
void MediaInternalsAudioFocusHelper::SetEnabled(bool enabled) { … }
bool MediaInternalsAudioFocusHelper::EnsureServiceConnection() { … }
void MediaInternalsAudioFocusHelper::OnMojoError() { … }
void MediaInternalsAudioFocusHelper::OnDebugMojoError() { … }
void MediaInternalsAudioFocusHelper::DidGetAudioFocusRequestList(
std::vector<media_session::mojom::AudioFocusRequestStatePtr> stack) { … }
void MediaInternalsAudioFocusHelper::DidGetAudioFocusDebugInfo(
const std::string& id,
media_session::mojom::MediaSessionDebugInfoPtr info) { … }
void MediaInternalsAudioFocusHelper::SerializeAndSendUpdate(
std::string_view function,
const base::Value::Dict& value) { … }
std::string MediaInternalsAudioFocusHelper::BuildNameString(
const media_session::mojom::AudioFocusRequestStatePtr& state,
const std::string& provided_name) const { … }
std::string MediaInternalsAudioFocusHelper::BuildStateString(
const media_session::mojom::AudioFocusRequestStatePtr& state,
const std::string& provided_state) const { … }
}