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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1407933010: media: Make MediaKeys ref-counted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 1 month 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
« no previous file with comments | « media/mojo/services/mojo_cdm_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 9 #include "base/stl_util.h"
9 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "build/build_config.h" 12 #include "build/build_config.h"
12 #include "media/base/cdm_callback_promise.h" 13 #include "media/base/cdm_callback_promise.h"
13 #include "media/base/cdm_context.h" 14 #include "media/base/cdm_context.h"
14 #include "media/base/cdm_key_information.h" 15 #include "media/base/cdm_key_information.h"
15 #include "media/base/decoder_buffer.h" 16 #include "media/base/decoder_buffer.h"
16 #include "media/base/media.h" 17 #include "media/base/media.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 const std::string& error_message) { 196 const std::string& error_message) {
196 FAIL() << "Unexpected Key Error"; 197 FAIL() << "Unexpected Key Error";
197 } 198 }
198 199
199 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 200 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
200 const std::vector<uint8_t>& init_data, 201 const std::vector<uint8_t>& init_data,
201 AesDecryptor* decryptor) = 0; 202 AesDecryptor* decryptor) = 0;
202 }; 203 };
203 204
204 FakeEncryptedMedia(AppBase* app) 205 FakeEncryptedMedia(AppBase* app)
205 : decryptor_(GURL::EmptyGURL(), 206 : decryptor_(new AesDecryptor(
206 base::Bind(&FakeEncryptedMedia::OnSessionMessage, 207 GURL::EmptyGURL(),
207 base::Unretained(this)), 208 base::Bind(&FakeEncryptedMedia::OnSessionMessage,
208 base::Bind(&FakeEncryptedMedia::OnSessionClosed, 209 base::Unretained(this)),
209 base::Unretained(this)), 210 base::Bind(&FakeEncryptedMedia::OnSessionClosed,
210 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, 211 base::Unretained(this)),
211 base::Unretained(this))), 212 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange,
212 cdm_context_(&decryptor_), 213 base::Unretained(this)))),
214 cdm_context_(decryptor_.get()),
213 app_(app) {} 215 app_(app) {}
214 216
215 CdmContext* GetCdmContext() { return &cdm_context_; } 217 CdmContext* GetCdmContext() { return &cdm_context_; }
216 218
217 // Callbacks for firing session events. Delegate to |app_|. 219 // Callbacks for firing session events. Delegate to |app_|.
218 void OnSessionMessage(const std::string& session_id, 220 void OnSessionMessage(const std::string& session_id,
219 MediaKeys::MessageType message_type, 221 MediaKeys::MessageType message_type,
220 const std::vector<uint8_t>& message, 222 const std::vector<uint8_t>& message,
221 const GURL& legacy_destination_url) { 223 const GURL& legacy_destination_url) {
222 app_->OnSessionMessage(session_id, message_type, message, 224 app_->OnSessionMessage(session_id, message_type, message,
223 legacy_destination_url, &decryptor_); 225 legacy_destination_url, decryptor_.get());
224 } 226 }
225 227
226 void OnSessionClosed(const std::string& session_id) { 228 void OnSessionClosed(const std::string& session_id) {
227 app_->OnSessionClosed(session_id); 229 app_->OnSessionClosed(session_id);
228 } 230 }
229 231
230 void OnSessionKeysChange(const std::string& session_id, 232 void OnSessionKeysChange(const std::string& session_id,
231 bool has_additional_usable_key, 233 bool has_additional_usable_key,
232 CdmKeysInfo keys_info) { 234 CdmKeysInfo keys_info) {
233 app_->OnSessionKeysChange(session_id, has_additional_usable_key, 235 app_->OnSessionKeysChange(session_id, has_additional_usable_key,
234 keys_info.Pass()); 236 keys_info.Pass());
235 } 237 }
236 238
237 void OnLegacySessionError(const std::string& session_id, 239 void OnLegacySessionError(const std::string& session_id,
238 const std::string& error_name, 240 const std::string& error_name,
239 uint32_t system_code, 241 uint32_t system_code,
240 const std::string& error_message) { 242 const std::string& error_message) {
241 app_->OnLegacySessionError(session_id, error_name, system_code, 243 app_->OnLegacySessionError(session_id, error_name, system_code,
242 error_message); 244 error_message);
243 } 245 }
244 246
245 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 247 void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
246 const std::vector<uint8_t>& init_data) { 248 const std::vector<uint8_t>& init_data) {
247 app_->OnEncryptedMediaInitData(init_data_type, init_data, &decryptor_); 249 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get());
248 } 250 }
249 251
250 private: 252 private:
251 class TestCdmContext : public CdmContext { 253 class TestCdmContext : public CdmContext {
252 public: 254 public:
253 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {} 255 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {}
254 256
255 Decryptor* GetDecryptor() final { return decryptor_; } 257 Decryptor* GetDecryptor() final { return decryptor_; }
256 int GetCdmId() const final { return kInvalidCdmId; } 258 int GetCdmId() const final { return kInvalidCdmId; }
257 259
258 private: 260 private:
259 Decryptor* decryptor_; 261 Decryptor* decryptor_;
260 }; 262 };
261 263
262 AesDecryptor decryptor_; 264 scoped_refptr<AesDecryptor> decryptor_;
263 TestCdmContext cdm_context_; 265 TestCdmContext cdm_context_;
264 scoped_ptr<AppBase> app_; 266 scoped_ptr<AppBase> app_;
265 }; 267 };
266 268
267 enum PromiseResult { RESOLVED, REJECTED }; 269 enum PromiseResult { RESOLVED, REJECTED };
268 270
269 // Provides |kSecretKey| in response to needkey. 271 // Provides |kSecretKey| in response to needkey.
270 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { 272 class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
271 public: 273 public:
272 KeyProvidingApp() {} 274 KeyProvidingApp() {}
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 1841
1840 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 1842 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
1841 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 1843 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
1842 Play(); 1844 Play();
1843 ASSERT_TRUE(WaitUntilOnEnded()); 1845 ASSERT_TRUE(WaitUntilOnEnded());
1844 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 1846 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1845 demuxer_->GetStartTime()); 1847 demuxer_->GetStartTime());
1846 } 1848 }
1847 1849
1848 } // namespace media 1850 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698