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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(uint8); | 210 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(uint8); |
211 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int16); | 211 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int16); |
212 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int32); | 212 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(int32); |
213 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(float); | 213 DEFINE_MAKE_AUDIO_BUFFER_INSTANCE(float); |
214 | 214 |
215 static const char kFakeVideoBufferHeader[] = "FakeVideoBufferForTest"; | 215 static const char kFakeVideoBufferHeader[] = "FakeVideoBufferForTest"; |
216 | 216 |
217 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( | 217 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest( |
218 const VideoDecoderConfig& config, | 218 const VideoDecoderConfig& config, |
219 base::TimeDelta timestamp, base::TimeDelta duration) { | 219 base::TimeDelta timestamp, base::TimeDelta duration) { |
220 Pickle pickle; | 220 base::Pickle pickle; |
221 pickle.WriteString(kFakeVideoBufferHeader); | 221 pickle.WriteString(kFakeVideoBufferHeader); |
222 pickle.WriteInt(config.coded_size().width()); | 222 pickle.WriteInt(config.coded_size().width()); |
223 pickle.WriteInt(config.coded_size().height()); | 223 pickle.WriteInt(config.coded_size().height()); |
224 pickle.WriteInt64(timestamp.InMilliseconds()); | 224 pickle.WriteInt64(timestamp.InMilliseconds()); |
225 | 225 |
226 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom( | 226 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom( |
227 static_cast<const uint8*>(pickle.data()), | 227 static_cast<const uint8*>(pickle.data()), |
228 static_cast<int>(pickle.size())); | 228 static_cast<int>(pickle.size())); |
229 buffer->set_timestamp(timestamp); | 229 buffer->set_timestamp(timestamp); |
230 buffer->set_duration(duration); | 230 buffer->set_duration(duration); |
231 buffer->set_is_key_frame(true); | 231 buffer->set_is_key_frame(true); |
232 | 232 |
233 return buffer; | 233 return buffer; |
234 } | 234 } |
235 | 235 |
236 bool VerifyFakeVideoBufferForTest( | 236 bool VerifyFakeVideoBufferForTest( |
237 const scoped_refptr<DecoderBuffer>& buffer, | 237 const scoped_refptr<DecoderBuffer>& buffer, |
238 const VideoDecoderConfig& config) { | 238 const VideoDecoderConfig& config) { |
239 // Check if the input |buffer| matches the |config|. | 239 // Check if the input |buffer| matches the |config|. |
240 PickleIterator pickle(Pickle(reinterpret_cast<const char*>(buffer->data()), | 240 base::PickleIterator pickle(base::Pickle( |
241 buffer->data_size())); | 241 reinterpret_cast<const char*>(buffer->data()), buffer->data_size())); |
242 std::string header; | 242 std::string header; |
243 int width = 0; | 243 int width = 0; |
244 int height = 0; | 244 int height = 0; |
245 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && | 245 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && |
246 pickle.ReadInt(&height); | 246 pickle.ReadInt(&height); |
247 return (success && header == kFakeVideoBufferHeader && | 247 return (success && header == kFakeVideoBufferHeader && |
248 width == config.coded_size().width() && | 248 width == config.coded_size().width() && |
249 height == config.coded_size().height()); | 249 height == config.coded_size().height()); |
250 } | 250 } |
251 | 251 |
(...skipping 14 matching lines...) Expand all Loading... |
266 expecting_b_ = false; | 266 expecting_b_ = false; |
267 } | 267 } |
268 | 268 |
269 void AddLogEntryForTest(MediaLog::MediaLogLevel level, | 269 void AddLogEntryForTest(MediaLog::MediaLogLevel level, |
270 const std::string& message) { | 270 const std::string& message) { |
271 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level) | 271 DVLOG(1) << "Media log (" << MediaLog::MediaLogLevelToString(level) |
272 << "): " << message; | 272 << "): " << message; |
273 } | 273 } |
274 | 274 |
275 } // namespace media | 275 } // namespace media |
OLD | NEW |