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

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

Issue 2050043002: Generate and assign media track ids in demuxers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-streamparser-trackid
Patch Set: rebase to ToT Created 4 years, 6 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
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.cc ('k') | media/test/pipeline_integration_test_base.cc » ('j') | 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 <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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 CHECK_NE(codecs_param_end, std::string::npos); 625 CHECK_NE(codecs_param_end, std::string::npos);
626 626
627 std::string codecs_param = mimetype_.substr( 627 std::string codecs_param = mimetype_.substr(
628 codecs_param_start, codecs_param_end - codecs_param_start); 628 codecs_param_start, codecs_param_end - codecs_param_start);
629 codecs = base::SplitString(codecs_param, ",", base::KEEP_WHITESPACE, 629 codecs = base::SplitString(codecs_param, ",", base::KEEP_WHITESPACE,
630 base::SPLIT_WANT_NONEMPTY); 630 base::SPLIT_WANT_NONEMPTY);
631 } 631 }
632 632
633 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk); 633 CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk);
634 chunk_demuxer_->SetTracksWatcher( 634 chunk_demuxer_->SetTracksWatcher(
635 kSourceId, base::Bind(&MockMediaSource::InitSegmentReceivedWrapper, 635 kSourceId, base::Bind(&MockMediaSource::InitSegmentReceived,
636 base::Unretained(this))); 636 base::Unretained(this)));
637 637
638 AppendData(initial_append_size_); 638 AppendData(initial_append_size_);
639 } 639 }
640 640
641 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 641 void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
642 const std::vector<uint8_t>& init_data) { 642 const std::vector<uint8_t>& init_data) {
643 DCHECK(!init_data.empty()); 643 DCHECK(!init_data.empty());
644 CHECK(!encrypted_media_init_data_cb_.is_null()); 644 CHECK(!encrypted_media_init_data_cb_.is_null());
645 encrypted_media_init_data_cb_.Run(init_data_type, init_data); 645 encrypted_media_init_data_cb_.Run(init_data_type, init_data);
646 } 646 }
647 647
648 base::TimeDelta last_timestamp_offset() const { 648 base::TimeDelta last_timestamp_offset() const {
649 return last_timestamp_offset_; 649 return last_timestamp_offset_;
650 } 650 }
651 651
652 // A workaround for gtest mocks not allowing moving scoped_ptrs. 652 void InitSegmentReceived(std::unique_ptr<MediaTracks> tracks) {
653 void InitSegmentReceivedWrapper(std::unique_ptr<MediaTracks> tracks) { 653 CHECK(tracks.get());
654 InitSegmentReceived(tracks); 654 EXPECT_GT(tracks->tracks().size(), 0u);
655 CHECK(chunk_demuxer_);
656 // Verify that track ids are unique.
657 std::set<MediaTrack::Id> track_ids;
658 for (const auto& track : tracks->tracks()) {
659 EXPECT_EQ(track_ids.end(), track_ids.find(track->id()));
660 track_ids.insert(track->id());
661 }
662 InitSegmentReceivedMock(tracks);
655 } 663 }
656 664
657 MOCK_METHOD1(InitSegmentReceived, void(std::unique_ptr<MediaTracks>&)); 665 MOCK_METHOD1(InitSegmentReceivedMock, void(std::unique_ptr<MediaTracks>&));
658 666
659 private: 667 private:
660 scoped_refptr<DecoderBuffer> file_data_; 668 scoped_refptr<DecoderBuffer> file_data_;
661 size_t current_position_; 669 size_t current_position_;
662 size_t initial_append_size_; 670 size_t initial_append_size_;
663 std::string mimetype_; 671 std::string mimetype_;
664 ChunkDemuxer* chunk_demuxer_; 672 ChunkDemuxer* chunk_demuxer_;
665 std::unique_ptr<Demuxer> owned_chunk_demuxer_; 673 std::unique_ptr<Demuxer> owned_chunk_demuxer_;
666 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; 674 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
667 base::TimeDelta last_timestamp_offset_; 675 base::TimeDelta last_timestamp_offset_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 return StartPipelineWithMediaSource(source, kNormal, encrypted_media); 723 return StartPipelineWithMediaSource(source, kNormal, encrypted_media);
716 } 724 }
717 725
718 PipelineStatus StartPipelineWithMediaSource( 726 PipelineStatus StartPipelineWithMediaSource(
719 MockMediaSource* source, 727 MockMediaSource* source,
720 uint8_t test_type, 728 uint8_t test_type,
721 FakeEncryptedMedia* encrypted_media) { 729 FakeEncryptedMedia* encrypted_media) {
722 hashing_enabled_ = test_type & kHashed; 730 hashing_enabled_ = test_type & kHashed;
723 clockless_playback_ = test_type & kClockless; 731 clockless_playback_ = test_type & kClockless;
724 732
725 EXPECT_CALL(*source, InitSegmentReceived(_)).Times(AtLeast(1)); 733 EXPECT_CALL(*source, InitSegmentReceivedMock(_)).Times(AtLeast(1));
726 EXPECT_CALL(*this, OnMetadata(_)) 734 EXPECT_CALL(*this, OnMetadata(_))
727 .Times(AtMost(1)) 735 .Times(AtMost(1))
728 .WillRepeatedly(SaveArg<0>(&metadata_)); 736 .WillRepeatedly(SaveArg<0>(&metadata_));
729 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 737 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
730 .Times(AnyNumber()); 738 .Times(AnyNumber());
731 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) 739 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
732 .Times(AnyNumber()); 740 .Times(AnyNumber());
733 EXPECT_CALL(*this, OnDurationChange()).Times(AnyNumber()); 741 EXPECT_CALL(*this, OnDurationChange()).Times(AnyNumber());
734 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1)); 742 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1));
735 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1)); 743 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1));
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 2228
2221 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 2229 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
2222 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 2230 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
2223 Play(); 2231 Play();
2224 ASSERT_TRUE(WaitUntilOnEnded()); 2232 ASSERT_TRUE(WaitUntilOnEnded());
2225 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 2233 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
2226 demuxer_->GetStartTime()); 2234 demuxer_->GetStartTime());
2227 } 2235 }
2228 2236
2229 } // namespace media 2237 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.cc ('k') | media/test/pipeline_integration_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698