| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "media/base/factory.h" | 7 #include "media/base/factory.h" |
| 8 #include "media/base/filter_host.h" | 8 #include "media/base/filter_host.h" |
| 9 #include "media/base/filters.h" | 9 #include "media/base/filters.h" |
| 10 #include "media/base/media_format.h" | 10 #include "media/base/media_format.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 MockFilterConfig config; | 33 MockFilterConfig config; |
| 34 scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); | 34 scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); |
| 35 c->AddFactory(MockDataSource::CreateFactory(&config)); | 35 c->AddFactory(MockDataSource::CreateFactory(&config)); |
| 36 c->AddFactory(MockDemuxer::CreateFactory(&config)); | 36 c->AddFactory(MockDemuxer::CreateFactory(&config)); |
| 37 c->AddFactory(MockAudioDecoder::CreateFactory(&config)); | 37 c->AddFactory(MockAudioDecoder::CreateFactory(&config)); |
| 38 c->AddFactory(MockAudioRenderer::CreateFactory(&config)); | 38 c->AddFactory(MockAudioRenderer::CreateFactory(&config)); |
| 39 c->AddFactory(MockVideoDecoder::CreateFactory(&config)); | 39 c->AddFactory(MockVideoDecoder::CreateFactory(&config)); |
| 40 c->AddFactory(new InstanceFilterFactory<TestVideoRenderer>(test_renderer)); | 40 c->AddFactory(new InstanceFilterFactory<TestVideoRenderer>(test_renderer)); |
| 41 media::InitializationHelper h; | 41 media::InitializationHelper h; |
| 42 h.Start(&p, c, url); | 42 h.Start(&p, c, url); |
| 43 h.Wait(); | |
| 44 EXPECT_TRUE(p.IsInitialized()); | |
| 45 p.SetPlaybackRate(1.0f); | 43 p.SetPlaybackRate(1.0f); |
| 46 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); | 44 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); |
| 47 p.Stop(); | 45 p.Stop(); |
| 48 // Allow a decent amount of variability here. We expect 15 or 16 frames | 46 // Allow a decent amount of variability here. We expect 15 or 16 frames |
| 49 // but for now make sure it's within a reasonable range. | 47 // but for now make sure it's within a reasonable range. |
| 50 // TODO(ralphl): This test is now DISABLED because sometimes on linux we | 48 // TODO(ralphl): This test is now DISABLED because sometimes on linux we |
| 51 // only get the first frame. Investigate why, but for now disabled. | 49 // only get the first frame. Investigate why, but for now disabled. |
| 52 int64 num_expected_frames = test_time / config.frame_duration; | 50 int64 num_expected_frames = test_time / config.frame_duration; |
| 53 EXPECT_GT(test_renderer->unique_frames(), num_expected_frames - 3); | 51 EXPECT_GT(test_renderer->unique_frames(), num_expected_frames - 3); |
| 54 EXPECT_LT(test_renderer->unique_frames(), num_expected_frames + 3); | 52 EXPECT_LT(test_renderer->unique_frames(), num_expected_frames + 3); |
| 55 } | 53 } |
| 56 | 54 |
| 57 TEST(VideoRenderer, SingleVideoFrame) { | 55 TEST(VideoRenderer, SingleVideoFrame) { |
| 58 base::TimeDelta test_time = base::TimeDelta::FromMilliseconds(100); | 56 base::TimeDelta test_time = base::TimeDelta::FromMilliseconds(100); |
| 59 std::string url(""); | 57 std::string url(""); |
| 60 PipelineImpl p; | 58 PipelineImpl p; |
| 61 scoped_refptr<TestVideoRenderer> test_renderer = new TestVideoRenderer(); | 59 scoped_refptr<TestVideoRenderer> test_renderer = new TestVideoRenderer(); |
| 62 MockFilterConfig config; | 60 MockFilterConfig config; |
| 63 config.media_duration = config.frame_duration; | 61 config.media_duration = config.frame_duration; |
| 64 scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); | 62 scoped_refptr<FilterFactoryCollection> c = new FilterFactoryCollection(); |
| 65 c->AddFactory(MockDataSource::CreateFactory(&config)); | 63 c->AddFactory(MockDataSource::CreateFactory(&config)); |
| 66 c->AddFactory(MockDemuxer::CreateFactory(&config)); | 64 c->AddFactory(MockDemuxer::CreateFactory(&config)); |
| 67 c->AddFactory(MockAudioDecoder::CreateFactory(&config)); | 65 c->AddFactory(MockAudioDecoder::CreateFactory(&config)); |
| 68 c->AddFactory(MockAudioRenderer::CreateFactory(&config)); | 66 c->AddFactory(MockAudioRenderer::CreateFactory(&config)); |
| 69 c->AddFactory(MockVideoDecoder::CreateFactory(&config)); | 67 c->AddFactory(MockVideoDecoder::CreateFactory(&config)); |
| 70 c->AddFactory(new InstanceFilterFactory<TestVideoRenderer>(test_renderer)); | 68 c->AddFactory(new InstanceFilterFactory<TestVideoRenderer>(test_renderer)); |
| 71 media::InitializationHelper h; | 69 media::InitializationHelper h; |
| 72 h.Start(&p, c, url); | 70 h.Start(&p, c, url); |
| 73 h.TimedWait(base::TimeDelta::FromSeconds(1)); | |
| 74 EXPECT_TRUE(p.IsInitialized()); | |
| 75 p.SetPlaybackRate(1.0f); | 71 p.SetPlaybackRate(1.0f); |
| 76 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); | 72 PlatformThread::Sleep(static_cast<int>(test_time.InMilliseconds())); |
| 77 p.Stop(); | 73 p.Stop(); |
| 78 EXPECT_EQ(test_renderer->unique_frames(), 1u); | 74 EXPECT_EQ(test_renderer->unique_frames(), 1u); |
| 79 EXPECT_EQ(test_renderer->paint_called(), 1u); | 75 EXPECT_EQ(test_renderer->paint_called(), 1u); |
| 80 } | 76 } |
| OLD | NEW |