Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.h

Issue 448893002: Update ClearKey to support CDM_6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cdm6
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ 5 #ifndef MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_
6 #define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ 6 #define MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 uint32 init_data_size, 42 uint32 init_data_size,
43 cdm::SessionType session_type) OVERRIDE; 43 cdm::SessionType session_type) OVERRIDE;
44 virtual void LoadSession(uint32 promise_id, 44 virtual void LoadSession(uint32 promise_id,
45 const char* web_session_id, 45 const char* web_session_id,
46 uint32_t web_session_id_length) OVERRIDE; 46 uint32_t web_session_id_length) OVERRIDE;
47 virtual void UpdateSession(uint32 promise_id, 47 virtual void UpdateSession(uint32 promise_id,
48 const char* web_session_id, 48 const char* web_session_id,
49 uint32_t web_session_id_length, 49 uint32_t web_session_id_length,
50 const uint8* response, 50 const uint8* response,
51 uint32 response_size) OVERRIDE; 51 uint32 response_size) OVERRIDE;
52 virtual void ReleaseSession(uint32 promise_id, 52 virtual void CloseSession(uint32 promise_id,
53 const char* web_session_id, 53 const char* web_session_id,
54 uint32_t web_session_id_length) OVERRIDE; 54 uint32_t web_session_id_length) OVERRIDE;
55 virtual void RemoveSession(uint32 promise_id,
56 const char* web_session_id,
57 uint32_t web_session_id_length) OVERRIDE;
58 virtual void GetUsableKeyIds(uint32_t promise_id,
59 const char* web_session_id,
60 uint32_t web_session_id_length) OVERRIDE;
55 virtual void SetServerCertificate( 61 virtual void SetServerCertificate(
56 uint32 promise_id, 62 uint32 promise_id,
57 const uint8_t* server_certificate_data, 63 const uint8_t* server_certificate_data,
58 uint32_t server_certificate_data_size) OVERRIDE; 64 uint32_t server_certificate_data_size) OVERRIDE;
59 virtual void TimerExpired(void* context) OVERRIDE; 65 virtual void TimerExpired(void* context) OVERRIDE;
60 virtual cdm::Status Decrypt(const cdm::InputBuffer_1& encrypted_buffer, 66 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
61 cdm::DecryptedBlock* decrypted_block) OVERRIDE; 67 cdm::DecryptedBlock* decrypted_block) OVERRIDE;
62 virtual cdm::Status InitializeAudioDecoder( 68 virtual cdm::Status InitializeAudioDecoder(
63 const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE; 69 const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE;
64 virtual cdm::Status InitializeVideoDecoder( 70 virtual cdm::Status InitializeVideoDecoder(
65 const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE; 71 const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE;
66 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE; 72 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE;
67 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE; 73 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE;
68 virtual cdm::Status DecryptAndDecodeFrame( 74 virtual cdm::Status DecryptAndDecodeFrame(
69 const cdm::InputBuffer_1& encrypted_buffer, 75 const cdm::InputBuffer& encrypted_buffer,
70 cdm::VideoFrame* video_frame) OVERRIDE; 76 cdm::VideoFrame* video_frame) OVERRIDE;
71 virtual cdm::Status DecryptAndDecodeSamples( 77 virtual cdm::Status DecryptAndDecodeSamples(
72 const cdm::InputBuffer_1& encrypted_buffer, 78 const cdm::InputBuffer& encrypted_buffer,
73 cdm::AudioFrames* audio_frames) OVERRIDE; 79 cdm::AudioFrames* audio_frames) OVERRIDE;
74 virtual void Destroy() OVERRIDE; 80 virtual void Destroy() OVERRIDE;
75 virtual void OnPlatformChallengeResponse( 81 virtual void OnPlatformChallengeResponse(
76 const cdm::PlatformChallengeResponse& response) OVERRIDE; 82 const cdm::PlatformChallengeResponse& response) OVERRIDE;
77 virtual void OnQueryOutputProtectionStatus( 83 virtual void OnQueryOutputProtectionStatus(
78 uint32_t link_mask, uint32_t output_protection_mask) OVERRIDE; 84 uint32_t link_mask, uint32_t output_protection_mask) OVERRIDE;
79 85
80 private: 86 private:
81 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This 87 // Emulates a session stored for |session_id_for_emulated_loadsession_|. This
82 // is necessary since aes_decryptor.cc does not support storing sessions. 88 // is necessary since aes_decryptor.cc does not support storing sessions.
83 void LoadLoadableSession(); 89 void LoadLoadableSession();
84 90
85 // ContentDecryptionModule callbacks. 91 // ContentDecryptionModule callbacks.
86 void OnSessionMessage(const std::string& web_session_id, 92 void OnSessionMessage(const std::string& web_session_id,
87 const std::vector<uint8>& message, 93 const std::vector<uint8>& message,
88 const GURL& destination_url); 94 const GURL& destination_url);
89 void OnSessionClosed(const std::string& web_session_id); 95 void OnSessionClosed(const std::string& web_session_id);
90 96
91 // Handle the success/failure of a promise. These methods are responsible for 97 // Handle the success/failure of a promise. These methods are responsible for
92 // calling |host_| to resolve or reject the promise. 98 // calling |host_| to resolve or reject the promise.
93 void OnSessionCreated(uint32 promise_id, const std::string& web_session_id); 99 void OnSessionCreated(uint32 promise_id, const std::string& web_session_id);
94 void OnSessionLoaded(uint32 promise_id, const std::string& web_session_id); 100 void OnSessionLoaded(uint32 promise_id, const std::string& web_session_id);
95 void OnSessionUpdated(uint32 promise_id, const std::string& web_session_id); 101 void OnSessionUpdated(uint32 promise_id, const std::string& web_session_id);
96 void OnSessionReleased(uint32 promise_id, const std::string& web_session_id); 102 void OnSessionReleased(uint32 promise_id, const std::string& web_session_id);
103 void OnUsableKeyIdsObtained(uint32 promise_id, const KeyIdsVector& key_ids);
97 void OnPromiseFailed(uint32 promise_id, 104 void OnPromiseFailed(uint32 promise_id,
98 MediaKeys::Exception exception_code, 105 MediaKeys::Exception exception_code,
99 uint32 system_code, 106 uint32 system_code,
100 const std::string& error_message); 107 const std::string& error_message);
101 108
102 // Prepares next heartbeat message and sets a timer for it. 109 // Prepares next heartbeat message and sets a timer for it.
103 void ScheduleNextHeartBeat(); 110 void ScheduleNextHeartBeat();
104 111
105 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|. 112 // Decrypts the |encrypted_buffer| and puts the result in |decrypted_buffer|.
106 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is 113 // Returns cdm::kSuccess if decryption succeeded. The decrypted result is
107 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the 114 // put in |decrypted_buffer|. If |encrypted_buffer| is empty, the
108 // |decrypted_buffer| is set to an empty (EOS) buffer. 115 // |decrypted_buffer| is set to an empty (EOS) buffer.
109 // Returns cdm::kNoKey if no decryption key was available. In this case 116 // Returns cdm::kNoKey if no decryption key was available. In this case
110 // |decrypted_buffer| should be ignored by the caller. 117 // |decrypted_buffer| should be ignored by the caller.
111 // Returns cdm::kDecryptError if any decryption error occurred. In this case 118 // Returns cdm::kDecryptError if any decryption error occurred. In this case
112 // |decrypted_buffer| should be ignored by the caller. 119 // |decrypted_buffer| should be ignored by the caller.
113 cdm::Status DecryptToMediaDecoderBuffer( 120 cdm::Status DecryptToMediaDecoderBuffer(
114 const cdm::InputBuffer_1& encrypted_buffer, 121 const cdm::InputBuffer& encrypted_buffer,
115 scoped_refptr<DecoderBuffer>* decrypted_buffer); 122 scoped_refptr<DecoderBuffer>* decrypted_buffer);
116 123
117 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 124 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
118 int64 CurrentTimeStampInMicroseconds() const; 125 int64 CurrentTimeStampInMicroseconds() const;
119 126
120 // Generates fake video frames with |duration_in_microseconds|. 127 // Generates fake video frames with |duration_in_microseconds|.
121 // Returns the number of samples generated in the |audio_frames|. 128 // Returns the number of samples generated in the |audio_frames|.
122 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds, 129 int GenerateFakeAudioFramesFromDuration(int64 duration_in_microseconds,
123 cdm::AudioFrames* audio_frames) const; 130 cdm::AudioFrames* audio_frames) const;
124 131
(...skipping 13 matching lines...) Expand all
138 145
139 AesDecryptor decryptor_; 146 AesDecryptor decryptor_;
140 147
141 ClearKeyCdmHost* host_; 148 ClearKeyCdmHost* host_;
142 149
143 const std::string key_system_; 150 const std::string key_system_;
144 151
145 std::string last_session_id_; 152 std::string last_session_id_;
146 std::string next_heartbeat_message_; 153 std::string next_heartbeat_message_;
147 154
155 // In order to simulate LoadSession(), CreateSession() and then
156 // UpdateSession() will be called to create a session with known keys.
157 // |session_id_for_emulated_loadsession_| is used to keep track of the
158 // session_id allocated by aes_decryptor, as the session_id will be returned
159 // as |kLoadableWebSessionId|. Future requests for this simulated session
160 // need to use |session_id_for_emulated_loadsession_| for all calls
161 // to aes_decryptor.
162 // |promise_id_for_emulated_loadsession_| is used to keep track of the
163 // original LoadSession() promise, as it is not resolved until the
164 // UpdateSession() call succeeds.
148 // TODO(xhwang): Extract testing code from main implementation. 165 // TODO(xhwang): Extract testing code from main implementation.
149 // See http://crbug.com/341751 166 // See http://crbug.com/341751
150 std::string session_id_for_emulated_loadsession_; 167 std::string session_id_for_emulated_loadsession_;
151 uint32_t promise_id_for_emulated_loadsession_; 168 uint32_t promise_id_for_emulated_loadsession_;
152 169
153 // Timer delay in milliseconds for the next host_->SetTimer() call. 170 // Timer delay in milliseconds for the next host_->SetTimer() call.
154 int64 timer_delay_ms_; 171 int64 timer_delay_ms_;
155 172
156 // Indicates whether a heartbeat timer has been set to prevent multiple timers 173 // Indicates whether a heartbeat timer has been set to prevent multiple timers
157 // from running. 174 // from running.
(...skipping 14 matching lines...) Expand all
172 scoped_ptr<CdmVideoDecoder> video_decoder_; 189 scoped_ptr<CdmVideoDecoder> video_decoder_;
173 190
174 scoped_ptr<FileIOTestRunner> file_io_test_runner_; 191 scoped_ptr<FileIOTestRunner> file_io_test_runner_;
175 192
176 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm); 193 DISALLOW_COPY_AND_ASSIGN(ClearKeyCdm);
177 }; 194 };
178 195
179 } // namespace media 196 } // namespace media
180 197
181 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_ 198 #endif // MEDIA_CDM_PPAPI_EXTERNAL_CLEAR_KEY_CLEAR_KEY_CDM_H_
OLDNEW
« no previous file with comments | « media/cdm/aes_decryptor_unittest.cc ('k') | media/cdm/ppapi/external_clear_key/clear_key_cdm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698