| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CDM_CDM_ADAPTER_H_ | 5 #ifndef MEDIA_CDM_CDM_ADAPTER_H_ |
| 6 #define MEDIA_CDM_CDM_ADAPTER_H_ | 6 #define MEDIA_CDM_CDM_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "media/base/decryptor.h" | 25 #include "media/base/decryptor.h" |
| 26 #include "media/base/media_export.h" | 26 #include "media/base/media_export.h" |
| 27 #include "media/base/media_keys.h" | 27 #include "media/base/media_keys.h" |
| 28 #include "media/cdm/api/content_decryption_module.h" | 28 #include "media/cdm/api/content_decryption_module.h" |
| 29 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 30 | 30 |
| 31 namespace media { | 31 namespace media { |
| 32 | 32 |
| 33 class AudioFramesImpl; | 33 class AudioFramesImpl; |
| 34 class CdmAllocator; | 34 class CdmAllocator; |
| 35 class CdmFileIOProvider; |
| 35 class CdmWrapper; | 36 class CdmWrapper; |
| 36 | 37 |
| 37 class MEDIA_EXPORT CdmAdapter : public MediaKeys, | 38 class MEDIA_EXPORT CdmAdapter : public MediaKeys, |
| 38 public CdmContext, | 39 public CdmContext, |
| 39 public Decryptor, | 40 public Decryptor, |
| 40 NON_EXPORTED_BASE(public cdm::Host_7), | 41 NON_EXPORTED_BASE(public cdm::Host_7), |
| 41 NON_EXPORTED_BASE(public cdm::Host_8) { | 42 NON_EXPORTED_BASE(public cdm::Host_8) { |
| 42 public: | 43 public: |
| 43 // Create the CDM using |cdm_path| and initialize it using |key_system| and | 44 // Create the CDM using |cdm_path| and initialize it using |key_system| and |
| 44 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory | 45 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory |
| 45 // and to create VideoFrames. Callbacks will be used for events generated | 46 // and to create VideoFrames. |file_io_provider| is to be used whenever the |
| 46 // by the CDM. |cdm_created_cb| will be called when the CDM is loaded and | 47 // CDM needs access to the file system. Callbacks will be used for events |
| 47 // initialized. | 48 // generated by the CDM. |cdm_created_cb| will be called when the CDM is |
| 49 // loaded and initialized. |
| 48 static void Create( | 50 static void Create( |
| 49 const std::string& key_system, | 51 const std::string& key_system, |
| 50 const base::FilePath& cdm_path, | 52 const base::FilePath& cdm_path, |
| 51 const CdmConfig& cdm_config, | 53 const CdmConfig& cdm_config, |
| 52 scoped_ptr<CdmAllocator> allocator, | 54 scoped_ptr<CdmAllocator> allocator, |
| 55 scoped_ptr<CdmFileIOProvider> file_io_provider, |
| 53 const SessionMessageCB& session_message_cb, | 56 const SessionMessageCB& session_message_cb, |
| 54 const SessionClosedCB& session_closed_cb, | 57 const SessionClosedCB& session_closed_cb, |
| 55 const LegacySessionErrorCB& legacy_session_error_cb, | 58 const LegacySessionErrorCB& legacy_session_error_cb, |
| 56 const SessionKeysChangeCB& session_keys_change_cb, | 59 const SessionKeysChangeCB& session_keys_change_cb, |
| 57 const SessionExpirationUpdateCB& session_expiration_update_cb, | 60 const SessionExpirationUpdateCB& session_expiration_update_cb, |
| 58 const CdmCreatedCB& cdm_created_cb); | 61 const CdmCreatedCB& cdm_created_cb); |
| 59 | 62 |
| 60 // MediaKeys implementation. | 63 // MediaKeys implementation. |
| 61 void SetServerCertificate(const std::vector<uint8_t>& certificate, | 64 void SetServerCertificate(const std::vector<uint8_t>& certificate, |
| 62 scoped_ptr<SimpleCdmPromise> promise) final; | 65 scoped_ptr<SimpleCdmPromise> promise) final; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 void EnableOutputProtection(uint32_t desired_protection_mask) override; | 145 void EnableOutputProtection(uint32_t desired_protection_mask) override; |
| 143 void QueryOutputProtectionStatus() override; | 146 void QueryOutputProtectionStatus() override; |
| 144 void OnDeferredInitializationDone(cdm::StreamType stream_type, | 147 void OnDeferredInitializationDone(cdm::StreamType stream_type, |
| 145 cdm::Status decoder_status) override; | 148 cdm::Status decoder_status) override; |
| 146 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override; | 149 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override; |
| 147 | 150 |
| 148 private: | 151 private: |
| 149 CdmAdapter(const std::string& key_system, | 152 CdmAdapter(const std::string& key_system, |
| 150 const CdmConfig& cdm_config, | 153 const CdmConfig& cdm_config, |
| 151 scoped_ptr<CdmAllocator> allocator, | 154 scoped_ptr<CdmAllocator> allocator, |
| 155 scoped_ptr<CdmFileIOProvider> file_io_provider, |
| 152 const SessionMessageCB& session_message_cb, | 156 const SessionMessageCB& session_message_cb, |
| 153 const SessionClosedCB& session_closed_cb, | 157 const SessionClosedCB& session_closed_cb, |
| 154 const LegacySessionErrorCB& legacy_session_error_cb, | 158 const LegacySessionErrorCB& legacy_session_error_cb, |
| 155 const SessionKeysChangeCB& session_keys_change_cb, | 159 const SessionKeysChangeCB& session_keys_change_cb, |
| 156 const SessionExpirationUpdateCB& session_expiration_update_cb); | 160 const SessionExpirationUpdateCB& session_expiration_update_cb); |
| 157 ~CdmAdapter() final; | 161 ~CdmAdapter() final; |
| 158 | 162 |
| 159 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if | 163 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if |
| 160 // the CDM is successfully loaded and initialized, rejected otherwise. | 164 // the CDM is successfully loaded and initialized, rejected otherwise. |
| 161 void Initialize(const base::FilePath& cdm_path, | 165 void Initialize(const base::FilePath& cdm_path, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 207 |
| 204 // Keep track of video frame natural size from the latest configuration | 208 // Keep track of video frame natural size from the latest configuration |
| 205 // as the CDM doesn't provide it. | 209 // as the CDM doesn't provide it. |
| 206 gfx::Size natural_size_; | 210 gfx::Size natural_size_; |
| 207 | 211 |
| 208 // Keep track of audio parameters. | 212 // Keep track of audio parameters. |
| 209 int audio_samples_per_second_; | 213 int audio_samples_per_second_; |
| 210 ChannelLayout audio_channel_layout_; | 214 ChannelLayout audio_channel_layout_; |
| 211 | 215 |
| 212 scoped_ptr<CdmAllocator> allocator_; | 216 scoped_ptr<CdmAllocator> allocator_; |
| 217 scoped_ptr<CdmFileIOProvider> file_io_provider_; |
| 213 | 218 |
| 214 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 219 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 215 | 220 |
| 216 // NOTE: Weak pointers must be invalidated before all other member variables. | 221 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 217 base::WeakPtrFactory<CdmAdapter> weak_factory_; | 222 base::WeakPtrFactory<CdmAdapter> weak_factory_; |
| 218 | 223 |
| 219 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 224 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
| 220 }; | 225 }; |
| 221 | 226 |
| 222 } // namespace media | 227 } // namespace media |
| 223 | 228 |
| 224 #endif // MEDIA_CDM_CDM_ADAPTER_H_ | 229 #endif // MEDIA_CDM_CDM_ADAPTER_H_ |
| OLD | NEW |