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

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 2645953004: Update duration when demuxed packets exceed known duration. (Closed)
Patch Set: Remove broken CGI server. Rate limit duration changed events. Created 3 years, 10 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/filters/ffmpeg_demuxer.cc ('k') | media/test/pipeline_integration_test.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 <algorithm> 8 #include <algorithm>
9 #include <deque> 9 #include <deque>
10 #include <string> 10 #include <string>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 message_loop_.task_runner(), data_source_.get(), 104 message_loop_.task_runner(), data_source_.get(),
105 encrypted_media_init_data_cb, tracks_updated_cb, new MediaLog())); 105 encrypted_media_init_data_cb, tracks_updated_cb, new MediaLog()));
106 } 106 }
107 107
108 MOCK_METHOD1(CheckPoint, void(int v)); 108 MOCK_METHOD1(CheckPoint, void(int v));
109 109
110 void InitializeDemuxerInternal(bool enable_text, 110 void InitializeDemuxerInternal(bool enable_text,
111 media::PipelineStatus expected_pipeline_status, 111 media::PipelineStatus expected_pipeline_status,
112 base::Time timeline_offset) { 112 base::Time timeline_offset) {
113 if (expected_pipeline_status == PIPELINE_OK) 113 if (expected_pipeline_status == PIPELINE_OK)
114 EXPECT_CALL(host_, SetDuration(_)); 114 EXPECT_CALL(host_, SetDuration(_)).Times(AnyNumber());
115 WaitableMessageLoopEvent event; 115 WaitableMessageLoopEvent event;
116 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), enable_text); 116 demuxer_->Initialize(&host_, event.GetPipelineStatusCB(), enable_text);
117 demuxer_->timeline_offset_ = timeline_offset; 117 demuxer_->timeline_offset_ = timeline_offset;
118 event.RunAndWaitForStatus(expected_pipeline_status); 118 event.RunAndWaitForStatus(expected_pipeline_status);
119 } 119 }
120 120
121 void InitializeDemuxer() { 121 void InitializeDemuxer() {
122 InitializeDemuxerInternal(/*enable_text=*/false, PIPELINE_OK, base::Time()); 122 InitializeDemuxerInternal(/*enable_text=*/false, PIPELINE_OK, base::Time());
123 } 123 }
124 124
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 MOCK_METHOD2(OnEncryptedMediaInitData, 216 MOCK_METHOD2(OnEncryptedMediaInitData,
217 void(EmeInitDataType init_data_type, 217 void(EmeInitDataType init_data_type,
218 const std::vector<uint8_t>& init_data)); 218 const std::vector<uint8_t>& init_data));
219 219
220 void OnMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks) { 220 void OnMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks) {
221 CHECK(tracks.get()); 221 CHECK(tracks.get());
222 media_tracks_ = std::move(tracks); 222 media_tracks_ = std::move(tracks);
223 } 223 }
224 224
225 // Accessor to demuxer internals. 225 // Accessor to demuxer internals.
226 void set_duration_known(bool duration_known) { 226 void SetDurationKnown(bool duration_known) {
227 demuxer_->duration_known_ = duration_known; 227 demuxer_->duration_known_ = duration_known;
228 if (!duration_known)
229 demuxer_->duration_ = kInfiniteDuration;
228 } 230 }
229 231
230 bool IsStreamStopped(DemuxerStream::Type type) { 232 bool IsStreamStopped(DemuxerStream::Type type) {
231 DemuxerStream* stream = demuxer_->GetStream(type); 233 DemuxerStream* stream = demuxer_->GetStream(type);
232 CHECK(stream); 234 CHECK(stream);
233 return !static_cast<FFmpegDemuxerStream*>(stream)->demuxer_; 235 return !static_cast<FFmpegDemuxerStream*>(stream)->demuxer_;
234 } 236 }
235 237
236 // Fixture members. 238 // Fixture members.
237 std::unique_ptr<FileDataSource> data_source_; 239 std::unique_ptr<FileDataSource> data_source_;
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 base::RunLoop().Run(); 810 base::RunLoop().Run();
809 } 811 }
810 812
811 EXPECT_TRUE(got_eos_buffer); 813 EXPECT_TRUE(got_eos_buffer);
812 } 814 }
813 815
814 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration) { 816 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration) {
815 // Verify that end of stream buffers are created. 817 // Verify that end of stream buffers are created.
816 CreateDemuxer("bear-320x240.webm"); 818 CreateDemuxer("bear-320x240.webm");
817 InitializeDemuxer(); 819 InitializeDemuxer();
818 set_duration_known(false); 820 SetDurationKnown(false);
819 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2767))); 821 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2744)));
820 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); 822 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO));
821 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::VIDEO)); 823 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::VIDEO));
822 } 824 }
823 825
824 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_VideoOnly) { 826 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_VideoOnly) {
825 // Verify that end of stream buffers are created. 827 // Verify that end of stream buffers are created.
826 CreateDemuxer("bear-320x240-video-only.webm"); 828 CreateDemuxer("bear-320x240-video-only.webm");
827 InitializeDemuxer(); 829 InitializeDemuxer();
828 set_duration_known(false); 830 SetDurationKnown(false);
829 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2736))); 831 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2703)));
830 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::VIDEO)); 832 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::VIDEO));
831 } 833 }
832 834
833 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_AudioOnly) { 835 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_AudioOnly) {
834 // Verify that end of stream buffers are created. 836 // Verify that end of stream buffers are created.
835 CreateDemuxer("bear-320x240-audio-only.webm"); 837 CreateDemuxer("bear-320x240-audio-only.webm");
836 InitializeDemuxer(); 838 InitializeDemuxer();
837 set_duration_known(false); 839 SetDurationKnown(false);
838 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2767))); 840 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(2744)));
839 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); 841 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO));
840 } 842 }
841 843
842 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_UnsupportedStream) { 844 TEST_F(FFmpegDemuxerTest, Read_EndOfStream_NoDuration_UnsupportedStream) {
843 // Verify that end of stream buffers are created and we don't crash 845 // Verify that end of stream buffers are created and we don't crash
844 // if there are streams in the file that we don't support. 846 // if there are streams in the file that we don't support.
845 CreateDemuxer("vorbis_audio_wmv_video.mkv"); 847 CreateDemuxer("vorbis_audio_wmv_video.mkv");
846 InitializeDemuxer(); 848 InitializeDemuxer();
847 set_duration_known(false); 849 SetDurationKnown(false);
848 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(1014))); 850 EXPECT_CALL(host_, SetDuration(base::TimeDelta::FromMilliseconds(991)));
chcunningham 2017/01/27 21:41:13 I'm confused about why the durations came down her
DaleCurtis 2017/01/27 21:50:56 I'm not sure, I spot checked a couple of the files
849 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); 851 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO));
850 } 852 }
851 853
852 TEST_F(FFmpegDemuxerTest, Seek) { 854 TEST_F(FFmpegDemuxerTest, Seek) {
853 // We're testing that the demuxer frees all queued packets when it receives 855 // We're testing that the demuxer frees all queued packets when it receives
854 // a Seek(). 856 // a Seek().
855 CreateDemuxer("bear-320x240.webm"); 857 CreateDemuxer("bear-320x240.webm");
856 InitializeDemuxer(); 858 InitializeDemuxer();
857 859
858 // Get our streams. 860 // Get our streams.
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); 1502 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1501 1503
1502 // Now pretend that audio stream got disabled. 1504 // Now pretend that audio stream got disabled.
1503 astream->set_enabled(false, base::TimeDelta()); 1505 astream->set_enabled(false, base::TimeDelta());
1504 // Since there's no other enabled streams, the preferred seeking stream should 1506 // Since there's no other enabled streams, the preferred seeking stream should
1505 // still be the audio stream. 1507 // still be the audio stream.
1506 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta())); 1508 EXPECT_EQ(astream, preferred_seeking_stream(base::TimeDelta()));
1507 } 1509 }
1508 1510
1509 } // namespace media 1511 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/test/pipeline_integration_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698