| 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 #ifndef MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ | 5 #ifndef MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ |
| 6 #define MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ | 6 #define MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class DummyTickClock : public base::TickClock { | 41 class DummyTickClock : public base::TickClock { |
| 42 public: | 42 public: |
| 43 DummyTickClock() : now_() {} | 43 DummyTickClock() : now_() {} |
| 44 ~DummyTickClock() override {} | 44 ~DummyTickClock() override {} |
| 45 base::TimeTicks NowTicks() override; | 45 base::TimeTicks NowTicks() override; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 base::TimeTicks now_; | 48 base::TimeTicks now_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 class PipelineTestRendererFactory { |
| 52 public: |
| 53 virtual ~PipelineTestRendererFactory() {} |
| 54 // Creates and returns a Renderer. |
| 55 virtual std::unique_ptr<Renderer> CreateRenderer( |
| 56 ScopedVector<VideoDecoder> prepend_video_decoders = |
| 57 ScopedVector<VideoDecoder>(), |
| 58 ScopedVector<AudioDecoder> prepend_audio_decoders = |
| 59 ScopedVector<AudioDecoder>()) = 0; |
| 60 }; |
| 61 |
| 62 enum PipelineType { |
| 63 Media, // Test the general media pipeline. |
| 64 MediaRemoting, // Test Media Remoting pipeline. |
| 65 }; |
| 66 |
| 51 // Integration tests for Pipeline. Real demuxers, real decoders, and | 67 // Integration tests for Pipeline. Real demuxers, real decoders, and |
| 52 // base renderer implementations are used to verify pipeline functionality. The | 68 // base renderer implementations are used to verify pipeline functionality. The |
| 53 // renderers used in these tests rely heavily on the AudioRendererBase & | 69 // renderers used in these tests rely heavily on the AudioRendererBase & |
| 54 // VideoRendererImpl implementations which contain a majority of the code used | 70 // VideoRendererImpl implementations which contain a majority of the code used |
| 55 // in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in | 71 // in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in |
| 56 // the browser. The renderers in this test don't actually write data to a | 72 // the browser. The renderers in this test don't actually write data to a |
| 57 // display or audio device. Both of these devices are simulated since they have | 73 // display or audio device. Both of these devices are simulated since they have |
| 58 // little effect on verifying pipeline behavior and allow tests to run faster | 74 // little effect on verifying pipeline behavior and allow tests to run faster |
| 59 // than real-time. | 75 // than real-time. |
| 60 class PipelineIntegrationTestBase : public Pipeline::Client { | 76 class PipelineIntegrationTestBase : public Pipeline::Client { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // Pipeline must have been started with clockless playback enabled. | 138 // Pipeline must have been started with clockless playback enabled. |
| 123 base::TimeDelta GetAudioTime(); | 139 base::TimeDelta GetAudioTime(); |
| 124 | 140 |
| 125 // Sets a callback to handle EME "encrypted" event. Must be called to test | 141 // Sets a callback to handle EME "encrypted" event. Must be called to test |
| 126 // potentially encrypted media. | 142 // potentially encrypted media. |
| 127 void set_encrypted_media_init_data_cb( | 143 void set_encrypted_media_init_data_cb( |
| 128 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { | 144 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { |
| 129 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 145 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
| 130 } | 146 } |
| 131 | 147 |
| 148 std::unique_ptr<Renderer> CreateRenderer( |
| 149 ScopedVector<VideoDecoder> prepend_video_decoders, |
| 150 ScopedVector<AudioDecoder> prepend_audio_decoders); |
| 151 |
| 132 protected: | 152 protected: |
| 133 base::MessageLoop message_loop_; | |
| 134 base::MD5Context md5_context_; | |
| 135 bool hashing_enabled_; | |
| 136 bool clockless_playback_; | |
| 137 | |
| 138 // TaskScheduler is used only for FFmpegDemuxer. | |
| 139 std::unique_ptr<base::test::ScopedTaskScheduler> task_scheduler_; | |
| 140 std::unique_ptr<Demuxer> demuxer_; | |
| 141 std::unique_ptr<DataSource> data_source_; | |
| 142 std::unique_ptr<PipelineImpl> pipeline_; | |
| 143 scoped_refptr<NullAudioSink> audio_sink_; | |
| 144 scoped_refptr<ClocklessAudioSink> clockless_audio_sink_; | |
| 145 std::unique_ptr<NullVideoSink> video_sink_; | |
| 146 bool ended_; | |
| 147 PipelineStatus pipeline_status_; | |
| 148 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | |
| 149 VideoPixelFormat last_video_frame_format_; | |
| 150 ColorSpace last_video_frame_color_space_; | |
| 151 DummyTickClock dummy_clock_; | |
| 152 PipelineMetadata metadata_; | |
| 153 scoped_refptr<VideoFrame> last_frame_; | |
| 154 base::TimeDelta current_duration_; | |
| 155 | |
| 156 PipelineStatus StartInternal( | 153 PipelineStatus StartInternal( |
| 157 std::unique_ptr<DataSource> data_source, | 154 std::unique_ptr<DataSource> data_source, |
| 158 CdmContext* cdm_context, | 155 CdmContext* cdm_context, |
| 159 uint8_t test_type, | 156 uint8_t test_type, |
| 160 ScopedVector<VideoDecoder> prepend_video_decoders = | 157 ScopedVector<VideoDecoder> prepend_video_decoders = |
| 161 ScopedVector<VideoDecoder>(), | 158 ScopedVector<VideoDecoder>(), |
| 162 ScopedVector<AudioDecoder> prepend_audio_decoders = | 159 ScopedVector<AudioDecoder> prepend_audio_decoders = |
| 163 ScopedVector<AudioDecoder>()); | 160 ScopedVector<AudioDecoder>()); |
| 164 | 161 |
| 165 PipelineStatus StartWithFile( | 162 PipelineStatus StartWithFile( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 176 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, | 173 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, |
| 177 const std::vector<uint8_t>& init_data); | 174 const std::vector<uint8_t>& init_data); |
| 178 | 175 |
| 179 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); | 176 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); |
| 180 | 177 |
| 181 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); | 178 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); |
| 182 | 179 |
| 183 // Creates Demuxer and sets |demuxer_|. | 180 // Creates Demuxer and sets |demuxer_|. |
| 184 void CreateDemuxer(std::unique_ptr<DataSource> data_source); | 181 void CreateDemuxer(std::unique_ptr<DataSource> data_source); |
| 185 | 182 |
| 186 // Creates and returns a Renderer. | |
| 187 virtual std::unique_ptr<Renderer> CreateRenderer( | |
| 188 ScopedVector<VideoDecoder> prepend_video_decoders = | |
| 189 ScopedVector<VideoDecoder>(), | |
| 190 ScopedVector<AudioDecoder> prepend_audio_decoders = | |
| 191 ScopedVector<AudioDecoder>()); | |
| 192 | |
| 193 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); | 183 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); |
| 194 | 184 |
| 195 void CheckDuration(); | 185 void CheckDuration(); |
| 196 | 186 |
| 197 // Return the media start time from |demuxer_|. | 187 // Return the media start time from |demuxer_|. |
| 198 base::TimeDelta GetStartTime(); | 188 base::TimeDelta GetStartTime(); |
| 199 | 189 |
| 190 #if BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 191 // Proxy all control and data flows through a media remoting RPC pipeline, to |
| 192 // test that an end-to-end media remoting pipeline works the same as a normal, |
| 193 // local pipeline. |
| 194 void SetUpRemotingPipeline(); |
| 195 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) |
| 196 |
| 200 MOCK_METHOD1(DecryptorAttached, void(bool)); | 197 MOCK_METHOD1(DecryptorAttached, void(bool)); |
| 201 // Pipeline::Client overrides. | 198 // Pipeline::Client overrides. |
| 202 void OnError(PipelineStatus status) override; | 199 void OnError(PipelineStatus status) override; |
| 203 void OnEnded() override; | 200 void OnEnded() override; |
| 204 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); | 201 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); |
| 205 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | 202 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); |
| 206 MOCK_METHOD0(OnDurationChange, void()); | 203 MOCK_METHOD0(OnDurationChange, void()); |
| 207 MOCK_METHOD2(OnAddTextTrack, | 204 MOCK_METHOD2(OnAddTextTrack, |
| 208 void(const TextTrackConfig& config, | 205 void(const TextTrackConfig& config, |
| 209 const AddTextTrackDoneCB& done_cb)); | 206 const AddTextTrackDoneCB& done_cb)); |
| 210 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 207 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
| 211 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); | 208 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); |
| 212 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); | 209 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); |
| 213 MOCK_METHOD0(OnVideoAverageKeyframeDistanceUpdate, void()); | 210 MOCK_METHOD0(OnVideoAverageKeyframeDistanceUpdate, void()); |
| 211 |
| 212 base::MessageLoop message_loop_; |
| 213 base::MD5Context md5_context_; |
| 214 bool hashing_enabled_; |
| 215 bool clockless_playback_; |
| 216 |
| 217 // TaskScheduler is used only for FFmpegDemuxer. |
| 218 std::unique_ptr<base::test::ScopedTaskScheduler> task_scheduler_; |
| 219 std::unique_ptr<Demuxer> demuxer_; |
| 220 std::unique_ptr<DataSource> data_source_; |
| 221 std::unique_ptr<PipelineImpl> pipeline_; |
| 222 scoped_refptr<NullAudioSink> audio_sink_; |
| 223 scoped_refptr<ClocklessAudioSink> clockless_audio_sink_; |
| 224 std::unique_ptr<NullVideoSink> video_sink_; |
| 225 bool ended_; |
| 226 PipelineStatus pipeline_status_; |
| 227 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; |
| 228 VideoPixelFormat last_video_frame_format_; |
| 229 ColorSpace last_video_frame_color_space_; |
| 230 DummyTickClock dummy_clock_; |
| 231 PipelineMetadata metadata_; |
| 232 scoped_refptr<VideoFrame> last_frame_; |
| 233 base::TimeDelta current_duration_; |
| 234 std::unique_ptr<PipelineTestRendererFactory> renderer_factory_; |
| 235 |
| 236 private: |
| 237 DISALLOW_COPY_AND_ASSIGN(PipelineIntegrationTestBase); |
| 214 }; | 238 }; |
| 215 | 239 |
| 216 } // namespace media | 240 } // namespace media |
| 217 | 241 |
| 218 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ | 242 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ |
| OLD | NEW |