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

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

Issue 1727243002: Unify media track info reporting on a demuxer level (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracks-impl-in-media
Patch Set: rebase Created 4 years, 9 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 (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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 chunk_demuxer_->StartWaitingForSeek(seek_time); 528 chunk_demuxer_->StartWaitingForSeek(seek_time);
529 } 529 }
530 530
531 void AppendData(size_t size) { 531 void AppendData(size_t size) {
532 DCHECK(chunk_demuxer_); 532 DCHECK(chunk_demuxer_);
533 DCHECK_LT(current_position_, file_data_->data_size()); 533 DCHECK_LT(current_position_, file_data_->data_size());
534 DCHECK_LE(current_position_ + size, file_data_->data_size()); 534 DCHECK_LE(current_position_ + size, file_data_->data_size());
535 535
536 chunk_demuxer_->AppendData( 536 chunk_demuxer_->AppendData(
537 kSourceId, file_data_->data() + current_position_, size, 537 kSourceId, file_data_->data() + current_position_, size,
538 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_, 538 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_);
539 base::Bind(&MockMediaSource::InitSegmentReceived,
540 base::Unretained(this)));
541 current_position_ += size; 539 current_position_ += size;
542 } 540 }
543 541
544 void AppendAtTime(base::TimeDelta timestamp_offset, 542 void AppendAtTime(base::TimeDelta timestamp_offset,
545 const uint8_t* pData, 543 const uint8_t* pData,
546 int size) { 544 int size) {
547 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 545 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
548 chunk_demuxer_->AppendData(kSourceId, pData, size, base::TimeDelta(), 546 chunk_demuxer_->AppendData(kSourceId, pData, size, base::TimeDelta(),
549 kInfiniteDuration(), &timestamp_offset, 547 kInfiniteDuration(), &timestamp_offset);
550 base::Bind(&MockMediaSource::InitSegmentReceived,
551 base::Unretained(this)));
552 last_timestamp_offset_ = timestamp_offset; 548 last_timestamp_offset_ = timestamp_offset;
553 } 549 }
554 550
555 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset, 551 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset,
556 base::TimeDelta append_window_start, 552 base::TimeDelta append_window_start,
557 base::TimeDelta append_window_end, 553 base::TimeDelta append_window_end,
558 const uint8_t* pData, 554 const uint8_t* pData,
559 int size) { 555 int size) {
560 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId)); 556 CHECK(!chunk_demuxer_->IsParsingMediaSegment(kSourceId));
561 chunk_demuxer_->AppendData(kSourceId, pData, size, append_window_start, 557 chunk_demuxer_->AppendData(kSourceId, pData, size, append_window_start,
562 append_window_end, &timestamp_offset, 558 append_window_end, &timestamp_offset);
563 base::Bind(&MockMediaSource::InitSegmentReceived,
564 base::Unretained(this)));
565 last_timestamp_offset_ = timestamp_offset; 559 last_timestamp_offset_ = timestamp_offset;
566 } 560 }
567 561
568 void SetMemoryLimits(size_t limit_bytes) { 562 void SetMemoryLimits(size_t limit_bytes) {
569 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes); 563 chunk_demuxer_->SetMemoryLimits(DemuxerStream::AUDIO, limit_bytes);
570 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes); 564 chunk_demuxer_->SetMemoryLimits(DemuxerStream::VIDEO, limit_bytes);
571 } 565 }
572 566
573 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) { 567 void EvictCodedFrames(base::TimeDelta currentMediaTime, size_t newDataSize) {
574 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize); 568 chunk_demuxer_->EvictCodedFrames(kSourceId, currentMediaTime, newDataSize);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 609
616 CHECK_NE(codecs_param_end, std::string::npos); 610 CHECK_NE(codecs_param_end, std::string::npos);
617 611
618 std::string codecs_param = mimetype_.substr( 612 std::string codecs_param = mimetype_.substr(
619 codecs_param_start, codecs_param_end - codecs_param_start); 613 codecs_param_start, codecs_param_end - codecs_param_start);
620 codecs = base::SplitString(codecs_param, ",", base::KEEP_WHITESPACE, 614 codecs = base::SplitString(codecs_param, ",", base::KEEP_WHITESPACE,
621 base::SPLIT_WANT_NONEMPTY); 615 base::SPLIT_WANT_NONEMPTY);
622 } 616 }
623 617
624 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); 618 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk);
619 chunk_demuxer_->SetTracksWatcher(
620 kSourceId, base::Bind(&MockMediaSource::InitSegmentReceivedWrapper,
621 base::Unretained(this)));
625 622
626 AppendData(initial_append_size_); 623 AppendData(initial_append_size_);
627 } 624 }
628 625
629 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 626 void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
630 const std::vector<uint8_t>& init_data) { 627 const std::vector<uint8_t>& init_data) {
631 DCHECK(!init_data.empty()); 628 DCHECK(!init_data.empty());
632 CHECK(!encrypted_media_init_data_cb_.is_null()); 629 CHECK(!encrypted_media_init_data_cb_.is_null());
633 encrypted_media_init_data_cb_.Run(init_data_type, init_data); 630 encrypted_media_init_data_cb_.Run(init_data_type, init_data);
634 } 631 }
635 632
636 base::TimeDelta last_timestamp_offset() const { 633 base::TimeDelta last_timestamp_offset() const {
637 return last_timestamp_offset_; 634 return last_timestamp_offset_;
638 } 635 }
639 636
640 MOCK_METHOD1(InitSegmentReceived, void(const MediaTracks&)); 637 // A workaround for gtest mocks not allowing moving scoped_ptrs.
638 void InitSegmentReceivedWrapper(scoped_ptr<MediaTracks> tracks) {
639 InitSegmentReceived(tracks);
640 }
641
642 MOCK_METHOD1(InitSegmentReceived, void(scoped_ptr<MediaTracks>&));
641 643
642 private: 644 private:
643 scoped_refptr<DecoderBuffer> file_data_; 645 scoped_refptr<DecoderBuffer> file_data_;
644 size_t current_position_; 646 size_t current_position_;
645 size_t initial_append_size_; 647 size_t initial_append_size_;
646 std::string mimetype_; 648 std::string mimetype_;
647 ChunkDemuxer* chunk_demuxer_; 649 ChunkDemuxer* chunk_demuxer_;
648 scoped_ptr<Demuxer> owned_chunk_demuxer_; 650 scoped_ptr<Demuxer> owned_chunk_demuxer_;
649 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; 651 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
650 base::TimeDelta last_timestamp_offset_; 652 base::TimeDelta last_timestamp_offset_;
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 2023
2022 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2024 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2023 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2025 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2024 Play(); 2026 Play();
2025 ASSERT_TRUE(WaitUntilOnEnded()); 2027 ASSERT_TRUE(WaitUntilOnEnded());
2026 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2028 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2027 demuxer_->GetStartTime()); 2029 demuxer_->GetStartTime());
2028 } 2030 }
2029 2031
2030 } // namespace media 2032 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698