OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/ptr_util.h" |
| 6 #include "media/base/test_data_util.h" |
| 7 #include "media/remoting/end2end_test_renderer.h" |
| 8 #include "media/test/mock_media_source.h" |
| 9 #include "media/test/pipeline_integration_test_base.h" |
| 10 |
| 11 namespace media { |
| 12 namespace remoting { |
| 13 |
| 14 namespace { |
| 15 |
| 16 constexpr char kWebM[] = "video/webm; codecs=\"vp8,vorbis\""; |
| 17 constexpr int kAppendTimeSec = 1; |
| 18 |
| 19 class TestRendererFactory final : public PipelineTestRendererFactory { |
| 20 public: |
| 21 explicit TestRendererFactory( |
| 22 std::unique_ptr<PipelineTestRendererFactory> renderer_factory) |
| 23 : default_renderer_factory_(std::move(renderer_factory)) {} |
| 24 ~TestRendererFactory() override {} |
| 25 |
| 26 // PipelineTestRendererFactory implementation. |
| 27 std::unique_ptr<Renderer> CreateRenderer( |
| 28 CreateVideoDecodersCB prepend_video_decoders_cb, |
| 29 CreateAudioDecodersCB prepend_audio_decoders_cb) override { |
| 30 std::unique_ptr<Renderer> renderer_impl = |
| 31 default_renderer_factory_->CreateRenderer(prepend_video_decoders_cb, |
| 32 prepend_audio_decoders_cb); |
| 33 return base::MakeUnique<End2EndTestRenderer>(std::move(renderer_impl)); |
| 34 } |
| 35 |
| 36 private: |
| 37 std::unique_ptr<PipelineTestRendererFactory> default_renderer_factory_; |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(TestRendererFactory); |
| 40 }; |
| 41 |
| 42 } // namespace |
| 43 |
| 44 class MediaRemotingIntegrationTest : public testing::Test, |
| 45 public PipelineIntegrationTestBase { |
| 46 public: |
| 47 MediaRemotingIntegrationTest() { |
| 48 std::unique_ptr<PipelineTestRendererFactory> factory = |
| 49 std::move(renderer_factory_); |
| 50 renderer_factory_.reset(new TestRendererFactory(std::move(factory))); |
| 51 } |
| 52 |
| 53 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(MediaRemotingIntegrationTest); |
| 55 }; |
| 56 |
| 57 TEST_F(MediaRemotingIntegrationTest, BasicPlayback) { |
| 58 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm", TestTypeFlags::kHashed)); |
| 59 Play(); |
| 60 ASSERT_TRUE(WaitUntilOnEnded()); |
| 61 |
| 62 EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash()); |
| 63 EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash()); |
| 64 } |
| 65 |
| 66 TEST_F(MediaRemotingIntegrationTest, BasicPlayback_MediaSource) { |
| 67 MockMediaSource source("bear-320x240.webm", kWebM, 219229); |
| 68 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 69 source.EndOfStream(); |
| 70 |
| 71 Play(); |
| 72 ASSERT_TRUE(WaitUntilOnEnded()); |
| 73 source.Shutdown(); |
| 74 Stop(); |
| 75 } |
| 76 |
| 77 TEST_F(MediaRemotingIntegrationTest, MediaSource_ConfigChange_WebM) { |
| 78 MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM, |
| 79 kAppendWholeFile); |
| 80 EXPECT_EQ(PIPELINE_OK, StartPipelineWithMediaSource(&source)); |
| 81 |
| 82 EXPECT_CALL(*this, OnVideoNaturalSizeChange(gfx::Size(640, 360))).Times(1); |
| 83 scoped_refptr<DecoderBuffer> second_file = |
| 84 ReadTestDataFile("bear-640x360.webm"); |
| 85 ASSERT_TRUE(source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec), |
| 86 second_file->data(), |
| 87 second_file->data_size())); |
| 88 source.EndOfStream(); |
| 89 |
| 90 Play(); |
| 91 EXPECT_TRUE(WaitUntilOnEnded()); |
| 92 |
| 93 source.Shutdown(); |
| 94 Stop(); |
| 95 } |
| 96 |
| 97 TEST_F(MediaRemotingIntegrationTest, SeekWhilePlaying) { |
| 98 ASSERT_EQ(PIPELINE_OK, Start("bear-320x240.webm")); |
| 99 |
| 100 base::TimeDelta duration(pipeline_->GetMediaDuration()); |
| 101 base::TimeDelta start_seek_time(duration / 4); |
| 102 base::TimeDelta seek_time(duration * 3 / 4); |
| 103 |
| 104 Play(); |
| 105 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time)); |
| 106 ASSERT_TRUE(Seek(seek_time)); |
| 107 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 108 ASSERT_TRUE(WaitUntilOnEnded()); |
| 109 |
| 110 // Make sure seeking after reaching the end works as expected. |
| 111 ASSERT_TRUE(Seek(seek_time)); |
| 112 EXPECT_GE(pipeline_->GetMediaTime(), seek_time); |
| 113 ASSERT_TRUE(WaitUntilOnEnded()); |
| 114 } |
| 115 |
| 116 } // namespace remoting |
| 117 } // namespace media |
OLD | NEW |