[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / media_service.cc
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.
4
5 #include "media/mojo/services/media_service.h"
6
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"
13
14 namespace media {
15
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();
22 }
23
24 MediaService::~MediaService() = default;
25
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_)
31     return;
32
33   interface_factory_receivers_.Add(
34       std::make_unique<InterfaceFactoryImpl>(std::move(frame_interfaces),
35                                              mojo_media_client_.get()),
36       std::move(receiver));
37 }
38
39 }  // namespace media