1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/cast/test/fake_video_encode_accelerator.h"
7 #include "base/logging.h"
13 static const unsigned int kMinimumInputCount = 1;
14 static const size_t kMinimumOutputBufferSize = 123456;
16 FakeVideoEncodeAccelerator::FakeVideoEncodeAccelerator(
17 VideoEncodeAccelerator::Client* client)
23 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {
26 void FakeVideoEncodeAccelerator::Initialize(
27 media::VideoFrame::Format input_format,
28 const gfx::Size& input_visible_size,
29 VideoCodecProfile output_profile,
30 uint32 initial_bitrate) {
33 if (output_profile != media::VP8PROFILE_MAIN &&
34 output_profile != media::H264PROFILE_MAIN) {
35 client_->NotifyError(kInvalidArgumentError);
38 client_->NotifyInitializeDone();
39 client_->RequireBitstreamBuffers(kMinimumInputCount,
41 kMinimumOutputBufferSize);
44 void FakeVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,
45 bool force_keyframe) {
47 DCHECK(!available_buffer_ids_.empty());
49 // Fake that we have encoded the frame; resulting in using the full output
51 int32 id = available_buffer_ids_.front();
52 available_buffer_ids_.pop_front();
54 bool is_key_fame = force_keyframe;
59 client_->BitstreamBufferReady(id, kMinimumOutputBufferSize, is_key_fame);
62 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
63 const BitstreamBuffer& buffer) {
64 available_buffer_ids_.push_back(buffer.id());
67 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
68 uint32 bitrate, uint32 framerate) {
72 void FakeVideoEncodeAccelerator::Destroy() {