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