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

Unified Diff: chromecast/media/cma/base/frame_generator_for_test.cc

Issue 609383004: Chromecast: adds test frame-segmenter code to support CMA unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cma-decrypt-context
Patch Set: style fixes Created 6 years, 2 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
Index: chromecast/media/cma/base/frame_generator_for_test.cc
diff --git a/chromecast/media/cma/base/frame_generator_for_test.cc b/chromecast/media/cma/base/frame_generator_for_test.cc
deleted file mode 100644
index c03fcf8847c4543ea86ddade92d595d8e3b1bb76..0000000000000000000000000000000000000000
--- a/chromecast/media/cma/base/frame_generator_for_test.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromecast/media/cma/base/frame_generator_for_test.h"
-
-#include "chromecast/media/cma/base/decoder_buffer_adapter.h"
-#include "chromecast/media/cma/base/decoder_buffer_base.h"
-#include "media/base/decoder_buffer.h"
-#include "media/base/decrypt_config.h"
-
-namespace chromecast {
-namespace media {
-
-FrameGeneratorForTest::FrameSpec::FrameSpec()
- : has_config(false),
- is_eos(false),
- has_decrypt_config(false),
- size(0) {
-}
-
-FrameGeneratorForTest::FrameSpec::~FrameSpec() {
-}
-
-FrameGeneratorForTest::FrameGeneratorForTest(
- const std::vector<FrameSpec> frame_specs)
- : frame_specs_(frame_specs),
- frame_idx_(0),
- total_buffer_size_(0) {
-}
-
-FrameGeneratorForTest::~FrameGeneratorForTest() {
-}
-
-bool FrameGeneratorForTest::HasDecoderConfig() const {
- if (frame_idx_ >= frame_specs_.size())
- return false;
-
- return frame_specs_[frame_idx_].has_config;
-}
-
-scoped_refptr<DecoderBufferBase> FrameGeneratorForTest::Generate() {
- if (frame_idx_ >= frame_specs_.size())
- return scoped_refptr<DecoderBufferBase>();
-
- const FrameSpec& frame_spec = frame_specs_[frame_idx_];
- frame_idx_++;
-
- if (frame_spec.is_eos) {
- return scoped_refptr<DecoderBufferBase>(
- new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()));
- }
-
- scoped_refptr< ::media::DecoderBuffer> buffer(
- new ::media::DecoderBuffer(frame_spec.size));
-
- // Timestamp.
- buffer->set_timestamp(frame_spec.timestamp);
-
- // Generate the frame data.
- for (size_t k = 0; k < frame_spec.size; k++) {
- buffer->writable_data()[k] = total_buffer_size_ & 0xff;
- total_buffer_size_++;
- }
-
- // Generate the decrypt configuration.
- if (frame_spec.has_decrypt_config) {
- uint32 frame_size = buffer->data_size();
- uint32 chunk_size = 1;
- std::vector< ::media::SubsampleEntry> subsamples;
- while (frame_size > 0) {
- ::media::SubsampleEntry subsample;
- subsample.clear_bytes = chunk_size;
- if (subsample.clear_bytes > frame_size)
- subsample.clear_bytes = frame_size;
- frame_size -= subsample.clear_bytes;
- chunk_size <<= 1;
-
- subsample.cypher_bytes = chunk_size;
- if (subsample.cypher_bytes > frame_size)
- subsample.cypher_bytes = frame_size;
- frame_size -= subsample.cypher_bytes;
- chunk_size <<= 1;
-
- subsamples.push_back(subsample);
- }
-
- char key_id[] = {
- 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
- 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
-
- char iv[] = {
- 0x0, 0x2, 0x1, 0x3, 0x5, 0x4, 0x7, 0x6,
- 0x9, 0x8, 0xb, 0xa, 0xd, 0xc, 0xf, 0xe };
-
- scoped_ptr< ::media::DecryptConfig> decrypt_config(
- new ::media::DecryptConfig(
- std::string(key_id, arraysize(key_id)),
- std::string(iv, arraysize(iv)),
- subsamples));
- buffer->set_decrypt_config(decrypt_config.Pass());
- }
-
- return scoped_refptr<DecoderBufferBase>(new DecoderBufferAdapter(buffer));
-}
-
-size_t FrameGeneratorForTest::RemainingFrameCount() const {
- size_t count = frame_specs_.size() - frame_idx_;
- return count;
-}
-
-} // namespace media
-} // namespace chromecast
« no previous file with comments | « chromecast/media/cma/base/frame_generator_for_test.h ('k') | chromecast/media/cma/base/mock_frame_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698