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_PROXY_MEDIA_KEYS_H_ | |
6 #define CONTENT_RENDERER_MEDIA_CDM_PROXY_MEDIA_KEYS_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <map> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "base/containers/hash_tables.h" | |
15 #include "base/containers/scoped_ptr_hash_map.h" | |
16 #include "base/macros.h" | |
17 #include "media/base/cdm_context.h" | |
18 #include "media/base/cdm_factory.h" | |
19 #include "media/base/cdm_promise.h" | |
20 #include "media/base/cdm_promise_adapter.h" | |
21 #include "media/base/media_keys.h" | |
22 | |
23 class GURL; | |
24 | |
25 namespace content { | |
26 | |
27 class RendererCdmManager; | |
28 | |
29 // A MediaKeys proxy that wraps the EME part of RendererCdmManager. | |
30 class ProxyMediaKeys : public media::MediaKeys, public media::CdmContext { | |
31 public: | |
32 static void Create( | |
33 const std::string& key_system, | |
34 const GURL& security_origin, | |
35 bool use_hw_secure_codecs, | |
36 RendererCdmManager* manager, | |
37 const media::SessionMessageCB& session_message_cb, | |
38 const media::SessionClosedCB& session_closed_cb, | |
39 const media::SessionKeysChangeCB& session_keys_change_cb, | |
40 const media::SessionExpirationUpdateCB& session_expiration_update_cb, | |
41 const media::CdmCreatedCB& cdm_created_cb); | |
42 | |
43 // MediaKeys implementation. | |
44 void SetServerCertificate( | |
45 const std::vector<uint8_t>& certificate, | |
46 std::unique_ptr<media::SimpleCdmPromise> promise) override; | |
47 void CreateSessionAndGenerateRequest( | |
48 SessionType session_type, | |
49 media::EmeInitDataType init_data_type, | |
50 const std::vector<uint8_t>& init_data, | |
51 std::unique_ptr<media::NewSessionCdmPromise> promise) override; | |
52 void LoadSession( | |
53 SessionType session_type, | |
54 const std::string& session_id, | |
55 std::unique_ptr<media::NewSessionCdmPromise> promise) override; | |
56 void UpdateSession(const std::string& session_id, | |
57 const std::vector<uint8_t>& response, | |
58 std::unique_ptr<media::SimpleCdmPromise> promise) override; | |
59 void CloseSession(const std::string& session_id, | |
60 std::unique_ptr<media::SimpleCdmPromise> promise) override; | |
61 void RemoveSession(const std::string& session_id, | |
62 std::unique_ptr<media::SimpleCdmPromise> promise) override; | |
63 media::CdmContext* GetCdmContext() override; | |
64 | |
65 // media::CdmContext implementation. | |
66 media::Decryptor* GetDecryptor() override; | |
67 int GetCdmId() const override; | |
68 | |
69 // Callbacks. | |
70 void OnSessionMessage(const std::string& session_id, | |
71 media::MediaKeys::MessageType message_type, | |
72 const std::vector<uint8_t>& message); | |
73 void OnSessionClosed(const std::string& session_id); | |
74 void OnSessionKeysChange(const std::string& session_id, | |
75 bool has_additional_usable_key, | |
76 media::CdmKeysInfo keys_info); | |
77 void OnSessionExpirationUpdate(const std::string& session_id, | |
78 const base::Time& new_expiry_time); | |
79 | |
80 void OnPromiseResolved(uint32_t promise_id); | |
81 void OnPromiseResolvedWithSession(uint32_t promise_id, | |
82 const std::string& session_id); | |
83 void OnPromiseRejected(uint32_t promise_id, | |
84 media::MediaKeys::Exception exception, | |
85 uint32_t system_code, | |
86 const std::string& error_message); | |
87 | |
88 private: | |
89 ProxyMediaKeys( | |
90 RendererCdmManager* manager, | |
91 const media::SessionMessageCB& session_message_cb, | |
92 const media::SessionClosedCB& session_closed_cb, | |
93 const media::SessionKeysChangeCB& session_keys_change_cb, | |
94 const media::SessionExpirationUpdateCB& session_expiration_update_cb); | |
95 | |
96 ~ProxyMediaKeys() override; | |
97 | |
98 void InitializeCdm(const std::string& key_system, | |
99 const GURL& security_origin, | |
100 bool use_hw_secure_codecs, | |
101 std::unique_ptr<media::SimpleCdmPromise> promise); | |
102 | |
103 RendererCdmManager* manager_; | |
104 int cdm_id_; | |
105 | |
106 media::SessionMessageCB session_message_cb_; | |
107 media::SessionClosedCB session_closed_cb_; | |
108 media::SessionKeysChangeCB session_keys_change_cb_; | |
109 media::SessionExpirationUpdateCB session_expiration_update_cb_; | |
110 | |
111 media::CdmPromiseAdapter cdm_promise_adapter_; | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(ProxyMediaKeys); | |
114 }; | |
115 | |
116 } // namespace content | |
117 | |
118 #endif // CONTENT_RENDERER_MEDIA_CDM_PROXY_MEDIA_KEYS_H_ | |
OLD | NEW |