| 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_CLIENTS_MOJO_CDM_H_ | 5 #ifndef MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ |
| 6 #define MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ | 6 #define MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public CdmContext, | 37 public CdmContext, |
| 38 public mojom::ContentDecryptionModuleClient { | 38 public mojom::ContentDecryptionModuleClient { |
| 39 public: | 39 public: |
| 40 static void Create( | 40 static void Create( |
| 41 const std::string& key_system, | 41 const std::string& key_system, |
| 42 const GURL& security_origin, | 42 const GURL& security_origin, |
| 43 const media::CdmConfig& cdm_config, | 43 const media::CdmConfig& cdm_config, |
| 44 mojom::ContentDecryptionModulePtr remote_cdm, | 44 mojom::ContentDecryptionModulePtr remote_cdm, |
| 45 const media::SessionMessageCB& session_message_cb, | 45 const media::SessionMessageCB& session_message_cb, |
| 46 const media::SessionClosedCB& session_closed_cb, | 46 const media::SessionClosedCB& session_closed_cb, |
| 47 const media::LegacySessionErrorCB& legacy_session_error_cb, | |
| 48 const media::SessionKeysChangeCB& session_keys_change_cb, | 47 const media::SessionKeysChangeCB& session_keys_change_cb, |
| 49 const media::SessionExpirationUpdateCB& session_expiration_update_cb, | 48 const media::SessionExpirationUpdateCB& session_expiration_update_cb, |
| 50 const media::CdmCreatedCB& cdm_created_cb); | 49 const media::CdmCreatedCB& cdm_created_cb); |
| 51 | 50 |
| 52 // MediaKeys implementation. | 51 // MediaKeys implementation. |
| 53 void SetServerCertificate(const std::vector<uint8_t>& certificate, | 52 void SetServerCertificate(const std::vector<uint8_t>& certificate, |
| 54 std::unique_ptr<SimpleCdmPromise> promise) final; | 53 std::unique_ptr<SimpleCdmPromise> promise) final; |
| 55 void CreateSessionAndGenerateRequest( | 54 void CreateSessionAndGenerateRequest( |
| 56 SessionType session_type, | 55 SessionType session_type, |
| 57 EmeInitDataType init_data_type, | 56 EmeInitDataType init_data_type, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 | 70 |
| 72 // CdmContext implementation. Can be called on a different thread. | 71 // CdmContext implementation. Can be called on a different thread. |
| 73 // All GetDecryptor() calls must be made on the same thread. | 72 // All GetDecryptor() calls must be made on the same thread. |
| 74 media::Decryptor* GetDecryptor() final; | 73 media::Decryptor* GetDecryptor() final; |
| 75 int GetCdmId() const final; | 74 int GetCdmId() const final; |
| 76 | 75 |
| 77 private: | 76 private: |
| 78 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, | 77 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, |
| 79 const SessionMessageCB& session_message_cb, | 78 const SessionMessageCB& session_message_cb, |
| 80 const SessionClosedCB& session_closed_cb, | 79 const SessionClosedCB& session_closed_cb, |
| 81 const LegacySessionErrorCB& legacy_session_error_cb, | |
| 82 const SessionKeysChangeCB& session_keys_change_cb, | 80 const SessionKeysChangeCB& session_keys_change_cb, |
| 83 const SessionExpirationUpdateCB& session_expiration_update_cb); | 81 const SessionExpirationUpdateCB& session_expiration_update_cb); |
| 84 | 82 |
| 85 ~MojoCdm() final; | 83 ~MojoCdm() final; |
| 86 | 84 |
| 87 void InitializeCdm(const std::string& key_system, | 85 void InitializeCdm(const std::string& key_system, |
| 88 const GURL& security_origin, | 86 const GURL& security_origin, |
| 89 const media::CdmConfig& cdm_config, | 87 const media::CdmConfig& cdm_config, |
| 90 std::unique_ptr<CdmInitializedPromise> promise); | 88 std::unique_ptr<CdmInitializedPromise> promise); |
| 91 | 89 |
| 92 void OnConnectionError(); | 90 void OnConnectionError(); |
| 93 | 91 |
| 94 // mojom::ContentDecryptionModuleClient implementation. | 92 // mojom::ContentDecryptionModuleClient implementation. |
| 95 void OnSessionMessage(const mojo::String& session_id, | 93 void OnSessionMessage(const mojo::String& session_id, |
| 96 mojom::CdmMessageType message_type, | 94 mojom::CdmMessageType message_type, |
| 97 mojo::Array<uint8_t> message, | 95 mojo::Array<uint8_t> message) final; |
| 98 const GURL& legacy_destination_url) final; | |
| 99 void OnSessionClosed(const mojo::String& session_id) final; | 96 void OnSessionClosed(const mojo::String& session_id) final; |
| 100 void OnLegacySessionError(const mojo::String& session_id, | |
| 101 mojom::CdmException exception, | |
| 102 uint32_t system_code, | |
| 103 const mojo::String& error_message) final; | |
| 104 void OnSessionKeysChange( | 97 void OnSessionKeysChange( |
| 105 const mojo::String& session_id, | 98 const mojo::String& session_id, |
| 106 bool has_additional_usable_key, | 99 bool has_additional_usable_key, |
| 107 mojo::Array<mojom::CdmKeyInformationPtr> keys_info) final; | 100 mojo::Array<mojom::CdmKeyInformationPtr> keys_info) final; |
| 108 void OnSessionExpirationUpdate(const mojo::String& session_id, | 101 void OnSessionExpirationUpdate(const mojo::String& session_id, |
| 109 double new_expiry_time_sec) final; | 102 double new_expiry_time_sec) final; |
| 110 | 103 |
| 111 // Callback for InitializeCdm. | 104 // Callback for InitializeCdm. |
| 112 // Note: Cannot use OnPromiseResult() below since we need to handle connection | 105 // Note: Cannot use OnPromiseResult() below since we need to handle connection |
| 113 // error. Also we have extra parameters |cdm_id| and |decryptor|, which aren't | 106 // error. Also we have extra parameters |cdm_id| and |decryptor|, which aren't |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 147 |
| 155 // Decryptor based on |decryptor_ptr_|, lazily created in GetDecryptor(). | 148 // Decryptor based on |decryptor_ptr_|, lazily created in GetDecryptor(). |
| 156 // Since GetDecryptor() can be called on a different thread, use | 149 // Since GetDecryptor() can be called on a different thread, use |
| 157 // |decryptor_task_runner_| to bind |decryptor_| to that thread. | 150 // |decryptor_task_runner_| to bind |decryptor_| to that thread. |
| 158 std::unique_ptr<MojoDecryptor> decryptor_; | 151 std::unique_ptr<MojoDecryptor> decryptor_; |
| 159 scoped_refptr<base::SingleThreadTaskRunner> decryptor_task_runner_; | 152 scoped_refptr<base::SingleThreadTaskRunner> decryptor_task_runner_; |
| 160 | 153 |
| 161 // Callbacks for firing session events. | 154 // Callbacks for firing session events. |
| 162 SessionMessageCB session_message_cb_; | 155 SessionMessageCB session_message_cb_; |
| 163 SessionClosedCB session_closed_cb_; | 156 SessionClosedCB session_closed_cb_; |
| 164 LegacySessionErrorCB legacy_session_error_cb_; | |
| 165 SessionKeysChangeCB session_keys_change_cb_; | 157 SessionKeysChangeCB session_keys_change_cb_; |
| 166 SessionExpirationUpdateCB session_expiration_update_cb_; | 158 SessionExpirationUpdateCB session_expiration_update_cb_; |
| 167 | 159 |
| 168 // Pending promise for InitializeCdm(). | 160 // Pending promise for InitializeCdm(). |
| 169 std::unique_ptr<CdmInitializedPromise> pending_init_promise_; | 161 std::unique_ptr<CdmInitializedPromise> pending_init_promise_; |
| 170 | 162 |
| 171 // This must be the last member. | 163 // This must be the last member. |
| 172 base::WeakPtrFactory<MojoCdm> weak_factory_; | 164 base::WeakPtrFactory<MojoCdm> weak_factory_; |
| 173 | 165 |
| 174 DISALLOW_COPY_AND_ASSIGN(MojoCdm); | 166 DISALLOW_COPY_AND_ASSIGN(MojoCdm); |
| 175 }; | 167 }; |
| 176 | 168 |
| 177 } // namespace media | 169 } // namespace media |
| 178 | 170 |
| 179 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ | 171 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ |
| OLD | NEW |