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 #ifndef MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_
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"
22 class MojoMediaClient;
24 class MEDIA_MOJO_EXPORT MediaService final : public mojom::MediaService {
26 MediaService(std::unique_ptr<MojoMediaClient> mojo_media_client,
27 mojo::PendingReceiver<mojom::MediaService> receiver);
29 MediaService(const MediaService&) = delete;
30 MediaService& operator=(const MediaService&) = delete;
32 ~MediaService() final;
35 void Create(mojo::PendingReceiver<mojom::MediaService> receiver);
37 // mojom::MediaService implementation:
38 void CreateInterfaceFactory(
39 mojo::PendingReceiver<mojom::InterfaceFactory> receiver,
40 mojo::PendingRemote<mojom::FrameInterfaceFactory> frame_interfaces) final;
42 mojo::Receiver<mojom::MediaService> receiver_;
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
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_;
52 DeferredDestroyUniqueReceiverSet<mojom::InterfaceFactory>
53 interface_factory_receivers_;
58 #endif // MEDIA_MOJO_SERVICES_MEDIA_SERVICE_H_