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_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/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "media/base/media_keys.h" | 12 #include "media/base/media_keys.h" |
| 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| 14 #include "media/mojo/services/mojo_cdm_promise.h" | |
| 14 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 | 18 |
| 19 class CdmFactory; | |
| 18 class MojoCdmServiceContext; | 20 class MojoCdmServiceContext; |
| 19 | 21 |
| 20 // A mojo::ContentDecryptionModule implementation backed by a media::MediaKeys. | 22 // A mojo::ContentDecryptionModule implementation backed by a media::MediaKeys. |
| 21 class MojoCdmService : public mojo::ContentDecryptionModule { | 23 class MojoCdmService : public mojo::ContentDecryptionModule { |
| 22 public: | 24 public: |
| 23 // Constructs a MojoCdmService and strongly binds it to the |request|. | 25 // Constructs a MojoCdmService and strongly binds it to the |request|. |
| 24 MojoCdmService(MojoCdmServiceContext* context, | 26 MojoCdmService(MojoCdmServiceContext* context, |
| 27 CdmFactory* cdm_factory, | |
| 25 mojo::InterfaceRequest<mojo::ContentDecryptionModule> request); | 28 mojo::InterfaceRequest<mojo::ContentDecryptionModule> request); |
| 26 | 29 |
| 27 ~MojoCdmService() final; | 30 ~MojoCdmService() final; |
| 28 | 31 |
| 29 // mojo::ContentDecryptionModule implementation. | 32 // mojo::ContentDecryptionModule implementation. |
| 30 void SetClient(mojo::ContentDecryptionModuleClientPtr client) final; | 33 void SetClient(mojo::ContentDecryptionModuleClientPtr client) final; |
| 31 void Initialize( | 34 void Initialize( |
| 32 const mojo::String& key_system, | 35 const mojo::String& key_system, |
| 33 const mojo::String& security_origin, | 36 const mojo::String& security_origin, |
| 34 int32_t cdm_id, | 37 int32_t cdm_id, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 55 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; | 58 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; |
| 56 void RemoveSession( | 59 void RemoveSession( |
| 57 const mojo::String& session_id, | 60 const mojo::String& session_id, |
| 58 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; | 61 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; |
| 59 void GetDecryptor(mojo::InterfaceRequest<mojo::Decryptor> decryptor) final; | 62 void GetDecryptor(mojo::InterfaceRequest<mojo::Decryptor> decryptor) final; |
| 60 | 63 |
| 61 // Get CdmContext to be used by the media pipeline. | 64 // Get CdmContext to be used by the media pipeline. |
| 62 CdmContext* GetCdmContext(); | 65 CdmContext* GetCdmContext(); |
| 63 | 66 |
| 64 private: | 67 private: |
| 68 // Callback for CdmFactory::Create(). | |
| 69 void OnCdmCreated(int cdm_id, | |
| 70 scoped_ptr<MojoCdmPromise<>> promise, | |
| 71 scoped_ptr<MediaKeys> cdm, | |
| 72 const std::string& error_message); | |
|
ddorwin
2015/07/09 18:13:04
Why aren't these parameters part of the promise? I
xhwang
2015/07/09 21:16:31
OnCdmCreated() needs to be bound into CdmCreatedCB
| |
| 73 | |
| 65 // Callbacks for firing session events. | 74 // Callbacks for firing session events. |
| 66 void OnSessionMessage(const std::string& session_id, | 75 void OnSessionMessage(const std::string& session_id, |
| 67 MediaKeys::MessageType message_type, | 76 MediaKeys::MessageType message_type, |
| 68 const std::vector<uint8_t>& message, | 77 const std::vector<uint8_t>& message, |
| 69 const GURL& legacy_destination_url); | 78 const GURL& legacy_destination_url); |
| 70 void OnSessionKeysChange(const std::string& session_id, | 79 void OnSessionKeysChange(const std::string& session_id, |
| 71 bool has_additional_usable_key, | 80 bool has_additional_usable_key, |
| 72 CdmKeysInfo keys_info); | 81 CdmKeysInfo keys_info); |
| 73 void OnSessionExpirationUpdate(const std::string& session_id, | 82 void OnSessionExpirationUpdate(const std::string& session_id, |
| 74 const base::Time& new_expiry_time); | 83 const base::Time& new_expiry_time); |
| 75 void OnSessionClosed(const std::string& session_id); | 84 void OnSessionClosed(const std::string& session_id); |
| 76 void OnLegacySessionError(const std::string& session_id, | 85 void OnLegacySessionError(const std::string& session_id, |
| 77 MediaKeys::Exception exception, | 86 MediaKeys::Exception exception, |
| 78 uint32_t system_code, | 87 uint32_t system_code, |
| 79 const std::string& error_message); | 88 const std::string& error_message); |
| 80 | 89 |
| 81 mojo::StrongBinding<mojo::ContentDecryptionModule> binding_; | 90 mojo::StrongBinding<mojo::ContentDecryptionModule> binding_; |
| 82 | 91 |
| 83 MojoCdmServiceContext* context_; | 92 MojoCdmServiceContext* context_; |
| 93 CdmFactory* cdm_factory_; | |
| 94 | |
| 84 scoped_ptr<MediaKeys> cdm_; | 95 scoped_ptr<MediaKeys> cdm_; |
| 85 | 96 |
| 86 // Set to a valid CDM ID if the |cdm_| is successfully created. | 97 // Set to a valid CDM ID if the |cdm_| is successfully created. |
| 87 int cdm_id_; | 98 int cdm_id_; |
| 88 | 99 |
| 89 mojo::ContentDecryptionModuleClientPtr client_; | 100 mojo::ContentDecryptionModuleClientPtr client_; |
| 90 | 101 |
| 91 base::WeakPtr<MojoCdmService> weak_this_; | 102 base::WeakPtr<MojoCdmService> weak_this_; |
| 92 base::WeakPtrFactory<MojoCdmService> weak_factory_; | 103 base::WeakPtrFactory<MojoCdmService> weak_factory_; |
| 93 | 104 |
| 94 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); | 105 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); |
| 95 }; | 106 }; |
| 96 | 107 |
| 97 } // namespace media | 108 } // namespace media |
| 98 | 109 |
| 99 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ | 110 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ |
| OLD | NEW |