[M120 Migration][MM][CAPI] Fix the logic for media using capi player.
[platform/framework/web/chromium-efl.git] / media / mojo / services / media_service.h
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 #ifndef MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_
7
8 #include <memory>
9
10 #include "build/build_config.h"
11 #include "media/mojo/mojom/frame_interface_factory.mojom.h"
12 #include "media/mojo/mojom/interface_factory.mojom.h"
13 #include "media/mojo/mojom/media_service.mojom.h"
14 #include "media/mojo/services/deferred_destroy_unique_receiver_set.h"
15 #include "media/mojo/services/media_mojo_export.h"
16 #include "mojo/public/cpp/bindings/pending_receiver.h"
17 #include "mojo/public/cpp/bindings/pending_remote.h"
18 #include "mojo/public/cpp/bindings/receiver.h"
19
20 namespace media {
21
22 class MojoMediaClient;
23
24 class MEDIA_MOJO_EXPORT MediaService final : public mojom::MediaService {
25  public:
26   MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client,
27                mojo::PendingReceiver<mojom::MediaService> receiver);
28
29   MediaService(const MediaService&) = delete;
30   MediaService& operator=(const MediaService&) = delete;
31
32   ~MediaService() final;
33
34  private:
35   void Create(mojo::PendingReceiver<mojom::MediaService> receiver);
36
37   // mojom::MediaService implementation:
38   void CreateInterfaceFactory(
39       mojo::PendingReceiver<mojom::InterfaceFactory> receiver,
40       mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) final;
41
42   mojo::Receiver<mojom::MediaService> receiver_;
43
44   // Note: Since each instance runs on a different thread, do not share a common
45   // MojoMediaClient with other instances to avoid threading issues. Hence using
46   // a unique_ptr here.
47   //
48   // Note: Since |*ref_factory_| is passed to |mojo_media_client_|,
49   // |mojo_media_client_| must be destructed before |ref_factory_|.
50   std::unique_ptr<MojoMediaClient> mojo_media_client_;
51
52   DeferredDestroyUniqueReceiverSet<mojom::InterfaceFactory>
53       interface_factory_receivers_;
54 };
55
56 }  // namespace media
57
58 #endif  // MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_