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

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

Issue 2479633002: Fix pipeline integration tests for seek / duration changes. (Closed)
Patch Set: Created 4 years, 1 month 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/test/pipeline_integration_test_base.h ('k') | no next file » | 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 "media/test/pipeline_integration_test_base.h" 5 #include "media/test/pipeline_integration_test_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; 43 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e";
44 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; 44 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,";
45 45
46 PipelineIntegrationTestBase::PipelineIntegrationTestBase() 46 PipelineIntegrationTestBase::PipelineIntegrationTestBase()
47 : hashing_enabled_(false), 47 : hashing_enabled_(false),
48 clockless_playback_(false), 48 clockless_playback_(false),
49 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())), 49 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())),
50 ended_(false), 50 ended_(false),
51 pipeline_status_(PIPELINE_OK), 51 pipeline_status_(PIPELINE_OK),
52 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), 52 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
53 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) { 53 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED),
54 current_duration_(kInfiniteDuration) {
54 ResetVideoHash(); 55 ResetVideoHash();
55 } 56 }
56 57
57 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { 58 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() {
58 if (pipeline_->IsRunning()) 59 if (pipeline_->IsRunning())
59 Stop(); 60 Stop();
60 61
61 pipeline_.reset(); 62 pipeline_.reset();
62 base::RunLoop().RunUntilIdle(); 63 base::RunLoop().RunUntilIdle();
63 } 64 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 hashing_enabled_ = test_type & kHashed; 137 hashing_enabled_ = test_type & kHashed;
137 clockless_playback_ = test_type & kClockless; 138 clockless_playback_ = test_type & kClockless;
138 139
139 EXPECT_CALL(*this, OnMetadata(_)) 140 EXPECT_CALL(*this, OnMetadata(_))
140 .Times(AtMost(1)) 141 .Times(AtMost(1))
141 .WillRepeatedly(SaveArg<0>(&metadata_)); 142 .WillRepeatedly(SaveArg<0>(&metadata_));
142 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH)) 143 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH))
143 .Times(AnyNumber()); 144 .Times(AnyNumber());
144 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING)) 145 EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
145 .Times(AnyNumber()); 146 .Times(AnyNumber());
146 EXPECT_CALL(*this, OnDurationChange()).Times(AtMost(1)); 147 // Permit at most two calls to OnDurationChange. CheckDuration will make sure
148 // that no more than one of them is a finite duration. This allows the
149 // pipeline to call back at the end of the media with the known duration.
150 EXPECT_CALL(*this, OnDurationChange())
151 .Times(AtMost(2))
152 .WillRepeatedly(
153 Invoke(this, &PipelineIntegrationTestBase::CheckDuration));
147 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1)); 154 EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1));
148 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1)); 155 EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1));
149 CreateDemuxer(std::move(data_source)); 156 CreateDemuxer(std::move(data_source));
150 157
151 if (cdm_context) { 158 if (cdm_context) {
152 EXPECT_CALL(*this, DecryptorAttached(true)); 159 EXPECT_CALL(*this, DecryptorAttached(true));
153 pipeline_->SetCdm( 160 pipeline_->SetCdm(
154 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached, 161 cdm_context, base::Bind(&PipelineIntegrationTestBase::DecryptorAttached,
155 base::Unretained(this))); 162 base::Unretained(this)));
156 } 163 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 int result; 392 int result;
386 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result)) 393 if (frame->metadata()->GetInteger(VideoFrameMetadata::COLOR_SPACE, &result))
387 last_video_frame_color_space_ = static_cast<ColorSpace>(result); 394 last_video_frame_color_space_ = static_cast<ColorSpace>(result);
388 if (!hashing_enabled_ || last_frame_ == frame) 395 if (!hashing_enabled_ || last_frame_ == frame)
389 return; 396 return;
390 last_frame_ = frame; 397 last_frame_ = frame;
391 DVLOG(3) << __FUNCTION__ << " pts=" << frame->timestamp().InSecondsF(); 398 DVLOG(3) << __FUNCTION__ << " pts=" << frame->timestamp().InSecondsF();
392 VideoFrame::HashFrameForTesting(&md5_context_, frame); 399 VideoFrame::HashFrameForTesting(&md5_context_, frame);
393 } 400 }
394 401
402 void PipelineIntegrationTestBase::CheckDuration() {
403 // Allow the pipeline to specify indefinite duration, then reduce it once
404 // it becomes known.
405 ASSERT_EQ(kInfiniteDuration, current_duration_);
406 base::TimeDelta new_duration = pipeline_->GetMediaDuration();
407 current_duration_ = new_duration;
408 }
409
410 base::TimeDelta PipelineIntegrationTestBase::GetStartTime() {
411 return demuxer_->GetStartTime();
412 }
413
395 void PipelineIntegrationTestBase::ResetVideoHash() { 414 void PipelineIntegrationTestBase::ResetVideoHash() {
396 DVLOG(1) << __FUNCTION__; 415 DVLOG(1) << __FUNCTION__;
397 base::MD5Init(&md5_context_); 416 base::MD5Init(&md5_context_);
398 } 417 }
399 418
400 std::string PipelineIntegrationTestBase::GetVideoHash() { 419 std::string PipelineIntegrationTestBase::GetVideoHash() {
401 DCHECK(hashing_enabled_); 420 DCHECK(hashing_enabled_);
402 base::MD5Digest digest; 421 base::MD5Digest digest;
403 base::MD5Final(&digest, &md5_context_); 422 base::MD5Final(&digest, &md5_context_);
404 return base::MD5DigestToBase16(digest); 423 return base::MD5DigestToBase16(digest);
(...skipping 11 matching lines...) Expand all
416 DCHECK(clockless_playback_); 435 DCHECK(clockless_playback_);
417 return clockless_audio_sink_->render_time(); 436 return clockless_audio_sink_->render_time();
418 } 437 }
419 438
420 base::TimeTicks DummyTickClock::NowTicks() { 439 base::TimeTicks DummyTickClock::NowTicks() {
421 now_ += base::TimeDelta::FromSeconds(60); 440 now_ += base::TimeDelta::FromSeconds(60);
422 return now_; 441 return now_;
423 } 442 }
424 443
425 } // namespace media 444 } // namespace media
OLDNEW
« no previous file with comments | « media/test/pipeline_integration_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698