#include "content/browser/renderer_host/media/render_frame_audio_input_stream_factory.h"
#include <cstdint>
#include <string>
#include <utility>
#include "base/check_op.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/trace_event/trace_event.h"
#include "base/unguessable_token.h"
#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/browser/media/forwarding_audio_stream_factory.h"
#include "content/browser/media/media_devices_permission_checker.h"
#include "content/browser/media/media_devices_util.h"
#include "content/browser/renderer_host/media/audio_input_device_manager.h"
#include "content/browser/renderer_host/media/media_devices_manager.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
#include "content/public/browser/audio_stream_broker.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/media_device_id.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents_media_capture_id.h"
#include "media/audio/audio_device_description.h"
#include "media/base/audio_parameters.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
#include "url/origin.h"
MediaDeviceType;
namespace content {
namespace {
AudioStreamBroker::LoopbackSource* GetLoopbackSourceOnUIThread(
int render_process_id,
int render_frame_id) { … }
void EnumerateOutputDevices(MediaStreamManager* media_stream_manager,
MediaDevicesManager::EnumerationCallback cb) { … }
void TranslateDeviceId(const std::string& device_id,
const MediaDeviceSaltAndOrigin& salt_and_origin,
base::RepeatingCallback<void(const std::string&)> cb,
const MediaDeviceEnumeration& device_array) { … }
void GotSaltAndOrigin(
int process_id,
int frame_id,
base::OnceCallback<void(const MediaDeviceSaltAndOrigin& salt_and_origin,
bool has_access)> cb,
const MediaDeviceSaltAndOrigin& salt_and_origin) { … }
void GetSaltOriginAndPermissionsOnUIThread(
int process_id,
int frame_id,
base::OnceCallback<void(const MediaDeviceSaltAndOrigin& salt_and_origin,
bool has_access)> cb) { … }
}
class RenderFrameAudioInputStreamFactory::Core final
: public blink::mojom::RendererAudioInputStreamFactory { … };
RenderFrameAudioInputStreamFactory::RenderFrameAudioInputStreamFactory(
mojo::PendingReceiver<blink::mojom::RendererAudioInputStreamFactory>
receiver,
MediaStreamManager* media_stream_manager,
RenderFrameHost* render_frame_host)
: … { … }
RenderFrameAudioInputStreamFactory::~RenderFrameAudioInputStreamFactory() { … }
RenderFrameAudioInputStreamFactory::Core::Core(
mojo::PendingReceiver<blink::mojom::RendererAudioInputStreamFactory>
receiver,
MediaStreamManager* media_stream_manager,
RenderFrameHost* render_frame_host)
: … { … }
RenderFrameAudioInputStreamFactory::Core::~Core() { … }
void RenderFrameAudioInputStreamFactory::Core::Init(
mojo::PendingReceiver<blink::mojom::RendererAudioInputStreamFactory>
receiver) { … }
void RenderFrameAudioInputStreamFactory::Core::CreateStream(
mojo::PendingRemote<blink::mojom::RendererAudioInputStreamFactoryClient>
client,
const base::UnguessableToken& session_id,
const media::AudioParameters& audio_params,
bool automatic_gain_control,
uint32_t shared_memory_count,
media::mojom::AudioProcessingConfigPtr processing_config) { … }
void RenderFrameAudioInputStreamFactory::Core::CreateLoopbackStream(
mojo::PendingRemote<blink::mojom::RendererAudioInputStreamFactoryClient>
client,
const media::AudioParameters& audio_params,
uint32_t shared_memory_count,
bool disable_local_echo,
AudioStreamBroker::LoopbackSource* loopback_source) { … }
void RenderFrameAudioInputStreamFactory::Core::AssociateInputAndOutputForAec(
const base::UnguessableToken& input_stream_id,
const std::string& output_device_id) { … }
void RenderFrameAudioInputStreamFactory::Core::
AssociateInputAndOutputForAecAfterCheckingAccess(
const base::UnguessableToken& input_stream_id,
const std::string& output_device_id,
const MediaDeviceSaltAndOrigin& salt_and_origin,
bool access_granted) { … }
void RenderFrameAudioInputStreamFactory::Core::
AssociateTranslatedOutputDeviceForAec(
const base::UnguessableToken& input_stream_id,
const std::string& raw_output_device_id) { … }
}