| 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 CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ | 6 #define CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <string> | 11 #include <string> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/basictypes.h" | 14 #include "base/macros.h" |
| 13 #include "content/common/media/cdm_messages_enums.h" | 15 #include "content/common/media/cdm_messages_enums.h" |
| 14 #include "content/public/renderer/render_frame_observer.h" | 16 #include "content/public/renderer/render_frame_observer.h" |
| 15 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
| 16 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 class WebFrame; | 21 class WebFrame; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 | 37 |
| 36 // Encrypted media related methods. | 38 // Encrypted media related methods. |
| 37 void InitializeCdm(int cdm_id, | 39 void InitializeCdm(int cdm_id, |
| 38 uint32_t promise_id, | 40 uint32_t promise_id, |
| 39 ProxyMediaKeys* media_keys, | 41 ProxyMediaKeys* media_keys, |
| 40 const std::string& key_system, | 42 const std::string& key_system, |
| 41 const GURL& security_origin, | 43 const GURL& security_origin, |
| 42 bool use_hw_secure_codecs); | 44 bool use_hw_secure_codecs); |
| 43 void SetServerCertificate(int cdm_id, | 45 void SetServerCertificate(int cdm_id, |
| 44 uint32_t promise_id, | 46 uint32_t promise_id, |
| 45 const std::vector<uint8>& certificate); | 47 const std::vector<uint8_t>& certificate); |
| 46 void CreateSessionAndGenerateRequest( | 48 void CreateSessionAndGenerateRequest( |
| 47 int cdm_id, | 49 int cdm_id, |
| 48 uint32_t promise_id, | 50 uint32_t promise_id, |
| 49 media::MediaKeys::SessionType session_type, | 51 media::MediaKeys::SessionType session_type, |
| 50 CdmHostMsg_CreateSession_InitDataType init_data_type, | 52 CdmHostMsg_CreateSession_InitDataType init_data_type, |
| 51 const std::vector<uint8>& init_data); | 53 const std::vector<uint8_t>& init_data); |
| 52 void LoadSession(int cdm_id, | 54 void LoadSession(int cdm_id, |
| 53 uint32_t promise_id, | 55 uint32_t promise_id, |
| 54 media::MediaKeys::SessionType session_type, | 56 media::MediaKeys::SessionType session_type, |
| 55 const std::string& session_id); | 57 const std::string& session_id); |
| 56 void UpdateSession(int cdm_id, | 58 void UpdateSession(int cdm_id, |
| 57 uint32_t promise_id, | 59 uint32_t promise_id, |
| 58 const std::string& session_id, | 60 const std::string& session_id, |
| 59 const std::vector<uint8>& response); | 61 const std::vector<uint8_t>& response); |
| 60 void CloseSession(int cdm_id, | 62 void CloseSession(int cdm_id, |
| 61 uint32_t promise_id, | 63 uint32_t promise_id, |
| 62 const std::string& session_id); | 64 const std::string& session_id); |
| 63 void RemoveSession(int cdm_id, | 65 void RemoveSession(int cdm_id, |
| 64 uint32_t promise_id, | 66 uint32_t promise_id, |
| 65 const std::string& session_id); | 67 const std::string& session_id); |
| 66 void DestroyCdm(int cdm_id); | 68 void DestroyCdm(int cdm_id); |
| 67 | 69 |
| 68 // Registers a ProxyMediaKeys object. Returns allocated CDM ID. | 70 // Registers a ProxyMediaKeys object. Returns allocated CDM ID. |
| 69 int RegisterMediaKeys(ProxyMediaKeys* media_keys); | 71 int RegisterMediaKeys(ProxyMediaKeys* media_keys); |
| 70 | 72 |
| 71 // Unregisters a ProxyMediaKeys object identified by |cdm_id|. | 73 // Unregisters a ProxyMediaKeys object identified by |cdm_id|. |
| 72 void UnregisterMediaKeys(int cdm_id); | 74 void UnregisterMediaKeys(int cdm_id); |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 // Gets the pointer to ProxyMediaKeys given the |cdm_id|. | 77 // Gets the pointer to ProxyMediaKeys given the |cdm_id|. |
| 76 ProxyMediaKeys* GetMediaKeys(int cdm_id); | 78 ProxyMediaKeys* GetMediaKeys(int cdm_id); |
| 77 | 79 |
| 78 // Message handlers. | 80 // Message handlers. |
| 79 void OnSessionMessage(int cdm_id, | 81 void OnSessionMessage(int cdm_id, |
| 80 const std::string& session_id, | 82 const std::string& session_id, |
| 81 media::MediaKeys::MessageType message_type, | 83 media::MediaKeys::MessageType message_type, |
| 82 const std::vector<uint8>& message, | 84 const std::vector<uint8_t>& message, |
| 83 const GURL& legacy_destination_url); | 85 const GURL& legacy_destination_url); |
| 84 void OnSessionClosed(int cdm_id, const std::string& session_id); | 86 void OnSessionClosed(int cdm_id, const std::string& session_id); |
| 85 void OnLegacySessionError(int cdm_id, | 87 void OnLegacySessionError(int cdm_id, |
| 86 const std::string& session_id, | 88 const std::string& session_id, |
| 87 media::MediaKeys::Exception exception, | 89 media::MediaKeys::Exception exception, |
| 88 uint32 system_code, | 90 uint32_t system_code, |
| 89 const std::string& error_message); | 91 const std::string& error_message); |
| 90 void OnSessionKeysChange( | 92 void OnSessionKeysChange( |
| 91 int cdm_id, | 93 int cdm_id, |
| 92 const std::string& session_id, | 94 const std::string& session_id, |
| 93 bool has_additional_usable_key, | 95 bool has_additional_usable_key, |
| 94 const std::vector<media::CdmKeyInformation>& key_info_vector); | 96 const std::vector<media::CdmKeyInformation>& key_info_vector); |
| 95 void OnSessionExpirationUpdate(int cdm_id, | 97 void OnSessionExpirationUpdate(int cdm_id, |
| 96 const std::string& session_id, | 98 const std::string& session_id, |
| 97 const base::Time& new_expiry_time); | 99 const base::Time& new_expiry_time); |
| 98 | 100 |
| 99 void OnPromiseResolved(int cdm_id, uint32_t promise_id); | 101 void OnPromiseResolved(int cdm_id, uint32_t promise_id); |
| 100 void OnPromiseResolvedWithSession(int cdm_id, | 102 void OnPromiseResolvedWithSession(int cdm_id, |
| 101 uint32_t promise_id, | 103 uint32_t promise_id, |
| 102 const std::string& session_id); | 104 const std::string& session_id); |
| 103 void OnPromiseRejected(int cdm_id, | 105 void OnPromiseRejected(int cdm_id, |
| 104 uint32_t promise_id, | 106 uint32_t promise_id, |
| 105 media::MediaKeys::Exception exception, | 107 media::MediaKeys::Exception exception, |
| 106 uint32_t system_code, | 108 uint32_t system_code, |
| 107 const std::string& error_message); | 109 const std::string& error_message); |
| 108 | 110 |
| 109 // CDM ID should be unique per renderer frame. | 111 // CDM ID should be unique per renderer frame. |
| 110 // TODO(xhwang): Use uint32 to prevent undefined overflow behavior. | 112 // TODO(xhwang): Use uint32_t to prevent undefined overflow behavior. |
| 111 int next_cdm_id_; | 113 int next_cdm_id_; |
| 112 | 114 |
| 113 // CDM ID to ProxyMediaKeys mapping. | 115 // CDM ID to ProxyMediaKeys mapping. |
| 114 std::map<int, ProxyMediaKeys*> proxy_media_keys_map_; | 116 std::map<int, ProxyMediaKeys*> proxy_media_keys_map_; |
| 115 | 117 |
| 116 DISALLOW_COPY_AND_ASSIGN(RendererCdmManager); | 118 DISALLOW_COPY_AND_ASSIGN(RendererCdmManager); |
| 117 }; | 119 }; |
| 118 | 120 |
| 119 } // namespace content | 121 } // namespace content |
| 120 | 122 |
| 121 #endif // CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ | 123 #endif // CONTENT_RENDERER_MEDIA_CDM_RENDERER_CDM_MANAGER_H_ |
| OLD | NEW |