OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_BASE_ANDROID_TEST_DATA_FACTORY_H_ | 5 #ifndef MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ |
6 #define MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ | 6 #define MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <set> |
9 #include <vector> | 10 #include <vector> |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
12 #include "media/base/android/demuxer_stream_player_params.h" | 13 #include "media/base/android/demuxer_stream_player_params.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 | 16 |
16 // TestDataFactory is used by MediaCodecDecoder unit test and MediaCodecPlayer | 17 // TestDataFactory is used by MediaCodecDecoder unit test and MediaCodecPlayer |
17 // unit test to simulate the audio or video access unit stream. | 18 // unit test to simulate the audio or video access unit stream. |
18 class TestDataFactory { | 19 class TestDataFactory { |
(...skipping 27 matching lines...) Expand all Loading... |
46 // and monotonically increases timestamps from 0 to |duration_|. | 47 // and monotonically increases timestamps from 0 to |duration_|. |
47 // The first unit to exceed |duration_| becomes EOS. The delay is set to 0. | 48 // The first unit to exceed |duration_| becomes EOS. The delay is set to 0. |
48 virtual bool CreateChunk(DemuxerData* chunk, base::TimeDelta* delay); | 49 virtual bool CreateChunk(DemuxerData* chunk, base::TimeDelta* delay); |
49 | 50 |
50 // In starvation mode we do not add EOS at the end. | 51 // In starvation mode we do not add EOS at the end. |
51 void SetStarvationMode(bool value) { starvation_mode_ = value; } | 52 void SetStarvationMode(bool value) { starvation_mode_ = value; } |
52 | 53 |
53 // Resets the timestamp for the next access unit. | 54 // Resets the timestamp for the next access unit. |
54 void SeekTo(const base::TimeDelta& seek_time); | 55 void SeekTo(const base::TimeDelta& seek_time); |
55 | 56 |
| 57 // Request that a chunk containing sole |kConfigChanged| unit is generated |
| 58 // before the first true data chunk. |
| 59 void RequestInitialConfigs(); |
| 60 |
| 61 void RequestConfigChange(base::TimeDelta config_position); |
| 62 |
56 // Returns the maximum PTS, taking into account possible modifications | 63 // Returns the maximum PTS, taking into account possible modifications |
57 // by subclasses. The SeekTo() resets this value. | 64 // by subclasses. The SeekTo() resets this value. |
58 base::TimeDelta last_pts() const { return last_pts_; } | 65 base::TimeDelta last_pts() const { return last_pts_; } |
59 | 66 |
60 protected: | 67 protected: |
61 // Called by constructor to load packets from files referred by | 68 // Called by constructor to load packets from files referred by |
62 // |file_name_template|. | 69 // |file_name_template|. |
63 virtual void LoadPackets(const char* file_name_template); | 70 virtual void LoadPackets(const char* file_name_template); |
64 | 71 |
65 // Used to modify the generated access unit by a subclass. | 72 // Used to modify the generated access unit by a subclass. |
66 virtual void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) {} | 73 virtual void ModifyAccessUnit(int index_in_chunk, AccessUnit* unit) {} |
67 | 74 |
68 base::TimeDelta duration_; | 75 base::TimeDelta duration_; |
69 base::TimeDelta frame_period_; | 76 base::TimeDelta frame_period_; |
| 77 |
| 78 private: |
| 79 typedef std::set<base::TimeDelta> PTSSet; |
| 80 |
| 81 // |left| is included in the interval, |right| is excluded. |
| 82 // If |left| == |right|, the interval is empty and the method returns false. |
| 83 bool HasReconfigForInterval(base::TimeDelta left, |
| 84 base::TimeDelta right) const; |
| 85 |
| 86 void AddConfiguration(DemuxerData* chunk); |
| 87 |
70 std::vector<uint8_t> packet_[4]; | 88 std::vector<uint8_t> packet_[4]; |
71 base::TimeDelta regular_pts_; // monotonically increasing PTS | 89 base::TimeDelta regular_pts_; // monotonically increasing PTS |
| 90 base::TimeDelta chunk_begin_pts_; // beginning of chunk time interval |
72 base::TimeDelta last_pts_; // subclass can modify PTS, maintain the last | 91 base::TimeDelta last_pts_; // subclass can modify PTS, maintain the last |
| 92 PTSSet reconfigs_; // ConfigChange requests |
| 93 size_t total_chunks_; // total number of chunks returned |
73 bool starvation_mode_; // true means no EOS at the end | 94 bool starvation_mode_; // true means no EOS at the end |
74 bool eos_reached_; // true if CreateChunk() returned EOS frame | 95 bool eos_reached_; // true if CreateChunk() returned EOS frame |
75 }; | 96 }; |
76 | 97 |
77 } // namespace media | 98 } // namespace media |
78 | 99 |
79 #endif // MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ | 100 #endif // MEDIA_BASE_ANDROID_TEST_DATA_FACTORY_H_ |
OLD | NEW |