1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/mojo/services/media_service.h"
7 #include "base/check.h"
8 #include "base/functional/bind.h"
9 #include "media/media_buildflags.h"
10 #include "media/mojo/mojom/interface_factory.mojom.h"
11 #include "media/mojo/services/interface_factory_impl.h"
12 #include "media/mojo/services/mojo_media_client.h"
16 MediaService::MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client,
17 mojo::PendingReceiver<mojom::MediaService> receiver)
18 : receiver_(this, std::move(receiver)),
19 mojo_media_client_(std::move(mojo_media_client)) {
20 DCHECK(mojo_media_client_);
21 mojo_media_client_->Initialize();
24 MediaService::~MediaService() = default;
26 void MediaService::CreateInterfaceFactory(
27 mojo::PendingReceiver<mojom::InterfaceFactory> receiver,
28 mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) {
29 // Ignore request if service has already stopped.
30 if (!mojo_media_client_)
33 interface_factory_receivers_.Add(
34 std::make_unique<InterfaceFactoryImpl>(std::move(frame_interfaces),
35 mojo_media_client_.get()),