Fix pipeline integration tests for seek / duration changes.
PipelineIntegrationTestBase now exposes GetMediaDuration(), so that tests can seek to the start of the media, rather than assuming it to be zero. The ffmpeg_regression_tests would fail, previously, if the media's start time wasn't zero, since they would seek to 0 and then get mad that the media time was something else. Also, this permits the pipeline to notify the client about an indefinite duration, then notify it about a smaller one. This happens if the media duration isn't known initially, but then becomes known when the end of media is found. Previously, the second call to Pipeline::Client::OnDurationChanged would cause the integration test base to get mad. Added a test case to ffmpeg_regression_tests which hits both of these cases. BUG=662118 TEST=ffmpeg_regression_tests Review-Url: https://codereview.chromium.org/2479633002 Cr-Commit-Position: refs/heads/master@{#429690}
This commit is contained in:
@ -163,6 +163,10 @@ FFMPEG_TEST_CASE(Cr599625,
|
||||
"security/599625.mp4",
|
||||
PIPELINE_OK,
|
||||
PIPELINE_ERROR_DECODE);
|
||||
// TODO(liberato): before crbug.com/658440 was fixed, this would fail if run
|
||||
// twice under ASAN. If run once, then it doesn't. However, it still catches
|
||||
// issues in crbug.com/662118, so it's included anyway.
|
||||
FFMPEG_TEST_CASE(Cr658440, "security/658440.flac", PIPELINE_OK, PIPELINE_OK);
|
||||
|
||||
// General MP4 test cases.
|
||||
FFMPEG_TEST_CASE(MP4_0,
|
||||
@ -354,7 +358,7 @@ TEST_P(FFmpegRegressionTest, BasicPlayback) {
|
||||
ASSERT_TRUE(ended_);
|
||||
|
||||
// Tack a seek on the end to catch any seeking issues.
|
||||
Seek(base::TimeDelta::FromMilliseconds(0));
|
||||
Seek(GetStartTime());
|
||||
}
|
||||
} else {
|
||||
// Don't bother checking the exact status as we only care that the
|
||||
|
@ -50,7 +50,8 @@ PipelineIntegrationTestBase::PipelineIntegrationTestBase()
|
||||
ended_(false),
|
||||
pipeline_status_(PIPELINE_OK),
|
||||
last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
|
||||
last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED) {
|
||||
last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED),
|
||||
current_duration_(kInfiniteDuration) {
|
||||
ResetVideoHash();
|
||||
}
|
||||
|
||||
@ -143,7 +144,13 @@ PipelineStatus PipelineIntegrationTestBase::StartInternal(
|
||||
.Times(AnyNumber());
|
||||
EXPECT_CALL(*this, OnBufferingStateChange(BUFFERING_HAVE_NOTHING))
|
||||
.Times(AnyNumber());
|
||||
EXPECT_CALL(*this, OnDurationChange()).Times(AtMost(1));
|
||||
// Permit at most two calls to OnDurationChange. CheckDuration will make sure
|
||||
// that no more than one of them is a finite duration. This allows the
|
||||
// pipeline to call back at the end of the media with the known duration.
|
||||
EXPECT_CALL(*this, OnDurationChange())
|
||||
.Times(AtMost(2))
|
||||
.WillRepeatedly(
|
||||
Invoke(this, &PipelineIntegrationTestBase::CheckDuration));
|
||||
EXPECT_CALL(*this, OnVideoNaturalSizeChange(_)).Times(AtMost(1));
|
||||
EXPECT_CALL(*this, OnVideoOpacityChange(_)).Times(AtMost(1));
|
||||
CreateDemuxer(std::move(data_source));
|
||||
@ -392,6 +399,18 @@ void PipelineIntegrationTestBase::OnVideoFramePaint(
|
||||
VideoFrame::HashFrameForTesting(&md5_context_, frame);
|
||||
}
|
||||
|
||||
void PipelineIntegrationTestBase::CheckDuration() {
|
||||
// Allow the pipeline to specify indefinite duration, then reduce it once
|
||||
// it becomes known.
|
||||
ASSERT_EQ(kInfiniteDuration, current_duration_);
|
||||
base::TimeDelta new_duration = pipeline_->GetMediaDuration();
|
||||
current_duration_ = new_duration;
|
||||
}
|
||||
|
||||
base::TimeDelta PipelineIntegrationTestBase::GetStartTime() {
|
||||
return demuxer_->GetStartTime();
|
||||
}
|
||||
|
||||
void PipelineIntegrationTestBase::ResetVideoHash() {
|
||||
DVLOG(1) << __FUNCTION__;
|
||||
base::MD5Init(&md5_context_);
|
||||
|
@ -151,6 +151,7 @@ class PipelineIntegrationTestBase : public Pipeline::Client {
|
||||
DummyTickClock dummy_clock_;
|
||||
PipelineMetadata metadata_;
|
||||
scoped_refptr<VideoFrame> last_frame_;
|
||||
base::TimeDelta current_duration_;
|
||||
|
||||
PipelineStatus StartInternal(
|
||||
std::unique_ptr<DataSource> data_source,
|
||||
@ -191,6 +192,11 @@ class PipelineIntegrationTestBase : public Pipeline::Client {
|
||||
|
||||
void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame);
|
||||
|
||||
void CheckDuration();
|
||||
|
||||
// Return the media start time from |demuxer_|.
|
||||
base::TimeDelta GetStartTime();
|
||||
|
||||
MOCK_METHOD1(DecryptorAttached, void(bool));
|
||||
// Pipeline::Client overrides.
|
||||
void OnError(PipelineStatus status) override;
|
||||
|
Reference in New Issue
Block a user