| 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 #include "media/base/test_helpers.h" | 5 #include "media/base/test_helpers.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return kNormalSize; | 144 return kNormalSize; |
| 145 } | 145 } |
| 146 | 146 |
| 147 gfx::Size TestVideoConfig::LargeCodedSize() { | 147 gfx::Size TestVideoConfig::LargeCodedSize() { |
| 148 return kLargeSize; | 148 return kLargeSize; |
| 149 } | 149 } |
| 150 | 150 |
| 151 template <class T> | 151 template <class T> |
| 152 scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format, | 152 scoped_refptr<AudioBuffer> MakeAudioBuffer(SampleFormat format, |
| 153 ChannelLayout channel_layout, | 153 ChannelLayout channel_layout, |
| 154 int channel_count, |
| 154 int sample_rate, | 155 int sample_rate, |
| 155 T start, | 156 T start, |
| 156 T increment, | 157 T increment, |
| 157 int frames, | 158 int frames, |
| 158 base::TimeDelta timestamp, | 159 base::TimeDelta timestamp, |
| 159 base::TimeDelta duration) { | 160 base::TimeDelta duration) { |
| 160 int channels = ChannelLayoutToChannelCount(channel_layout); | 161 int channels = ChannelLayoutToChannelCount(channel_layout); |
| 161 scoped_refptr<AudioBuffer> output = | 162 scoped_refptr<AudioBuffer> output = AudioBuffer::CreateBuffer( |
| 162 AudioBuffer::CreateBuffer(format, channel_layout, sample_rate, frames); | 163 format, channel_layout, channel_count, sample_rate, frames); |
| 163 output->set_timestamp(timestamp); | 164 output->set_timestamp(timestamp); |
| 164 output->set_duration(duration); | 165 output->set_duration(duration); |
| 165 | 166 |
| 166 // Create a block of memory with values: | 167 // Create a block of memory with values: |
| 167 // start | 168 // start |
| 168 // start + increment | 169 // start + increment |
| 169 // start + 2 * increment, ... | 170 // start + 2 * increment, ... |
| 170 // For interleaved data, raw data will be: | 171 // For interleaved data, raw data will be: |
| 171 // start | 172 // start |
| 172 // start + channels * increment | 173 // start + channels * increment |
| (...skipping 18 matching lines...) Expand all Loading... |
| 191 } | 192 } |
| 192 return output; | 193 return output; |
| 193 } | 194 } |
| 194 | 195 |
| 195 // Instantiate all the types of MakeAudioBuffer() and | 196 // Instantiate all the types of MakeAudioBuffer() and |
| 196 // MakeAudioBuffer() needed. | 197 // MakeAudioBuffer() needed. |
| 197 #define DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(type) \ | 198 #define DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(type) \ |
| 198 template scoped_refptr<AudioBuffer> MakeAudioBuffer<type>( \ | 199 template scoped_refptr<AudioBuffer> MakeAudioBuffer<type>( \ |
| 199 SampleFormat format, \ | 200 SampleFormat format, \ |
| 200 ChannelLayout channel_layout, \ | 201 ChannelLayout channel_layout, \ |
| 202 int channel_count, \ |
| 201 int sample_rate, \ | 203 int sample_rate, \ |
| 202 type start, \ | 204 type start, \ |
| 203 type increment, \ | 205 type increment, \ |
| 204 int frames, \ | 206 int frames, \ |
| 205 base::TimeDelta start_time, \ | 207 base::TimeDelta start_time, \ |
| 206 base::TimeDelta duration) | 208 base::TimeDelta duration) |
| 207 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(uint8); | 209 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(uint8); |
| 208 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int16); | 210 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int16); |
| 209 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int32); | 211 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int32); |
| 210 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(float); | 212 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(float); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 239 int width = 0; | 241 int width = 0; |
| 240 int height = 0; | 242 int height = 0; |
| 241 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && | 243 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && |
| 242 pickle.ReadInt(&height); | 244 pickle.ReadInt(&height); |
| 243 return (success && header == kFakeVideoBufferHeader && | 245 return (success && header == kFakeVideoBufferHeader && |
| 244 width == config.coded_size().width() && | 246 width == config.coded_size().width() && |
| 245 height == config.coded_size().height()); | 247 height == config.coded_size().height()); |
| 246 } | 248 } |
| 247 | 249 |
| 248 } // namespace media | 250 } // namespace media |
| OLD | NEW |