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 29 matching lines...) Expand all Loading... | |
40 class DummyTickClock : public base::TickClock { | 40 class DummyTickClock : public base::TickClock { |
41 public: | 41 public: |
42 DummyTickClock() : now_() {} | 42 DummyTickClock() : now_() {} |
43 ~DummyTickClock() override {} | 43 ~DummyTickClock() override {} |
44 base::TimeTicks NowTicks() override; | 44 base::TimeTicks NowTicks() override; |
45 | 45 |
46 private: | 46 private: |
47 base::TimeTicks now_; | 47 base::TimeTicks now_; |
48 }; | 48 }; |
49 | 49 |
50 class PipelineTestRendererFactory { | |
51 public: | |
52 virtual ~PipelineTestRendererFactory() {} | |
53 // Creates and returns a Renderer. | |
54 virtual std::unique_ptr<Renderer> CreateRenderer( | |
55 ScopedVector<VideoDecoder> prepend_video_decoders = | |
miu
2017/03/29 01:39:15
ScopedVector is deprecated. Please use std::unique
xjz
2017/03/30 23:21:31
This involves the refactor of VideoRendererImpl an
| |
56 ScopedVector<VideoDecoder>(), | |
57 ScopedVector<AudioDecoder> prepend_audio_decoders = | |
58 ScopedVector<AudioDecoder>()) = 0; | |
59 }; | |
60 | |
50 // Integration tests for Pipeline. Real demuxers, real decoders, and | 61 // Integration tests for Pipeline. Real demuxers, real decoders, and |
51 // base renderer implementations are used to verify pipeline functionality. The | 62 // base renderer implementations are used to verify pipeline functionality. The |
52 // renderers used in these tests rely heavily on the AudioRendererBase & | 63 // renderers used in these tests rely heavily on the AudioRendererBase & |
53 // VideoRendererImpl implementations which contain a majority of the code used | 64 // VideoRendererImpl implementations which contain a majority of the code used |
54 // in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in | 65 // in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in |
55 // the browser. The renderers in this test don't actually write data to a | 66 // the browser. The renderers in this test don't actually write data to a |
56 // display or audio device. Both of these devices are simulated since they have | 67 // display or audio device. Both of these devices are simulated since they have |
57 // little effect on verifying pipeline behavior and allow tests to run faster | 68 // little effect on verifying pipeline behavior and allow tests to run faster |
58 // than real-time. | 69 // than real-time. |
59 class PipelineIntegrationTestBase : public Pipeline::Client { | 70 class PipelineIntegrationTestBase : public Pipeline::Client { |
60 public: | 71 public: |
61 PipelineIntegrationTestBase(); | 72 PipelineIntegrationTestBase(); |
62 virtual ~PipelineIntegrationTestBase(); | 73 ~PipelineIntegrationTestBase(); |
miu
2017/03/29 01:39:15
Just to make sure the right dtor gets called, let'
xjz
2017/03/30 23:21:31
Done.
| |
63 | 74 |
64 // Test types for advanced testing and benchmarking (e.g., underflow is | 75 // Test types for advanced testing and benchmarking (e.g., underflow is |
65 // disabled to ensure consistent hashes). May be combined using the bitwise | 76 // disabled to ensure consistent hashes). May be combined using the bitwise |
66 // or operator (and as such must have values that are powers of two). | 77 // or operator (and as such must have values that are powers of two). |
67 enum TestTypeFlags { | 78 enum TestTypeFlags { |
68 kNormal = 0, | 79 kNormal = 0, |
69 kHashed = 1, | 80 kHashed = 1, |
70 kClockless = 2, | 81 kClockless = 2, |
71 kExpectDemuxerFailure = 4, | 82 kExpectDemuxerFailure = 4, |
72 kUnreliableDuration = 8, | 83 kUnreliableDuration = 8, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 // Pipeline must have been started with clockless playback enabled. | 132 // Pipeline must have been started with clockless playback enabled. |
122 base::TimeDelta GetAudioTime(); | 133 base::TimeDelta GetAudioTime(); |
123 | 134 |
124 // Sets a callback to handle EME "encrypted" event. Must be called to test | 135 // Sets a callback to handle EME "encrypted" event. Must be called to test |
125 // potentially encrypted media. | 136 // potentially encrypted media. |
126 void set_encrypted_media_init_data_cb( | 137 void set_encrypted_media_init_data_cb( |
127 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { | 138 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb) { |
128 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; | 139 encrypted_media_init_data_cb_ = encrypted_media_init_data_cb; |
129 } | 140 } |
130 | 141 |
142 std::unique_ptr<Renderer> CreateRenderer( | |
143 ScopedVector<VideoDecoder> prepend_video_decoders, | |
144 ScopedVector<AudioDecoder> prepend_audio_decoders); | |
145 | |
131 protected: | 146 protected: |
132 base::MessageLoop message_loop_; | |
133 base::MD5Context md5_context_; | |
134 bool hashing_enabled_; | |
135 bool clockless_playback_; | |
136 std::unique_ptr<Demuxer> demuxer_; | |
137 std::unique_ptr<DataSource> data_source_; | |
138 std::unique_ptr<PipelineImpl> pipeline_; | |
139 scoped_refptr<NullAudioSink> audio_sink_; | |
140 scoped_refptr<ClocklessAudioSink> clockless_audio_sink_; | |
141 std::unique_ptr<NullVideoSink> video_sink_; | |
142 bool ended_; | |
143 PipelineStatus pipeline_status_; | |
144 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | |
145 VideoPixelFormat last_video_frame_format_; | |
146 ColorSpace last_video_frame_color_space_; | |
147 DummyTickClock dummy_clock_; | |
148 PipelineMetadata metadata_; | |
149 scoped_refptr<VideoFrame> last_frame_; | |
150 base::TimeDelta current_duration_; | |
151 | |
152 PipelineStatus StartInternal( | 147 PipelineStatus StartInternal( |
153 std::unique_ptr<DataSource> data_source, | 148 std::unique_ptr<DataSource> data_source, |
154 CdmContext* cdm_context, | 149 CdmContext* cdm_context, |
155 uint8_t test_type, | 150 uint8_t test_type, |
156 ScopedVector<VideoDecoder> prepend_video_decoders = | 151 ScopedVector<VideoDecoder> prepend_video_decoders = |
157 ScopedVector<VideoDecoder>(), | 152 ScopedVector<VideoDecoder>(), |
158 ScopedVector<AudioDecoder> prepend_audio_decoders = | 153 ScopedVector<AudioDecoder> prepend_audio_decoders = |
159 ScopedVector<AudioDecoder>()); | 154 ScopedVector<AudioDecoder>()); |
160 | 155 |
161 PipelineStatus StartWithFile( | 156 PipelineStatus StartWithFile( |
(...skipping 10 matching lines...) Expand all Loading... | |
172 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, | 167 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, |
173 const std::vector<uint8_t>& init_data); | 168 const std::vector<uint8_t>& init_data); |
174 | 169 |
175 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); | 170 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); |
176 | 171 |
177 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); | 172 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); |
178 | 173 |
179 // Creates Demuxer and sets |demuxer_|. | 174 // Creates Demuxer and sets |demuxer_|. |
180 void CreateDemuxer(std::unique_ptr<DataSource> data_source); | 175 void CreateDemuxer(std::unique_ptr<DataSource> data_source); |
181 | 176 |
182 // Creates and returns a Renderer. | |
183 virtual std::unique_ptr<Renderer> CreateRenderer( | |
184 ScopedVector<VideoDecoder> prepend_video_decoders = | |
185 ScopedVector<VideoDecoder>(), | |
186 ScopedVector<AudioDecoder> prepend_audio_decoders = | |
187 ScopedVector<AudioDecoder>()); | |
188 | |
189 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); | 177 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); |
190 | 178 |
191 void CheckDuration(); | 179 void CheckDuration(); |
192 | 180 |
193 // Return the media start time from |demuxer_|. | 181 // Return the media start time from |demuxer_|. |
194 base::TimeDelta GetStartTime(); | 182 base::TimeDelta GetStartTime(); |
195 | 183 |
196 MOCK_METHOD1(DecryptorAttached, void(bool)); | 184 MOCK_METHOD1(DecryptorAttached, void(bool)); |
197 // Pipeline::Client overrides. | 185 // Pipeline::Client overrides. |
198 void OnError(PipelineStatus status) override; | 186 void OnError(PipelineStatus status) override; |
199 void OnEnded() override; | 187 void OnEnded() override; |
200 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); | 188 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); |
201 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | 189 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); |
202 MOCK_METHOD0(OnDurationChange, void()); | 190 MOCK_METHOD0(OnDurationChange, void()); |
203 MOCK_METHOD2(OnAddTextTrack, | 191 MOCK_METHOD2(OnAddTextTrack, |
204 void(const TextTrackConfig& config, | 192 void(const TextTrackConfig& config, |
205 const AddTextTrackDoneCB& done_cb)); | 193 const AddTextTrackDoneCB& done_cb)); |
206 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 194 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
207 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); | 195 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); |
208 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); | 196 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); |
197 | |
198 base::MessageLoop message_loop_; | |
199 base::MD5Context md5_context_; | |
200 bool hashing_enabled_; | |
201 bool clockless_playback_; | |
202 std::unique_ptr<Demuxer> demuxer_; | |
203 std::unique_ptr<DataSource> data_source_; | |
204 std::unique_ptr<PipelineImpl> pipeline_; | |
205 scoped_refptr<NullAudioSink> audio_sink_; | |
206 scoped_refptr<ClocklessAudioSink> clockless_audio_sink_; | |
207 std::unique_ptr<NullVideoSink> video_sink_; | |
208 bool ended_; | |
209 PipelineStatus pipeline_status_; | |
210 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_; | |
211 VideoPixelFormat last_video_frame_format_; | |
212 ColorSpace last_video_frame_color_space_; | |
213 DummyTickClock dummy_clock_; | |
214 PipelineMetadata metadata_; | |
215 scoped_refptr<VideoFrame> last_frame_; | |
216 base::TimeDelta current_duration_; | |
217 std::unique_ptr<PipelineTestRendererFactory> renderer_factory_; | |
218 | |
219 private: | |
220 DISALLOW_COPY_AND_ASSIGN(PipelineIntegrationTestBase); | |
209 }; | 221 }; |
210 | 222 |
211 } // namespace media | 223 } // namespace media |
212 | 224 |
213 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ | 225 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ |
OLD | NEW |