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 : client_(NULL), first_(true) {}
19 FakeVideoEncodeAccelerator::~FakeVideoEncodeAccelerator() {}
21 void FakeVideoEncodeAccelerator::Initialize(
22 media::VideoFrame::Format input_format,
23 const gfx::Size& input_visible_size,
24 VideoCodecProfile output_profile,
25 uint32 initial_bitrate,
28 if (output_profile != media::VP8PROFILE_MAIN &&
29 output_profile != media::H264PROFILE_MAIN) {
30 client_->NotifyError(kInvalidArgumentError);
33 client_->NotifyInitializeDone();
34 client_->RequireBitstreamBuffers(
35 kMinimumInputCount, input_visible_size, kMinimumOutputBufferSize);
38 void FakeVideoEncodeAccelerator::Encode(const scoped_refptr<VideoFrame>& frame,
39 bool force_keyframe) {
41 DCHECK(!available_buffer_ids_.empty());
43 // Fake that we have encoded the frame; resulting in using the full output
45 int32 id = available_buffer_ids_.front();
46 available_buffer_ids_.pop_front();
48 bool is_key_fame = force_keyframe;
53 client_->BitstreamBufferReady(id, kMinimumOutputBufferSize, is_key_fame);
56 void FakeVideoEncodeAccelerator::UseOutputBitstreamBuffer(
57 const BitstreamBuffer& buffer) {
58 available_buffer_ids_.push_back(buffer.id());
61 void FakeVideoEncodeAccelerator::RequestEncodingParametersChange(
67 void FakeVideoEncodeAccelerator::Destroy() { delete this; }