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