OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 ContentDecryptionModule::MessageType message_type, | 201 ContentDecryptionModule::MessageType message_type, |
202 const std::vector<uint8_t>& message, | 202 const std::vector<uint8_t>& message, |
203 AesDecryptor* decryptor) = 0; | 203 AesDecryptor* decryptor) = 0; |
204 | 204 |
205 virtual void OnSessionClosed(const std::string& session_id) = 0; | 205 virtual void OnSessionClosed(const std::string& session_id) = 0; |
206 | 206 |
207 virtual void OnSessionKeysChange(const std::string& session_id, | 207 virtual void OnSessionKeysChange(const std::string& session_id, |
208 bool has_additional_usable_key, | 208 bool has_additional_usable_key, |
209 CdmKeysInfo keys_info) = 0; | 209 CdmKeysInfo keys_info) = 0; |
210 | 210 |
| 211 virtual void OnSessionExpirationUpdate(const std::string& session_id, |
| 212 base::Time new_expiry_time) = 0; |
| 213 |
211 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 214 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
212 const std::vector<uint8_t>& init_data, | 215 const std::vector<uint8_t>& init_data, |
213 AesDecryptor* decryptor) = 0; | 216 AesDecryptor* decryptor) = 0; |
214 }; | 217 }; |
215 | 218 |
216 FakeEncryptedMedia(AppBase* app) | 219 FakeEncryptedMedia(AppBase* app) |
217 : decryptor_(new AesDecryptor( | 220 : decryptor_(new AesDecryptor( |
218 GURL::EmptyGURL(), | 221 GURL::EmptyGURL(), |
219 base::Bind(&FakeEncryptedMedia::OnSessionMessage, | 222 base::Bind(&FakeEncryptedMedia::OnSessionMessage, |
220 base::Unretained(this)), | 223 base::Unretained(this)), |
221 base::Bind(&FakeEncryptedMedia::OnSessionClosed, | 224 base::Bind(&FakeEncryptedMedia::OnSessionClosed, |
222 base::Unretained(this)), | 225 base::Unretained(this)), |
223 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, | 226 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, |
| 227 base::Unretained(this)), |
| 228 base::Bind(&FakeEncryptedMedia::OnSessionExpirationUpdate, |
224 base::Unretained(this)))), | 229 base::Unretained(this)))), |
225 cdm_context_(decryptor_.get()), | 230 cdm_context_(decryptor_.get()), |
226 app_(app) {} | 231 app_(app) {} |
227 | 232 |
228 CdmContext* GetCdmContext() { return &cdm_context_; } | 233 CdmContext* GetCdmContext() { return &cdm_context_; } |
229 | 234 |
230 // Callbacks for firing session events. Delegate to |app_|. | 235 // Callbacks for firing session events. Delegate to |app_|. |
231 void OnSessionMessage(const std::string& session_id, | 236 void OnSessionMessage(const std::string& session_id, |
232 ContentDecryptionModule::MessageType message_type, | 237 ContentDecryptionModule::MessageType message_type, |
233 const std::vector<uint8_t>& message) { | 238 const std::vector<uint8_t>& message) { |
234 app_->OnSessionMessage(session_id, message_type, message, decryptor_.get()); | 239 app_->OnSessionMessage(session_id, message_type, message, decryptor_.get()); |
235 } | 240 } |
236 | 241 |
237 void OnSessionClosed(const std::string& session_id) { | 242 void OnSessionClosed(const std::string& session_id) { |
238 app_->OnSessionClosed(session_id); | 243 app_->OnSessionClosed(session_id); |
239 } | 244 } |
240 | 245 |
241 void OnSessionKeysChange(const std::string& session_id, | 246 void OnSessionKeysChange(const std::string& session_id, |
242 bool has_additional_usable_key, | 247 bool has_additional_usable_key, |
243 CdmKeysInfo keys_info) { | 248 CdmKeysInfo keys_info) { |
244 app_->OnSessionKeysChange(session_id, has_additional_usable_key, | 249 app_->OnSessionKeysChange(session_id, has_additional_usable_key, |
245 std::move(keys_info)); | 250 std::move(keys_info)); |
246 } | 251 } |
247 | 252 |
| 253 void OnSessionExpirationUpdate(const std::string& session_id, |
| 254 base::Time new_expiry_time) { |
| 255 app_->OnSessionExpirationUpdate(session_id, new_expiry_time); |
| 256 } |
| 257 |
248 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 258 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
249 const std::vector<uint8_t>& init_data) { | 259 const std::vector<uint8_t>& init_data) { |
250 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get()); | 260 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get()); |
251 } | 261 } |
252 | 262 |
253 private: | 263 private: |
254 class TestCdmContext : public CdmContext { | 264 class TestCdmContext : public CdmContext { |
255 public: | 265 public: |
256 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {} | 266 TestCdmContext(Decryptor* decryptor) : decryptor_(decryptor) {} |
257 | 267 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 EXPECT_EQ(current_session_id_, session_id); | 357 EXPECT_EQ(current_session_id_, session_id); |
348 } | 358 } |
349 | 359 |
350 void OnSessionKeysChange(const std::string& session_id, | 360 void OnSessionKeysChange(const std::string& session_id, |
351 bool has_additional_usable_key, | 361 bool has_additional_usable_key, |
352 CdmKeysInfo keys_info) override { | 362 CdmKeysInfo keys_info) override { |
353 EXPECT_EQ(current_session_id_, session_id); | 363 EXPECT_EQ(current_session_id_, session_id); |
354 EXPECT_EQ(has_additional_usable_key, true); | 364 EXPECT_EQ(has_additional_usable_key, true); |
355 } | 365 } |
356 | 366 |
| 367 void OnSessionExpirationUpdate(const std::string& session_id, |
| 368 base::Time new_expiry_time) override { |
| 369 EXPECT_EQ(current_session_id_, session_id); |
| 370 } |
| 371 |
357 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 372 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
358 const std::vector<uint8_t>& init_data, | 373 const std::vector<uint8_t>& init_data, |
359 AesDecryptor* decryptor) override { | 374 AesDecryptor* decryptor) override { |
360 // Since only 1 session is created, skip the request if the |init_data| | 375 // Since only 1 session is created, skip the request if the |init_data| |
361 // has been seen before (no need to add the same key again). | 376 // has been seen before (no need to add the same key again). |
362 if (init_data == prev_init_data_) | 377 if (init_data == prev_init_data_) |
363 return; | 378 return; |
364 prev_init_data_ = init_data; | 379 prev_init_data_ = init_data; |
365 | 380 |
366 if (current_session_id_.empty()) { | 381 if (current_session_id_.empty()) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 FAIL() << "Unexpected Closed"; | 445 FAIL() << "Unexpected Closed"; |
431 } | 446 } |
432 | 447 |
433 void OnSessionKeysChange(const std::string& session_id, | 448 void OnSessionKeysChange(const std::string& session_id, |
434 bool has_additional_usable_key, | 449 bool has_additional_usable_key, |
435 CdmKeysInfo keys_info) override { | 450 CdmKeysInfo keys_info) override { |
436 EXPECT_FALSE(session_id.empty()); | 451 EXPECT_FALSE(session_id.empty()); |
437 EXPECT_EQ(has_additional_usable_key, true); | 452 EXPECT_EQ(has_additional_usable_key, true); |
438 } | 453 } |
439 | 454 |
| 455 void OnSessionExpirationUpdate(const std::string& session_id, |
| 456 base::Time new_expiry_time) override {} |
| 457 |
440 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 458 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
441 const std::vector<uint8_t>& init_data, | 459 const std::vector<uint8_t>& init_data, |
442 AesDecryptor* decryptor) override {} | 460 AesDecryptor* decryptor) override {} |
443 }; | 461 }; |
444 | 462 |
445 // Helper class that emulates calls made on the ChunkDemuxer by the | 463 // Helper class that emulates calls made on the ChunkDemuxer by the |
446 // Media Source API. | 464 // Media Source API. |
447 class MockMediaSource { | 465 class MockMediaSource { |
448 public: | 466 public: |
449 MockMediaSource(const std::string& filename, | 467 MockMediaSource(const std::string& filename, |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2672 | 2690 |
2673 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2691 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2674 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2692 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2675 Play(); | 2693 Play(); |
2676 ASSERT_TRUE(WaitUntilOnEnded()); | 2694 ASSERT_TRUE(WaitUntilOnEnded()); |
2677 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2695 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2678 demuxer_->GetStartTime()); | 2696 demuxer_->GetStartTime()); |
2679 } | 2697 } |
2680 | 2698 |
2681 } // namespace media | 2699 } // namespace media |
OLD | NEW |