| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MOJO_CDM_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "media/base/media_keys.h" | 13 #include "media/base/media_keys.h" |
| 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 15 #include "media/mojo/services/mojo_cdm_promise.h" | 15 #include "media/mojo/services/mojo_cdm_promise.h" |
| 16 #include "media/mojo/services/mojo_cdm_service_context.h" | 16 #include "media/mojo/services/mojo_cdm_service_context.h" |
| 17 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 17 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 18 #include "mojo/public/cpp/bindings/strong_binding.h" | 18 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 19 | 19 |
| 20 namespace media { | 20 namespace media { |
| 21 | 21 |
| 22 class CdmFactory; | 22 class CdmFactory; |
| 23 | 23 |
| 24 // A interfaces::ContentDecryptionModule implementation backed by a | 24 // A interfaces::ContentDecryptionModule implementation backed by a |
| 25 // media::MediaKeys. | 25 // media::MediaKeys. |
| 26 class MojoCdmService : public interfaces::ContentDecryptionModule { | 26 class MojoCdmService : public interfaces::ContentDecryptionModule { |
| 27 public: | 27 public: |
| 28 // Get the CDM associated with |cdm_id|, which is unique per process. |
| 29 // Can be called on any thread. The returned CDM is not guaranteed to be |
| 30 // thread safe. |
| 31 // Note: This provides a generic hack to get the CDM in the process where |
| 32 // MojoMediaApplication is running, regardless of which render process or |
| 33 // render frame the caller is associated with. In the future, we should move |
| 34 // all out-of-process media players into the MojoMediaApplicaiton so that we |
| 35 // can use MojoCdmServiceContext (per render frame) to get the CDM. |
| 36 static scoped_refptr<MediaKeys> GetCdm(int cdm_id); |
| 37 |
| 28 // Constructs a MojoCdmService and strongly binds it to the |request|. | 38 // Constructs a MojoCdmService and strongly binds it to the |request|. |
| 29 MojoCdmService( | 39 MojoCdmService( |
| 30 base::WeakPtr<MojoCdmServiceContext> context, | 40 base::WeakPtr<MojoCdmServiceContext> context, |
| 31 mojo::ServiceProvider* service_provider, | 41 mojo::ServiceProvider* service_provider, |
| 32 CdmFactory* cdm_factory, | 42 CdmFactory* cdm_factory, |
| 33 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request); | 43 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request); |
| 34 | 44 |
| 35 ~MojoCdmService() final; | 45 ~MojoCdmService() final; |
| 36 | 46 |
| 37 // interfaces::ContentDecryptionModule implementation. | 47 // interfaces::ContentDecryptionModule implementation. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 125 |
| 116 base::WeakPtr<MojoCdmService> weak_this_; | 126 base::WeakPtr<MojoCdmService> weak_this_; |
| 117 base::WeakPtrFactory<MojoCdmService> weak_factory_; | 127 base::WeakPtrFactory<MojoCdmService> weak_factory_; |
| 118 | 128 |
| 119 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); | 129 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); |
| 120 }; | 130 }; |
| 121 | 131 |
| 122 } // namespace media | 132 } // namespace media |
| 123 | 133 |
| 124 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 134 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
| OLD | NEW |