OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 #ifndef MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ | |
6 #define MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ | |
7 | |
8 #include <stdint.h> | |
9 #include <vector> | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/time/time.h" | |
12 #include "media/base/android/demuxer_stream_player_params.h" | |
13 | |
14 namespace media { | |
15 | |
16 // TestDataFactory is used by MediaCodecDecoder unit test and MediaCodecPlayer | |
17 // unit test to simulate the audio or video access unit stream. | |
18 class TestDataFactory { | |
19 public: | |
20 // These methods return corresponding demuxer configs. | |
21 static DemuxerConfigs CreateAudioConfigs(AudioCodec audio_codec, | |
22 const base::TimeDelta& duration); | |
23 static DemuxerConfigs CreateVideoConfigs(VideoCodec video_codec, | |
24 const base::TimeDelta& duration, | |
25 const gfx::Size& video_size); | |
26 | |
27 // Constructor calls |LoadPackets| to load packets from files. | |
28 // Parameters: | |
29 // file_name_template: the sprintf format string used to generate a file | |
30 // name for the packet in the form e.g. "h264-AxB-%d" | |
31 // The |%d| will be replaced by 0, 1, 2, 3. | |
32 // duration: after the last AU exceeds duration the factory generates EOS | |
33 // unit and stops. | |
34 // frame_period: PTS increment between units. | |
35 TestDataFactory(const char* file_name_template, | |
36 const base::TimeDelta& duration, | |
37 const base::TimeDelta& frame_period); | |
38 virtual ~TestDataFactory(); | |
39 | |
40 // Returns demuxer configuration for this factory. | |
41 virtual DemuxerConfigs GetConfigs() = 0; | |
42 | |
43 // Populates next chunk and the corresponding delay. | |
44 // Default implementation repeatedly uses |packet_| array in order 0-1-2-3 | |
45 // and monotonically increases timestamps from 0 to |duration_|. | |
46 // The first unit to exceed |duration_| becomes EOS. The delay is set to 0. | |
47 virtual void CreateChunk(DemuxerData* chunk, base::TimeDelta* delay); | |
48 | |
49 base::TimeDelta last_pts() const { return last_pts_; } | |
50 | |
51 protected: | |
52 // Called by constructor to load packets from files referred by | |
53 // |file_name_template|. | |
54 virtual void LoadPackets(const char* file_name_template); | |
55 | |
56 // Used to modify the generated access unit by a subclass. | |
57 virtual void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) {} | |
58 | |
59 base::TimeDelta duration_; | |
60 base::TimeDelta frame_period_; | |
61 std::vector<uint8_t> packet_[4]; | |
62 base::TimeDelta regular_pts_; // monotonically increasing PTS | |
63 base::TimeDelta last_pts_; // subclass can modify PTS, maintains the last | |
64 }; | |
65 | |
66 } // namespace media | |
67 | |
68 #endif // MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ | |
OLD | NEW |