OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ |
6 #define MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ | 6 #define MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/mojo/interfaces/service_factory.mojom.h" | 10 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 11 #include "media/mojo/interfaces/renderer.mojom.h" |
11 #include "media/mojo/services/mojo_cdm_service_context.h" | 12 #include "media/mojo/services/mojo_cdm_service_context.h" |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/application/public/cpp/interface_factory.h" |
13 | 14 |
14 namespace mojo { | 15 namespace mojo { |
15 class AppRefCount; | 16 class ApplicationImpl; |
16 class ServiceProvider; | 17 class ServiceProvider; |
17 } | 18 } // namespace mojo |
18 | 19 |
19 namespace media { | 20 namespace media { |
20 | 21 |
21 class CdmFactory; | 22 class CdmFactory; |
22 class MediaLog; | 23 class MediaLog; |
23 class MojoMediaClient; | 24 class MojoMediaClient; |
24 class RendererFactory; | 25 class RendererFactory; |
25 | 26 |
26 class ServiceFactoryImpl : public interfaces::ServiceFactory { | 27 class ServiceFactoryImpl |
| 28 : public mojo::InterfaceFactory<interfaces::Renderer>, |
| 29 public mojo::InterfaceFactory<interfaces::ContentDecryptionModule> { |
27 public: | 30 public: |
28 ServiceFactoryImpl(mojo::InterfaceRequest<interfaces::ServiceFactory> request, | 31 ServiceFactoryImpl(scoped_ptr<MojoMediaClient> mojo_media_client, |
29 mojo::ServiceProvider* service_provider, | 32 scoped_refptr<MediaLog> media_log); |
30 scoped_refptr<MediaLog> media_log, | 33 ~ServiceFactoryImpl() override; |
31 scoped_ptr<mojo::AppRefCount> parent_app_refcount, | |
32 MojoMediaClient* mojo_media_client); | |
33 ~ServiceFactoryImpl() final; | |
34 | 34 |
35 // interfaces::ServiceFactory implementation. | 35 void Initialize(mojo::ApplicationImpl* app); |
36 void CreateRenderer( | 36 |
37 mojo::InterfaceRequest<interfaces::Renderer> renderer) final; | 37 // mojo::InterfaceFactory<interfaces::Renderer> implementation. |
38 void CreateCdm( | 38 void Create(mojo::ApplicationConnection* connection, |
39 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> cdm) final; | 39 mojo::InterfaceRequest<interfaces::Renderer> request) final; |
| 40 // mojo::InterfaceFactory<interfaces::ContentDecryptionModule> implementation. |
| 41 void Create(mojo::ApplicationConnection* connection, |
| 42 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> |
| 43 request) final; |
40 | 44 |
41 private: | 45 private: |
| 46 struct ServiceBundle; |
| 47 ServiceBundle* GetOrCreateServiceBundle(const std::string& url); |
| 48 void OnServiceBundleEmpty(const std::string& url); |
| 49 |
42 RendererFactory* GetRendererFactory(); | 50 RendererFactory* GetRendererFactory(); |
43 CdmFactory* GetCdmFactory(); | 51 CdmFactory* GetCdmFactory(mojo::ServiceProvider* service_provider); |
44 | 52 |
45 MojoCdmServiceContext cdm_service_context_; | 53 mojo::ApplicationImpl* app_; |
| 54 scoped_ptr<MojoMediaClient> mojo_media_client_; |
| 55 scoped_refptr<MediaLog> media_log_; |
46 | 56 |
47 mojo::StrongBinding<interfaces::ServiceFactory> binding_; | 57 scoped_ptr<CdmFactory> cdm_factory_; |
48 mojo::ServiceProvider* service_provider_; | |
49 scoped_refptr<MediaLog> media_log_; | |
50 scoped_ptr<mojo::AppRefCount> parent_app_refcount_; | |
51 MojoMediaClient* mojo_media_client_; | |
52 | |
53 scoped_ptr<RendererFactory> renderer_factory_; | 58 scoped_ptr<RendererFactory> renderer_factory_; |
54 scoped_ptr<CdmFactory> cdm_factory_; | 59 std::map<std::string, scoped_ptr<ServiceBundle>> service_bundle_map_; |
55 | 60 |
56 DISALLOW_COPY_AND_ASSIGN(ServiceFactoryImpl); | 61 DISALLOW_COPY_AND_ASSIGN(ServiceFactoryImpl); |
57 }; | 62 }; |
58 | 63 |
59 } // namespace media | 64 } // namespace media |
60 | 65 |
61 #endif // MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ | 66 #endif // MEDIA_MOJO_SERVICES_SERVICE_FACTORY_IMPL_H_ |
OLD | NEW |