Commit f514a8b3 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert AudioInputStreamClient to new Mojo types

This CL converts AudioInputStreamClient{Ptr, Request} in chrome,
components, content and media to the new Mojo type, and uses
pending_receiver<pending_receiver> in resource_provider.mojom.

Bug: 955171
Change-Id: Ib7856c3c65ff70f658b9e6c56b72a9a2b73648e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866709
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709441}
parent 1a83e88d
......@@ -34,6 +34,7 @@
#include "content/public/browser/service_process_host.h"
#include "content/public/browser/video_capture_device_launcher.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/network/public/mojom/network_service.mojom.h"
......@@ -296,14 +297,15 @@ void CastMirroringServiceHost::CreateAudioStream(
base::BindRepeating(
[](mojo::PendingRemote<mojom::AudioStreamCreatorClient> client,
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe) {
// TODO(crbug.com/1015488): Remove |initially_muted| argument from
// mojom::AudioStreamCreatorClient::StreamCreated().
mojo::Remote<mojom::AudioStreamCreatorClient> audio_client(
std::move(client));
audio_client->StreamCreated(
std::move(stream), std::move(client_request),
std::move(stream), std::move(client_receiver),
std::move(data_pipe), false /* initially_muted */);
},
base::Passed(&client)));
......
......@@ -24,6 +24,7 @@
#include "media/capture/video_capture_types.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_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -220,11 +221,12 @@ class CastMirroringServiceHostBrowserTest
// mojom::AudioStreamCreatorClient mocks.
MOCK_METHOD0(OnAudioStreamCreated, void());
void StreamCreated(mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted) override {
EXPECT_TRUE(stream);
EXPECT_TRUE(client_request);
EXPECT_TRUE(client_receiver);
EXPECT_TRUE(data_pipe);
OnAudioStreamCreated();
}
......
......@@ -18,7 +18,7 @@ import "services/viz/public/mojom/gpu.mojom";
interface AudioStreamCreatorClient {
StreamCreated(
pending_remote<media.mojom.AudioInputStream> stream,
media.mojom.AudioInputStreamClient& client_request,
pending_receiver<media.mojom.AudioInputStreamClient> client_receiver,
media.mojom.ReadOnlyAudioDataPipe data_pipe,
bool initially_muted);
};
......
......@@ -11,8 +11,7 @@
namespace mirroring {
CapturedAudioInput::CapturedAudioInput(StreamCreatorCallback callback)
: stream_creator_callback_(std::move(callback)),
stream_client_binding_(this) {
: stream_creator_callback_(std::move(callback)) {
DETACH_FROM_SEQUENCE(sequence_checker_);
DCHECK(!stream_creator_callback_.is_null());
}
......@@ -48,8 +47,7 @@ void CapturedAudioInput::SetVolume(double volume) {
void CapturedAudioInput::CloseStream() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
delegate_ = nullptr;
if (stream_client_binding_.is_bound())
stream_client_binding_.Unbind();
stream_client_receiver_.reset();
stream_.reset();
}
......@@ -60,16 +58,16 @@ void CapturedAudioInput::SetOutputDeviceForAec(
void CapturedAudioInput::StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient> client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(delegate_);
DCHECK(!stream_);
DCHECK(!stream_client_binding_.is_bound());
DCHECK(!stream_client_receiver_.is_bound());
stream_.Bind(std::move(stream));
stream_client_binding_.Bind(std::move(client_request));
stream_client_receiver_.Bind(std::move(client_receiver));
base::PlatformFile socket_handle;
auto result =
......
......@@ -12,7 +12,7 @@
#include "components/mirroring/mojom/resource_provider.mojom.h"
#include "media/audio/audio_input_ipc.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -46,7 +46,8 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) CapturedAudioInput final
// mojom::AudioStreamCreatorClient implementation
void StreamCreated(mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted) override;
......@@ -57,7 +58,8 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) CapturedAudioInput final
SEQUENCE_CHECKER(sequence_checker_);
const StreamCreatorCallback stream_creator_callback_;
mojo::Binding<media::mojom::AudioInputStreamClient> stream_client_binding_;
mojo::Receiver<media::mojom::AudioInputStreamClient> stream_client_receiver_{
this};
mojo::Receiver<mojom::AudioStreamCreatorClient>
stream_creator_client_receiver_{this};
media::AudioInputIPCDelegate* delegate_ = nullptr;
......
......@@ -73,8 +73,9 @@ class CapturedAudioInputTest : public ::testing::Test {
base::CancelableSyncSocket::CreatePair(&socket_, &foreign_socket));
mojo::Remote<mojom::AudioStreamCreatorClient> audio_client(
std::move(client));
stream_client_.reset();
audio_client->StreamCreated(
std::move(pending_stream), mojo::MakeRequest(&stream_client_),
std::move(pending_stream), stream_client_.BindNewPipeAndPassReceiver(),
{base::in_place, base::ReadOnlySharedMemoryRegion::Create(1024).region,
mojo::WrapPlatformFile(foreign_socket.Release())},
initially_muted);
......@@ -142,7 +143,7 @@ class CapturedAudioInputTest : public ::testing::Test {
std::unique_ptr<media::AudioInputIPC> audio_input_;
MockDelegate delegate_;
MockStream* stream_ = nullptr;
media::mojom::AudioInputStreamClientPtr stream_client_;
mojo::Remote<media::mojom::AudioInputStreamClient> stream_client_;
base::CancelableSyncSocket socket_;
DISALLOW_COPY_AND_ASSIGN(CapturedAudioInputTest);
......
......@@ -204,9 +204,7 @@ void AudioInputStreamBroker::StreamCreated(
DCHECK(stream_id.has_value());
DCHECK(renderer_factory_client_);
renderer_factory_client_->StreamCreated(
std::move(stream),
media::mojom::AudioInputStreamClientRequest(
pending_client_receiver_.PassPipe()),
std::move(stream), std::move(pending_client_receiver_),
std::move(data_pipe), initially_muted, stream_id);
}
void AudioInputStreamBroker::ObserverBindingLost(
......
......@@ -58,13 +58,14 @@ class MockRendererAudioInputStreamFactoryClient
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> input_stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {
EXPECT_TRUE(stream_id.has_value());
input_stream_.Bind(std::move(input_stream));
client_request_ = std::move(client_request);
client_receiver_ = std::move(client_receiver);
OnStreamCreated();
}
......@@ -73,7 +74,7 @@ class MockRendererAudioInputStreamFactoryClient
private:
mojo::Receiver<mojom::RendererAudioInputStreamFactoryClient> receiver_{this};
mojo::Remote<media::mojom::AudioInputStream> input_stream_;
media::mojom::AudioInputStreamClientRequest client_request_;
mojo::PendingReceiver<media::mojom::AudioInputStreamClient> client_receiver_;
DISALLOW_COPY_AND_ASSIGN(MockRendererAudioInputStreamFactoryClient);
};
......@@ -92,7 +93,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
bool requested = false;
mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver;
media::mojom::AudioInputStreamClientPtr client;
mojo::Remote<media::mojom::AudioInputStreamClient> client;
media::mojom::AudioInputStreamObserverPtr observer;
mojo::Remote<media::mojom::AudioLog> log;
const std::string device_id;
......
......@@ -66,14 +66,14 @@ void AudioLoopbackStreamBroker::CreateStream(
audio::mojom::StreamFactory* factory) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!observer_binding_.is_bound());
DCHECK(!client_request_);
DCHECK(!client_receiver_);
DCHECK(source_);
if (muter_) // Mute the source.
muter_->Connect(factory);
media::mojom::AudioInputStreamClientPtr client;
client_request_ = mojo::MakeRequest(&client);
mojo::PendingRemote<media::mojom::AudioInputStreamClient> client;
client_receiver_ = client.InitWithNewPipeAndPassReceiver();
mojo::PendingRemote<media::mojom::AudioInputStream> stream;
mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver =
......@@ -87,7 +87,7 @@ void AudioLoopbackStreamBroker::CreateStream(
&AudioLoopbackStreamBroker::Cleanup, base::Unretained(this)));
factory->CreateLoopbackStream(
std::move(stream_receiver), client.PassInterface(),
std::move(stream_receiver), std::move(client),
observer_ptr.PassInterface(), params_, shared_memory_count_,
source_->GetGroupID(),
base::BindOnce(&AudioLoopbackStreamBroker::StreamCreated,
......@@ -117,7 +117,7 @@ void AudioLoopbackStreamBroker::StreamCreated(
DCHECK(renderer_factory_client_);
renderer_factory_client_->StreamCreated(
std::move(stream), std::move(client_request_), std::move(data_pipe),
std::move(stream), std::move(client_receiver_), std::move(data_pipe),
false /* |initially_muted|: Loopback streams are never muted. */,
base::nullopt /* |stream_id|: Loopback streams don't have ids */);
}
......
......@@ -18,6 +18,7 @@
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -78,7 +79,7 @@ class CONTENT_EXPORT AudioLoopbackStreamBroker final
mojo::Remote<mojom::RendererAudioInputStreamFactoryClient>
renderer_factory_client_;
mojo::Binding<AudioInputStreamObserver> observer_binding_;
media::mojom::AudioInputStreamClientRequest client_request_;
mojo::PendingReceiver<media::mojom::AudioInputStreamClient> client_receiver_;
base::WeakPtrFactory<AudioLoopbackStreamBroker> weak_ptr_factory_{this};
......
......@@ -73,14 +73,15 @@ class MockRendererAudioInputStreamFactoryClient
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> input_stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {
// Loopback streams have no stream ids.
EXPECT_FALSE(stream_id.has_value());
input_stream_.Bind(std::move(input_stream));
client_request_ = std::move(client_request);
client_receiver_ = std::move(client_receiver);
OnStreamCreated();
}
......@@ -89,7 +90,7 @@ class MockRendererAudioInputStreamFactoryClient
private:
mojo::Receiver<mojom::RendererAudioInputStreamFactoryClient> receiver_{this};
mojo::Remote<media::mojom::AudioInputStream> input_stream_;
media::mojom::AudioInputStreamClientRequest client_request_;
mojo::PendingReceiver<media::mojom::AudioInputStreamClient> client_receiver_;
};
class MockStreamFactory : public audio::FakeStreamFactory {
......@@ -107,7 +108,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
bool requested = false;
mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver;
media::mojom::AudioInputStreamClientPtr client;
mojo::Remote<media::mojom::AudioInputStreamClient> client;
media::mojom::AudioInputStreamObserverPtr observer;
const media::AudioParameters params;
uint32_t shared_memory_count;
......
......@@ -45,12 +45,13 @@ class StreamCreatedCallbackAdapter final
// mojom::RendererAudioInputStreamFactoryClient implementation.
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
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_request),
callback_.Run(std::move(stream), std::move(client_receiver),
std::move(data_pipe));
}
......
......@@ -8,17 +8,17 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "mojo/public/cpp/bindings/interface_request.h"
namespace content {
namespace {
media::mojom::AudioInputStreamClientPtr CreatePtrAndStoreRequest(
media::mojom::AudioInputStreamClientRequest* request_out) {
media::mojom::AudioInputStreamClientPtr ptr;
*request_out = mojo::MakeRequest(&ptr);
return ptr;
mojo::PendingRemote<media::mojom::AudioInputStreamClient>
CreateRemoteAndStoreReceiver(
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>* receiver_out) {
mojo::PendingRemote<media::mojom::AudioInputStreamClient> remote;
*receiver_out = remote.InitWithNewPipeAndPassReceiver();
return remote;
}
} // namespace
......@@ -32,9 +32,8 @@ AudioInputStreamHandle::AudioInputStreamHandle(
: stream_id_(base::UnguessableToken::Create()),
deleter_callback_(std::move(deleter_callback)),
client_remote_(std::move(client_pending_remote)),
stream_client_request_(),
stream_(pending_stream_.InitWithNewPipeAndPassReceiver(),
CreatePtrAndStoreRequest(&stream_client_request_),
CreateRemoteAndStoreReceiver(&pending_stream_client_),
std::move(create_delegate_callback),
base::BindOnce(&AudioInputStreamHandle::OnCreated,
base::Unretained(this)),
......@@ -65,7 +64,7 @@ void AudioInputStreamHandle::OnCreated(
DCHECK(deleter_callback_)
<< "|deleter_callback_| was called, but |this| hasn't been destructed!";
client_remote_->StreamCreated(
std::move(pending_stream_), std::move(stream_client_request_),
std::move(pending_stream_), std::move(pending_stream_client_),
std::move(data_pipe), initially_muted, stream_id_);
}
......
......@@ -13,6 +13,7 @@
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "media/mojo/services/mojo_audio_input_stream.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/buffer.h"
......@@ -50,7 +51,8 @@ class CONTENT_EXPORT AudioInputStreamHandle {
DeleterCallback deleter_callback_;
mojo::Remote<mojom::RendererAudioInputStreamFactoryClient> client_remote_;
mojo::PendingRemote<media::mojom::AudioInputStream> pending_stream_;
media::mojom::AudioInputStreamClientRequest stream_client_request_;
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
pending_stream_client_;
media::MojoAudioInputStream stream_;
DISALLOW_COPY_AND_ASSIGN(AudioInputStreamHandle);
......
......@@ -50,19 +50,20 @@ class MockRendererAudioInputStreamFactoryClient
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> input_stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {
EXPECT_TRUE(stream_id.has_value());
input_stream_.Bind(std::move(input_stream));
client_request_ = std::move(client_request);
client_receiver_ = std::move(client_receiver);
Created();
}
private:
mojo::Remote<media::mojom::AudioInputStream> input_stream_;
media::mojom::AudioInputStreamClientRequest client_request_;
mojo::PendingReceiver<media::mojom::AudioInputStreamClient> client_receiver_;
};
using MockDeleter =
......
......@@ -81,7 +81,8 @@ class MockRendererAudioInputStreamFactoryClient
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> input_stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {
......
......@@ -145,7 +145,8 @@ class MAYBE_RenderFrameAudioInputStreamFactoryTest
public:
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override {}
......
......@@ -45,7 +45,7 @@ interface RendererAudioInputStreamFactoryClient {
// fresh stream.
StreamCreated(
pending_remote<media.mojom.AudioInputStream> stream,
media.mojom.AudioInputStreamClient& client_request,
pending_receiver<media.mojom.AudioInputStreamClient> client_request,
media.mojom.ReadOnlyAudioDataPipe data_pipe,
bool initially_muted,
mojo_base.mojom.UnguessableToken? stream_id);
......
......@@ -32,7 +32,8 @@ class CONTENT_EXPORT AudioLoopbackStreamCreator {
// The callback that is called when the requested stream is created.
using StreamCreatedCallback = base::RepeatingCallback<void(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe)>;
// Creates an InProcessAudioLoopbackStreamCreator that handles creating audio
......
......@@ -21,8 +21,7 @@ MojoAudioInputIPC::MojoAudioInputIPC(
StreamAssociatorCB stream_associator)
: source_params_(source_params),
stream_creator_(std::move(stream_creator)),
stream_associator_(std::move(stream_associator)),
stream_client_binding_(this) {
stream_associator_(std::move(stream_associator)) {
DETACH_FROM_SEQUENCE(sequence_checker_);
DCHECK(stream_creator_);
DCHECK(stream_associator_);
......@@ -82,10 +81,8 @@ media::AudioProcessorControls* MojoAudioInputIPC::GetProcessorControls() {
void MojoAudioInputIPC::CloseStream() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
delegate_ = nullptr;
if (factory_client_receiver_.is_bound())
factory_client_receiver_.reset();
if (stream_client_binding_.is_bound())
stream_client_binding_.Unbind();
factory_client_receiver_.reset();
stream_client_receiver_.reset();
stream_.reset();
processor_controls_.reset();
}
......@@ -110,20 +107,21 @@ void MojoAudioInputIPC::StopEchoCancellationDump() {
void MojoAudioInputIPC::StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest stream_client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
stream_client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(delegate_);
DCHECK(!stream_);
DCHECK(!stream_client_binding_.is_bound());
DCHECK(!stream_client_receiver_.is_bound());
UMA_HISTOGRAM_TIMES("Media.Audio.Render.InputDeviceStreamCreationTime",
base::TimeTicks::Now() - stream_creation_start_time_);
stream_.Bind(std::move(stream));
stream_client_binding_.Bind(std::move(stream_client_request));
stream_client_receiver_.Bind(std::move(stream_client_receiver));
// Keep the stream_id, if we get one. Regular input stream have stream ids,
// but Loopback streams do not.
......
......@@ -18,7 +18,6 @@
#include "media/audio/audio_source_parameters.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "media/webrtc/audio_processor_controls.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
......@@ -77,7 +76,8 @@ class CONTENT_EXPORT MojoAudioInputIPC
private:
void StreamCreated(
mojo::PendingRemote<media::mojom::AudioInputStream> stream,
media::mojom::AudioInputStreamClientRequest stream_client_request,
mojo::PendingReceiver<media::mojom::AudioInputStreamClient>
stream_client_receiver,
media::mojom::ReadOnlyAudioDataPipePtr data_pipe,
bool initially_muted,
const base::Optional<base::UnguessableToken>& stream_id) override;
......@@ -95,7 +95,7 @@ class CONTENT_EXPORT MojoAudioInputIPC
mojo::Remote<audio::mojom::AudioProcessorControls> processor_controls_;
// Initialized on StreamCreated.
base::Optional<base::UnguessableToken> stream_id_;
mojo::Binding<AudioInputStreamClient> stream_client_binding_;
mojo::Receiver<AudioInputStreamClient> stream_client_receiver_{this};
mojo::Receiver<RendererAudioInputStreamFactoryClient>
factory_client_receiver_{this};
media::AudioInputIPCDelegate* delegate_ = nullptr;
......
......@@ -101,7 +101,7 @@ class FakeStreamCreator {
base::CancelableSyncSocket::CreatePair(&socket_, &foreign_socket));
factory_client_->StreamCreated(
receiver_.BindNewPipeAndPassRemote(),
mojo::MakeRequest(&stream_client_),
stream_client_.BindNewPipeAndPassReceiver(),
{base::in_place,
base::ReadOnlySharedMemoryRegion::Create(kMemoryLength).region,
mojo::WrapPlatformFile(foreign_socket.Release())},
......@@ -114,6 +114,7 @@ class FakeStreamCreator {
}
void Rearm() {
stream_client_.reset();
receiver_.reset();
socket_.Close();
}
......@@ -125,7 +126,7 @@ class FakeStreamCreator {
private:
media::mojom::AudioInputStream* stream_;
media::mojom::AudioInputStreamClientPtr stream_client_;
mojo::Remote<media::mojom::AudioInputStreamClient> stream_client_;
mojo::Remote<mojom::RendererAudioInputStreamFactoryClient> factory_client_;
mojo::Receiver<media::mojom::AudioInputStream> receiver_;
bool initially_muted_;
......
......@@ -17,7 +17,7 @@ namespace media {
MojoAudioInputStream::MojoAudioInputStream(
mojo::PendingReceiver<mojom::AudioInputStream> receiver,
mojom::AudioInputStreamClientPtr client,
mojo::PendingRemote<mojom::AudioInputStreamClient> client,
CreateDelegateCallback create_delegate_callback,
StreamCreatedCallback stream_created_callback,
base::OnceClosure deleter_callback)
......@@ -31,7 +31,7 @@ MojoAudioInputStream::MojoAudioInputStream(
// |this| owns |receiver_|, so unretained is safe.
receiver_.set_disconnect_handler(
base::BindOnce(&MojoAudioInputStream::OnError, base::Unretained(this)));
client_.set_connection_error_handler(
client_.set_disconnect_handler(
base::BindOnce(&MojoAudioInputStream::OnError, base::Unretained(this)));
delegate_ = std::move(create_delegate_callback).Run(this);
if (!delegate_) {
......
......@@ -14,7 +14,9 @@
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media {
......@@ -35,11 +37,12 @@ class MEDIA_MOJO_EXPORT MojoAudioInputStream
// stream has been initialized. |deleter_callback| is called when this class
// should be removed (stream ended/error). |deleter_callback| is required to
// destroy |this| synchronously.
MojoAudioInputStream(mojo::PendingReceiver<mojom::AudioInputStream> receiver,
mojom::AudioInputStreamClientPtr client,
CreateDelegateCallback create_delegate_callback,
StreamCreatedCallback stream_created_callback,
base::OnceClosure deleter_callback);
MojoAudioInputStream(
mojo::PendingReceiver<mojom::AudioInputStream> receiver,
mojo::PendingRemote<mojom::AudioInputStreamClient> client,
CreateDelegateCallback create_delegate_callback,
StreamCreatedCallback stream_created_callback,
base::OnceClosure deleter_callback);
~MojoAudioInputStream() override;
......@@ -67,7 +70,7 @@ class MEDIA_MOJO_EXPORT MojoAudioInputStream
StreamCreatedCallback stream_created_callback_;
base::OnceClosure deleter_callback_;
mojo::Receiver<AudioInputStream> receiver_;
mojom::AudioInputStreamClientPtr client_;
mojo::Remote<mojom::AudioInputStreamClient> client_;
std::unique_ptr<AudioInputDelegate> delegate_;
base::WeakPtrFactory<MojoAudioInputStream> weak_factory_{this};
......
......@@ -12,7 +12,7 @@
#include "base/sync_socket.h"
#include "base/test/task_environment.h"
#include "media/audio/audio_input_controller.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -145,13 +145,14 @@ class MojoAudioInputStreamTest : public Test {
public:
MojoAudioInputStreamTest()
: foreign_socket_(std::make_unique<TestCancelableSyncSocket>()),
client_binding_(&client_, mojo::MakeRequest(&client_ptr_)) {}
client_receiver_(&client_) {}
mojo::Remote<mojom::AudioInputStream> CreateAudioInput() {
mojo::Remote<mojom::AudioInputStream> stream;
ExpectDelegateCreation();
impl_ = std::make_unique<MojoAudioInputStream>(
stream.BindNewPipeAndPassReceiver(), std::move(client_ptr_),
stream.BindNewPipeAndPassReceiver(),
client_receiver_.BindNewPipeAndPassRemote(),
base::BindOnce(&MockDelegateFactory::CreateDelegate,
base::Unretained(&mock_delegate_factory_)),
base::BindOnce(&MockClient::Initialized, base::Unretained(&client_)),
......@@ -182,8 +183,7 @@ class MojoAudioInputStreamTest : public Test {
StrictMock<MockDelegateFactory> mock_delegate_factory_;
StrictMock<MockDeleter> deleter_;
StrictMock<MockClient> client_;
media::mojom::AudioInputStreamClientPtr client_ptr_;
mojo::Binding<media::mojom::AudioInputStreamClient> client_binding_;
mojo::Receiver<media::mojom::AudioInputStreamClient> client_receiver_;
std::unique_ptr<MojoAudioInputStream> impl_;
DISALLOW_COPY_AND_ASSIGN(MojoAudioInputStreamTest);
......@@ -194,7 +194,8 @@ TEST_F(MojoAudioInputStreamTest, NoDelegate_SignalsError) {
EXPECT_CALL(client_, OnError());
mojo::Remote<mojom::AudioInputStream> stream_remote;
MojoAudioInputStream stream(
stream_remote.BindNewPipeAndPassReceiver(), std::move(client_ptr_),
stream_remote.BindNewPipeAndPassReceiver(),
client_receiver_.BindNewPipeAndPassRemote(),
base::BindOnce(&CreateNoDelegate), base::BindOnce(&NotCalled),
base::BindOnce([](bool* p) { *p = true; }, &deleter_called));
EXPECT_FALSE(deleter_called)
......
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