Commit a5af2468 authored by Yuri Wiitala's avatar Yuri Wiitala Committed by Commit Bot

Remove dead code / content public API: AudioLoopbackStreamCreator

A recent change removed the use of this content public API. It provided
legacy/duplicate functionality to that found in
content/public/browser/audio_service.h.

Bug: 1111026
Change-Id: Ie498c0b743f7c03cc65bb5613dd2765a3f2d2de3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523744
Auto-Submit: Yuri Wiitala <miu@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825542}
parent be10d8ff
......@@ -1075,8 +1075,6 @@ source_set("browser") {
"media/forwarding_audio_stream_factory.h",
"media/hardware_key_media_controller.cc",
"media/hardware_key_media_controller.h",
"media/in_process_audio_loopback_stream_creator.cc",
"media/in_process_audio_loopback_stream_creator.h",
"media/media_devices_permission_checker.cc",
"media/media_devices_permission_checker.h",
"media/media_devices_util.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/media/in_process_audio_loopback_stream_creator.h"
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/check_op.h"
#include "base/location.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "media/audio/audio_device_description.h"
#include "media/base/user_input_monitor.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/public/mojom/media/renderer_audio_input_stream_factory.mojom.h"
namespace content {
namespace {
// A blink::mojom::RendererAudioInputStreamFactoryClient that holds a
// AudioLoopbackStreamCreator::StreamCreatedCallback. The callback runs when the
// requested audio stream is created.
class StreamCreatedCallbackAdapter final
: public blink::mojom::RendererAudioInputStreamFactoryClient {
public:
explicit StreamCreatedCallbackAdapter(
const AudioLoopbackStreamCreator::StreamCreatedCallback& callback)
: callback_(callback) {
DCHECK(callback_);
}
~StreamCreatedCallbackAdapter() override {}
// blink::mojom::RendererAudioInputStreamFactoryClient implementation.
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {
DCHECK(!initially_muted); // Loopback streams shouldn't be started muted.
callback_.Run(std::move(stream), std::move(client_receiver),
std::move(data_pipe));
}
private:
const AudioLoopbackStreamCreator::StreamCreatedCallback callback_;
DISALLOW_COPY_AND_ASSIGN(StreamCreatedCallbackAdapter);
};
void CreateLoopbackStreamHelper(
ForwardingAudioStreamFactory::Core* factory,
AudioStreamBroker::LoopbackSource* loopback_source,
const media::AudioParameters& params,
uint32_t total_segments,
mojo::PendingRemote<blink::mojom::RendererAudioInputStreamFactoryClient>
client_remote) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const bool mute_source = true;
factory->CreateLoopbackStream(-1, -1, loopback_source, params, total_segments,
mute_source, std::move(client_remote));
}
void CreateSystemWideLoopbackStreamHelper(
ForwardingAudioStreamFactory::Core* factory,
const media::AudioParameters& params,
uint32_t total_segments,
mojo::PendingRemote<blink::mojom::RendererAudioInputStreamFactoryClient>
client_remote) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const bool enable_agc = false;
factory->CreateInputStream(
-1, -1, media::AudioDeviceDescription::kLoopbackWithMuteDeviceId, params,
total_segments, enable_agc, std::move(client_remote));
}
} // namespace
InProcessAudioLoopbackStreamCreator::InProcessAudioLoopbackStreamCreator()
: factory_(nullptr,
BrowserMainLoop::GetInstance()
? static_cast<media::UserInputMonitorBase*>(
BrowserMainLoop::GetInstance()->user_input_monitor())
: nullptr,
AudioStreamBrokerFactory::CreateImpl()) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
InProcessAudioLoopbackStreamCreator::~InProcessAudioLoopbackStreamCreator() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
void InProcessAudioLoopbackStreamCreator::CreateLoopbackStream(
WebContents* loopback_source,
const media::AudioParameters& params,
uint32_t total_segments,
const StreamCreatedCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
mojo::PendingRemote<blink::mojom::RendererAudioInputStreamFactoryClient>
client;
mojo::MakeSelfOwnedReceiver(
std::make_unique<StreamCreatedCallbackAdapter>(callback),
client.InitWithNewPipeAndPassReceiver());
// Deletion of factory_.core() is posted to the IO thread when |factory_| is
// destroyed, so Unretained is safe below.
if (loopback_source) {
GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&CreateLoopbackStreamHelper, factory_.core(),
static_cast<WebContentsImpl*>(loopback_source)
->GetAudioStreamFactory()
->core(),
params, total_segments, std::move(client)));
return;
}
// A null |frame_of_source_web_contents| requests system-wide loopback.
GetIOThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(&CreateSystemWideLoopbackStreamHelper, factory_.core(),
params, total_segments, std::move(client)));
}
} // namespace content
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_MEDIA_IN_PROCESS_AUDIO_LOOPBACK_STREAM_CREATOR_H_
#define CONTENT_BROWSER_MEDIA_IN_PROCESS_AUDIO_LOOPBACK_STREAM_CREATOR_H_
#include "base/macros.h"
#include "content/browser/media/forwarding_audio_stream_factory.h"
#include "content/public/browser/audio_loopback_stream_creator.h"
namespace media {
class AudioParameters;
}
namespace content {
// This class handles creating a loopback stream that either captures audio from
// a WebContents or the system-wide loopback through the Audio Service.
// This class is operated on the UI thread.
class CONTENT_EXPORT InProcessAudioLoopbackStreamCreator final
: public AudioLoopbackStreamCreator {
public:
InProcessAudioLoopbackStreamCreator();
~InProcessAudioLoopbackStreamCreator() override;
private:
// AudioLoopbackStreamCreator implementation.
void CreateLoopbackStream(WebContents* loopback_source,
const media::AudioParameters& params,
uint32_t total_segments,
const StreamCreatedCallback& callback) override;
ForwardingAudioStreamFactory factory_;
DISALLOW_COPY_AND_ASSIGN(InProcessAudioLoopbackStreamCreator);
};
} // namespace content
#endif // CONTENT_BROWSER_MEDIA_IN_PROCESS_AUDIO_LOOPBACK_STREAM_CREATOR_H_
......@@ -30,8 +30,6 @@ source_set("browser_sources") {
"allow_service_worker_result.h",
"appcache_service.cc",
"appcache_service.h",
"audio_loopback_stream_creator.cc",
"audio_loopback_stream_creator.h",
"audio_service.h",
"audio_service_info.cc",
"audio_service_info.h",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/audio_loopback_stream_creator.h"
#include "content/browser/media/in_process_audio_loopback_stream_creator.h"
namespace content {
// static
std::unique_ptr<AudioLoopbackStreamCreator>
AudioLoopbackStreamCreator::CreateInProcessAudioLoopbackStreamCreator() {
return std::make_unique<InProcessAudioLoopbackStreamCreator>();
}
AudioLoopbackStreamCreator::~AudioLoopbackStreamCreator() = default;
} // namespace content
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_AUDIO_LOOPBACK_STREAM_CREATOR_H_
#define CONTENT_PUBLIC_BROWSER_AUDIO_LOOPBACK_STREAM_CREATOR_H_
#include "base/callback.h"
#include "content/common/content_export.h"
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
namespace media {
class AudioParameters;
}
namespace content {
class WebContents;
// This interface is used by the embedder to ask the Audio Service to create a
// loopback stream that either captures audio from a tab or the system-wide
// loopback.
// Note: Use this to request loopback audio for a privileged embedder feature,
// and not for consumption by a renderer. For renderers, use the
// mojom::RendererAudioInputStreamFactory interface instead.
class CONTENT_EXPORT AudioLoopbackStreamCreator {
public:
virtual ~AudioLoopbackStreamCreator();
// The callback that is called when the requested stream is created.
using StreamCreatedCallback = base::RepeatingCallback<void(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe)>;
// Creates an InProcessAudioLoopbackStreamCreator that handles creating audio
// loopback stream through the Audio Service.
static std::unique_ptr<AudioLoopbackStreamCreator>
CreateInProcessAudioLoopbackStreamCreator();
// Creates a loopback stream that captures the audio from |loopback_source|,
// or the default system playback if |loopback_source| is null. Local output
// of the source/system audio is muted during capturing.
virtual void CreateLoopbackStream(WebContents* loopback_source,
const media::AudioParameters& params,
uint32_t total_segments,
const StreamCreatedCallback& callback) = 0;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_AUDIO_LOOPBACK_STREAM_CREATOR_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment