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 CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ | 5 #ifndef CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
6 #define CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ | 6 #define CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
| 12 #include <vector> |
12 | 13 |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
17 #include "media/base/browser_cdm.h" | 18 #include "media/base/browser_cdm.h" |
18 #include "media/cdm/json_web_key.h" | 19 #include "media/cdm/json_web_key.h" |
19 | 20 |
20 namespace base { | 21 namespace base { |
21 class MessageLoopProxy; | 22 class MessageLoopProxy; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ::media::CdmContext* GetCdmContext() override; | 61 ::media::CdmContext* GetCdmContext() override; |
61 | 62 |
62 // Returns the decryption context needed to decrypt frames encrypted with | 63 // Returns the decryption context needed to decrypt frames encrypted with |
63 // |key_id|. | 64 // |key_id|. |
64 // Returns null if |key_id| is not available. | 65 // Returns null if |key_id| is not available. |
65 virtual scoped_refptr<DecryptContext> GetDecryptContext( | 66 virtual scoped_refptr<DecryptContext> GetDecryptContext( |
66 const std::string& key_id) const = 0; | 67 const std::string& key_id) const = 0; |
67 | 68 |
68 protected: | 69 protected: |
69 void OnSessionMessage(const std::string& session_id, | 70 void OnSessionMessage(const std::string& session_id, |
70 const std::vector<uint8>& message, | 71 const std::vector<uint8_t>& message, |
71 const GURL& destination_url); | 72 const GURL& destination_url); |
72 void OnSessionClosed(const std::string& session_id); | 73 void OnSessionClosed(const std::string& session_id); |
73 void OnSessionKeysChange(const std::string& session_id, | 74 void OnSessionKeysChange(const std::string& session_id, |
74 const ::media::KeyIdAndKeyPairs& keys); | 75 const ::media::KeyIdAndKeyPairs& keys); |
75 | 76 |
76 private: | 77 private: |
77 friend class BrowserCdmCastUi; | 78 friend class BrowserCdmCastUi; |
78 | 79 |
79 // Helper methods for forwarding calls to methods that take raw pointers. | |
80 void SetServerCertificateHelper( | |
81 const std::vector<uint8>& certificate_data, | |
82 scoped_ptr<::media::SimpleCdmPromise> promise); | |
83 void CreateSessionAndGenerateRequestHelper( | |
84 ::media::MediaKeys::SessionType session_type, | |
85 ::media::EmeInitDataType init_data_type, | |
86 const std::vector<uint8>& init_data, | |
87 scoped_ptr<::media::NewSessionCdmPromise> promise); | |
88 void UpdateSessionHelper(const std::string& session_id, | |
89 const std::vector<uint8>& response, | |
90 scoped_ptr<::media::SimpleCdmPromise> promise); | |
91 | |
92 ::media::SessionMessageCB session_message_cb_; | 80 ::media::SessionMessageCB session_message_cb_; |
93 ::media::SessionClosedCB session_closed_cb_; | 81 ::media::SessionClosedCB session_closed_cb_; |
94 ::media::LegacySessionErrorCB legacy_session_error_cb_; | 82 ::media::LegacySessionErrorCB legacy_session_error_cb_; |
95 ::media::SessionKeysChangeCB session_keys_change_cb_; | 83 ::media::SessionKeysChangeCB session_keys_change_cb_; |
96 ::media::SessionExpirationUpdateCB session_expiration_update_cb_; | 84 ::media::SessionExpirationUpdateCB session_expiration_update_cb_; |
97 | 85 |
98 scoped_ptr<::media::PlayerTrackerImpl> player_tracker_impl_; | 86 scoped_ptr<::media::PlayerTrackerImpl> player_tracker_impl_; |
99 | 87 |
100 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
101 | 89 |
(...skipping 13 matching lines...) Expand all Loading... |
115 // PlayerTracker implementation: | 103 // PlayerTracker implementation: |
116 int RegisterPlayer(const base::Closure& new_key_cb, | 104 int RegisterPlayer(const base::Closure& new_key_cb, |
117 const base::Closure& cdm_unset_cb) override; | 105 const base::Closure& cdm_unset_cb) override; |
118 void UnregisterPlayer(int registration_id) override; | 106 void UnregisterPlayer(int registration_id) override; |
119 | 107 |
120 BrowserCdmCast* browser_cdm_cast() const; | 108 BrowserCdmCast* browser_cdm_cast() const; |
121 | 109 |
122 private: | 110 private: |
123 // ::media::MediaKeys implementation: | 111 // ::media::MediaKeys implementation: |
124 void SetServerCertificate( | 112 void SetServerCertificate( |
125 const uint8* certificate_data, | 113 const std::vector<uint8_t>& certificate, |
126 int certificate_data_length, | |
127 scoped_ptr<::media::SimpleCdmPromise> promise) override; | 114 scoped_ptr<::media::SimpleCdmPromise> promise) override; |
128 void CreateSessionAndGenerateRequest( | 115 void CreateSessionAndGenerateRequest( |
129 ::media::MediaKeys::SessionType session_type, | 116 ::media::MediaKeys::SessionType session_type, |
130 ::media::EmeInitDataType init_data_type, | 117 ::media::EmeInitDataType init_data_type, |
131 const uint8* init_data, | 118 const std::vector<uint8_t>& init_data, |
132 int init_data_length, | |
133 scoped_ptr<::media::NewSessionCdmPromise> promise) override; | 119 scoped_ptr<::media::NewSessionCdmPromise> promise) override; |
134 void LoadSession(::media::MediaKeys::SessionType session_type, | 120 void LoadSession(::media::MediaKeys::SessionType session_type, |
135 const std::string& session_id, | 121 const std::string& session_id, |
136 scoped_ptr<::media::NewSessionCdmPromise> promise) override; | 122 scoped_ptr<::media::NewSessionCdmPromise> promise) override; |
137 void UpdateSession(const std::string& session_id, | 123 void UpdateSession(const std::string& session_id, |
138 const uint8* response, | 124 const std::vector<uint8_t>& response, |
139 int response_length, | |
140 scoped_ptr<::media::SimpleCdmPromise> promise) override; | 125 scoped_ptr<::media::SimpleCdmPromise> promise) override; |
141 void CloseSession(const std::string& session_id, | 126 void CloseSession(const std::string& session_id, |
142 scoped_ptr<::media::SimpleCdmPromise> promise) override; | 127 scoped_ptr<::media::SimpleCdmPromise> promise) override; |
143 void RemoveSession(const std::string& session_id, | 128 void RemoveSession(const std::string& session_id, |
144 scoped_ptr<::media::SimpleCdmPromise> promise) override; | 129 scoped_ptr<::media::SimpleCdmPromise> promise) override; |
145 ::media::CdmContext* GetCdmContext() override; | 130 ::media::CdmContext* GetCdmContext() override; |
146 | 131 |
147 scoped_ptr<BrowserCdmCast> browser_cdm_cast_; | 132 scoped_ptr<BrowserCdmCast> browser_cdm_cast_; |
148 scoped_refptr<base::MessageLoopProxy> cdm_loop_; | 133 scoped_refptr<base::MessageLoopProxy> cdm_loop_; |
149 | 134 |
150 base::ThreadChecker thread_checker_; | 135 base::ThreadChecker thread_checker_; |
151 | 136 |
152 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCastUi); | 137 DISALLOW_COPY_AND_ASSIGN(BrowserCdmCastUi); |
153 }; | 138 }; |
154 | 139 |
155 } // namespace media | 140 } // namespace media |
156 } // namespace chromecast | 141 } // namespace chromecast |
157 | 142 |
158 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ | 143 #endif // CHROMECAST_MEDIA_CDM_BROWSER_CDM_CAST_H_ |
OLD | NEW |