Chromium Code Reviews| 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 |
| + |
| + |