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_BASE_TEST_HELPERS_H_ | 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ |
6 #define MEDIA_BASE_TEST_HELPERS_H_ | 6 #define MEDIA_BASE_TEST_HELPERS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "media/base/channel_layout.h" | 10 #include "media/base/channel_layout.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // Returns coded size for Normal and Large config. | 80 // Returns coded size for Normal and Large config. |
81 static gfx::Size NormalCodedSize(); | 81 static gfx::Size NormalCodedSize(); |
82 static gfx::Size LargeCodedSize(); | 82 static gfx::Size LargeCodedSize(); |
83 | 83 |
84 private: | 84 private: |
85 DISALLOW_IMPLICIT_CONSTRUCTORS(TestVideoConfig); | 85 DISALLOW_IMPLICIT_CONSTRUCTORS(TestVideoConfig); |
86 }; | 86 }; |
87 | 87 |
88 // Create an AudioBuffer containing |frames| frames of data, where each sample | 88 // Create an AudioBuffer containing |frames| frames of data, where each sample |
89 // is of type T. |start| and |increment| are used to specify the values for the | 89 // is of type T. |
90 // samples, which are created in channel order. The value for frame and channel | |
91 // is determined by: | |
92 // | 90 // |
93 // |start| + |channel| * |frames| * |increment| + index * |increment| | 91 // For interleaved formats, each frame will have the data from |channels| |
| 92 // channels interleaved. |start| and |increment| are used to specify the values |
| 93 // for the samples. Since this is interleaved data, channel 0 data will be: |
| 94 // |start| |
| 95 // |start| + |channels| * |increment| |
| 96 // |start| + 2 * |channels| * |increment|, and so on. |
| 97 // Data for subsequent channels is similar. No check is done that |format| |
| 98 // requires data to be of type T, but it is verified that |format| is an |
| 99 // interleaved format. |
94 // | 100 // |
95 // E.g., for a stereo buffer the values in channel 0 will be: | 101 // For planar formats, there will be a block for each of |channel| channels. |
96 // start | 102 // |start| and |increment| are used to specify the values for the samples, which |
97 // start + increment | 103 // are created in channel order. Since this is planar data, channel 0 data will |
98 // start + 2 * increment, ... | 104 // be: |
| 105 // |start| |
| 106 // |start| + |increment| |
| 107 // |start| + 2 * |increment|, and so on. |
| 108 // Data for channel 1 will follow where channel 0 ends. Subsequent channels are |
| 109 // similar. No check is done that |format| requires data to be of type T, but it |
| 110 // is verified that |format| is a planar format. |
99 // | 111 // |
100 // While, values in channel 1 will be: | 112 // |start_time| will be used as the start time for the samples. |duration| is |
101 // start + frames * increment | 113 // the duration. |
102 // start + (frames + 1) * increment | |
103 // start + (frames + 2) * increment, ... | |
104 // | |
105 // |start_time| will be used as the start time for the samples. | |
106 template <class T> | 114 template <class T> |
107 scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format, | 115 scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format, |
108 ChannelLayout channel_layout, | 116 ChannelLayout channel_layout, |
109 size_t channel_count, | 117 int channel_count, |
110 int sample_rate, | 118 int sample_rate, |
111 T start, | 119 T start, |
112 T increment, | 120 T increment, |
113 size_t frames, | 121 int frames, |
114 base::TimeDelta timestamp); | 122 base::TimeDelta timestamp, |
| 123 base::TimeDelta duration); |
115 | 124 |
116 // Create a fake video DecoderBuffer for testing purpose. The buffer contains | 125 // Create a fake video DecoderBuffer for testing purpose. The buffer contains |
117 // part of video decoder config info embedded so that the testing code can do | 126 // part of video decoder config info embedded so that the testing code can do |
118 // some sanity check. | 127 // some sanity check. |
119 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( | 128 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( |
120 const VideoDecoderConfig& config, | 129 const VideoDecoderConfig& config, |
121 base::TimeDelta timestamp, | 130 base::TimeDelta timestamp, |
122 base::TimeDelta duration); | 131 base::TimeDelta duration); |
123 | 132 |
124 // Verify if a fake video DecoderBuffer is valid. | 133 // Verify if a fake video DecoderBuffer is valid. |
125 bool VerifyFakeVideoBufferForTest(const scoped_refptr<DecoderBuffer>& buffer, | 134 bool VerifyFakeVideoBufferForTest(const scoped_refptr<DecoderBuffer>& buffer, |
126 const VideoDecoderConfig& config); | 135 const VideoDecoderConfig& config); |
127 | 136 |
128 } // namespace media | 137 } // namespace media |
129 | 138 |
130 #endif // MEDIA_BASE_TEST_HELPERS_H_ | 139 #endif // MEDIA_BASE_TEST_HELPERS_H_ |
OLD | NEW |