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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/test_helpers.h ('k') | media/base/video_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/test_helpers.cc
diff --git a/media/base/test_helpers.cc b/media/base/test_helpers.cc
index 54850f9d671bb82c6fb9d9865b6c8a98d6f4cc1e..eda49d3b588f4846920cb3ffbc5ab239149a3b0b 100644
--- a/media/base/test_helpers.cc
+++ b/media/base/test_helpers.cc
@@ -7,11 +7,13 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/pickle.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "media/base/audio_buffer.h"
#include "media/base/bind_to_loop.h"
+#include "media/base/decoder_buffer.h"
#include "ui/gfx/rect.h"
using ::testing::_;
@@ -242,4 +244,40 @@ DEFINE_INTERLEAVED_INSTANCE(float);
DEFINE_PLANAR_INSTANCE(int16);
DEFINE_PLANAR_INSTANCE(float);
+static const char kFakeVideoBufferHeader[] = "FakeVideoBufferForTest";
+
+scoped_refptr<DecoderBuffer> CreateFakeVideoBufferForTest(
+ const VideoDecoderConfig& config,
+ base::TimeDelta timestamp, base::TimeDelta duration) {
+ Pickle pickle;
+ pickle.WriteString(kFakeVideoBufferHeader);
+ pickle.WriteInt(config.coded_size().width());
+ pickle.WriteInt(config.coded_size().height());
+ pickle.WriteInt64(timestamp.InMilliseconds());
+
+ scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom(
+ static_cast<const uint8*>(pickle.data()),
+ static_cast<int>(pickle.size()));
+ buffer->SetTimestamp(timestamp);
+ buffer->SetDuration(duration);
+
+ return buffer;
+}
+
+bool VerifyFakeVideoBufferForTest(
+ const scoped_refptr<DecoderBuffer>& buffer,
+ const VideoDecoderConfig& config) {
+ // Check if the input |buffer| matches the |config|.
+ PickleIterator pickle(Pickle(reinterpret_cast<const char*>(buffer->GetData()),
+ buffer->GetDataSize()));
+ std::string header;
+ int width = 0;
+ int height = 0;
+ bool success = pickle.ReadString(&header) && pickle.ReadInt(&width) &&
+ pickle.ReadInt(&height);
+ return (success && header == kFakeVideoBufferHeader &&
+ width == config.coded_size().width() &&
+ height == config.coded_size().height());
+}
+
} // namespace media
« 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