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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 const char kMP4VideoVP9[] = "video/mp4; codecs=\"vp09.00.00.08.01.01.00.00\""; | 107 const char kMP4VideoVP9[] = "video/mp4; codecs=\"vp09.00.00.08.01.01.00.00\""; |
108 #endif | 108 #endif |
109 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 109 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
110 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 110 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
111 const char kMP3[] = "audio/mpeg"; | 111 const char kMP3[] = "audio/mpeg"; |
112 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 112 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
113 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; | 113 const char kMP2AudioSBR[] = "video/mp2t; codecs=\"avc1.4D4041,mp4a.40.5\""; |
114 #endif | 114 #endif |
115 #endif // defined(USE_PROPRIETARY_CODECS) | 115 #endif // defined(USE_PROPRIETARY_CODECS) |
116 | 116 |
117 // Key used to encrypt test files. | |
118 const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | |
119 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c}; | |
120 | |
121 // The key ID for all encrypted files. | |
122 const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | |
123 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35}; | |
124 | |
125 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); | 117 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); |
126 | 118 |
127 // Constants for the Media Source config change tests. | 119 // Constants for the Media Source config change tests. |
128 const int kAppendTimeSec = 1; | 120 const int kAppendTimeSec = 1; |
129 const int kAppendTimeMs = kAppendTimeSec * 1000; | 121 const int kAppendTimeMs = kAppendTimeSec * 1000; |
130 const int k320WebMFileDurationMs = 2736; | 122 const int k320WebMFileDurationMs = 2736; |
131 const int k320EncWebMFileDurationMs = 2737; | 123 const int k320EncWebMFileDurationMs = 2737; |
132 const int k640WebMFileDurationMs = 2749; | 124 const int k640WebMFileDurationMs = 2749; |
133 const int kOpusEndTrimmingWebMFileDurationMs = 2741; | 125 const int kOpusEndTrimmingWebMFileDurationMs = 2741; |
134 const int kVP9WebMFileDurationMs = 2736; | 126 const int kVP9WebMFileDurationMs = 2736; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 Decryptor* decryptor_; | 278 Decryptor* decryptor_; |
287 }; | 279 }; |
288 | 280 |
289 scoped_refptr<AesDecryptor> decryptor_; | 281 scoped_refptr<AesDecryptor> decryptor_; |
290 TestCdmContext cdm_context_; | 282 TestCdmContext cdm_context_; |
291 std::unique_ptr<AppBase> app_; | 283 std::unique_ptr<AppBase> app_; |
292 }; | 284 }; |
293 | 285 |
294 enum PromiseResult { RESOLVED, REJECTED }; | 286 enum PromiseResult { RESOLVED, REJECTED }; |
295 | 287 |
296 // Provides |kSecretKey| in response to the encrypted event. | 288 // Provides the test key in response to the encrypted event. |
297 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { | 289 class KeyProvidingApp : public FakeEncryptedMedia::AppBase { |
298 public: | 290 public: |
299 KeyProvidingApp() {} | 291 KeyProvidingApp() {} |
300 | 292 |
301 void OnResolveWithSession(PromiseResult expected, | 293 void OnResolveWithSession(PromiseResult expected, |
302 const std::string& session_id) { | 294 const std::string& session_id) { |
303 EXPECT_EQ(expected, RESOLVED); | 295 EXPECT_EQ(expected, RESOLVED); |
304 EXPECT_GT(session_id.length(), 0ul); | 296 EXPECT_GT(session_id.length(), 0ul); |
305 current_session_id_ = session_id; | 297 current_session_id_ = session_id; |
306 } | 298 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 if (current_session_id_.empty()) { | 382 if (current_session_id_.empty()) { |
391 decryptor->CreateSessionAndGenerateRequest( | 383 decryptor->CreateSessionAndGenerateRequest( |
392 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, | 384 MediaKeys::TEMPORARY_SESSION, init_data_type, init_data, |
393 CreateSessionPromise(RESOLVED)); | 385 CreateSessionPromise(RESOLVED)); |
394 EXPECT_FALSE(current_session_id_.empty()); | 386 EXPECT_FALSE(current_session_id_.empty()); |
395 } | 387 } |
396 } | 388 } |
397 | 389 |
398 virtual bool LookupKey(const std::vector<uint8_t>& key_id, | 390 virtual bool LookupKey(const std::vector<uint8_t>& key_id, |
399 std::vector<uint8_t>* key) { | 391 std::vector<uint8_t>* key) { |
400 // As there is no key rotation, the key ID provided should be |kKeyId| | 392 // No key rotation. |
401 // which uses |kSecretKey| as the key. | 393 return LookupTestKeyVector(key_id, false, key); |
402 EXPECT_EQ(std::vector<uint8_t>(kKeyId, kKeyId + arraysize(kKeyId)), key_id); | |
403 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey)); | |
404 return true; | |
405 } | 394 } |
406 | 395 |
407 std::string current_session_id_; | 396 std::string current_session_id_; |
408 std::vector<uint8_t> prev_init_data_; | 397 std::vector<uint8_t> prev_init_data_; |
409 }; | 398 }; |
410 | 399 |
411 class RotatingKeyProvidingApp : public KeyProvidingApp { | 400 class RotatingKeyProvidingApp : public KeyProvidingApp { |
412 public: | 401 public: |
413 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} | 402 RotatingKeyProvidingApp() : num_distinct_need_key_calls_(0) {} |
414 ~RotatingKeyProvidingApp() override { | 403 ~RotatingKeyProvidingApp() override { |
(...skipping 11 matching lines...) Expand all Loading... | |
426 prev_init_data_ = init_data; | 415 prev_init_data_ = init_data; |
427 ++num_distinct_need_key_calls_; | 416 ++num_distinct_need_key_calls_; |
428 | 417 |
429 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, | 418 decryptor->CreateSessionAndGenerateRequest(MediaKeys::TEMPORARY_SESSION, |
430 init_data_type, init_data, | 419 init_data_type, init_data, |
431 CreateSessionPromise(RESOLVED)); | 420 CreateSessionPromise(RESOLVED)); |
432 } | 421 } |
433 | 422 |
434 bool LookupKey(const std::vector<uint8_t>& key_id, | 423 bool LookupKey(const std::vector<uint8_t>& key_id, |
435 std::vector<uint8_t>* key) override { | 424 std::vector<uint8_t>* key) override { |
436 // The Key and KeyId for this testing key provider are created by left | 425 // With key rotation. |
437 // rotating |kSecretKey| and |kKeyId|. Note that this implementation is | 426 return LookupTestKeyVector(key_id, true, key); |
438 // only intended for testing purpose. The actual key rotation algorithm | |
439 // can be much more complicated. | |
440 // Find out the rotating position from |starting_key_id| and apply on |key|. | |
441 std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId)); | |
442 for (size_t pos = 0; pos < starting_key_id.size(); ++pos) { | |
443 std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos, | |
444 starting_key_id.end()); | |
445 if (key_id == starting_key_id) { | |
446 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey)); | |
447 std::rotate(key->begin(), key->begin() + pos, key->end()); | |
448 return true; | |
449 } | |
450 } | |
451 return false; | |
452 } | 427 } |
453 | 428 |
454 uint32_t num_distinct_need_key_calls_; | 429 uint32_t num_distinct_need_key_calls_; |
455 }; | 430 }; |
456 | 431 |
457 // Ignores the encrypted event and does not perform a license request. | 432 // Ignores the encrypted event and does not perform a license request. |
458 class NoResponseApp : public FakeEncryptedMedia::AppBase { | 433 class NoResponseApp : public FakeEncryptedMedia::AppBase { |
459 public: | 434 public: |
460 void OnSessionMessage(const std::string& session_id, | 435 void OnSessionMessage(const std::string& session_id, |
461 MediaKeys::MessageType message_type, | 436 MediaKeys::MessageType message_type, |
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1785 source.EndOfStream(); | 1760 source.EndOfStream(); |
1786 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1761 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
1787 | 1762 |
1788 Play(); | 1763 Play(); |
1789 | 1764 |
1790 ASSERT_TRUE(WaitUntilOnEnded()); | 1765 ASSERT_TRUE(WaitUntilOnEnded()); |
1791 source.Shutdown(); | 1766 source.Shutdown(); |
1792 Stop(); | 1767 Stop(); |
1793 } | 1768 } |
1794 | 1769 |
1795 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 1770 #if BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
ddorwin
2016/06/23 19:42:01
It would be better if we could always run this tes
dougsteed
2016/09/25 21:52:30
As you mention below, this was an unrelated change
| |
1796 TEST_F(PipelineIntegrationTest, Mp2ts_AAC_HE_SBR_Audio) { | 1771 TEST_F(PipelineIntegrationTest, Mp2ts_AAC_HE_SBR_Audio) { |
1797 EXPECT_CALL(*this, OnDurationChange()).Times(AnyNumber()); | 1772 EXPECT_CALL(*this, OnDurationChange()).Times(AnyNumber()); |
1798 | 1773 |
1799 MockMediaSource source("bear-1280x720-aac_he.ts", kMP2AudioSBR, | 1774 MockMediaSource source("bear-1280x720-aac_he.ts", kMP2AudioSBR, |
1800 kAppendWholeFile); | 1775 kAppendWholeFile); |
1801 StartPipelineWithMediaSource(&source); | 1776 StartPipelineWithMediaSource(&source); |
1802 | 1777 |
1803 source.EndOfStream(); | 1778 source.EndOfStream(); |
1804 ASSERT_EQ(PIPELINE_OK, pipeline_status_); | 1779 ASSERT_EQ(PIPELINE_OK, pipeline_status_); |
1805 | 1780 |
1806 // When SBR is not taken into account correctly by mpeg2ts parser, it will | 1781 // When SBR is not taken into account correctly by mpeg2ts parser, it will |
ddorwin
2016/06/23 19:42:01
[I guess this was added in another CL, but I'm onl
dougsteed
2016/09/25 21:52:30
will inform servolk@
servolk
2016/09/26 23:15:20
It's both the former and the latter. This did happ
| |
1807 // estimate audio frame durations incorrectly and that will lead to gaps in | 1782 // estimate audio frame durations incorrectly and that will lead to gaps in |
1808 // buffered ranges (so this check will fail) and stalled playback. | 1783 // buffered ranges (so this check will fail) and stalled playback. |
ddorwin
2016/06/23 19:42:01
"stall"
dougsteed
2016/09/25 21:52:30
ditto
servolk
2016/09/26 23:15:20
I actually meant to say here that "... incorrect d
| |
1809 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1784 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
1810 } | 1785 } |
1811 #endif | 1786 #endif |
1812 | 1787 |
1813 TEST_F(PipelineIntegrationTest, | 1788 TEST_F(PipelineIntegrationTest, |
1814 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { | 1789 MAYBE_EME(EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly)) { |
1815 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, | 1790 MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio, |
1816 kAppendWholeFile); | 1791 kAppendWholeFile); |
1817 FakeEncryptedMedia encrypted_media(new NoResponseApp()); | 1792 FakeEncryptedMedia encrypted_media(new NoResponseApp()); |
1818 StartPipelineWithEncryptedMedia(&source, &encrypted_media); | 1793 StartPipelineWithEncryptedMedia(&source, &encrypted_media); |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2194 | 2169 |
2195 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2170 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
2196 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2171 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
2197 Play(); | 2172 Play(); |
2198 ASSERT_TRUE(WaitUntilOnEnded()); | 2173 ASSERT_TRUE(WaitUntilOnEnded()); |
2199 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2174 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
2200 demuxer_->GetStartTime()); | 2175 demuxer_->GetStartTime()); |
2201 } | 2176 } |
2202 | 2177 |
2203 } // namespace media | 2178 } // namespace media |
OLD | NEW |