#include "third_party/blink/renderer/modules/mediastream/processed_local_audio_source.h"
#include <algorithm>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "media/audio/audio_source_parameters.h"
#include "media/base/channel_layout.h"
#include "media/base/media_switches.h"
#include "media/base/sample_rates.h"
#include "media/media_buildflags.h"
#include "media/webrtc/webrtc_features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-blink.h"
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_constraints_util.h"
#include "third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.h"
#include "third_party/blink/renderer/modules/webrtc/webrtc_audio_device_impl.h"
#include "third_party/blink/renderer/platform/mediastream/audio_service_audio_processor_proxy.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/webrtc/media/base/media_channel.h"
namespace blink {
EchoCancellationType;
namespace {
void SendLogMessage(const std::string& message) { … }
void* const kProcessedLocalAudioSourceIdentifier = …;
std::string GetEnsureSourceIsStartedLogString(
const blink::MediaStreamDevice& device) { … }
std::string GetAudioProcesingPropertiesLogString(
const blink::AudioProcessingProperties& properties) { … }
constexpr bool IsIndependentSystemNsAllowed() { … }
void LogInputDeviceParametersToUma(
const media::AudioParameters& input_device_params) { … }
}
bool ProcessedLocalAudioSource::OutputAudioAtProcessingSampleRate() { … }
ProcessedLocalAudioSource::ProcessedLocalAudioSource(
LocalFrame& frame,
const blink::MediaStreamDevice& device,
bool disable_local_echo,
const blink::AudioProcessingProperties& audio_processing_properties,
int num_requested_channels,
ConstraintsRepeatingCallback started_callback,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
ProcessedLocalAudioSource::~ProcessedLocalAudioSource() { … }
ProcessedLocalAudioSource* ProcessedLocalAudioSource::From(
blink::MediaStreamAudioSource* source) { … }
void ProcessedLocalAudioSource::SendLogMessageWithSessionId(
const std::string& message) const { … }
std::optional<blink::AudioProcessingProperties>
ProcessedLocalAudioSource::GetAudioProcessingProperties() const { … }
void* ProcessedLocalAudioSource::GetClassIdentifier() const { … }
bool ProcessedLocalAudioSource::EnsureSourceIsStarted() { … }
void ProcessedLocalAudioSource::EnsureSourceIsStopped() { … }
scoped_refptr<webrtc::AudioProcessorInterface>
ProcessedLocalAudioSource::GetAudioProcessor() const { … }
void ProcessedLocalAudioSource::SetVolume(double volume) { … }
void ProcessedLocalAudioSource::OnCaptureStarted() { … }
void ProcessedLocalAudioSource::Capture(
const media::AudioBus* audio_bus,
base::TimeTicks audio_capture_time,
const media::AudioGlitchInfo& glitch_info,
double volume,
bool key_pressed) { … }
void ProcessedLocalAudioSource::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) { … }
void ProcessedLocalAudioSource::OnCaptureMuted(bool is_muted) { … }
void ProcessedLocalAudioSource::OnCaptureProcessorCreated(
media::AudioProcessorControls* controls) { … }
void ProcessedLocalAudioSource::ChangeSourceImpl(
const MediaStreamDevice& new_device) { … }
void ProcessedLocalAudioSource::SetOutputDeviceForAec(
const std::string& output_device_id) { … }
void ProcessedLocalAudioSource::DeliverProcessedAudio(
const media::AudioBus& processed_audio,
base::TimeTicks audio_capture_time,
std::optional<double> new_volume) { … }
}