Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: media/base/test_helpers.cc

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win64 Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/test_helpers.h ('k') | media/base/video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
13 #include "media/base/audio_buffer.h" 14 #include "media/base/audio_buffer.h"
14 #include "media/base/bind_to_loop.h" 15 #include "media/base/bind_to_loop.h"
16 #include "media/base/decoder_buffer.h"
15 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
16 18
17 using ::testing::_; 19 using ::testing::_;
18 using ::testing::StrictMock; 20 using ::testing::StrictMock;
19 21
20 namespace media { 22 namespace media {
21 23
22 // Utility mock for testing methods expecting Closures and PipelineStatusCBs. 24 // Utility mock for testing methods expecting Closures and PipelineStatusCBs.
23 class MockCallback : public base::RefCountedThreadSafe<MockCallback> { 25 class MockCallback : public base::RefCountedThreadSafe<MockCallback> {
24 public: 26 public:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 template scoped_refptr<AudioBuffer> MakePlanarAudioBuffer<type>( \ 237 template scoped_refptr<AudioBuffer> MakePlanarAudioBuffer<type>( \
236 SampleFormat format, \ 238 SampleFormat format, \
237 int channels, \ 239 int channels, \
238 type start, \ 240 type start, \
239 type increment, \ 241 type increment, \
240 int frames, \ 242 int frames, \
241 base::TimeDelta start_time); 243 base::TimeDelta start_time);
242 DEFINE_PLANAR_INSTANCE(int16); 244 DEFINE_PLANAR_INSTANCE(int16);
243 DEFINE_PLANAR_INSTANCE(float); 245 DEFINE_PLANAR_INSTANCE(float);
244 246
247 static const char kFakeVideoBufferHeader[] = "FakeVideoBufferForTest";
248
249 scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest(
250 const VideoDecoderConfig& config,
251 base::TimeDelta timestamp, base::TimeDelta duration) {
252 Pickle pickle;
253 pickle.WriteString(kFakeVideoBufferHeader);
254 pickle.WriteInt(config.coded_size().width());
255 pickle.WriteInt(config.coded_size().height());
256 pickle.WriteInt64(timestamp.InMilliseconds());
257
258 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom(
259 static_cast<const uint8*>(pickle.data()),
260 static_cast<int>(pickle.size()));
261 buffer->SetTimestamp(timestamp);
262 buffer->SetDuration(duration);
263
264 return buffer;
265 }
266
267 bool VerifyFakeVideoBufferForTest(
268 const scoped_refptr<DecoderBuffer>& buffer,
269 const VideoDecoderConfig& config) {
270 // Check if the input |buffer| matches the |config|.
271 PickleIterator pickle(Pickle(reinterpret_cast<const char*>(buffer->GetData()),
272 buffer->GetDataSize()));
273 std::string header;
274 int width = 0;
275 int height = 0;
276 bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) &&
277 pickle.ReadInt(&height);
278 return (success && header == kFakeVideoBufferHeader &&
279 width == config.coded_size().width() &&
280 height == config.coded_size().height());
281 }
282
245 } // namespace media 283 } // namespace media
OLDNEW
« no previous file with comments | « media/base/test_helpers.h ('k') | media/base/video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698