| 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/base/pipeline_impl.h" | 5 #include "media/base/pipeline_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime)); | 817 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime)); |
| 818 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); | 818 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); |
| 819 | 819 |
| 820 // Media time should not go backwards even if the renderer returns an | 820 // Media time should not go backwards even if the renderer returns an |
| 821 // errorneous value. PipelineImpl should clamp it to last reported value. | 821 // errorneous value. PipelineImpl should clamp it to last reported value. |
| 822 EXPECT_CALL(*renderer_, GetMediaTime()) | 822 EXPECT_CALL(*renderer_, GetMediaTime()) |
| 823 .WillRepeatedly(Return(base::TimeDelta::FromSeconds(1))); | 823 .WillRepeatedly(Return(base::TimeDelta::FromSeconds(1))); |
| 824 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); | 824 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); |
| 825 } | 825 } |
| 826 | 826 |
| 827 // Seeking posts a task from main thread to media thread to seek the renderer, |
| 828 // resetting its internal clock. Calling GetMediaTime() should be safe even |
| 829 // when the renderer has not performed the seek (simulated by its continuing |
| 830 // to return the pre-seek time). Verifies fix for http://crbug.com/675556 |
| 831 TEST_F(PipelineImplTest, GetMediaTimeAfterSeek) { |
| 832 CreateAudioStream(); |
| 833 MockDemuxerStreamVector streams; |
| 834 streams.push_back(audio_stream()); |
| 835 SetDemuxerExpectations(&streams); |
| 836 SetRendererExpectations(); |
| 837 StartPipelineAndExpect(PIPELINE_OK); |
| 838 |
| 839 // Pipeline should report the same media time returned by the renderer. |
| 840 base::TimeDelta kMediaTime = base::TimeDelta::FromSeconds(2); |
| 841 EXPECT_CALL(*renderer_, GetMediaTime()).WillRepeatedly(Return(kMediaTime)); |
| 842 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); |
| 843 |
| 844 // Seek backward 1 second. Do not run RunLoop to ensure renderer is not yet |
| 845 // notified of the seek (via media thread). |
| 846 base::TimeDelta kSeekTime = kMediaTime - base::TimeDelta::FromSeconds(1); |
| 847 ExpectSeek(kSeekTime, false); |
| 848 pipeline_->Seek(kSeekTime, base::Bind(&CallbackHelper::OnSeek, |
| 849 base::Unretained(&callbacks_))); |
| 850 |
| 851 // Verify pipeline returns the seek time in spite of renderer returning the |
| 852 // stale media time. |
| 853 EXPECT_EQ(kSeekTime, pipeline_->GetMediaTime()); |
| 854 EXPECT_EQ(kMediaTime, renderer_->GetMediaTime()); |
| 855 |
| 856 // Allow seek task to post to the renderer. |
| 857 base::RunLoop().RunUntilIdle(); |
| 858 |
| 859 // With seek completed, pipeline should again return the renderer's media time |
| 860 // (as long as media time is moving forward). |
| 861 EXPECT_EQ(kMediaTime, pipeline_->GetMediaTime()); |
| 862 } |
| 863 |
| 827 class PipelineTeardownTest : public PipelineImplTest { | 864 class PipelineTeardownTest : public PipelineImplTest { |
| 828 public: | 865 public: |
| 829 enum TeardownState { | 866 enum TeardownState { |
| 830 kInitDemuxer, | 867 kInitDemuxer, |
| 831 kInitRenderer, | 868 kInitRenderer, |
| 832 kFlushing, | 869 kFlushing, |
| 833 kSeeking, | 870 kSeeking, |
| 834 kPlaying, | 871 kPlaying, |
| 835 kSuspending, | 872 kSuspending, |
| 836 kSuspended, | 873 kSuspended, |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1123 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1087 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1124 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1088 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); | 1125 INSTANTIATE_TEARDOWN_TEST(Error, Suspending); |
| 1089 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); | 1126 INSTANTIATE_TEARDOWN_TEST(Error, Suspended); |
| 1090 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); | 1127 INSTANTIATE_TEARDOWN_TEST(Error, Resuming); |
| 1091 | 1128 |
| 1092 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); | 1129 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); |
| 1093 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); | 1130 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Suspended); |
| 1094 | 1131 |
| 1095 } // namespace media | 1132 } // namespace media |
| OLD | NEW |