#include "services/media_session/audio_focus_manager.h"
#include <iterator>
#include <utility>
#include <vector>
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_observer.h"
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/media_session/audio_focus_request.h"
#include "services/media_session/public/cpp/features.h"
#include "services/media_session/public/mojom/audio_focus.mojom.h"
namespace media_session {
namespace {
mojom::EnforcementMode GetDefaultEnforcementMode() { … }
}
class MediaPowerDelegate : public base::PowerSuspendObserver { … };
class AudioFocusManager::SourceObserverHolder { … };
void AudioFocusManager::RequestAudioFocus(
mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver,
mojo::PendingRemote<mojom::MediaSession> session,
mojom::MediaSessionInfoPtr session_info,
mojom::AudioFocusType type,
RequestAudioFocusCallback callback) { … }
void AudioFocusManager::RequestGroupedAudioFocus(
const base::UnguessableToken& request_id,
mojo::PendingReceiver<mojom::AudioFocusRequestClient> receiver,
mojo::PendingRemote<mojom::MediaSession> session,
mojom::MediaSessionInfoPtr session_info,
mojom::AudioFocusType type,
const base::UnguessableToken& group_id,
RequestGroupedAudioFocusCallback callback) { … }
void AudioFocusManager::GetFocusRequests(GetFocusRequestsCallback callback) { … }
void AudioFocusManager::GetDebugInfoForRequest(
const RequestId& request_id,
GetDebugInfoForRequestCallback callback) { … }
void AudioFocusManager::AbandonAudioFocusInternal(RequestId id) { … }
void AudioFocusManager::AddObserver(
mojo::PendingRemote<mojom::AudioFocusObserver> observer) { … }
void AudioFocusManager::SetSource(const base::UnguessableToken& identity,
const std::string& name) { … }
void AudioFocusManager::SetEnforcementMode(mojom::EnforcementMode mode) { … }
void AudioFocusManager::AddSourceObserver(
const base::UnguessableToken& source_id,
mojo::PendingRemote<mojom::AudioFocusObserver> observer) { … }
void AudioFocusManager::GetSourceFocusRequests(
const base::UnguessableToken& source_id,
GetFocusRequestsCallback callback) { … }
void AudioFocusManager::RequestIdReleased(
const base::UnguessableToken& request_id) { … }
void AudioFocusManager::CreateActiveMediaController(
mojo::PendingReceiver<mojom::MediaController> receiver) { … }
void AudioFocusManager::CreateMediaControllerForSession(
mojo::PendingReceiver<mojom::MediaController> receiver,
const base::UnguessableToken& receiver_id) { … }
void AudioFocusManager::SuspendAllSessions() { … }
void AudioFocusManager::BindToInterface(
mojo::PendingReceiver<mojom::AudioFocusManager> receiver) { … }
void AudioFocusManager::BindToDebugInterface(
mojo::PendingReceiver<mojom::AudioFocusManagerDebug> receiver) { … }
void AudioFocusManager::BindToControllerManagerInterface(
mojo::PendingReceiver<mojom::MediaControllerManager> receiver) { … }
void AudioFocusManager::RequestAudioFocusInternal(
std::unique_ptr<AudioFocusRequest> row,
mojom::AudioFocusType type) { … }
void AudioFocusManager::EnforceAudioFocus() { … }
void AudioFocusManager::MaybeUpdateActiveSession() { … }
AudioFocusManager::AudioFocusManager()
: … { … }
AudioFocusManager::~AudioFocusManager() = default;
std::unique_ptr<AudioFocusRequest> AudioFocusManager::RemoveFocusEntryIfPresent(
RequestId id) { … }
bool AudioFocusManager::IsFocusEntryPresent(
const base::UnguessableToken& id) const { … }
const std::string& AudioFocusManager::GetBindingSourceName() const { … }
const base::UnguessableToken& AudioFocusManager::GetBindingIdentity() const { … }
bool AudioFocusManager::IsSessionOnTopOfAudioFocusStack(
RequestId id,
mojom::AudioFocusType type) const { … }
bool AudioFocusManager::ShouldSessionBeSuspended(
const AudioFocusRequest* session,
const EnforcementState& state) const { … }
bool AudioFocusManager::ShouldSessionBeDucked(
const AudioFocusRequest* session,
const EnforcementState& state) const { … }
void AudioFocusManager::EnforceSingleSession(AudioFocusRequest* session,
const EnforcementState& state) { … }
void AudioFocusManager::CleanupSourceObservers() { … }
}