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 |
11 #include "base/md5.h" | 11 #include "base/md5.h" |
12 #include "base/memory/scoped_vector.h" | |
13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
14 #include "base/test/scoped_task_scheduler.h" | 13 #include "base/test/scoped_task_scheduler.h" |
15 #include "media/audio/clockless_audio_sink.h" | 14 #include "media/audio/clockless_audio_sink.h" |
16 #include "media/audio/null_audio_sink.h" | 15 #include "media/audio/null_audio_sink.h" |
17 #include "media/base/demuxer.h" | 16 #include "media/base/demuxer.h" |
18 #include "media/base/null_video_sink.h" | 17 #include "media/base/null_video_sink.h" |
19 #include "media/base/pipeline_impl.h" | 18 #include "media/base/pipeline_impl.h" |
20 #include "media/base/pipeline_status.h" | 19 #include "media/base/pipeline_status.h" |
21 #include "media/base/text_track.h" | 20 #include "media/base/text_track.h" |
22 #include "media/base/text_track_config.h" | 21 #include "media/base/text_track_config.h" |
23 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
24 #include "media/renderers/video_renderer_impl.h" | 23 #include "media/renderers/video_renderer_impl.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
26 | 25 |
27 namespace media { | 26 namespace media { |
28 | 27 |
29 class AudioDecoder; | |
30 class CdmContext; | 28 class CdmContext; |
31 class VideoDecoder; | |
32 | 29 |
33 // Empty MD5 hash string. Used to verify empty video tracks. | 30 // Empty MD5 hash string. Used to verify empty video tracks. |
34 extern const char kNullVideoHash[]; | 31 extern const char kNullVideoHash[]; |
35 | 32 |
36 // Empty hash string. Used to verify empty audio tracks. | 33 // Empty hash string. Used to verify empty audio tracks. |
37 extern const char kNullAudioHash[]; | 34 extern const char kNullAudioHash[]; |
38 | 35 |
39 // Dummy tick clock which advances extremely quickly (1 minute every time | 36 // Dummy tick clock which advances extremely quickly (1 minute every time |
40 // NowTicks() is called). | 37 // NowTicks() is called). |
41 class DummyTickClock : public base::TickClock { | 38 class DummyTickClock : public base::TickClock { |
(...skipping 29 matching lines...) Expand all Loading... |
71 kClockless = 2, | 68 kClockless = 2, |
72 kExpectDemuxerFailure = 4, | 69 kExpectDemuxerFailure = 4, |
73 kUnreliableDuration = 8, | 70 kUnreliableDuration = 8, |
74 }; | 71 }; |
75 | 72 |
76 // Starts the pipeline with a file specified by |filename|, optionally with a | 73 // Starts the pipeline with a file specified by |filename|, optionally with a |
77 // CdmContext or a |test_type|, returning the final status code after it has | 74 // CdmContext or a |test_type|, returning the final status code after it has |
78 // started. |filename| points at a test file located under media/test/data/. | 75 // started. |filename| points at a test file located under media/test/data/. |
79 PipelineStatus Start(const std::string& filename); | 76 PipelineStatus Start(const std::string& filename); |
80 PipelineStatus Start(const std::string& filename, CdmContext* cdm_context); | 77 PipelineStatus Start(const std::string& filename, CdmContext* cdm_context); |
81 PipelineStatus Start(const std::string& filename, | 78 PipelineStatus Start( |
82 uint8_t test_type, | 79 const std::string& filename, |
83 ScopedVector<VideoDecoder> prepend_video_decoders = | 80 uint8_t test_type, |
84 ScopedVector<VideoDecoder>(), | 81 CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(), |
85 ScopedVector<AudioDecoder> prepend_audio_decoders = | 82 CreateAudioDecodersCB prepend_audio_decoders_cb = |
86 ScopedVector<AudioDecoder>()); | 83 CreateAudioDecodersCB()); |
87 | 84 |
88 // Starts the pipeline with |data| (with |size| bytes). The |data| will be | 85 // Starts the pipeline with |data| (with |size| bytes). The |data| will be |
89 // valid throughtout the lifetime of this test. | 86 // valid throughtout the lifetime of this test. |
90 PipelineStatus Start(const uint8_t* data, size_t size, uint8_t test_type); | 87 PipelineStatus Start(const uint8_t* data, size_t size, uint8_t test_type); |
91 | 88 |
92 void Play(); | 89 void Play(); |
93 void Pause(); | 90 void Pause(); |
94 bool Seek(base::TimeDelta seek_time); | 91 bool Seek(base::TimeDelta seek_time); |
95 bool Suspend(); | 92 bool Suspend(); |
96 bool Resume(base::TimeDelta seek_time); | 93 bool Resume(base::TimeDelta seek_time); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 ColorSpace last_video_frame_color_space_; | 147 ColorSpace last_video_frame_color_space_; |
151 DummyTickClock dummy_clock_; | 148 DummyTickClock dummy_clock_; |
152 PipelineMetadata metadata_; | 149 PipelineMetadata metadata_; |
153 scoped_refptr<VideoFrame> last_frame_; | 150 scoped_refptr<VideoFrame> last_frame_; |
154 base::TimeDelta current_duration_; | 151 base::TimeDelta current_duration_; |
155 | 152 |
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 CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(), |
161 ScopedVector<VideoDecoder>(), | 158 CreateAudioDecodersCB prepend_audio_decoders_cb = |
162 ScopedVector<AudioDecoder> prepend_audio_decoders = | 159 CreateAudioDecodersCB()); |
163 ScopedVector<AudioDecoder>()); | |
164 | 160 |
165 PipelineStatus StartWithFile( | 161 PipelineStatus StartWithFile( |
166 const std::string& filename, | 162 const std::string& filename, |
167 CdmContext* cdm_context, | 163 CdmContext* cdm_context, |
168 uint8_t test_type, | 164 uint8_t test_type, |
169 ScopedVector<VideoDecoder> prepend_video_decoders = | 165 CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(), |
170 ScopedVector<VideoDecoder>(), | 166 CreateAudioDecodersCB prepend_audio_decoders_cb = |
171 ScopedVector<AudioDecoder> prepend_audio_decoders = | 167 CreateAudioDecodersCB()); |
172 ScopedVector<AudioDecoder>()); | |
173 | 168 |
174 void OnSeeked(base::TimeDelta seek_time, PipelineStatus status); | 169 void OnSeeked(base::TimeDelta seek_time, PipelineStatus status); |
175 void OnStatusCallback(PipelineStatus status); | 170 void OnStatusCallback(PipelineStatus status); |
176 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, | 171 void DemuxerEncryptedMediaInitDataCB(EmeInitDataType type, |
177 const std::vector<uint8_t>& init_data); | 172 const std::vector<uint8_t>& init_data); |
178 | 173 |
179 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); | 174 void DemuxerMediaTracksUpdatedCB(std::unique_ptr<MediaTracks> tracks); |
180 | 175 |
181 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); | 176 void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time); |
182 | 177 |
183 // Creates Demuxer and sets |demuxer_|. | 178 // Creates Demuxer and sets |demuxer_|. |
184 void CreateDemuxer(std::unique_ptr<DataSource> data_source); | 179 void CreateDemuxer(std::unique_ptr<DataSource> data_source); |
185 | 180 |
186 // Creates and returns a Renderer. | 181 // Creates and returns a Renderer. |
187 virtual std::unique_ptr<Renderer> CreateRenderer( | 182 virtual std::unique_ptr<Renderer> CreateRenderer( |
188 ScopedVector<VideoDecoder> prepend_video_decoders = | 183 CreateVideoDecodersCB prepend_video_decoders_cb = CreateVideoDecodersCB(), |
189 ScopedVector<VideoDecoder>(), | 184 CreateAudioDecodersCB prepend_audio_decoders_cb = |
190 ScopedVector<AudioDecoder> prepend_audio_decoders = | 185 CreateAudioDecodersCB()); |
191 ScopedVector<AudioDecoder>()); | |
192 | 186 |
193 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); | 187 void OnVideoFramePaint(const scoped_refptr<VideoFrame>& frame); |
194 | 188 |
195 void CheckDuration(); | 189 void CheckDuration(); |
196 | 190 |
197 // Return the media start time from |demuxer_|. | 191 // Return the media start time from |demuxer_|. |
198 base::TimeDelta GetStartTime(); | 192 base::TimeDelta GetStartTime(); |
199 | 193 |
200 MOCK_METHOD1(DecryptorAttached, void(bool)); | 194 MOCK_METHOD1(DecryptorAttached, void(bool)); |
201 // Pipeline::Client overrides. | 195 // Pipeline::Client overrides. |
202 void OnError(PipelineStatus status) override; | 196 void OnError(PipelineStatus status) override; |
203 void OnEnded() override; | 197 void OnEnded() override; |
204 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); | 198 MOCK_METHOD1(OnMetadata, void(PipelineMetadata)); |
205 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); | 199 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); |
206 MOCK_METHOD0(OnDurationChange, void()); | 200 MOCK_METHOD0(OnDurationChange, void()); |
207 MOCK_METHOD2(OnAddTextTrack, | 201 MOCK_METHOD2(OnAddTextTrack, |
208 void(const TextTrackConfig& config, | 202 void(const TextTrackConfig& config, |
209 const AddTextTrackDoneCB& done_cb)); | 203 const AddTextTrackDoneCB& done_cb)); |
210 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); | 204 MOCK_METHOD0(OnWaitingForDecryptionKey, void(void)); |
211 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); | 205 MOCK_METHOD1(OnVideoNaturalSizeChange, void(const gfx::Size&)); |
212 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); | 206 MOCK_METHOD1(OnVideoOpacityChange, void(bool)); |
213 MOCK_METHOD0(OnVideoAverageKeyframeDistanceUpdate, void()); | 207 MOCK_METHOD0(OnVideoAverageKeyframeDistanceUpdate, void()); |
214 }; | 208 }; |
215 | 209 |
216 } // namespace media | 210 } // namespace media |
217 | 211 |
218 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ | 212 #endif // MEDIA_TEST_PIPELINE_INTEGRATION_TEST_BASE_H_ |
OLD | NEW |