| 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/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "media/base/media_keys.h" | 13 #include "media/base/media_keys.h" |
| 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 14 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 14 #include "media/mojo/services/mojo_cdm_promise.h" | 15 #include "media/mojo/services/mojo_cdm_promise.h" |
| 15 #include "media/mojo/services/mojo_cdm_service_context.h" | 16 #include "media/mojo/services/mojo_cdm_service_context.h" |
| 16 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 17 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/strong_binding.h" | 18 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 final; | 70 final; |
| 70 void GetDecryptor( | 71 void GetDecryptor( |
| 71 mojo::InterfaceRequest<interfaces::Decryptor> decryptor) final; | 72 mojo::InterfaceRequest<interfaces::Decryptor> decryptor) final; |
| 72 | 73 |
| 73 // Get CdmContext to be used by the media pipeline. | 74 // Get CdmContext to be used by the media pipeline. |
| 74 CdmContext* GetCdmContext(); | 75 CdmContext* GetCdmContext(); |
| 75 | 76 |
| 76 private: | 77 private: |
| 77 // Callback for CdmFactory::Create(). | 78 // Callback for CdmFactory::Create(). |
| 78 void OnCdmCreated(scoped_ptr<MojoCdmPromise<int>> promise, | 79 void OnCdmCreated(scoped_ptr<MojoCdmPromise<int>> promise, |
| 79 scoped_ptr<MediaKeys> cdm, | 80 const scoped_refptr<MediaKeys>& cdm, |
| 80 const std::string& error_message); | 81 const std::string& error_message); |
| 81 | 82 |
| 82 // Callbacks for firing session events. | 83 // Callbacks for firing session events. |
| 83 void OnSessionMessage(const std::string& session_id, | 84 void OnSessionMessage(const std::string& session_id, |
| 84 MediaKeys::MessageType message_type, | 85 MediaKeys::MessageType message_type, |
| 85 const std::vector<uint8_t>& message, | 86 const std::vector<uint8_t>& message, |
| 86 const GURL& legacy_destination_url); | 87 const GURL& legacy_destination_url); |
| 87 void OnSessionKeysChange(const std::string& session_id, | 88 void OnSessionKeysChange(const std::string& session_id, |
| 88 bool has_additional_usable_key, | 89 bool has_additional_usable_key, |
| 89 CdmKeysInfo keys_info); | 90 CdmKeysInfo keys_info); |
| 90 void OnSessionExpirationUpdate(const std::string& session_id, | 91 void OnSessionExpirationUpdate(const std::string& session_id, |
| 91 const base::Time& new_expiry_time); | 92 const base::Time& new_expiry_time); |
| 92 void OnSessionClosed(const std::string& session_id); | 93 void OnSessionClosed(const std::string& session_id); |
| 93 void OnLegacySessionError(const std::string& session_id, | 94 void OnLegacySessionError(const std::string& session_id, |
| 94 MediaKeys::Exception exception, | 95 MediaKeys::Exception exception, |
| 95 uint32_t system_code, | 96 uint32_t system_code, |
| 96 const std::string& error_message); | 97 const std::string& error_message); |
| 97 | 98 |
| 98 // CDM ID to be assigned to the next successfully initialized CDM. This ID is | 99 // CDM ID to be assigned to the next successfully initialized CDM. This ID is |
| 99 // unique per process. It will be used to locate the CDM by the media players | 100 // unique per process. It will be used to locate the CDM by the media players |
| 100 // living in the same process. | 101 // living in the same process. |
| 101 static int next_cdm_id_; | 102 static int next_cdm_id_; |
| 102 | 103 |
| 103 mojo::StrongBinding<interfaces::ContentDecryptionModule> binding_; | 104 mojo::StrongBinding<interfaces::ContentDecryptionModule> binding_; |
| 104 base::WeakPtr<MojoCdmServiceContext> context_; | 105 base::WeakPtr<MojoCdmServiceContext> context_; |
| 105 | 106 |
| 106 mojo::ServiceProvider* service_provider_; | 107 mojo::ServiceProvider* service_provider_; |
| 107 CdmFactory* cdm_factory_; | 108 CdmFactory* cdm_factory_; |
| 108 scoped_ptr<MediaKeys> cdm_; | 109 scoped_refptr<MediaKeys> cdm_; |
| 109 | 110 |
| 110 // Set to a valid CDM ID if the |cdm_| is successfully created. | 111 // Set to a valid CDM ID if the |cdm_| is successfully created. |
| 111 int cdm_id_; | 112 int cdm_id_; |
| 112 | 113 |
| 113 interfaces::ContentDecryptionModuleClientPtr client_; | 114 interfaces::ContentDecryptionModuleClientPtr client_; |
| 114 | 115 |
| 115 base::WeakPtr<MojoCdmService> weak_this_; | 116 base::WeakPtr<MojoCdmService> weak_this_; |
| 116 base::WeakPtrFactory<MojoCdmService> weak_factory_; | 117 base::WeakPtrFactory<MojoCdmService> weak_factory_; |
| 117 | 118 |
| 118 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); | 119 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace media | 122 } // namespace media |
| 122 | 123 |
| 123 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 124 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
| OLD | NEW |