#include "content/browser/renderer_host/media/render_frame_audio_output_stream_factory.h"
#include <inttypes.h>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/containers/flat_set.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/unguessable_token.h"
#include "content/browser/media/forwarding_audio_stream_factory.h"
#include "content/browser/renderer_host/media/audio_output_authorization_handler.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "media/base/output_device_info.h"
#include "media/mojo/mojom/audio_output_stream.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace content {
namespace {
const char* OutputDeviceStatusToString(media::OutputDeviceStatus status) { … }
}
class RenderFrameAudioOutputStreamFactory::Core final
: public blink::mojom::RendererAudioOutputStreamFactory { … };
RenderFrameAudioOutputStreamFactory::RenderFrameAudioOutputStreamFactory(
RenderFrameHost* frame,
media::AudioSystem* audio_system,
MediaStreamManager* media_stream_manager,
mojo::PendingReceiver<blink::mojom::RendererAudioOutputStreamFactory>
receiver)
: … { … }
RenderFrameAudioOutputStreamFactory::~RenderFrameAudioOutputStreamFactory() { … }
void RenderFrameAudioOutputStreamFactory::
SetAuthorizedDeviceIdForGlobalMediaControls(std::string hashed_device_id) { … }
size_t
RenderFrameAudioOutputStreamFactory::CurrentNumberOfProvidersForTesting() { … }
RenderFrameAudioOutputStreamFactory::Core::Core(
RenderFrameHost* frame,
media::AudioSystem* audio_system,
MediaStreamManager* media_stream_manager,
mojo::PendingReceiver<blink::mojom::RendererAudioOutputStreamFactory>
receiver)
: … { … }
void RenderFrameAudioOutputStreamFactory::Core::Init(
mojo::PendingReceiver<blink::mojom::RendererAudioOutputStreamFactory>
receiver) { … }
void RenderFrameAudioOutputStreamFactory::Core::
SetAuthorizedDeviceIdForGlobalMediaControls(std::string hashed_device_id) { … }
void RenderFrameAudioOutputStreamFactory::Core::RequestDeviceAuthorization(
mojo::PendingReceiver<media::mojom::AudioOutputStreamProvider>
provider_receiver,
const std::optional<base::UnguessableToken>& session_id,
const std::string& device_id,
RequestDeviceAuthorizationCallback callback) { … }
void RenderFrameAudioOutputStreamFactory::Core::AuthorizationCompleted(
base::TimeTicks auth_start_time,
mojo::PendingReceiver<media::mojom::AudioOutputStreamProvider> receiver,
RequestDeviceAuthorizationCallback callback,
media::OutputDeviceStatus status,
const media::AudioParameters& params,
const std::string& raw_device_id,
const std::string& device_id_for_renderer) { … }
void RenderFrameAudioOutputStreamFactory::Core::DeleteProvider(
media::mojom::AudioOutputStreamProvider* stream_provider) { … }
void RenderFrameAudioOutputStreamFactory::Core::SendLogMessage(
const std::string& message) const { … }
}