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