| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "media/base/cdm_context.h" | 9 #include "media/base/cdm_context.h" |
| 10 #include "media/base/media_log.h" | 10 #include "media/base/media_log.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 void PipelineIntegrationTestBase::OnSeeked(base::TimeDelta seek_time, | 58 void PipelineIntegrationTestBase::OnSeeked(base::TimeDelta seek_time, |
| 59 PipelineStatus status) { | 59 PipelineStatus status) { |
| 60 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); | 60 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); |
| 61 pipeline_status_ = status; | 61 pipeline_status_ = status; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PipelineIntegrationTestBase::OnStatusCallback( | 64 void PipelineIntegrationTestBase::OnStatusCallback( |
| 65 PipelineStatus status) { | 65 PipelineStatus status) { |
| 66 pipeline_status_ = status; | 66 pipeline_status_ = status; |
| 67 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 67 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB( | 70 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB( |
| 71 EmeInitDataType type, | 71 EmeInitDataType type, |
| 72 const std::vector<uint8>& init_data) { | 72 const std::vector<uint8>& init_data) { |
| 73 DCHECK(!init_data.empty()); | 73 DCHECK(!init_data.empty()); |
| 74 CHECK(!encrypted_media_init_data_cb_.is_null()); | 74 CHECK(!encrypted_media_init_data_cb_.is_null()); |
| 75 encrypted_media_init_data_cb_.Run(type, init_data); | 75 encrypted_media_init_data_cb_.Run(type, init_data); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PipelineIntegrationTestBase::OnEnded() { | 78 void PipelineIntegrationTestBase::OnEnded() { |
| 79 DCHECK(!ended_); | 79 DCHECK(!ended_); |
| 80 ended_ = true; | 80 ended_ = true; |
| 81 pipeline_status_ = PIPELINE_OK; | 81 pipeline_status_ = PIPELINE_OK; |
| 82 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 82 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool PipelineIntegrationTestBase::WaitUntilOnEnded() { | 85 bool PipelineIntegrationTestBase::WaitUntilOnEnded() { |
| 86 if (ended_) | 86 if (ended_) |
| 87 return (pipeline_status_ == PIPELINE_OK); | 87 return (pipeline_status_ == PIPELINE_OK); |
| 88 message_loop_.Run(); | 88 message_loop_.Run(); |
| 89 EXPECT_TRUE(ended_); | 89 EXPECT_TRUE(ended_); |
| 90 return ended_ && (pipeline_status_ == PIPELINE_OK); | 90 return ended_ && (pipeline_status_ == PIPELINE_OK); |
| 91 } | 91 } |
| 92 | 92 |
| 93 PipelineStatus PipelineIntegrationTestBase::WaitUntilEndedOrError() { | 93 PipelineStatus PipelineIntegrationTestBase::WaitUntilEndedOrError() { |
| 94 if (ended_ || pipeline_status_ != PIPELINE_OK) | 94 if (ended_ || pipeline_status_ != PIPELINE_OK) |
| 95 return pipeline_status_; | 95 return pipeline_status_; |
| 96 message_loop_.Run(); | 96 message_loop_.Run(); |
| 97 return pipeline_status_; | 97 return pipeline_status_; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void PipelineIntegrationTestBase::OnError(PipelineStatus status) { | 100 void PipelineIntegrationTestBase::OnError(PipelineStatus status) { |
| 101 DCHECK_NE(status, PIPELINE_OK); | 101 DCHECK_NE(status, PIPELINE_OK); |
| 102 pipeline_status_ = status; | 102 pipeline_status_ = status; |
| 103 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 103 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) { | 106 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) { |
| 107 return Start(filename, nullptr); | 107 return Start(filename, nullptr); |
| 108 } | 108 } |
| 109 | 109 |
| 110 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, | 110 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, |
| 111 CdmContext* cdm_context) { | 111 CdmContext* cdm_context) { |
| 112 EXPECT_CALL(*this, OnMetadata(_)) | 112 EXPECT_CALL(*this, OnMetadata(_)) |
| 113 .Times(AtMost(1)) | 113 .Times(AtMost(1)) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) | 168 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) |
| 169 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); | 169 .WillOnce(InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitNow)); |
| 170 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked, | 170 pipeline_->Seek(seek_time, base::Bind(&PipelineIntegrationTestBase::OnSeeked, |
| 171 base::Unretained(this), seek_time)); | 171 base::Unretained(this), seek_time)); |
| 172 message_loop_.Run(); | 172 message_loop_.Run(); |
| 173 return (pipeline_status_ == PIPELINE_OK); | 173 return (pipeline_status_ == PIPELINE_OK); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void PipelineIntegrationTestBase::Stop() { | 176 void PipelineIntegrationTestBase::Stop() { |
| 177 DCHECK(pipeline_->IsRunning()); | 177 DCHECK(pipeline_->IsRunning()); |
| 178 pipeline_->Stop(base::MessageLoop::QuitClosure()); | 178 pipeline_->Stop(base::MessageLoop::QuitWhenIdleClosure()); |
| 179 message_loop_.Run(); | 179 message_loop_.Run(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void PipelineIntegrationTestBase::QuitAfterCurrentTimeTask( | 182 void PipelineIntegrationTestBase::QuitAfterCurrentTimeTask( |
| 183 const base::TimeDelta& quit_time) { | 183 const base::TimeDelta& quit_time) { |
| 184 if (pipeline_->GetMediaTime() >= quit_time || | 184 if (pipeline_->GetMediaTime() >= quit_time || |
| 185 pipeline_status_ != PIPELINE_OK) { | 185 pipeline_status_ != PIPELINE_OK) { |
| 186 message_loop_.Quit(); | 186 message_loop_.QuitWhenIdle(); |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 | 189 |
| 190 message_loop_.PostDelayedTask( | 190 message_loop_.PostDelayedTask( |
| 191 FROM_HERE, | 191 FROM_HERE, |
| 192 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask, | 192 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask, |
| 193 base::Unretained(this), quit_time), | 193 base::Unretained(this), quit_time), |
| 194 base::TimeDelta::FromMilliseconds(10)); | 194 base::TimeDelta::FromMilliseconds(10)); |
| 195 } | 195 } |
| 196 | 196 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 DCHECK(clockless_playback_); | 337 DCHECK(clockless_playback_); |
| 338 return clockless_audio_sink_->render_time(); | 338 return clockless_audio_sink_->render_time(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 base::TimeTicks DummyTickClock::NowTicks() { | 341 base::TimeTicks DummyTickClock::NowTicks() { |
| 342 now_ += base::TimeDelta::FromSeconds(60); | 342 now_ += base::TimeDelta::FromSeconds(60); |
| 343 return now_; | 343 return now_; |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace media | 346 } // namespace media |
| OLD | NEW |