chromium/third_party/blink/renderer/modules/webrtc/webrtc_audio_renderer.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/webrtc/webrtc_audio_renderer.h"

#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "build/build_config.h"
#include "media/audio/audio_sink_parameters.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_capturer_source.h"
#include "media/base/audio_latency.h"
#include "media/base/audio_parameters.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/channel_layout.h"
#include "media/base/sample_rates.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/public/web/web_local_frame_client.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/modules/mediastream/media_stream_audio_renderer.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/webrtc/peer_connection_remote_audio_source.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/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/webrtc/api/media_stream_interface.h"

namespace WTF {

CrossThreadCopier<rtc::scoped_refptr<T>>;

}  // namespace WTF

namespace blink {

namespace {

// Audio parameters that don't change.
const media::AudioParameters::Format kFormat =;

// Time constant for AudioPowerMonitor. See See AudioPowerMonitor ctor comments
// for details.
constexpr base::TimeDelta kPowerMeasurementTimeConstant =;

// Time in seconds between two successive measurements of audio power levels.
constexpr base::TimeDelta kPowerMonitorLogInterval =;

// Used for UMA histograms.
const int kRenderTimeHistogramMinMicroseconds =;
const int kRenderTimeHistogramMaxMicroseconds =;  // 1 second

const char* OutputDeviceStatusToString(media::OutputDeviceStatus status) {}

const char* StateToString(WebRtcAudioRenderer::State state) {}

// This is a simple wrapper class that's handed out to users of a shared
// WebRtcAudioRenderer instance.  This class maintains the per-user 'playing'
// and 'started' states to avoid problems related to incorrect usage which
// might violate the implementation assumptions inside WebRtcAudioRenderer
// (see the play reference count).
class SharedAudioRenderer : public MediaStreamAudioRenderer {};

}  // namespace

WebRtcAudioRenderer::AudioStreamTracker::AudioStreamTracker(
    scoped_refptr<base::SingleThreadTaskRunner> task_runner,
    WebRtcAudioRenderer* renderer,
    int sample_rate)
    :{}

WebRtcAudioRenderer::AudioStreamTracker::~AudioStreamTracker() {}

void WebRtcAudioRenderer::AudioStreamTracker::OnRenderCallbackCalled() {}

void WebRtcAudioRenderer::AudioStreamTracker::MeasurePower(
    const media::AudioBus& buffer,
    int frames) {}

void WebRtcAudioRenderer::AudioStreamTracker::LogAudioPowerLevel() {}

void WebRtcAudioRenderer::AudioStreamTracker::CheckAlive(TimerBase*) {}

WebRtcAudioRenderer::WebRtcAudioRenderer(
    const scoped_refptr<base::SingleThreadTaskRunner>& signaling_thread,
    MediaStreamDescriptor* media_stream_descriptor,
    WebLocalFrame& web_frame,
    const base::UnguessableToken& session_id,
    const String& device_id,
    base::RepeatingCallback<void()> on_render_error_callback)
    :{}

WebRtcAudioRenderer::~WebRtcAudioRenderer() {}

bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {}

scoped_refptr<MediaStreamAudioRenderer>
WebRtcAudioRenderer::CreateSharedAudioRendererProxy(
    MediaStreamDescriptor* media_stream_descriptor) {}

bool WebRtcAudioRenderer::IsStarted() const {}

bool WebRtcAudioRenderer::CurrentThreadIsRenderingThread() {}

void WebRtcAudioRenderer::Start() {}

void WebRtcAudioRenderer::Play() {}

void WebRtcAudioRenderer::EnterPlayState() {}

void WebRtcAudioRenderer::Pause() {}

void WebRtcAudioRenderer::EnterPauseState() {}

void WebRtcAudioRenderer::Stop() {}

void WebRtcAudioRenderer::SetVolume(float volume) {}

base::TimeDelta WebRtcAudioRenderer::GetCurrentRenderTime() {}

void WebRtcAudioRenderer::SwitchOutputDevice(
    const std::string& device_id,
    media::OutputDeviceStatusCB callback) {}

int WebRtcAudioRenderer::Render(base::TimeDelta delay,
                                base::TimeTicks delay_timestamp,
                                const media::AudioGlitchInfo& glitch_info,
                                media::AudioBus* audio_bus) {}

void WebRtcAudioRenderer::OnRenderError() {}

void WebRtcAudioRenderer::OnRenderErrorCrossThread() {}

// Called by AudioPullFifo when more data is necessary.
void WebRtcAudioRenderer::SourceCallback(int fifo_frame_delay,
                                         media::AudioBus* audio_bus) {}

void WebRtcAudioRenderer::UpdateSourceVolume(
    webrtc::AudioSourceInterface* source) {}

bool WebRtcAudioRenderer::AddPlayingState(webrtc::AudioSourceInterface* source,
                                          PlayingState* state) {}

bool WebRtcAudioRenderer::RemovePlayingState(
    webrtc::AudioSourceInterface* source,
    PlayingState* state) {}

void WebRtcAudioRenderer::OnPlayStateChanged(
    MediaStreamDescriptor* media_stream_descriptor,
    PlayingState* state) {}

void WebRtcAudioRenderer::OnPlayStateRemoved(PlayingState* state) {}

void WebRtcAudioRenderer::PrepareSink() {}

void WebRtcAudioRenderer::SendLogMessage(const WTF::String& message) {}

}  // namespace blink