| 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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 base::TimeDelta timestamp, base::TimeDelta duration) { | 251 base::TimeDelta timestamp, base::TimeDelta duration) { |
| 252 Pickle pickle; | 252 Pickle pickle; |
| 253 pickle.WriteString(kFakeVideoBufferHeader); | 253 pickle.WriteString(kFakeVideoBufferHeader); |
| 254 pickle.WriteInt(config.coded_size().width()); | 254 pickle.WriteInt(config.coded_size().width()); |
| 255 pickle.WriteInt(config.coded_size().height()); | 255 pickle.WriteInt(config.coded_size().height()); |
| 256 pickle.WriteInt64(timestamp.InMilliseconds()); | 256 pickle.WriteInt64(timestamp.InMilliseconds()); |
| 257 | 257 |
| 258 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom( | 258 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom( |
| 259 static_cast<const uint8*>(pickle.data()), | 259 static_cast<const uint8*>(pickle.data()), |
| 260 static_cast<int>(pickle.size())); | 260 static_cast<int>(pickle.size())); |
| 261 buffer->SetTimestamp(timestamp); | 261 buffer->set_timestamp(timestamp); |
| 262 buffer->SetDuration(duration); | 262 buffer->set_duration(duration); |
| 263 | 263 |
| 264 return buffer; | 264 return buffer; |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool VerifyFakeVideoBufferForTest( | 267 bool VerifyFakeVideoBufferForTest( |
| 268 const scoped_refptr<DecoderBuffer>& buffer, | 268 const scoped_refptr<DecoderBuffer>& buffer, |
| 269 const VideoDecoderConfig& config) { | 269 const VideoDecoderConfig& config) { |
| 270 // Check if the input |buffer| matches the |config|. | 270 // Check if the input |buffer| matches the |config|. |
| 271 PickleIterator pickle(Pickle(reinterpret_cast<const char*>(buffer->GetData()), | 271 PickleIterator pickle(Pickle(reinterpret_cast<const char*>(buffer->data()), |
| 272 buffer->GetDataSize())); | 272 buffer->data_size())); |
| 273 std::string header; | 273 std::string header; |
| 274 int width = 0; | 274 int width = 0; |
| 275 int height = 0; | 275 int height = 0; |
| 276 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && | 276 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) && |
| 277 pickle.ReadInt(&height); | 277 pickle.ReadInt(&height); |
| 278 return (success && header == kFakeVideoBufferHeader && | 278 return (success && header == kFakeVideoBufferHeader && |
| 279 width == config.coded_size().width() && | 279 width == config.coded_size().width() && |
| 280 height == config.coded_size().height()); | 280 height == config.coded_size().height()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace media | 283 } // namespace media |
| OLD | NEW |