| 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 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 #if defined(USE_PROPRIETARY_CODECS) | 98 #if defined(USE_PROPRIETARY_CODECS) |
| 99 const char kADTS[] = "audio/aac"; | 99 const char kADTS[] = "audio/aac"; |
| 100 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; | 100 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\""; |
| 101 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; | 101 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\""; |
| 102 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; | 102 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\""; |
| 103 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; | 103 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\""; |
| 104 const char kMP3[] = "audio/mpeg"; | 104 const char kMP3[] = "audio/mpeg"; |
| 105 #endif // defined(USE_PROPRIETARY_CODECS) | 105 #endif // defined(USE_PROPRIETARY_CODECS) |
| 106 | 106 |
| 107 // Key used to encrypt test files. | 107 // Key used to encrypt test files. |
| 108 const uint8_t kSecretKey[] = { | 108 const uint8_t kSecretKey[] = {0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, |
| 109 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, | 109 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c}; |
| 110 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c | |
| 111 }; | |
| 112 | 110 |
| 113 // The key ID for all encrypted files. | 111 // The key ID for all encrypted files. |
| 114 const uint8_t kKeyId[] = { | 112 const uint8_t kKeyId[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, |
| 115 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, | 113 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35}; |
| 116 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35 | |
| 117 }; | |
| 118 | 114 |
| 119 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); | 115 const size_t kAppendWholeFile = std::numeric_limits<size_t>::max(); |
| 120 | 116 |
| 121 // Constants for the Media Source config change tests. | 117 // Constants for the Media Source config change tests. |
| 122 const int kAppendTimeSec = 1; | 118 const int kAppendTimeSec = 1; |
| 123 const int kAppendTimeMs = kAppendTimeSec * 1000; | 119 const int kAppendTimeMs = kAppendTimeSec * 1000; |
| 124 const int k320WebMFileDurationMs = 2736; | 120 const int k320WebMFileDurationMs = 2736; |
| 125 const int k320EncWebMFileDurationMs = 2737; | 121 const int k320EncWebMFileDurationMs = 2737; |
| 126 const int k640WebMFileDurationMs = 2749; | 122 const int k640WebMFileDurationMs = 2749; |
| 127 const int kOpusEndTrimmingWebMFileDurationMs = 2741; | 123 const int kOpusEndTrimmingWebMFileDurationMs = 2741; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 public: | 288 public: |
| 293 KeyProvidingApp() {} | 289 KeyProvidingApp() {} |
| 294 | 290 |
| 295 void OnResolveWithSession(PromiseResult expected, | 291 void OnResolveWithSession(PromiseResult expected, |
| 296 const std::string& session_id) { | 292 const std::string& session_id) { |
| 297 EXPECT_EQ(expected, RESOLVED); | 293 EXPECT_EQ(expected, RESOLVED); |
| 298 EXPECT_GT(session_id.length(), 0ul); | 294 EXPECT_GT(session_id.length(), 0ul); |
| 299 current_session_id_ = session_id; | 295 current_session_id_ = session_id; |
| 300 } | 296 } |
| 301 | 297 |
| 302 void OnResolve(PromiseResult expected) { | 298 void OnResolve(PromiseResult expected) { EXPECT_EQ(expected, RESOLVED); } |
| 303 EXPECT_EQ(expected, RESOLVED); | |
| 304 } | |
| 305 | 299 |
| 306 void OnReject(PromiseResult expected, | 300 void OnReject(PromiseResult expected, |
| 307 media::MediaKeys::Exception exception_code, | 301 media::MediaKeys::Exception exception_code, |
| 308 uint32_t system_code, | 302 uint32_t system_code, |
| 309 const std::string& error_message) { | 303 const std::string& error_message) { |
| 310 EXPECT_EQ(expected, REJECTED) << error_message; | 304 EXPECT_EQ(expected, REJECTED) << error_message; |
| 311 } | 305 } |
| 312 | 306 |
| 313 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) { | 307 scoped_ptr<SimpleCdmPromise> CreatePromise(PromiseResult expected) { |
| 314 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( | 308 scoped_ptr<media::SimpleCdmPromise> promise(new media::CdmCallbackPromise<>( |
| 315 base::Bind( | 309 base::Bind(&KeyProvidingApp::OnResolve, base::Unretained(this), |
| 316 &KeyProvidingApp::OnResolve, base::Unretained(this), expected), | 310 expected), |
| 317 base::Bind( | 311 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), |
| 318 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); | 312 expected))); |
| 319 return promise; | 313 return promise; |
| 320 } | 314 } |
| 321 | 315 |
| 322 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( | 316 scoped_ptr<NewSessionCdmPromise> CreateSessionPromise( |
| 323 PromiseResult expected) { | 317 PromiseResult expected) { |
| 324 scoped_ptr<media::NewSessionCdmPromise> promise( | 318 scoped_ptr<media::NewSessionCdmPromise> promise( |
| 325 new media::CdmCallbackPromise<std::string>( | 319 new media::CdmCallbackPromise<std::string>( |
| 326 base::Bind(&KeyProvidingApp::OnResolveWithSession, | 320 base::Bind(&KeyProvidingApp::OnResolveWithSession, |
| 327 base::Unretained(this), | 321 base::Unretained(this), expected), |
| 328 expected), | 322 base::Bind(&KeyProvidingApp::OnReject, base::Unretained(this), |
| 329 base::Bind( | 323 expected))); |
| 330 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); | |
| 331 return promise; | 324 return promise; |
| 332 } | 325 } |
| 333 | 326 |
| 334 void OnSessionMessage(const std::string& session_id, | 327 void OnSessionMessage(const std::string& session_id, |
| 335 MediaKeys::MessageType message_type, | 328 MediaKeys::MessageType message_type, |
| 336 const std::vector<uint8_t>& message, | 329 const std::vector<uint8_t>& message, |
| 337 const GURL& legacy_destination_url, | 330 const GURL& legacy_destination_url, |
| 338 AesDecryptor* decryptor) override { | 331 AesDecryptor* decryptor) override { |
| 339 EXPECT_FALSE(session_id.empty()); | 332 EXPECT_FALSE(session_id.empty()); |
| 340 EXPECT_FALSE(message.empty()); | 333 EXPECT_FALSE(message.empty()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 void set_encrypted_media_init_data_cb( | 506 void set_encrypted_media_init_data_cb( |
| 514 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { | 507 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { |
| 515 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 508 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
| 516 } | 509 } |
| 517 | 510 |
| 518 void Seek(base::TimeDelta seek_time, | 511 void Seek(base::TimeDelta seek_time, |
| 519 size_t new_position, | 512 size_t new_position, |
| 520 size_t seek_append_size) { | 513 size_t seek_append_size) { |
| 521 chunk_demuxer_->StartWaitingForSeek(seek_time); | 514 chunk_demuxer_->StartWaitingForSeek(seek_time); |
| 522 | 515 |
| 523 chunk_demuxer_->ResetParserState( | 516 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(), |
| 524 kSourceId, | 517 kInfiniteDuration(), |
| 525 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); | 518 &last_timestamp_offset_); |
| 526 | 519 |
| 527 DCHECK_LT(new_position, file_data_->data_size()); | 520 DCHECK_LT(new_position, file_data_->data_size()); |
| 528 current_position_ = new_position; | 521 current_position_ = new_position; |
| 529 | 522 |
| 530 AppendData(seek_append_size); | 523 AppendData(seek_append_size); |
| 531 } | 524 } |
| 532 | 525 |
| 533 void Seek(base::TimeDelta seek_time) { | 526 void Seek(base::TimeDelta seek_time) { |
| 534 chunk_demuxer_->StartWaitingForSeek(seek_time); | 527 chunk_demuxer_->StartWaitingForSeek(seek_time); |
| 535 } | 528 } |
| 536 | 529 |
| 537 void AppendData(size_t size) { | 530 void AppendData(size_t size) { |
| 538 DCHECK(chunk_demuxer_); | 531 DCHECK(chunk_demuxer_); |
| 539 DCHECK_LT(current_position_, file_data_->data_size()); | 532 DCHECK_LT(current_position_, file_data_->data_size()); |
| 540 DCHECK_LE(current_position_ + size, file_data_->data_size()); | 533 DCHECK_LE(current_position_ + size, file_data_->data_size()); |
| 541 | 534 |
| 542 chunk_demuxer_->AppendData( | 535 chunk_demuxer_->AppendData( |
| 543 kSourceId, file_data_->data() + current_position_, size, | 536 kSourceId, file_data_->data() + current_position_, size, |
| 544 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_, | 537 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_, |
| 545 base::Bind(&MockMediaSource::InitSegmentReceived, | 538 base::Bind(&MockMediaSource::InitSegmentReceived, |
| 546 base::Unretained(this))); | 539 base::Unretained(this))); |
| 547 current_position_ += size; | 540 current_position_ += size; |
| 548 } | 541 } |
| 549 | 542 |
| 550 void AppendAtTime(base::TimeDelta timestamp_offset, | 543 void AppendAtTime(base::TimeDelta timestamp_offset, |
| 551 const uint8_t* pData, | 544 const uint8_t* pData, |
| 552 int size) { | 545 int size) { |
| 553 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); | 546 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); |
| 554 chunk_demuxer_->AppendData(kSourceId, pData, size, | 547 chunk_demuxer_->AppendData(kSourceId, pData, size, base::TimeDelta(), |
| 555 base::TimeDelta(), kInfiniteDuration(), | 548 kInfiniteDuration(), ×tamp_offset, |
| 556 ×tamp_offset, | |
| 557 base::Bind(&MockMediaSource::InitSegmentReceived, | 549 base::Bind(&MockMediaSource::InitSegmentReceived, |
| 558 base::Unretained(this))); | 550 base::Unretained(this))); |
| 559 last_timestamp_offset_ = timestamp_offset; | 551 last_timestamp_offset_ = timestamp_offset; |
| 560 } | 552 } |
| 561 | 553 |
| 562 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, | 554 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, |
| 563 base::TimeDelta append_window_start, | 555 base::TimeDelta append_window_start, |
| 564 base::TimeDelta append_window_end, | 556 base::TimeDelta append_window_end, |
| 565 const uint8_t* pData, | 557 const uint8_t* pData, |
| 566 int size) { | 558 int size) { |
| 567 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); | 559 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); |
| 568 chunk_demuxer_->AppendData(kSourceId, | 560 chunk_demuxer_->AppendData(kSourceId, pData, size, append_window_start, |
| 569 pData, | 561 append_window_end, ×tamp_offset, |
| 570 size, | |
| 571 append_window_start, | |
| 572 append_window_end, | |
| 573 ×tamp_offset, | |
| 574 base::Bind(&MockMediaSource::InitSegmentReceived, | 562 base::Bind(&MockMediaSource::InitSegmentReceived, |
| 575 base::Unretained(this))); | 563 base::Unretained(this))); |
| 576 last_timestamp_offset_ = timestamp_offset; | 564 last_timestamp_offset_ = timestamp_offset; |
| 577 } | 565 } |
| 578 | 566 |
| 579 void SetMemoryLimits(size_t limit_bytes) { | 567 void SetMemoryLimits(size_t limit_bytes) { |
| 580 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes); | 568 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes); |
| 581 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes); | 569 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes); |
| 582 } | 570 } |
| 583 | 571 |
| 584 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { | 572 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { |
| 585 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); | 573 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); |
| 586 } | 574 } |
| 587 | 575 |
| 588 void RemoveRange(base::TimeDelta start, base::TimeDelta end) { | 576 void RemoveRange(base::TimeDelta start, base::TimeDelta end) { |
| 589 chunk_demuxer_->Remove(kSourceId, start, end); | 577 chunk_demuxer_->Remove(kSourceId, start, end); |
| 590 } | 578 } |
| 591 | 579 |
| 592 void EndOfStream() { | 580 void EndOfStream() { chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); } |
| 593 chunk_demuxer_->MarkEndOfStream(PIPELINE_OK); | |
| 594 } | |
| 595 | 581 |
| 596 void Shutdown() { | 582 void Shutdown() { |
| 597 if (!chunk_demuxer_) | 583 if (!chunk_demuxer_) |
| 598 return; | 584 return; |
| 599 chunk_demuxer_->ResetParserState( | 585 chunk_demuxer_->ResetParserState(kSourceId, base::TimeDelta(), |
| 600 kSourceId, | 586 kInfiniteDuration(), |
| 601 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_); | 587 &last_timestamp_offset_); |
| 602 chunk_demuxer_->Shutdown(); | 588 chunk_demuxer_->Shutdown(); |
| 603 chunk_demuxer_ = NULL; | 589 chunk_demuxer_ = NULL; |
| 604 } | 590 } |
| 605 | 591 |
| 606 void DemuxerOpened() { | 592 void DemuxerOpened() { |
| 607 base::MessageLoop::current()->PostTask( | 593 base::MessageLoop::current()->PostTask( |
| 608 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask, | 594 FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask, |
| 609 base::Unretained(this))); | 595 base::Unretained(this))); |
| 610 } | 596 } |
| 611 | 597 |
| 612 void DemuxerOpenedTask() { | 598 void DemuxerOpenedTask() { |
| 613 // This code assumes that |mimetype_| is one of the following forms. | 599 // This code assumes that |mimetype_| is one of the following forms. |
| 614 // 1. audio/mpeg | 600 // 1. audio/mpeg |
| 615 // 2. video/webm;codec="vorbis,vp8". | 601 // 2. video/webm;codec="vorbis,vp8". |
| 616 size_t semicolon = mimetype_.find(";"); | 602 size_t semicolon = mimetype_.find(";"); |
| 617 std::string type = mimetype_; | 603 std::string type = mimetype_; |
| 618 std::vector<std::string> codecs; | 604 std::vector<std::string> codecs; |
| 619 if (semicolon != std::string::npos) { | 605 if (semicolon != std::string::npos) { |
| 620 type = mimetype_.substr(0, semicolon); | 606 type = mimetype_.substr(0, semicolon); |
| 621 size_t codecs_param_start = mimetype_.find("codecs=\"", semicolon); | 607 size_t codecs_param_start = mimetype_.find("codecs=\"", semicolon); |
| 622 | 608 |
| 623 CHECK_NE(codecs_param_start, std::string::npos); | 609 CHECK_NE(codecs_param_start, std::string::npos); |
| 624 | 610 |
| 625 codecs_param_start += 8; // Skip over the codecs=". | 611 codecs_param_start += 8; // Skip over the codecs=". |
| 626 | 612 |
| 627 size_t codecs_param_end = mimetype_.find("\"", codecs_param_start); | 613 size_t codecs_param_end = mimetype_.find("\"", codecs_param_start); |
| 628 | 614 |
| 629 CHECK_NE(codecs_param_end, std::string::npos); | 615 CHECK_NE(codecs_param_end, std::string::npos); |
| 630 | 616 |
| 631 std::string codecs_param = | 617 std::string codecs_param = mimetype_.substr( |
| 632 mimetype_.substr(codecs_param_start, | 618 codecs_param_start, codecs_param_end - codecs_param_start); |
| 633 codecs_param_end - codecs_param_start); | 619 codecs = base::SplitString(codecs_param, ",", base::KEEP_WHITESPACE, |
| 634 codecs = base::SplitString( | 620 base::SPLIT_WANT_NONEMPTY); |
| 635 codecs_param, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | |
| 636 } | 621 } |
| 637 | 622 |
| 638 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); | 623 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); |
| 639 | 624 |
| 640 AppendData(initial_append_size_); | 625 AppendData(initial_append_size_); |
| 641 } | 626 } |
| 642 | 627 |
| 643 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 628 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
| 644 const std::vector<uint8_t>& init_data) { | 629 const std::vector<uint8_t>& init_data) { |
| 645 DCHECK(!init_data.empty()); | 630 DCHECK(!init_data.empty()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 hashing_enabled_ = true; | 717 hashing_enabled_ = true; |
| 733 StartPipelineWithMediaSource(source); | 718 StartPipelineWithMediaSource(source); |
| 734 } | 719 } |
| 735 | 720 |
| 736 void StartHashedClocklessPipelineWithMediaSource(MockMediaSource* source) { | 721 void StartHashedClocklessPipelineWithMediaSource(MockMediaSource* source) { |
| 737 hashing_enabled_ = true; | 722 hashing_enabled_ = true; |
| 738 clockless_playback_ = true; | 723 clockless_playback_ = true; |
| 739 StartPipelineWithMediaSource(source); | 724 StartPipelineWithMediaSource(source); |
| 740 } | 725 } |
| 741 | 726 |
| 742 void StartPipelineWithEncryptedMedia( | 727 void StartPipelineWithEncryptedMedia(MockMediaSource* source, |
| 743 MockMediaSource* source, | 728 FakeEncryptedMedia* encrypted_media) { |
| 744 FakeEncryptedMedia* encrypted_media) { | |
| 745 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); | 729 EXPECT_CALL(*source, InitSegmentReceived()).Times(AtLeast(1)); |
| 746 EXPECT_CALL(*this, OnMetadata(_)) | 730 EXPECT_CALL(*this, OnMetadata(_)) |
| 747 .Times(AtMost(1)) | 731 .Times(AtMost(1)) |
| 748 .WillRepeatedly(SaveArg<0>(&metadata_)); | 732 .WillRepeatedly(SaveArg<0>(&metadata_)); |
| 749 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 733 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) |
| 750 .Times(AnyNumber()); | 734 .Times(AnyNumber()); |
| 751 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) | 735 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_NOTHING)) |
| 752 .Times(AnyNumber()); | 736 .Times(AnyNumber()); |
| 753 EXPECT_CALL(*this, DecryptorAttached(true)); | 737 EXPECT_CALL(*this, DecryptorAttached(true)); |
| 754 | 738 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 | 984 |
| 1001 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 985 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1002 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 986 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1003 EXPECT_EQ(k320WebMFileDurationMs, | 987 EXPECT_EQ(k320WebMFileDurationMs, |
| 1004 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 988 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1005 | 989 |
| 1006 Play(); | 990 Play(); |
| 1007 | 991 |
| 1008 ASSERT_TRUE(WaitUntilOnEnded()); | 992 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1009 | 993 |
| 1010 EXPECT_EQ(kLiveTimelineOffset(), | 994 EXPECT_EQ(kLiveTimelineOffset(), demuxer_->GetTimelineOffset()); |
| 1011 demuxer_->GetTimelineOffset()); | |
| 1012 source.Shutdown(); | 995 source.Shutdown(); |
| 1013 Stop(); | 996 Stop(); |
| 1014 } | 997 } |
| 1015 | 998 |
| 1016 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { | 999 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP9_WebM) { |
| 1017 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); | 1000 MockMediaSource source("bear-vp9.webm", kWebMVP9, 67504); |
| 1018 StartPipelineWithMediaSource(&source); | 1001 StartPipelineWithMediaSource(&source); |
| 1019 source.EndOfStream(); | 1002 source.EndOfStream(); |
| 1020 | 1003 |
| 1021 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1004 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1287 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); | 1270 EXPECT_EQ(325, source.last_timestamp_offset().InMilliseconds()); |
| 1288 | 1271 |
| 1289 // Trim off multiple frames off the beginning of the segment which will cause | 1272 // Trim off multiple frames off the beginning of the segment which will cause |
| 1290 // the first decoded frame to be incorrect if preroll isn't implemented. | 1273 // the first decoded frame to be incorrect if preroll isn't implemented. |
| 1291 const base::TimeDelta adts_preroll_duration = | 1274 const base::TimeDelta adts_preroll_duration = |
| 1292 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); | 1275 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100); |
| 1293 const base::TimeDelta append_time = | 1276 const base::TimeDelta append_time = |
| 1294 source.last_timestamp_offset() - adts_preroll_duration; | 1277 source.last_timestamp_offset() - adts_preroll_duration; |
| 1295 | 1278 |
| 1296 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); | 1279 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.adts"); |
| 1297 source.AppendAtTimeWithWindow(append_time, | 1280 source.AppendAtTimeWithWindow( |
| 1298 append_time + adts_preroll_duration, | 1281 append_time, append_time + adts_preroll_duration, kInfiniteDuration(), |
| 1299 kInfiniteDuration(), | 1282 second_file->data(), second_file->data_size()); |
| 1300 second_file->data(), | |
| 1301 second_file->data_size()); | |
| 1302 source.EndOfStream(); | 1283 source.EndOfStream(); |
| 1303 | 1284 |
| 1304 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); | 1285 EXPECT_EQ(592, source.last_timestamp_offset().InMilliseconds()); |
| 1305 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1286 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1306 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1287 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1307 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1288 EXPECT_EQ(592, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1308 | 1289 |
| 1309 Play(); | 1290 Play(); |
| 1310 | 1291 |
| 1311 EXPECT_TRUE(WaitUntilOnEnded()); | 1292 EXPECT_TRUE(WaitUntilOnEnded()); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); | 1402 EXPECT_EQ(313, source.last_timestamp_offset().InMilliseconds()); |
| 1422 | 1403 |
| 1423 // There are 576 silent frames at the start of this mp3. The second append | 1404 // There are 576 silent frames at the start of this mp3. The second append |
| 1424 // should trim them off. | 1405 // should trim them off. |
| 1425 const base::TimeDelta mp3_preroll_duration = | 1406 const base::TimeDelta mp3_preroll_duration = |
| 1426 base::TimeDelta::FromSecondsD(576.0 / 44100); | 1407 base::TimeDelta::FromSecondsD(576.0 / 44100); |
| 1427 const base::TimeDelta append_time = | 1408 const base::TimeDelta append_time = |
| 1428 source.last_timestamp_offset() - mp3_preroll_duration; | 1409 source.last_timestamp_offset() - mp3_preroll_duration; |
| 1429 | 1410 |
| 1430 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); | 1411 scoped_refptr<DecoderBuffer> second_file = ReadTestDataFile("sfx.mp3"); |
| 1431 source.AppendAtTimeWithWindow(append_time, | 1412 source.AppendAtTimeWithWindow(append_time, append_time + mp3_preroll_duration, |
| 1432 append_time + mp3_preroll_duration, | 1413 kInfiniteDuration(), second_file->data(), |
| 1433 kInfiniteDuration(), | |
| 1434 second_file->data(), | |
| 1435 second_file->data_size()); | 1414 second_file->data_size()); |
| 1436 source.EndOfStream(); | 1415 source.EndOfStream(); |
| 1437 | 1416 |
| 1438 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); | 1417 EXPECT_EQ(613, source.last_timestamp_offset().InMilliseconds()); |
| 1439 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); | 1418 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); |
| 1440 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); | 1419 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); |
| 1441 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); | 1420 EXPECT_EQ(613, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); |
| 1442 | 1421 |
| 1443 Play(); | 1422 Play(); |
| 1444 | 1423 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 | 1850 |
| 1872 TEST_F(PipelineIntegrationTest, Rotated_Metadata_270) { | 1851 TEST_F(PipelineIntegrationTest, Rotated_Metadata_270) { |
| 1873 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); | 1852 ASSERT_EQ(PIPELINE_OK, Start("bear_rotate_270.mp4")); |
| 1874 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); | 1853 ASSERT_EQ(VIDEO_ROTATION_270, metadata_.video_rotation); |
| 1875 } | 1854 } |
| 1876 #endif // defined(USE_PROPRIETARY_CODECS) | 1855 #endif // defined(USE_PROPRIETARY_CODECS) |
| 1877 | 1856 |
| 1878 // Verify audio decoder & renderer can handle aborted demuxer reads. | 1857 // Verify audio decoder & renderer can handle aborted demuxer reads. |
| 1879 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { | 1858 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) { |
| 1880 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, | 1859 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM, |
| 1881 16384, | 1860 16384, base::TimeDelta::FromMilliseconds(464), |
| 1882 base::TimeDelta::FromMilliseconds(464), | 1861 base::TimeDelta::FromMilliseconds(617), 0x10CA, |
| 1883 base::TimeDelta::FromMilliseconds(617), | 1862 19730)); |
| 1884 0x10CA, 19730)); | |
| 1885 } | 1863 } |
| 1886 | 1864 |
| 1887 // Verify video decoder & renderer can handle aborted demuxer reads. | 1865 // Verify video decoder & renderer can handle aborted demuxer reads. |
| 1888 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { | 1866 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) { |
| 1889 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, | 1867 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM, |
| 1890 32768, | 1868 32768, base::TimeDelta::FromMilliseconds(167), |
| 1891 base::TimeDelta::FromMilliseconds(167), | |
| 1892 base::TimeDelta::FromMilliseconds(1668), | 1869 base::TimeDelta::FromMilliseconds(1668), |
| 1893 0x1C896, 65536)); | 1870 0x1C896, 65536)); |
| 1894 } | 1871 } |
| 1895 | 1872 |
| 1896 // Verify that Opus audio in WebM containers can be played back. | 1873 // Verify that Opus audio in WebM containers can be played back. |
| 1897 TEST_F(PipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { | 1874 TEST_F(PipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) { |
| 1898 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); | 1875 ASSERT_EQ(PIPELINE_OK, Start("bear-opus-end-trimming.webm")); |
| 1899 Play(); | 1876 Play(); |
| 1900 ASSERT_TRUE(WaitUntilOnEnded()); | 1877 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1901 } | 1878 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 Play(); | 1953 Play(); |
| 1977 ASSERT_TRUE(WaitUntilOnEnded()); | 1954 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1978 } | 1955 } |
| 1979 | 1956 |
| 1980 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays | 1957 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays |
| 1981 // correctly at 48kHz | 1958 // correctly at 48kHz |
| 1982 TEST_F(PipelineIntegrationTest, BasicPlayback_Opus441kHz) { | 1959 TEST_F(PipelineIntegrationTest, BasicPlayback_Opus441kHz) { |
| 1983 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); | 1960 ASSERT_EQ(PIPELINE_OK, Start("sfx-opus-441.webm")); |
| 1984 Play(); | 1961 Play(); |
| 1985 ASSERT_TRUE(WaitUntilOnEnded()); | 1962 ASSERT_TRUE(WaitUntilOnEnded()); |
| 1986 EXPECT_EQ(48000, | 1963 EXPECT_EQ(48000, demuxer_->GetStream(DemuxerStream::AUDIO) |
| 1987 demuxer_->GetStream(DemuxerStream::AUDIO) | 1964 ->audio_decoder_config() |
| 1988 ->audio_decoder_config() | 1965 .samples_per_second()); |
| 1989 .samples_per_second()); | |
| 1990 } | 1966 } |
| 1991 | 1967 |
| 1992 // Same as above but using MediaSource. | 1968 // Same as above but using MediaSource. |
| 1993 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { | 1969 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus441kHz) { |
| 1994 MockMediaSource source( | 1970 MockMediaSource source("sfx-opus-441.webm", kOpusAudioOnlyWebM, |
| 1995 "sfx-opus-441.webm", kOpusAudioOnlyWebM, kAppendWholeFile); | 1971 kAppendWholeFile); |
| 1996 StartPipelineWithMediaSource(&source); | 1972 StartPipelineWithMediaSource(&source); |
| 1997 source.EndOfStream(); | 1973 source.EndOfStream(); |
| 1998 Play(); | 1974 Play(); |
| 1999 ASSERT_TRUE(WaitUntilOnEnded()); | 1975 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2000 source.Shutdown(); | 1976 source.Shutdown(); |
| 2001 Stop(); | 1977 Stop(); |
| 2002 EXPECT_EQ(48000, | 1978 EXPECT_EQ(48000, demuxer_->GetStream(DemuxerStream::AUDIO) |
| 2003 demuxer_->GetStream(DemuxerStream::AUDIO) | 1979 ->audio_decoder_config() |
| 2004 ->audio_decoder_config() | 1980 .samples_per_second()); |
| 2005 .samples_per_second()); | |
| 2006 } | 1981 } |
| 2007 | 1982 |
| 2008 // Ensures audio-only playback with missing or negative timestamps works. Tests | 1983 // Ensures audio-only playback with missing or negative timestamps works. Tests |
| 2009 // the common live-streaming case for chained ogg. See http://crbug.com/396864. | 1984 // the common live-streaming case for chained ogg. See http://crbug.com/396864. |
| 2010 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOgg) { | 1985 TEST_F(PipelineIntegrationTest, BasicPlaybackChainedOgg) { |
| 2011 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg")); | 1986 ASSERT_EQ(PIPELINE_OK, Start("double-sfx.ogg")); |
| 2012 Play(); | 1987 Play(); |
| 2013 ASSERT_TRUE(WaitUntilOnEnded()); | 1988 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2014 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); | 1989 ASSERT_EQ(base::TimeDelta(), demuxer_->GetStartTime()); |
| 2015 } | 1990 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2045 | 2020 |
| 2046 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 2021 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
| 2047 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); | 2022 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); |
| 2048 Play(); | 2023 Play(); |
| 2049 ASSERT_TRUE(WaitUntilOnEnded()); | 2024 ASSERT_TRUE(WaitUntilOnEnded()); |
| 2050 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 2025 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
| 2051 demuxer_->GetStartTime()); | 2026 demuxer_->GetStartTime()); |
| 2052 } | 2027 } |
| 2053 | 2028 |
| 2054 } // namespace media | 2029 } // namespace media |
| OLD | NEW |