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

Unified Diff: media/cast/test/fake_video_encode_accelerator.cc

Issue 116623002: Cast: Adding support for GPU accelerated encode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed dependency on content Created 7 years 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: media/cast/test/fake_video_encode_accelerator.cc
diff --git a/media/cast/test/fake_video_encode_accelerator.cc b/media/cast/test/fake_video_encode_accelerator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f81286dc927fd76ba3cacc43406bdca92985d510
--- /dev/null
+++ b/media/cast/test/fake_video_encode_accelerator.cc
@@ -0,0 +1,77 @@
+// Copyright 2013 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 "media/cast/test/fake_video_encode_accelerator.h"
+
+namespace media {
+namespace cast {
+namespace test {
+
+static const unsigned int kMinimumInputCount = 1;
+static const size_t kMinimumOutputBufferSize = 123456;
+
+FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator(
+ VideoEncodeAccelerator::Client* client)
+ : client_(client ),
mikhal1 2013/12/17 22:39:47 remove extra space
pwestin 2013/12/19 16:03:47 Done.
+ first_(true) {
mikhal1 2013/12/17 22:39:47 DCHECK on client?
pwestin 2013/12/19 16:03:47 Done.
+}
+
+FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {
+}
+
+void FakeVideoEncodeAccelerator::Initialize(
+ media::VideoFrame::Format input_format,
+ const gfx::Size& input_visible_size,
+ VideoCodecProfile output_profile,
+ uint32 initial_bitrate) {
+ DCHECK(client_);
+
+ if (output_profile != media::VP8PROFILE_MAIN &&
+ output_profile != media::H264PROFILE_MAIN) {
+ client_->NotifyError(kInvalidArgumentError);
+ return;
+ }
+ client_->NotifyInitializeDone();
+ client_->RequireBitstreamBuffers(kMinimumInputCount,
+ input_visible_size,
+ kMinimumOutputBufferSize);
+}
+
+void FakeVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,
+ bool force_keyframe) {
+ DCHECK(client_);
+ DCHECK(!available_buffer_ids_.empty());
+
+ // Fake that we have encoded the frame; resulting in using the full output
+ // buffer.
+ int32 id = available_buffer_ids_.front();
+ available_buffer_ids_.pop_front();
+
+ bool is_key_fame = force_keyframe;
+ if (first_) {
mikhal1 2013/12/17 22:39:47 If it's the first frame, won't the encoder create
pwestin 2013/12/19 16:03:47 in normal case yes but this is a fake encoder, no
+ is_key_fame = true;
+ first_ = false;
+ }
+ client_->BitstreamBufferReady(id, kMinimumOutputBufferSize, is_key_fame);
+}
+
+void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
+ const BitstreamBuffer& buffer) {
+ available_buffer_ids_.push_back(buffer.id());
+}
+
+void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
+ uint32 bitrate, uint32 framerate) {
+ // No-op.
mikhal1 2013/12/17 22:39:47 What does this mean?
pwestin 2013/12/19 16:03:47 No operation; frequently used in chrome ~940 times
+}
+
+void FakeVideoEncodeAccelerator::Destroy() {
+ delete this;
+}
+
+} // namespace test
+} // namespace cast
+} // namespace media
+
+

Powered by Google App Engine
This is Rietveld 408576698