| 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_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "media/base/cdm_context.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_type_trait.h" | 15 #include "media/mojo/services/mojo_type_trait.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 class ServiceProvider; | 18 class ServiceProvider; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace media { | 21 namespace media { |
| 21 | 22 |
| 22 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That | 23 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That |
| 23 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the | 24 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the |
| 24 // mojo::ContentDecryptionModuleClient interface. | 25 // mojo::ContentDecryptionModuleClient interface. |
| 25 class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { | 26 class MojoCdm : public MediaKeys, |
| 27 public CdmContext, |
| 28 public mojo::ContentDecryptionModuleClient { |
| 26 public: | 29 public: |
| 27 // |media_renderer_provider| is a ServiceProvider from a connected | 30 // |media_renderer_provider| is a ServiceProvider from a connected |
| 28 // Application that is hosting a mojo::MediaRenderer. | 31 // Application that is hosting a mojo::MediaRenderer. |
| 29 MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm, | 32 MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm, |
| 33 int32_t cdm_id, |
| 30 const SessionMessageCB& session_message_cb, | 34 const SessionMessageCB& session_message_cb, |
| 31 const SessionClosedCB& session_closed_cb, | 35 const SessionClosedCB& session_closed_cb, |
| 32 const LegacySessionErrorCB& legacy_session_error_cb, | 36 const LegacySessionErrorCB& legacy_session_error_cb, |
| 33 const SessionKeysChangeCB& session_keys_change_cb, | 37 const SessionKeysChangeCB& session_keys_change_cb, |
| 34 const SessionExpirationUpdateCB& session_expiration_update_cb); | 38 const SessionExpirationUpdateCB& session_expiration_update_cb); |
| 35 ~MojoCdm() final; | 39 ~MojoCdm() final; |
| 36 | 40 |
| 37 // MediaKeys implementation. | 41 // MediaKeys implementation. |
| 38 void SetServerCertificate(const std::vector<uint8_t>& certificate, | 42 void SetServerCertificate(const std::vector<uint8_t>& certificate, |
| 39 scoped_ptr<SimpleCdmPromise> promise) final; | 43 scoped_ptr<SimpleCdmPromise> promise) final; |
| 40 void CreateSessionAndGenerateRequest( | 44 void CreateSessionAndGenerateRequest( |
| 41 SessionType session_type, | 45 SessionType session_type, |
| 42 EmeInitDataType init_data_type, | 46 EmeInitDataType init_data_type, |
| 43 const std::vector<uint8_t>& init_data, | 47 const std::vector<uint8_t>& init_data, |
| 44 scoped_ptr<NewSessionCdmPromise> promise) final; | 48 scoped_ptr<NewSessionCdmPromise> promise) final; |
| 45 void LoadSession(SessionType session_type, | 49 void LoadSession(SessionType session_type, |
| 46 const std::string& session_id, | 50 const std::string& session_id, |
| 47 scoped_ptr<NewSessionCdmPromise> promise) final; | 51 scoped_ptr<NewSessionCdmPromise> promise) final; |
| 48 void UpdateSession(const std::string& session_id, | 52 void UpdateSession(const std::string& session_id, |
| 49 const std::vector<uint8_t>& response, | 53 const std::vector<uint8_t>& response, |
| 50 scoped_ptr<SimpleCdmPromise> promise) final; | 54 scoped_ptr<SimpleCdmPromise> promise) final; |
| 51 void CloseSession(const std::string& session_id, | 55 void CloseSession(const std::string& session_id, |
| 52 scoped_ptr<SimpleCdmPromise> promise) final; | 56 scoped_ptr<SimpleCdmPromise> promise) final; |
| 53 void RemoveSession(const std::string& session_id, | 57 void RemoveSession(const std::string& session_id, |
| 54 scoped_ptr<SimpleCdmPromise> promise) final; | 58 scoped_ptr<SimpleCdmPromise> promise) final; |
| 55 CdmContext* GetCdmContext() final; | 59 CdmContext* GetCdmContext() final; |
| 56 | 60 |
| 61 // CdmContext implementation. |
| 62 media::Decryptor* GetDecryptor() final; |
| 63 int GetCdmId() const final; |
| 64 |
| 57 private: | 65 private: |
| 58 // mojo::ContentDecryptionModuleClient implementation. | 66 // mojo::ContentDecryptionModuleClient implementation. |
| 59 void OnSessionMessage(const mojo::String& session_id, | 67 void OnSessionMessage(const mojo::String& session_id, |
| 60 mojo::CdmMessageType message_type, | 68 mojo::CdmMessageType message_type, |
| 61 mojo::Array<uint8_t> message, | 69 mojo::Array<uint8_t> message, |
| 62 const mojo::String& legacy_destination_url) final; | 70 const mojo::String& legacy_destination_url) final; |
| 63 void OnSessionClosed(const mojo::String& session_id) final; | 71 void OnSessionClosed(const mojo::String& session_id) final; |
| 64 void OnLegacySessionError(const mojo::String& session_id, | 72 void OnLegacySessionError(const mojo::String& session_id, |
| 65 mojo::CdmException exception, | 73 mojo::CdmException exception, |
| 66 uint32_t system_code, | 74 uint32_t system_code, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 typename MojoTypeTrait<T>::MojoType... args) { | 90 typename MojoTypeTrait<T>::MojoType... args) { |
| 83 if (result->success) | 91 if (result->success) |
| 84 promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. | 92 promise->resolve(args.template To<T>()...); // See ISO C++03 14.2/4. |
| 85 else | 93 else |
| 86 RejectPromise(promise.Pass(), result.Pass()); | 94 RejectPromise(promise.Pass(), result.Pass()); |
| 87 } | 95 } |
| 88 | 96 |
| 89 mojo::ContentDecryptionModulePtr remote_cdm_; | 97 mojo::ContentDecryptionModulePtr remote_cdm_; |
| 90 mojo::Binding<ContentDecryptionModuleClient> binding_; | 98 mojo::Binding<ContentDecryptionModuleClient> binding_; |
| 91 | 99 |
| 100 const int32_t cdm_id_; |
| 101 |
| 92 // Callbacks for firing session events. | 102 // Callbacks for firing session events. |
| 93 SessionMessageCB session_message_cb_; | 103 SessionMessageCB session_message_cb_; |
| 94 SessionClosedCB session_closed_cb_; | 104 SessionClosedCB session_closed_cb_; |
| 95 LegacySessionErrorCB legacy_session_error_cb_; | 105 LegacySessionErrorCB legacy_session_error_cb_; |
| 96 SessionKeysChangeCB session_keys_change_cb_; | 106 SessionKeysChangeCB session_keys_change_cb_; |
| 97 SessionExpirationUpdateCB session_expiration_update_cb_; | 107 SessionExpirationUpdateCB session_expiration_update_cb_; |
| 98 | 108 |
| 99 base::WeakPtrFactory<MojoCdm> weak_factory_; | 109 base::WeakPtrFactory<MojoCdm> weak_factory_; |
| 100 | 110 |
| 101 DISALLOW_COPY_AND_ASSIGN(MojoCdm); | 111 DISALLOW_COPY_AND_ASSIGN(MojoCdm); |
| 102 }; | 112 }; |
| 103 | 113 |
| 104 } // namespace media | 114 } // namespace media |
| 105 | 115 |
| 106 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | 116 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
| OLD | NEW |