Migrate references of media::mojom::AudioOutputStreamProviderClient
Convert both the implementation and clients in the browser and renderer processes for the media.mojom.AudioOutputStreamProviderClient interface, and adapt unit tests. Bug: 955171 Change-Id: I8791ab3d52f134d7ec29ea9703709641e40edc16 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803286 Commit-Queue: Mario Sanchez Prada <mario@igalia.com> Reviewed-by: Yuri Wiitala <miu@chromium.org> Reviewed-by: Tommi <tommi@chromium.org> Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org> Reviewed-by: Dominick Ng <dominickn@chromium.org> Cr-Commit-Position: refs/heads/master@{#698426}
This commit is contained in:

committed by
Commit Bot

parent
082c18e504
commit
93a282d83e
@ -69,7 +69,7 @@ AudioOutputStreamBroker::AudioOutputStreamBroker(
|
||||
const base::UnguessableToken& group_id,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
DeleterCallback deleter,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client)
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client)
|
||||
: AudioStreamBroker(render_process_id, render_frame_id),
|
||||
output_device_id_(output_device_id),
|
||||
params_(params),
|
||||
@ -92,7 +92,7 @@ AudioOutputStreamBroker::AudioOutputStreamBroker(
|
||||
media_observer->OnCreatingAudioStream(render_process_id, render_frame_id);
|
||||
|
||||
// Unretained is safe because |this| owns |client_|
|
||||
client_.set_connection_error_handler(
|
||||
client_.set_disconnect_handler(
|
||||
base::BindOnce(&AudioOutputStreamBroker::Cleanup, base::Unretained(this),
|
||||
DisconnectReason::kTerminatedByClient));
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "media/mojo/mojom/audio_output_stream.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/audio/public/mojom/stream_factory.mojom.h"
|
||||
|
||||
namespace content {
|
||||
@ -37,7 +38,8 @@ class CONTENT_EXPORT AudioOutputStreamBroker final : public AudioStreamBroker {
|
||||
const base::UnguessableToken& group_id,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
DeleterCallback deleter,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
client);
|
||||
|
||||
~AudioOutputStreamBroker() final;
|
||||
|
||||
@ -67,7 +69,7 @@ class CONTENT_EXPORT AudioOutputStreamBroker final : public AudioStreamBroker {
|
||||
|
||||
DeleterCallback deleter_;
|
||||
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client_;
|
||||
mojo::Remote<media::mojom::AudioOutputStreamProviderClient> client_;
|
||||
|
||||
AudioOutputStreamObserverImpl observer_;
|
||||
mojo::AssociatedReceiver<media::mojom::AudioOutputStreamObserver>
|
||||
|
@ -17,10 +17,9 @@
|
||||
#include "media/base/audio_parameters.h"
|
||||
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
|
||||
#include "media/mojo/mojom/audio_output_stream.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.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"
|
||||
#include "mojo/public/cpp/system/buffer.h"
|
||||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
@ -53,7 +52,7 @@ using MockDeleterCallback = StrictMock<
|
||||
class MockAudioOutputStreamProviderClient
|
||||
: public media::mojom::AudioOutputStreamProviderClient {
|
||||
public:
|
||||
MockAudioOutputStreamProviderClient() : binding_(this) {}
|
||||
MockAudioOutputStreamProviderClient() = default;
|
||||
~MockAudioOutputStreamProviderClient() override {}
|
||||
|
||||
void Created(mojo::PendingRemote<media::mojom::AudioOutputStream>,
|
||||
@ -65,19 +64,21 @@ class MockAudioOutputStreamProviderClient
|
||||
|
||||
MOCK_METHOD2(ConnectionError, void(uint32_t, const std::string&));
|
||||
|
||||
media::mojom::AudioOutputStreamProviderClientPtr MakePtr() {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr ptr;
|
||||
binding_.Bind(mojo::MakeRequest(&ptr));
|
||||
binding_.set_connection_error_with_reason_handler(
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
MakePendingRemote() {
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
pending_remote;
|
||||
receiver_.Bind(pending_remote.InitWithNewPipeAndPassReceiver());
|
||||
receiver_.set_disconnect_with_reason_handler(
|
||||
base::BindOnce(&MockAudioOutputStreamProviderClient::ConnectionError,
|
||||
base::Unretained(this)));
|
||||
return ptr;
|
||||
return pending_remote;
|
||||
}
|
||||
|
||||
void CloseBinding() { binding_.Close(); }
|
||||
void CloseReceiver() { receiver_.reset(); }
|
||||
|
||||
private:
|
||||
mojo::Binding<media::mojom::AudioOutputStreamProviderClient> binding_;
|
||||
mojo::Receiver<media::mojom::AudioOutputStreamProviderClient> receiver_{this};
|
||||
DISALLOW_COPY_AND_ASSIGN(MockAudioOutputStreamProviderClient);
|
||||
};
|
||||
|
||||
@ -151,7 +152,7 @@ struct TestEnvironment {
|
||||
group,
|
||||
base::nullopt,
|
||||
deleter.Get(),
|
||||
provider_client.MakePtr())) {}
|
||||
provider_client.MakePendingRemote())) {}
|
||||
|
||||
void RunUntilIdle() { env.RunUntilIdle(); }
|
||||
|
||||
@ -175,7 +176,7 @@ TEST(AudioOutputStreamBrokerTest, StoresProcessAndFrameId) {
|
||||
AudioOutputStreamBroker broker(
|
||||
kRenderProcessId, kRenderFrameId, kStreamId, kDeviceId, TestParams(),
|
||||
base::UnguessableToken::Create(), base::nullopt, deleter.Get(),
|
||||
provider_client.MakePtr());
|
||||
provider_client.MakePendingRemote());
|
||||
|
||||
EXPECT_EQ(kRenderProcessId, broker.render_process_id());
|
||||
EXPECT_EQ(kRenderFrameId, broker.render_frame_id());
|
||||
@ -186,7 +187,7 @@ TEST(AudioOutputStreamBrokerTest, ClientDisconnect_CallsDeleter) {
|
||||
|
||||
EXPECT_CALL(env.deleter, Run(env.broker.release()))
|
||||
.WillOnce(testing::DeleteArg<0>());
|
||||
env.provider_client.CloseBinding();
|
||||
env.provider_client.CloseReceiver();
|
||||
env.RunUntilIdle();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,8 @@ class AudioStreamBrokerFactoryImpl final : public AudioStreamBrokerFactory {
|
||||
const base::UnguessableToken& group_id,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
AudioStreamBroker::DeleterCallback deleter,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client) final {
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client)
|
||||
final {
|
||||
return std::make_unique<AudioOutputStreamBroker>(
|
||||
render_process_id, render_frame_id, stream_id, output_device_id, params,
|
||||
group_id, processing_id, std::move(deleter), std::move(client));
|
||||
|
@ -131,7 +131,8 @@ class CONTENT_EXPORT AudioStreamBrokerFactory {
|
||||
const base::UnguessableToken& group_id,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
AudioStreamBroker::DeleterCallback deleter,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client) = 0;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
client) = 0;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioStreamBrokerFactory);
|
||||
|
@ -96,7 +96,7 @@ void ForwardingAudioStreamFactory::Core::CreateOutputStream(
|
||||
const std::string& device_id,
|
||||
const media::AudioParameters& params,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client) {
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
|
||||
// |this| owns |outputs_|, so Unretained is safe.
|
||||
|
@ -98,7 +98,8 @@ class CONTENT_EXPORT ForwardingAudioStreamFactory final
|
||||
const std::string& device_id,
|
||||
const media::AudioParameters& params,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
client);
|
||||
|
||||
void CreateLoopbackStream(
|
||||
int render_process_id,
|
||||
|
@ -133,7 +133,8 @@ class MockBrokerFactory : public AudioStreamBrokerFactory {
|
||||
const base::UnguessableToken& group_id,
|
||||
const base::Optional<base::UnguessableToken>& processing_id,
|
||||
AudioStreamBroker::DeleterCallback deleter,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client) final {
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client)
|
||||
final {
|
||||
std::unique_ptr<MockBroker> prepared_broker =
|
||||
std::move(prepared_output_stream_brokers_.front());
|
||||
prepared_output_stream_brokers_.pop();
|
||||
@ -306,7 +307,7 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
CreateOutputStream_CreatesOutputStream) {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
base::WeakPtr<MockBroker> broker = ExpectOutputBrokerConstruction(main_rfh());
|
||||
|
||||
ForwardingAudioStreamFactory factory(
|
||||
@ -314,7 +315,7 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
std::move(broker_factory_));
|
||||
|
||||
EXPECT_CALL(*broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -406,7 +407,6 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
OutputBrokerDeleterCalled_DestroysOutputStream) {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
base::WeakPtr<MockBroker> main_rfh_broker =
|
||||
ExpectOutputBrokerConstruction(main_rfh());
|
||||
base::WeakPtr<MockBroker> other_rfh_broker =
|
||||
@ -418,7 +418,8 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
{
|
||||
EXPECT_CALL(*main_rfh_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -426,7 +427,8 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
}
|
||||
{
|
||||
EXPECT_CALL(*other_rfh_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
other_rfh()->GetProcess()->GetID(), other_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -452,7 +454,6 @@ TEST_F(ForwardingAudioStreamFactoryTest, DestroyFrame_DestroysRelatedStreams) {
|
||||
base::WeakPtr<MockBroker> other_rfh_loopback_broker =
|
||||
ExpectLoopbackBrokerConstruction(other_rfh());
|
||||
|
||||
media::mojom::AudioOutputStreamProviderClientPtr output_client;
|
||||
base::WeakPtr<MockBroker> main_rfh_output_broker =
|
||||
ExpectOutputBrokerConstruction(main_rfh());
|
||||
base::WeakPtr<MockBroker> other_rfh_output_broker =
|
||||
@ -517,7 +518,9 @@ TEST_F(ForwardingAudioStreamFactoryTest, DestroyFrame_DestroysRelatedStreams) {
|
||||
|
||||
{
|
||||
EXPECT_CALL(*main_rfh_output_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&output_client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
output_client;
|
||||
ignore_result(output_client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(output_client));
|
||||
@ -525,7 +528,9 @@ TEST_F(ForwardingAudioStreamFactoryTest, DestroyFrame_DestroysRelatedStreams) {
|
||||
}
|
||||
{
|
||||
EXPECT_CALL(*other_rfh_output_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&output_client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
output_client;
|
||||
ignore_result(output_client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
other_rfh()->GetProcess()->GetID(), other_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(output_client));
|
||||
@ -552,7 +557,8 @@ TEST_F(ForwardingAudioStreamFactoryTest, DestroyWebContents_DestroysStreams) {
|
||||
base::WeakPtr<MockBroker> input_broker =
|
||||
ExpectInputBrokerConstruction(main_rfh());
|
||||
|
||||
media::mojom::AudioOutputStreamProviderClientPtr output_client;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
output_client;
|
||||
base::WeakPtr<MockBroker> output_broker =
|
||||
ExpectOutputBrokerConstruction(main_rfh());
|
||||
|
||||
@ -568,7 +574,7 @@ TEST_F(ForwardingAudioStreamFactoryTest, DestroyWebContents_DestroysStreams) {
|
||||
nullptr, std::move(input_client));
|
||||
|
||||
EXPECT_CALL(*output_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&output_client);
|
||||
ignore_result(output_client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(output_client));
|
||||
@ -588,7 +594,6 @@ TEST_F(ForwardingAudioStreamFactoryTest, LastStreamDeleted_ClearsFactoryPtr) {
|
||||
base::WeakPtr<MockBroker> other_rfh_input_broker =
|
||||
ExpectInputBrokerConstruction(other_rfh());
|
||||
|
||||
media::mojom::AudioOutputStreamProviderClientPtr output_client;
|
||||
base::WeakPtr<MockBroker> main_rfh_output_broker =
|
||||
ExpectOutputBrokerConstruction(main_rfh());
|
||||
base::WeakPtr<MockBroker> other_rfh_output_broker =
|
||||
@ -623,7 +628,9 @@ TEST_F(ForwardingAudioStreamFactoryTest, LastStreamDeleted_ClearsFactoryPtr) {
|
||||
|
||||
{
|
||||
EXPECT_CALL(*main_rfh_output_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&output_client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
output_client;
|
||||
ignore_result(output_client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(output_client));
|
||||
@ -631,7 +638,9 @@ TEST_F(ForwardingAudioStreamFactoryTest, LastStreamDeleted_ClearsFactoryPtr) {
|
||||
}
|
||||
{
|
||||
EXPECT_CALL(*other_rfh_output_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&output_client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
output_client;
|
||||
ignore_result(output_client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
other_rfh()->GetProcess()->GetID(), other_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(output_client));
|
||||
@ -680,14 +689,14 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
}
|
||||
|
||||
TEST_F(ForwardingAudioStreamFactoryTest, MuteWithOutputStream_ConnectsMuter) {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
base::WeakPtr<MockBroker> broker = ExpectOutputBrokerConstruction(main_rfh());
|
||||
ForwardingAudioStreamFactory factory(
|
||||
web_contents(), nullptr /*user_input_monitor*/, std::move(connector_),
|
||||
std::move(broker_factory_));
|
||||
|
||||
EXPECT_CALL(*broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -712,7 +721,7 @@ TEST_F(ForwardingAudioStreamFactoryTest, MuteWithOutputStream_ConnectsMuter) {
|
||||
|
||||
TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
WhenMuting_ConnectedWhenOutputStreamExists) {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
base::WeakPtr<MockBroker> broker = ExpectOutputBrokerConstruction(main_rfh());
|
||||
ForwardingAudioStreamFactory factory(
|
||||
web_contents(), nullptr /*user_input_monitor*/, std::move(connector_),
|
||||
@ -728,7 +737,7 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
EXPECT_FALSE(stream_factory_.IsMuterConnected());
|
||||
|
||||
EXPECT_CALL(*broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -748,7 +757,6 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
WhenMuting_AddRemoveSecondStream_DoesNotChangeMuting) {
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
base::WeakPtr<MockBroker> broker = ExpectOutputBrokerConstruction(main_rfh());
|
||||
base::WeakPtr<MockBroker> another_broker =
|
||||
ExpectOutputBrokerConstruction(main_rfh());
|
||||
@ -758,7 +766,8 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
{
|
||||
EXPECT_CALL(*broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
@ -776,7 +785,8 @@ TEST_F(ForwardingAudioStreamFactoryTest,
|
||||
|
||||
{
|
||||
EXPECT_CALL(*another_broker, CreateStream(NotNull()));
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
factory.core()->CreateOutputStream(
|
||||
main_rfh()->GetProcess()->GetID(), main_rfh()->GetRoutingID(),
|
||||
kOutputDeviceId, kParams, base::nullopt, std::move(client));
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "content/public/test/test_browser_context.h"
|
||||
#include "media/base/audio_parameters.h"
|
||||
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
@ -32,12 +31,6 @@ namespace content {
|
||||
namespace {
|
||||
|
||||
using testing::Test;
|
||||
using AudioOutputStreamProviderClient =
|
||||
media::mojom::AudioOutputStreamProviderClient;
|
||||
using AudioOutputStreamProviderClientPtr =
|
||||
mojo::InterfacePtr<AudioOutputStreamProviderClient>;
|
||||
using AudioOutputStreamProviderClientRequest =
|
||||
mojo::InterfaceRequest<AudioOutputStreamProviderClient>;
|
||||
|
||||
const int kStreamId = 0;
|
||||
const int kRenderProcessId = 42;
|
||||
@ -158,15 +151,14 @@ class MockContext : public RendererAudioOutputStreamFactoryContext {
|
||||
DISALLOW_COPY_AND_ASSIGN(MockContext);
|
||||
};
|
||||
|
||||
class MockClient : public AudioOutputStreamProviderClient {
|
||||
class MockClient : public media::mojom::AudioOutputStreamProviderClient {
|
||||
public:
|
||||
MockClient() : provider_client_binding_(this) {}
|
||||
MockClient() = default;
|
||||
~MockClient() override {}
|
||||
|
||||
AudioOutputStreamProviderClientPtr MakeProviderClientPtr() {
|
||||
AudioOutputStreamProviderClientPtr p;
|
||||
provider_client_binding_.Bind(mojo::MakeRequest(&p));
|
||||
return p;
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
MakeProviderClientPendingRemote() {
|
||||
return provider_client_receiver_.BindNewPipeAndPassRemote();
|
||||
}
|
||||
|
||||
void Created(mojo::PendingRemote<media::mojom::AudioOutputStream> stream,
|
||||
@ -181,7 +173,8 @@ class MockClient : public AudioOutputStreamProviderClient {
|
||||
MOCK_METHOD0(OnError, void());
|
||||
|
||||
private:
|
||||
mojo::Binding<AudioOutputStreamProviderClient> provider_client_binding_;
|
||||
mojo::Receiver<media::mojom::AudioOutputStreamProviderClient>
|
||||
provider_client_receiver_{this};
|
||||
mojo::Remote<media::mojom::AudioOutputStream> stream_;
|
||||
bool was_called_ = false;
|
||||
|
||||
@ -232,7 +225,7 @@ TEST(OldRenderFrameAudioOutputStreamFactoryTest, CreateStream) {
|
||||
// Ensure that we don't blow up getting a processing ID, despite not using it.
|
||||
const base::UnguessableToken kUnusedProcessingId =
|
||||
base::UnguessableToken::Create();
|
||||
provider->Acquire(params, client.MakeProviderClientPtr(),
|
||||
provider->Acquire(params, client.MakeProviderClientPendingRemote(),
|
||||
kUnusedProcessingId);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_NE(event_handler, nullptr);
|
||||
@ -295,8 +288,8 @@ TEST(OldRenderFrameAudioOutputStreamFactoryTest,
|
||||
const std::string& id) {}));
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
provider->Acquire(GetTestAudioParameters(), client.MakeProviderClientPtr(),
|
||||
base::nullopt);
|
||||
provider->Acquire(GetTestAudioParameters(),
|
||||
client.MakeProviderClientPendingRemote(), base::nullopt);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_NE(event_handler, nullptr);
|
||||
EXPECT_FALSE(delegate_is_destructed);
|
||||
@ -327,8 +320,8 @@ TEST(OldRenderFrameAudioOutputStreamFactoryTest, DelegateError_DeletesStream) {
|
||||
const std::string& id) {}));
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
provider->Acquire(GetTestAudioParameters(), client.MakeProviderClientPtr(),
|
||||
base::nullopt);
|
||||
provider->Acquire(GetTestAudioParameters(),
|
||||
client.MakeProviderClientPendingRemote(), base::nullopt);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
ASSERT_NE(event_handler, nullptr);
|
||||
EXPECT_FALSE(delegate_is_destructed);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "media/base/output_device_info.h"
|
||||
#include "media/mojo/mojom/audio_output_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"
|
||||
|
||||
namespace content {
|
||||
@ -72,7 +73,8 @@ class RenderFrameAudioOutputStreamFactory::Core final
|
||||
|
||||
void Acquire(
|
||||
const media::AudioParameters& params,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr provider_client,
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
provider_client,
|
||||
const base::Optional<base::UnguessableToken>& processing_id) final {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
TRACE_EVENT1("audio",
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "media/audio/test_audio_thread.h"
|
||||
#include "media/base/audio_parameters.h"
|
||||
#include "media/mojo/mojom/audio_output_stream.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.h"
|
||||
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
@ -221,8 +220,8 @@ TEST_F(RenderFrameAudioOutputStreamFactoryTest,
|
||||
provider_remote.BindNewPipeAndPassReceiver(), base::nullopt,
|
||||
kDefaultDeviceId, mock_callback.Get());
|
||||
{
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
provider_remote->Acquire(kParams, std::move(client), base::nullopt);
|
||||
}
|
||||
|
||||
@ -258,8 +257,8 @@ TEST_F(RenderFrameAudioOutputStreamFactoryTest,
|
||||
}
|
||||
// Now factory is destructed. Trying to create a stream should fail.
|
||||
{
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
provider_remote->Acquire(kParams, std::move(client), base::nullopt);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ MojoAudioOutputIPC::MojoAudioOutputIPC(
|
||||
FactoryAccessorCB factory_accessor,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
|
||||
: factory_accessor_(std::move(factory_accessor)),
|
||||
binding_(this),
|
||||
io_task_runner_(std::move(io_task_runner)) {}
|
||||
|
||||
MojoAudioOutputIPC::~MojoAudioOutputIPC() {
|
||||
@ -82,16 +81,17 @@ void MojoAudioOutputIPC::CreateStream(
|
||||
}
|
||||
|
||||
DCHECK_EQ(delegate_, delegate);
|
||||
// Since the creation callback won't fire if the provider binding is gone
|
||||
// Since the creation callback won't fire if the provider receiver is gone
|
||||
// and |this| owns |stream_provider_|, unretained is safe.
|
||||
stream_creation_start_time_ = base::TimeTicks::Now();
|
||||
media::mojom::AudioOutputStreamProviderClientPtr client_ptr;
|
||||
binding_.Bind(mojo::MakeRequest(&client_ptr));
|
||||
// Unretained is safe because |this| owns |binding_|.
|
||||
binding_.set_connection_error_with_reason_handler(
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
client_remote;
|
||||
receiver_.Bind(client_remote.InitWithNewPipeAndPassReceiver());
|
||||
// Unretained is safe because |this| owns |receiver_|.
|
||||
receiver_.set_disconnect_with_reason_handler(
|
||||
base::BindOnce(&MojoAudioOutputIPC::ProviderClientBindingDisconnected,
|
||||
base::Unretained(this)));
|
||||
stream_provider_->Acquire(params, std::move(client_ptr), processing_id);
|
||||
stream_provider_->Acquire(params, std::move(client_remote), processing_id);
|
||||
}
|
||||
|
||||
void MojoAudioOutputIPC::PlayStream() {
|
||||
@ -118,7 +118,7 @@ void MojoAudioOutputIPC::CloseStream() {
|
||||
DCHECK(io_task_runner_->RunsTasksInCurrentSequence());
|
||||
stream_provider_.reset();
|
||||
stream_.reset();
|
||||
binding_.Close();
|
||||
receiver_.reset();
|
||||
delegate_ = nullptr;
|
||||
expected_state_ = kPaused;
|
||||
volume_ = base::nullopt;
|
||||
@ -155,7 +155,7 @@ bool MojoAudioOutputIPC::AuthorizationRequested() const {
|
||||
}
|
||||
|
||||
bool MojoAudioOutputIPC::StreamCreationRequested() const {
|
||||
return binding_.is_bound();
|
||||
return receiver_.is_bound();
|
||||
}
|
||||
|
||||
mojo::PendingReceiver<media::mojom::AudioOutputStreamProvider>
|
||||
|
@ -18,9 +18,9 @@
|
||||
#include "media/audio/audio_output_ipc.h"
|
||||
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
|
||||
#include "media/mojo/mojom/audio_output_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"
|
||||
|
||||
namespace content {
|
||||
@ -95,7 +95,7 @@ class CONTENT_EXPORT MojoAudioOutputIPC
|
||||
enum { kPaused, kPlaying } expected_state_ = kPaused;
|
||||
base::Optional<double> volume_;
|
||||
|
||||
mojo::Binding<media::mojom::AudioOutputStreamProviderClient> binding_;
|
||||
mojo::Receiver<media::mojom::AudioOutputStreamProviderClient> receiver_{this};
|
||||
mojo::Remote<media::mojom::AudioOutputStreamProvider> stream_provider_;
|
||||
mojo::Remote<media::mojom::AudioOutputStream> stream_;
|
||||
media::AudioOutputIPCDelegate* delegate_ = nullptr;
|
||||
|
@ -62,11 +62,13 @@ class TestStreamProvider : public media::mojom::AudioOutputStreamProvider {
|
||||
|
||||
void Acquire(
|
||||
const media::AudioParameters& params,
|
||||
media::mojom::AudioOutputStreamProviderClientPtr provider_client,
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStreamProviderClient>
|
||||
pending_provider_client,
|
||||
const base::Optional<base::UnguessableToken>& processing_id) override {
|
||||
EXPECT_EQ(receiver_, base::nullopt);
|
||||
EXPECT_NE(stream_, nullptr);
|
||||
std::swap(provider_client, provider_client_);
|
||||
provider_client_.reset();
|
||||
provider_client_.Bind(std::move(pending_provider_client));
|
||||
mojo::PendingRemote<media::mojom::AudioOutputStream> stream_pending_remote;
|
||||
receiver_.emplace(stream_,
|
||||
stream_pending_remote.InitWithNewPipeAndPassReceiver());
|
||||
@ -88,7 +90,7 @@ class TestStreamProvider : public media::mojom::AudioOutputStreamProvider {
|
||||
|
||||
private:
|
||||
media::mojom::AudioOutputStream* stream_;
|
||||
media::mojom::AudioOutputStreamProviderClientPtr provider_client_;
|
||||
mojo::Remote<media::mojom::AudioOutputStreamProviderClient> provider_client_;
|
||||
base::Optional<mojo::Receiver<media::mojom::AudioOutputStream>> receiver_;
|
||||
base::CancelableSyncSocket socket_;
|
||||
};
|
||||
|
@ -71,12 +71,11 @@ interface AudioOutputStreamObserver {
|
||||
interface AudioOutputStreamProvider {
|
||||
// Creates a new AudioOutputStream using |params|. |client| is notified when
|
||||
// the stream is ready. The stream lifetime is bound by the lifetime of
|
||||
// |client|. On error, the |client| will have a disconnect reason among the
|
||||
// specified ones in AudioOutputStreamProviderClient. |processing_id|, if
|
||||
// provided, identifies the group of input and output streams that are related
|
||||
// during audio processing.
|
||||
// Can only be called once.
|
||||
Acquire(AudioParameters params, AudioOutputStreamProviderClient client,
|
||||
// |client|. |processing_id|, if provided, identifies the group of input and
|
||||
// output streams that are related during audio processing.
|
||||
// This method fails if it is called more than once.
|
||||
Acquire(AudioParameters params,
|
||||
pending_remote<AudioOutputStreamProviderClient> client,
|
||||
mojo_base.mojom.UnguessableToken? processing_id);
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,7 @@ MojoAudioOutputStreamProvider::~MojoAudioOutputStreamProvider() {
|
||||
|
||||
void MojoAudioOutputStreamProvider::Acquire(
|
||||
const AudioParameters& params,
|
||||
mojom::AudioOutputStreamProviderClientPtr provider_client,
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamProviderClient> provider_client,
|
||||
const base::Optional<base::UnguessableToken>& processing_id) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
// |processing_id| gets dropped here. It's not supported outside of the audio
|
||||
@ -58,7 +58,7 @@ void MojoAudioOutputStreamProvider::Acquire(
|
||||
return;
|
||||
}
|
||||
|
||||
provider_client_ = std::move(provider_client);
|
||||
provider_client_.Bind(std::move(provider_client));
|
||||
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamObserver> pending_observer;
|
||||
observer_receiver_.Bind(pending_observer.InitWithNewPipeAndPassReceiver());
|
||||
|
@ -16,6 +16,7 @@
|
||||
#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 {
|
||||
|
||||
@ -46,7 +47,8 @@ class MEDIA_MOJO_EXPORT MojoAudioOutputStreamProvider
|
||||
// mojom::AudioOutputStreamProvider implementation.
|
||||
void Acquire(
|
||||
const AudioParameters& params,
|
||||
mojom::AudioOutputStreamProviderClientPtr provider_client,
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamProviderClient>
|
||||
provider_client,
|
||||
const base::Optional<base::UnguessableToken>& processing_id) override;
|
||||
|
||||
// Called when |audio_output_| had an error.
|
||||
@ -63,7 +65,7 @@ class MEDIA_MOJO_EXPORT MojoAudioOutputStreamProvider
|
||||
std::unique_ptr<mojom::AudioOutputStreamObserver> observer_;
|
||||
mojo::Receiver<mojom::AudioOutputStreamObserver> observer_receiver_;
|
||||
base::Optional<MojoAudioOutputStream> audio_output_;
|
||||
mojom::AudioOutputStreamProviderClientPtr provider_client_;
|
||||
mojo::Remote<mojom::AudioOutputStreamProviderClient> provider_client_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputStreamProvider);
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "media/audio/audio_output_delegate.h"
|
||||
#include "media/base/audio_parameters.h"
|
||||
#include "mojo/core/embedder/embedder.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -88,13 +89,13 @@ TEST(MojoAudioOutputStreamProviderTest, AcquireTwice_BadMessage) {
|
||||
base::BindOnce(&CreateFakeDelegate), deleter.Get(),
|
||||
std::make_unique<FakeObserver>());
|
||||
|
||||
mojom::AudioOutputStreamProviderClientPtr client_1;
|
||||
mojo::MakeRequest(&client_1);
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamProviderClient> client_1;
|
||||
ignore_result(client_1.InitWithNewPipeAndPassReceiver());
|
||||
provider_remote->Acquire(media::AudioParameters::UnavailableDeviceParams(),
|
||||
std::move(client_1), base::nullopt);
|
||||
|
||||
mojom::AudioOutputStreamProviderClientPtr client_2;
|
||||
mojo::MakeRequest(&client_2);
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamProviderClient> client_2;
|
||||
ignore_result(client_2.InitWithNewPipeAndPassReceiver());
|
||||
provider_remote->Acquire(media::AudioParameters::UnavailableDeviceParams(),
|
||||
std::move(client_2), base::nullopt);
|
||||
|
||||
@ -127,8 +128,8 @@ TEST(MojoAudioOutputStreamProviderTest,
|
||||
base::BindOnce(&CreateFakeDelegate), deleter.Get(),
|
||||
std::make_unique<FakeObserver>());
|
||||
|
||||
mojom::AudioOutputStreamProviderClientPtr client;
|
||||
mojo::MakeRequest(&client);
|
||||
mojo::PendingRemote<mojom::AudioOutputStreamProviderClient> client;
|
||||
ignore_result(client.InitWithNewPipeAndPassReceiver());
|
||||
provider_remote->Acquire(params, std::move(client), base::nullopt);
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
|
Reference in New Issue
Block a user